updated folder colors, reordering, new todo page, updated sidebar
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -331,12 +331,42 @@ test('users can mark a todo done and reopen it', function () {
|
||||
->assertSet('todoCounts.completed', 1);
|
||||
|
||||
expect($todo->fresh()->completed_at)->not->toBeNull();
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Completed);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('toggleComplete', $todo->id)
|
||||
->assertSet('todoCounts.completed', 0);
|
||||
|
||||
expect($todo->fresh()->completed_at)->toBeNull();
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Open);
|
||||
});
|
||||
|
||||
test('an in-progress todo is marked completed when checked', 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')
|
||||
->call('toggleComplete', $todo->id);
|
||||
|
||||
expect($todo->fresh()->completed_at)->not->toBeNull();
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Completed);
|
||||
});
|
||||
|
||||
test('checking an on-hold todo does not overwrite its status', 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::OnHold)->create(['description' => 'Waiting for signoff']);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('toggleComplete', $todo->id);
|
||||
|
||||
expect($todo->fresh()->completed_at)->not->toBeNull();
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::OnHold);
|
||||
});
|
||||
|
||||
test('completed todos render with strikethrough styling', function () {
|
||||
@@ -355,6 +385,29 @@ test('completed todos render with strikethrough styling', function () {
|
||||
->assertDontSeeHtml('line-through text-zinc-400">Pending task');
|
||||
});
|
||||
|
||||
test('completed todos show their completion date and days to completion', function () {
|
||||
$this->travelTo('2026-09-10 09:00:00');
|
||||
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
$todo = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Shipped feature']);
|
||||
|
||||
$this->travelTo('2026-09-18 09:00:00');
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('toggleComplete', $todo->id);
|
||||
|
||||
$todo->refresh();
|
||||
|
||||
expect($todo->daysToComplete())->toBe(8);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSee('Sep 18, 2026')
|
||||
->assertSee('Completed in 8 days');
|
||||
});
|
||||
|
||||
test('users can delete a todo', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
@@ -432,3 +485,137 @@ test('users cannot create todos in another user folders', function () {
|
||||
|
||||
$this->assertDatabaseCount('todos', 0);
|
||||
});
|
||||
|
||||
test('new todos are added to the top of the priority order', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Older todo', 'position' => 2]);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Middle todo', 'position' => 1]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('openCreateForm')
|
||||
->set('description', 'Newest todo')
|
||||
->set('formFolderId', $folder->id)
|
||||
->call('saveTodo');
|
||||
|
||||
$newest = Todo::where('description', 'Newest todo')->firstOrFail();
|
||||
|
||||
expect($newest->position)->toBe(0);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['Newest todo', 'Middle todo', 'Older todo']);
|
||||
});
|
||||
|
||||
test('users can move a todo up in the priority order', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
$first = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'First todo', 'position' => 0]);
|
||||
$second = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Second todo', 'position' => 1]);
|
||||
$third = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Third todo', 'position' => 2]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('moveTodo', $third->id, 'up');
|
||||
|
||||
expect($first->fresh()->position)->toBe(0);
|
||||
expect($second->fresh()->position)->toBe(2);
|
||||
expect($third->fresh()->position)->toBe(1);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['First todo', 'Third todo', 'Second todo']);
|
||||
});
|
||||
|
||||
test('users can move a todo down in the priority order', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
$first = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'First todo', 'position' => 0]);
|
||||
$second = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Second todo', 'position' => 1]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('moveTodo', $first->id, 'down');
|
||||
|
||||
expect($first->fresh()->position)->toBe(1);
|
||||
expect($second->fresh()->position)->toBe(0);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['Second todo', 'First todo']);
|
||||
});
|
||||
|
||||
test('moving the first todo up does nothing', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
$first = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'First todo', 'position' => 0]);
|
||||
$second = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Second todo', 'position' => 1]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('moveTodo', $first->id, 'up');
|
||||
|
||||
expect($first->fresh()->position)->toBe(0);
|
||||
expect($second->fresh()->position)->toBe(1);
|
||||
});
|
||||
|
||||
test('users can drag a todo to a new position', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
$first = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'First todo', 'position' => 0]);
|
||||
$second = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Second todo', 'position' => 1]);
|
||||
$third = Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Third todo', 'position' => 2]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->call('handleSort', $first->id, 2);
|
||||
|
||||
expect($first->fresh()->position)->toBe(2);
|
||||
expect($second->fresh()->position)->toBe(0);
|
||||
expect($third->fresh()->position)->toBe(1);
|
||||
});
|
||||
|
||||
test('dragging accounts for the pagination offset', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
$todos = collect(range(1, 12))
|
||||
->map(fn (int $n) => Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Todo '.$n,
|
||||
'position' => $n - 1,
|
||||
]));
|
||||
|
||||
$todoEleven = $todos->get(10);
|
||||
$todoTwelve = $todos->get(11);
|
||||
|
||||
Livewire::withQueryParams(['page' => 2])
|
||||
->test('pages::dashboard')
|
||||
->assertSee('Todo 12')
|
||||
->call('handleSort', $todoTwelve->id, 0);
|
||||
|
||||
expect($todoEleven->fresh()->position)->toBe(11);
|
||||
expect($todoTwelve->fresh()->position)->toBe(10);
|
||||
});
|
||||
|
||||
test('completed todos sort last regardless of their position', function () {
|
||||
$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', 'position' => 0]);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Pending task', 'position' => 1]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['Pending task', 'Finished task']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user