Add value for field
This commit is contained in:
parent
78d6c6d864
commit
64c2cb9408
|
@ -25,6 +25,9 @@ abstract class Field extends Data
|
|||
public ColumnData $columns;
|
||||
public bool $forMembers;
|
||||
|
||||
/** @var mixed */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @param array<array-key, mixed> $input
|
||||
*/
|
||||
|
@ -133,7 +136,7 @@ abstract class Field extends Data
|
|||
'name' => '',
|
||||
'type' => static::type(),
|
||||
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
||||
'default' => static::default(),
|
||||
'value' => static::default(),
|
||||
'required' => false,
|
||||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
|
|
|
@ -42,8 +42,8 @@ class FormFactory extends Factory
|
|||
'description' => $this->faker->text(),
|
||||
'excerpt' => $this->faker->words(10, true),
|
||||
'config' => ['sections' => []],
|
||||
'from' => $this->faker->dateTime()->format('Y-m-d H:i:s'),
|
||||
'to' => $this->faker->dateTime()->format('Y-m-d H:i:s'),
|
||||
'from' => $this->faker->dateTimeBetween('+1 week', '+4 weeks')->format('Y-m-d H:i:s'),
|
||||
'to' => $this->faker->dateTimeBetween('+1 week', '+4 weeks')->format('Y-m-d H:i:s'),
|
||||
'registration_from' => $this->faker->dateTimeBetween('-2 weeks', 'now')->format('Y-m-d H:i:s'),
|
||||
'registration_until' => $this->faker->dateTimeBetween('now', '+2 weeks')->format('Y-m-d H:i:s'),
|
||||
'mail_top' => $this->faker->text(),
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Tests\EndToEnd\Form;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Formtemplate;
|
||||
use App\Subactivity;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
@ -11,7 +10,7 @@ use Illuminate\Support\Facades\Storage;
|
|||
use Tests\EndToEndTestCase;
|
||||
use Tests\Feature\Form\FormtemplateSectionRequest;
|
||||
|
||||
class FormApiListActionTest extends EndToEndTestCase
|
||||
class FormApiListActionTest extends FormTestCase
|
||||
{
|
||||
|
||||
use DatabaseTransactions;
|
||||
|
@ -21,7 +20,6 @@ class FormApiListActionTest extends EndToEndTestCase
|
|||
Carbon::setTestNow(Carbon::parse('2023-03-02'));
|
||||
Storage::fake('temp');
|
||||
$this->loginNami()->withoutExceptionHandling();
|
||||
Formtemplate::factory()->name('tname')->sections([FormtemplateSectionRequest::new()->name('sname')])->create();
|
||||
$form = Form::factory()
|
||||
->name('lala 2')
|
||||
->excerpt('fff')
|
||||
|
@ -50,6 +48,18 @@ class FormApiListActionTest extends EndToEndTestCase
|
|||
->assertJsonPath('meta.total', 1);
|
||||
}
|
||||
|
||||
public function testItDisplaysDefaultValueOfField(): void
|
||||
{
|
||||
Storage::fake('temp');
|
||||
$this->loginNami()->withoutExceptionHandling();
|
||||
Form::factory()->withImage('headerImage', 'lala-2.jpg')
|
||||
->sections([FormtemplateSectionRequest::new()->fields([$this->textField()])])
|
||||
->create();
|
||||
|
||||
sleep(1);
|
||||
$this->get('/api/form?perPage=15')->assertJsonPath('data.0.config.sections.0.fields.0.value', '');
|
||||
}
|
||||
|
||||
public function testItDisplaysRemoteGroups(): void
|
||||
{
|
||||
$this->loginNami()->withoutExceptionHandling();
|
||||
|
|
|
@ -48,6 +48,7 @@ class FormtemplateFieldRequest extends RequestFactory
|
|||
|
||||
return self::new([
|
||||
'type' => $field::type(),
|
||||
'value' => $field::default(),
|
||||
...$field::fake((new static())->faker),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class FormtemplateIndexActionTest extends TestCase
|
|||
'name' => '',
|
||||
'type' => 'DropdownField',
|
||||
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
||||
'default' => null,
|
||||
'value' => null,
|
||||
'required' => false,
|
||||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
|
@ -51,7 +51,7 @@ class FormtemplateIndexActionTest extends TestCase
|
|||
'name' => '',
|
||||
'type' => 'TextField',
|
||||
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
||||
'default' => '',
|
||||
'value' => '',
|
||||
'required' => false,
|
||||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
|
@ -64,7 +64,7 @@ class FormtemplateIndexActionTest extends TestCase
|
|||
'name' => '',
|
||||
'type' => 'TextareaField',
|
||||
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
||||
'default' => '',
|
||||
'value' => '',
|
||||
'required' => false,
|
||||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
|
|
Loading…
Reference in New Issue