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 () {
|
||||
@@ -142,6 +143,97 @@ test('todos can be created without a due date', function () {
|
||||
expect($todo->due_date)->toBeNull();
|
||||
});
|
||||
|
||||
test('users can set a status when creating a todo', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('openCreateForm')
|
||||
->set('description', 'Fix login bug')
|
||||
->set('todoStatus', 'blocked')
|
||||
->set('formFolderId', $folder->id)
|
||||
->call('saveTodo')
|
||||
->assertSet('showTodoForm', false);
|
||||
|
||||
$todo = Todo::where('description', 'Fix login bug')->firstOrFail();
|
||||
expect($todo->status)->toBe(TodoStatus::Blocked);
|
||||
});
|
||||
|
||||
test('an invalid todo status is rejected', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('openCreateForm')
|
||||
->set('description', 'Nope')
|
||||
->set('todoStatus', 'bogus')
|
||||
->set('formFolderId', $folder->id)
|
||||
->call('saveTodo')
|
||||
->assertHasErrors('todoStatus');
|
||||
|
||||
$this->assertDatabaseCount('todos', 0);
|
||||
});
|
||||
|
||||
test('users can change the status of an existing todo', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
$todo = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Write report']);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('openEditForm', $todo->id)
|
||||
->set('todoStatus', 'on-hold')
|
||||
->call('saveTodo');
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::OnHold);
|
||||
});
|
||||
|
||||
test('todos show their status badge in the list', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
$todo = Todo::factory()->recycle($user)->for($folder)->withStatus(TodoStatus::InProgress)->create(['description' => 'Draft plan']);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeHtml('data-test="todo-status-'.$todo->id.'"')
|
||||
->assertSee('In Progress');
|
||||
});
|
||||
|
||||
test('todo list filters by workflow status', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->withStatus(TodoStatus::Blocked)->create(['description' => 'Blocked task']);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Open task']);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->set('status', 'blocked')
|
||||
->assertSee('Blocked task')
|
||||
->assertDontSee('Open task');
|
||||
});
|
||||
|
||||
test('cancelled and deferred todos are excluded from the open count', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Active task', 'due_date' => today()->addDays(3)]);
|
||||
Todo::factory()->recycle($user)->for($folder)->withStatus(TodoStatus::Cancelled)->create(['description' => 'Cancelled task']);
|
||||
Todo::factory()->recycle($user)->for($folder)->withStatus(TodoStatus::Deferred)->create(['description' => 'Deferred task']);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSet('todoCounts.open', 1);
|
||||
});
|
||||
|
||||
test('users can save and update notes on a todo', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
@@ -247,6 +339,22 @@ test('users can mark a todo done and reopen it', function () {
|
||||
expect($todo->fresh()->completed_at)->toBeNull();
|
||||
});
|
||||
|
||||
test('completed todos render with strikethrough styling', function () {
|
||||
$this->travelTo('2026-09-18 09:00:00');
|
||||
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->completed()->create(['description' => 'Finished task']);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Pending task', 'due_date' => today()->addDays(3)]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeHtml('<span class="line-through text-zinc-400">Finished task</span>')
|
||||
->assertDontSeeHtml('line-through text-zinc-400">Pending task');
|
||||
});
|
||||
|
||||
test('users can delete a todo', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Reference in New Issue
Block a user