updated folder colors, reordering, new todo page, updated sidebar
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-09-21 00:33:10 -07:00
parent df016dad14
commit f8fc561602
25 changed files with 1980 additions and 264 deletions
+212
View File
@@ -4,6 +4,7 @@ use App\Models\Folder;
use App\Models\Todo;
use App\Models\User;
use App\TodoStatus;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Livewire\Livewire;
test('guests are redirected to the login page', function () {
@@ -241,3 +242,214 @@ test('a todo description is required when adding from the folders page', functio
$this->assertDatabaseCount('todos', 0);
});
test('clicking the open badge expands the open todos in the folder', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
Todo::factory()->recycle($user)->for($work)->create(['description' => 'Open task', 'due_date' => today()->addDays(2)]);
Todo::factory()->recycle($user)->for($work)->completed()->create(['description' => 'Done task']);
Livewire::test('pages::folders')
->call('toggleExpandFolder', $work->id)
->assertSet('expandedFolderId', $work->id)
->assertSee('Open task')
->assertDontSee('Done task');
});
test('clicking the open badge again collapses the folder todos', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
Todo::factory()->recycle($user)->for($work)->create(['description' => 'Open task', 'due_date' => today()->addDays(2)]);
Livewire::test('pages::folders')
->call('toggleExpandFolder', $work->id)
->call('toggleExpandFolder', $work->id)
->assertSet('expandedFolderId', null)
->assertDontSee('Open task');
});
test('only the clicked folder is expanded at a time', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
$personal = Folder::factory()->for($user)->create(['name' => 'Personal']);
Todo::factory()->recycle($user)->for($work)->create(['description' => 'Work task', 'due_date' => today()->addDays(2)]);
Todo::factory()->recycle($user)->for($personal)->create(['description' => 'Personal task', 'due_date' => today()->addDays(2)]);
Livewire::test('pages::folders')
->call('toggleExpandFolder', $work->id)
->call('toggleExpandFolder', $personal->id)
->assertSet('expandedFolderId', $personal->id)
->assertDontSee('Work task')
->assertSee('Personal task');
});
test('users can move a todo to another folder from the folders page', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
$personal = Folder::factory()->for($user)->create(['name' => 'Personal']);
$todo = Todo::factory()->recycle($user)->for($work)->create(['description' => 'Move me', 'due_date' => today()->addDay()]);
Livewire::test('pages::folders')
->call('toggleExpandFolder', $work->id)
->call('moveTodoToFolder', $todo->id, $personal->id);
expect($todo->fresh()->folder_id)->toBe($personal->id);
});
test('users cannot move a todo to another user folder', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
$todo = Todo::factory()->recycle($user)->for($work)->create(['description' => 'Mine', 'due_date' => today()->addDay()]);
$owner = User::factory()->create();
$foreign = Folder::factory()->for($owner)->create(['name' => 'Foreign']);
$this->expectException(ModelNotFoundException::class);
Livewire::test('pages::folders')
->call('moveTodoToFolder', $todo->id, $foreign->id);
});
test('users cannot move another user todo', function () {
$owner = User::factory()->create();
$ownerFolder = Folder::factory()->for($owner)->create(['name' => 'Owner Folder']);
$ownerTodo = Todo::factory()->recycle($owner)->for($ownerFolder)->create(['description' => 'Owner secret', 'due_date' => today()->addDay()]);
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
$this->expectException(ModelNotFoundException::class);
Livewire::test('pages::folders')
->call('moveTodoToFolder', $ownerTodo->id, $work->id);
});
test('users can create a top-level folder with a color', function () {
$user = User::factory()->create();
$this->actingAs($user);
Livewire::test('pages::folders')
->set('newFolderName', 'Work')
->set('newFolderColor', 'blue')
->call('createTopLevelFolder')
->assertSet('newFolderColor', '');
$this->assertDatabaseHas('folders', [
'user_id' => $user->id,
'name' => 'Work',
'color' => 'blue',
'parent_id' => null,
]);
});
test('users can create a sub-folder with a color', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work', 'color' => null]);
Livewire::test('pages::folders')
->call('startChildCreate', $work->id)
->set('newChildName', 'Acme Corp')
->set('newChildColor', 'emerald')
->call('createChildFolder')
->assertSet('newChildColor', '');
$this->assertDatabaseHas('folders', [
'user_id' => $user->id,
'name' => 'Acme Corp',
'color' => 'emerald',
'parent_id' => $work->id,
]);
});
test('an invalid folder color is rejected', function () {
$user = User::factory()->create();
$this->actingAs($user);
Livewire::test('pages::folders')
->set('newFolderName', 'Work')
->set('newFolderColor', 'neon')
->call('createTopLevelFolder')
->assertHasErrors('newFolderColor');
$this->assertDatabaseCount('folders', 0);
});
test('the folder color dot is shown on the folders page', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work', 'color' => 'indigo']);
Livewire::test('pages::folders')
->assertSee("data-test=\"folder-dot-{$work->id}\"", false);
});
test('the color picker offers the palette options', function () {
$user = User::factory()->create();
$this->actingAs($user);
Livewire::test('pages::folders')
->assertSee('color-option-none', false)
->assertSee('color-option-blue', false)
->assertSee('color-option-pink', false);
});
test('users can choose a color for an existing folder', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work', 'color' => null]);
Livewire::test('pages::folders')
->call('startColorEdit', $work->id)
->assertSet('colorDraft', '')
->set('colorDraft', 'violet')
->call('saveFolderColor')
->assertSet('colorEditingFolderId', null);
expect($work->fresh()->color)->toBe('violet');
});
test('users can clear the color of an existing folder', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work', 'color' => 'amber']);
Livewire::test('pages::folders')
->call('startColorEdit', $work->id)
->assertSet('colorDraft', 'amber')
->set('colorDraft', '')
->call('saveFolderColor');
expect($work->fresh()->color)->toBeNull();
});
test('an invalid color is rejected when editing a folder', function () {
$user = User::factory()->create();
$this->actingAs($user);
$work = Folder::factory()->for($user)->create(['name' => 'Work', 'color' => null]);
Livewire::test('pages::folders')
->call('startColorEdit', $work->id)
->set('colorDraft', 'neon')
->call('saveFolderColor')
->assertHasErrors('colorDraft');
expect($work->fresh()->color)->toBeNull();
});