This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use App\Models\Folder;
|
||||
use App\Models\Todo;
|
||||
use App\Models\User;
|
||||
use App\TodoStatus;
|
||||
use Livewire\Livewire;
|
||||
|
||||
test('guests are redirected to the login page', function () {
|
||||
@@ -181,6 +182,52 @@ test('the view-todos button links to the filtered dashboard', function () {
|
||||
->assertSee((string) route('dashboard', ['folder' => $work->id]));
|
||||
});
|
||||
|
||||
test('the add todo dialog on the folders page shows the target folder', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
$acme = Folder::factory()->childOf($work)->create(['name' => 'Acme Corp']);
|
||||
|
||||
Livewire::test('pages::folders')
|
||||
->call('startTodoCreate', $acme->id)
|
||||
->assertSeeHtml('data-test="add-todo-folder-name"')
|
||||
->assertSeeHtml('data-test="add-todo-title-folder"')
|
||||
->assertSeeText('Add todo - Work / Acme Corp');
|
||||
});
|
||||
|
||||
test('users can set a status when adding a todo from the folders page', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Livewire::test('pages::folders')
|
||||
->call('startTodoCreate', $work->id)
|
||||
->set('todoDescription', 'Review contract')
|
||||
->set('todoStatus', 'deferred')
|
||||
->call('saveFolderTodo');
|
||||
|
||||
$todo = Todo::where('description', 'Review contract')->firstOrFail();
|
||||
expect($todo->status)->toBe(TodoStatus::Deferred);
|
||||
});
|
||||
|
||||
test('an invalid status is rejected when adding from the folders page', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Livewire::test('pages::folders')
|
||||
->call('startTodoCreate', $work->id)
|
||||
->set('todoDescription', 'Nope')
|
||||
->set('todoStatus', 'bogus')
|
||||
->call('saveFolderTodo')
|
||||
->assertHasErrors('todoStatus');
|
||||
|
||||
$this->assertDatabaseCount('todos', 0);
|
||||
});
|
||||
|
||||
test('a todo description is required when adding from the folders page', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Reference in New Issue
Block a user