2024-02-21 23:18:31 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Form;
|
|
|
|
|
|
|
|
use App\Form\Models\Form;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
|
|
|
|
class FormUpdateMetaActionTest extends FormTestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItUpdatesMetaOfForm(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami()->withoutExceptionHandling();
|
|
|
|
$form = Form::factory()
|
|
|
|
->sections([FormtemplateSectionRequest::new()->fields([
|
|
|
|
$this->textField('textone'),
|
|
|
|
$this->dropdownField('texttwo'),
|
|
|
|
])])->create();
|
|
|
|
|
|
|
|
$this->patchJson(route('form.update-meta', ['form' => $form]), [
|
|
|
|
'active_columns' => ['textone'],
|
2024-12-12 03:07:10 +01:00
|
|
|
'sorting' => ['by' => 'textone', 'direction' => false],
|
2024-02-21 23:18:31 +01:00
|
|
|
])->assertOk()
|
|
|
|
->assertJsonPath('active_columns.0', 'textone')
|
2024-12-12 03:07:10 +01:00
|
|
|
->assertJsonPath('sorting.by', 'textone');
|
2024-02-21 23:18:31 +01:00
|
|
|
|
|
|
|
$form = Form::latest()->first();
|
2024-12-12 03:07:10 +01:00
|
|
|
$this->assertEquals(['by' => 'textone', 'direction' => false], $form->meta['sorting']);
|
2024-02-21 23:18:31 +01:00
|
|
|
$this->assertEquals(['textone'], $form->meta['active_columns']);
|
|
|
|
}
|
2024-04-12 00:14:02 +02:00
|
|
|
|
|
|
|
public function testItCanSetCreatedAtMeta(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami()->withoutExceptionHandling();
|
|
|
|
$form = Form::factory()->create();
|
|
|
|
|
|
|
|
$this->patchJson(route('form.update-meta', ['form' => $form]), [
|
|
|
|
'active_columns' => ['created_at'],
|
2024-12-12 03:07:10 +01:00
|
|
|
'sorting' => ['by' => 'textone', 'direction' => false],
|
2024-04-12 00:14:02 +02:00
|
|
|
])->assertOk();
|
|
|
|
|
|
|
|
$form = Form::latest()->first();
|
2024-12-12 03:07:10 +01:00
|
|
|
$this->assertEquals(['by' => 'textone', 'direction' => false], $form->fresh()->meta['sorting']);
|
2024-04-12 00:14:02 +02:00
|
|
|
$this->assertEquals(['created_at'], $form->fresh()->meta['active_columns']);
|
|
|
|
}
|
2024-02-21 23:18:31 +01:00
|
|
|
}
|