This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Livewire\Livewire;
|
||||
|
||||
test('guests are redirected from the lifetime access page', function () {
|
||||
$this->get(route('admin.lifetime-access'))
|
||||
->assertRedirect(route('login'));
|
||||
});
|
||||
|
||||
test('non-admins cannot access the lifetime access page', function () {
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
$this->get(route('admin.lifetime-access'))->assertForbidden();
|
||||
});
|
||||
|
||||
test('workspace admins are not site admins and cannot access the lifetime access page', function () {
|
||||
$workspaceAdmin = User::factory()->create();
|
||||
|
||||
$this->actingAs($workspaceAdmin);
|
||||
|
||||
$this->get(route('admin.lifetime-access'))->assertForbidden();
|
||||
});
|
||||
|
||||
test('a non-admin cannot toggle lifetime access through a direct action call', function () {
|
||||
$admin = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
$member = User::factory()->create();
|
||||
|
||||
$component = Livewire::test('pages::admin.lifetime-access');
|
||||
|
||||
$this->actingAs($member);
|
||||
|
||||
$component->call('toggleLifetimeAccess', $member->id)->assertForbidden();
|
||||
|
||||
expect($member->fresh()->currentOrganization->lifetime_access)->toBeFalse();
|
||||
});
|
||||
|
||||
test('non-admins do not see the lifetime access navigation item', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$this->get(route('dashboard'))
|
||||
->assertOk()
|
||||
->assertDontSee('Lifetime access');
|
||||
});
|
||||
|
||||
test('admins see the lifetime access navigation item', function () {
|
||||
$user = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$this->get(route('dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Lifetime access');
|
||||
});
|
||||
|
||||
test('site admins see the site admin navigation group', function () {
|
||||
$user = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$this->get(route('dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Site admin');
|
||||
});
|
||||
|
||||
test('workspace admins do not see the site admin navigation group', function () {
|
||||
$workspaceAdmin = User::factory()->create();
|
||||
|
||||
$this->actingAs($workspaceAdmin);
|
||||
|
||||
$this->get(route('dashboard'))
|
||||
->assertOk()
|
||||
->assertDontSee('Site admin');
|
||||
});
|
||||
|
||||
test('admins can view the lifetime access page', function () {
|
||||
$user = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$this->get(route('admin.lifetime-access'))->assertOk();
|
||||
});
|
||||
|
||||
test('the lifetime access page lists users with their status', function () {
|
||||
$admin = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
$lifetimeUser = User::factory()->create(['name' => 'Lifetime User']);
|
||||
$lifetimeUser->currentOrganization->update(['lifetime_access' => true]);
|
||||
|
||||
$regularUser = User::factory()->create(['name' => 'Regular User']);
|
||||
|
||||
Livewire::test('pages::admin.lifetime-access')
|
||||
->assertSee('Lifetime User')
|
||||
->assertSee('Regular User')
|
||||
->assertSee('Lifetime')
|
||||
->assertSee('None');
|
||||
});
|
||||
|
||||
test('admins can enable lifetime access for a user', function () {
|
||||
$admin = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
$member = User::factory()->create(['name' => 'Member One']);
|
||||
|
||||
expect($member->fresh()->currentOrganization->lifetime_access)->toBeFalse();
|
||||
|
||||
Livewire::test('pages::admin.lifetime-access')
|
||||
->call('toggleLifetimeAccess', $member->id)
|
||||
->assertSet('showLimitForm', false);
|
||||
|
||||
expect($member->fresh()->currentOrganization->lifetime_access)->toBeTrue();
|
||||
});
|
||||
|
||||
test('admins can disable lifetime access for a user', function () {
|
||||
$admin = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
$member = User::factory()->create(['name' => 'Member Two']);
|
||||
$member->currentOrganization->update(['lifetime_access' => true]);
|
||||
|
||||
expect($member->fresh()->currentOrganization->lifetime_access)->toBeTrue();
|
||||
|
||||
Livewire::test('pages::admin.lifetime-access')
|
||||
->call('toggleLifetimeAccess', $member->id);
|
||||
|
||||
expect($member->fresh()->currentOrganization->lifetime_access)->toBeFalse();
|
||||
});
|
||||
|
||||
test('admins can search users by name or email', function () {
|
||||
$admin = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
$match = User::factory()->create(['name' => 'Ada Lovelace', 'email' => 'ada@example.com']);
|
||||
$emailMatch = User::factory()->create(['name' => 'Grace Hopper', 'email' => 'grace@searchable.test']);
|
||||
$other = User::factory()->create(['name' => 'Alan Turing', 'email' => 'alan@example.com']);
|
||||
|
||||
Livewire::test('pages::admin.lifetime-access')
|
||||
->set('search', 'lovelace')
|
||||
->assertSee('Ada Lovelace')
|
||||
->assertDontSee('Alan Turing')
|
||||
->set('search', 'searchable.test')
|
||||
->assertSee('Grace Hopper')
|
||||
->assertDontSee($match->name)
|
||||
->assertDontSee($other->name);
|
||||
});
|
||||
|
||||
test('the lifetime access list is paginated', function () {
|
||||
$admin = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
User::factory()->count(12)->create();
|
||||
|
||||
$component = Livewire::test('pages::admin.lifetime-access');
|
||||
|
||||
expect($component->instance()->users->perPage())->toBe(10)
|
||||
->and($component->instance()->users->total())->toBe(13);
|
||||
});
|
||||
@@ -42,7 +42,7 @@ test('a non-admin cannot save a notes limit through a direct action call', funct
|
||||
|
||||
$component->set('notesLimitInput', '2500')->call('saveNotesLimit')->assertForbidden();
|
||||
|
||||
expect($member->fresh()->notes_limit)->toBe(1000);
|
||||
expect($member->fresh()->notesLimit())->toBe(1000);
|
||||
});
|
||||
|
||||
test('non-admins do not see the notes limits navigation item', function () {
|
||||
@@ -128,7 +128,7 @@ test('a notes limit must be a valid positive number', function () {
|
||||
->call('saveNotesLimit')
|
||||
->assertHasErrors('notesLimitInput');
|
||||
|
||||
expect($member->fresh()->notes_limit)->toBe(1000);
|
||||
expect($member->fresh()->notesLimit())->toBe(1000);
|
||||
});
|
||||
|
||||
test('admins can search users by name or email', function () {
|
||||
|
||||
@@ -12,7 +12,8 @@ test('base data includes a default admin user', function () {
|
||||
|
||||
expect($admin)->not->toBeNull()
|
||||
->and($admin->name)->toBe('Administrator')
|
||||
->and($admin->notes_limit)->toBe(1000);
|
||||
->and($admin->notes_limit)->toBeNull()
|
||||
->and($admin->notesLimit())->toBe(1000);
|
||||
$this->assertTrue($admin->isSiteAdmin());
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use App\WorkspaceType;
|
||||
use Laravel\Cashier\Subscription;
|
||||
|
||||
test('the default plans are seeded', function () {
|
||||
expect(Plan::query()->orderBy('sort_order')->pluck('key')->all())
|
||||
->toBe(['free', 'personal', 'family', 'organization', 'unlimited']);
|
||||
});
|
||||
|
||||
test('a plan casts its workspace type and limits', function () {
|
||||
$free = Plan::query()->where('key', 'free')->firstOrFail();
|
||||
|
||||
expect($free->workspace_type)->toBe(WorkspaceType::Personal)
|
||||
->and($free->is_active)->toBeTrue()
|
||||
->and($free->seat_limit)->toBe(1)
|
||||
->and($free->max_folders)->toBe(3)
|
||||
->and($free->max_folder_depth)->toBe(1)
|
||||
->and($free->max_notes_per_folder)->toBe(50)
|
||||
->and($free->note_chars)->toBe(1000);
|
||||
});
|
||||
|
||||
test('the unlimited plan has no limits', function () {
|
||||
$unlimited = Plan::query()->where('key', 'unlimited')->firstOrFail();
|
||||
|
||||
expect($unlimited->max_folders)->toBeNull()
|
||||
->and($unlimited->max_folder_depth)->toBeNull()
|
||||
->and($unlimited->max_notes_per_folder)->toBeNull()
|
||||
->and($unlimited->note_chars)->toBeNull();
|
||||
});
|
||||
|
||||
test('only the personal plan is purchasable by default', function () {
|
||||
expect(Plan::query()->where('key', 'personal')->firstOrFail()->isPurchasable())->toBeTrue()
|
||||
->and(Plan::query()->where('key', 'free')->firstOrFail()->isPurchasable())->toBeFalse()
|
||||
->and(Plan::query()->where('key', 'unlimited')->firstOrFail()->isPurchasable())->toBeFalse();
|
||||
});
|
||||
|
||||
test('a plan created through the factory can be given caps and a price', function () {
|
||||
$plan = Plan::factory()->limited(2, 1, 10, 200)->purchasable('price_abc')->create();
|
||||
|
||||
expect($plan->max_folders)->toBe(2)
|
||||
->and($plan->note_chars)->toBe(200)
|
||||
->and($plan->isPurchasable())->toBeTrue()
|
||||
->and($plan->stripe_price)->toBe('price_abc');
|
||||
});
|
||||
|
||||
test('an organization belongs to a plan', function () {
|
||||
$organization = Organization::factory()->withPlan('family')->create();
|
||||
|
||||
expect($organization->plan)->not->toBeNull()
|
||||
->and($organization->plan->key)->toBe('family');
|
||||
});
|
||||
|
||||
test('the factory user is given the unlimited plan', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
expect($user->currentOrganization()->first()->plan->key)->toBe('unlimited');
|
||||
});
|
||||
|
||||
test('the factory user can be given a specific plan', function () {
|
||||
$user = User::factory()->unsubscribed()->withFreePlan()->create();
|
||||
|
||||
expect($user->currentOrganization()->first()->plan->key)->toBe('free');
|
||||
});
|
||||
|
||||
test('the backfill assigns a plan to every existing workspace', function () {
|
||||
$legacy = Organization::factory()->personal()->withLifetimeAccess()->create();
|
||||
$subscriber = Organization::factory()->personal()->create();
|
||||
$plain = Organization::factory()->personal()->create();
|
||||
|
||||
Subscription::factory()->active()
|
||||
->withPrice(config('plans.plans.pro.price'))
|
||||
->create(['organization_id' => $subscriber->id]);
|
||||
|
||||
// Simulate a database that predates the backfill.
|
||||
Organization::query()->update(['plan_id' => null]);
|
||||
|
||||
$migration = require database_path('migrations/2026_10_16_043630_backfill_organization_plans.php');
|
||||
$migration->up();
|
||||
|
||||
expect($legacy->refresh()->plan->key)->toBe('unlimited')
|
||||
->and($subscriber->refresh()->plan->key)->toBe('personal')
|
||||
->and($plain->refresh()->plan->key)->toBe('free');
|
||||
});
|
||||
@@ -670,3 +670,37 @@ test('completed todos sort last regardless of their position', function () {
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['Pending task', 'Finished task']);
|
||||
});
|
||||
|
||||
test('dashboard todos can be sorted by a column', 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)->create([
|
||||
'description' => 'Later task',
|
||||
'due_date' => today()->addDays(2),
|
||||
'position' => 0,
|
||||
]);
|
||||
Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Sooner task',
|
||||
'due_date' => today()->addDay(),
|
||||
'position' => 1,
|
||||
]);
|
||||
Todo::factory()->recycle($user)->for($folder)->noDueDate()->create([
|
||||
'description' => 'No due task',
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['Later task', 'Sooner task', 'No due task'])
|
||||
->call('sort', 'due_date')
|
||||
->assertSet('sortBy', 'due_date')
|
||||
->assertSet('sortDirection', 'asc')
|
||||
->assertSeeInOrder(['Sooner task', 'Later task', 'No due task'])
|
||||
->call('sort', 'due_date')
|
||||
->assertSet('sortDirection', 'desc')
|
||||
->assertSeeInOrder(['Later task', 'Sooner task', 'No due task']);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Folder;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Todo;
|
||||
use App\Models\User;
|
||||
use App\OrganizationRole;
|
||||
use App\TodoStatus;
|
||||
use Livewire\Livewire;
|
||||
|
||||
test('guests are redirected to the login page', function () {
|
||||
$response = $this->get(route('kanban'));
|
||||
|
||||
$response->assertRedirect(route('login'));
|
||||
});
|
||||
|
||||
test('authenticated users can visit the kanban page', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$response = $this->get(route('kanban'));
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('the board groups todos into status columns', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Open task',
|
||||
'status' => TodoStatus::Open,
|
||||
'position' => 0,
|
||||
]);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Progress task',
|
||||
'status' => TodoStatus::InProgress,
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->completed()->create([
|
||||
'description' => 'Completed on hold',
|
||||
'status' => TodoStatus::OnHold,
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Completed status',
|
||||
'status' => TodoStatus::Completed,
|
||||
'position' => 3,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->assertSeeHtml('wire:sort="moveTodo"')
|
||||
->assertSeeHtml('wire:sort:group="kanban"')
|
||||
->assertSeeHtml('wire:sort:group-id="open"')
|
||||
->assertSeeHtml('wire:sort:group-id="completed"')
|
||||
->assertSeeHtmlInOrder([
|
||||
'data-test="kanban-column-open"',
|
||||
'Open task',
|
||||
'data-test="kanban-column-in-progress"',
|
||||
'Progress task',
|
||||
'data-test="kanban-column-on-hold"',
|
||||
'data-test="kanban-column-blocked"',
|
||||
'data-test="kanban-column-cancelled"',
|
||||
'data-test="kanban-column-deferred"',
|
||||
'data-test="kanban-column-completed"',
|
||||
'Completed status',
|
||||
'Completed on hold',
|
||||
]);
|
||||
});
|
||||
|
||||
test('moving a todo to another status column updates 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)->create([
|
||||
'description' => 'Move me',
|
||||
'status' => TodoStatus::Open,
|
||||
'position' => 0,
|
||||
]);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Existing progress',
|
||||
'status' => TodoStatus::InProgress,
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('moveTodo', $todo->id, 1, 'in-progress')
|
||||
->assertSeeHtmlInOrder([
|
||||
'data-test="kanban-column-in-progress"',
|
||||
'Existing progress',
|
||||
'Move me',
|
||||
]);
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::InProgress);
|
||||
expect($todo->fresh()->completed_at)->toBeNull();
|
||||
expect(Todo::query()->where('status', TodoStatus::InProgress)->priority()->pluck('description')->all())
|
||||
->toBe(['Existing progress', 'Move me']);
|
||||
});
|
||||
|
||||
test('toggling complete moves a todo into and out of the completed column', 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' => 'Toggle me',
|
||||
'status' => TodoStatus::Open,
|
||||
'position' => 0,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('toggleComplete', $todo->id)
|
||||
->assertSeeHtmlInOrder([
|
||||
'data-test="kanban-column-completed"',
|
||||
'Toggle me',
|
||||
]);
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Completed);
|
||||
expect($todo->fresh()->completed_at)->not->toBeNull();
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('toggleComplete', $todo->id)
|
||||
->assertSeeHtmlInOrder([
|
||||
'data-test="kanban-column-open"',
|
||||
'Toggle me',
|
||||
]);
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Open);
|
||||
expect($todo->fresh()->completed_at)->toBeNull();
|
||||
});
|
||||
|
||||
test('moving a todo to completed marks it complete without losing its workflow status', 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 = Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Finish me',
|
||||
'status' => TodoStatus::Blocked,
|
||||
'position' => 0,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('moveTodo', $todo->id, 0, 'completed')
|
||||
->assertSeeHtmlInOrder([
|
||||
'data-test="kanban-column-completed"',
|
||||
'Finish me',
|
||||
]);
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Blocked);
|
||||
expect($todo->fresh()->completed_at)->not->toBeNull();
|
||||
});
|
||||
|
||||
test('moving an open todo to completed also completes 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)->create([
|
||||
'description' => 'Open task',
|
||||
'status' => TodoStatus::Open,
|
||||
'position' => 0,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('moveTodo', $todo->id, 0, 'completed');
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Completed);
|
||||
expect($todo->fresh()->completed_at)->not->toBeNull();
|
||||
});
|
||||
|
||||
test('moving a completed todo back to a status column reopens it', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
$todo = Todo::factory()->recycle($user)->for($folder)->completed()->create([
|
||||
'description' => 'Reopen me',
|
||||
'status' => TodoStatus::OnHold,
|
||||
'position' => 0,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('moveTodo', $todo->id, 0, 'on-hold')
|
||||
->assertSeeHtmlInOrder([
|
||||
'data-test="kanban-column-on-hold"',
|
||||
'Reopen me',
|
||||
]);
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::OnHold);
|
||||
expect($todo->fresh()->completed_at)->toBeNull();
|
||||
});
|
||||
|
||||
test('reordering within a column keeps the order of other columns', 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 open',
|
||||
'status' => TodoStatus::Open,
|
||||
'position' => 0,
|
||||
]);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Second open',
|
||||
'status' => TodoStatus::Open,
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$blocked = Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Blocked task',
|
||||
'status' => TodoStatus::Blocked,
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('moveTodo', $first->id, 1, 'open');
|
||||
|
||||
expect(Todo::query()->where('status', TodoStatus::Open)->priority()->pluck('description')->all())
|
||||
->toBe(['Second open', 'First open']);
|
||||
expect($blocked->fresh()->position)->toBe(2);
|
||||
});
|
||||
|
||||
test('the board filters by search', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Review design']);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Review proposal']);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->set('search', 'proposal')
|
||||
->assertDontSee('Review design')
|
||||
->assertSee('Review proposal');
|
||||
});
|
||||
|
||||
test('adding a todo from a column preselects that status', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->call('openCreateForm', 'blocked')
|
||||
->assertSet('todoStatus', 'blocked')
|
||||
->set('description', 'Blocked task')
|
||||
->set('formFolderId', $folder->id)
|
||||
->call('saveTodo')
|
||||
->assertSet('showTodoForm', false)
|
||||
->assertSeeHtmlInOrder([
|
||||
'data-test="kanban-column-blocked"',
|
||||
'Blocked task',
|
||||
]);
|
||||
|
||||
$todo = Todo::where('description', 'Blocked task')->firstOrFail();
|
||||
|
||||
expect($todo->status)->toBe(TodoStatus::Blocked);
|
||||
});
|
||||
|
||||
test('users do not see another user todos on the board', function () {
|
||||
$owner = User::factory()->create();
|
||||
$ownerFolder = Folder::factory()->for($owner)->create(['name' => 'Owner Folder']);
|
||||
Todo::factory()->recycle($owner)->for($ownerFolder)->create(['description' => 'Owner secret']);
|
||||
|
||||
$intruder = User::factory()->create();
|
||||
$this->actingAs($intruder);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->assertDontSee('Owner secret')
|
||||
->assertDontSee('Owner Folder');
|
||||
});
|
||||
|
||||
test('viewers cannot move todos on the board', function () {
|
||||
$owner = User::factory()->create();
|
||||
$member = User::factory()->create();
|
||||
|
||||
$organization = Organization::factory()->family()->withMember($owner)->create();
|
||||
$owner->forceFill(['current_organization_id' => $organization->id])->save();
|
||||
$organization->users()->attach($member, ['role' => OrganizationRole::Member->value]);
|
||||
$member->forceFill(['current_organization_id' => $organization->id])->save();
|
||||
|
||||
$folder = Folder::factory()->for($owner)->inOrganization($organization)->sharedWithWorkspace()->create(['name' => 'Shared List']);
|
||||
$todo = Todo::factory()->recycle($owner)->for($folder)->create([
|
||||
'description' => 'Shared task',
|
||||
'status' => TodoStatus::Open,
|
||||
]);
|
||||
|
||||
$this->actingAs($member);
|
||||
|
||||
Livewire::test('pages::kanban')
|
||||
->assertSee('Shared task')
|
||||
->call('moveTodo', $todo->id, 0, 'in-progress')
|
||||
->assertStatus(403);
|
||||
|
||||
expect($todo->fresh()->status)->toBe(TodoStatus::Open);
|
||||
});
|
||||
@@ -266,6 +266,87 @@ test('users do not see another user todos', function () {
|
||||
->assertDontSee('Owner secret');
|
||||
});
|
||||
|
||||
test('todos can be sorted by a column and returned to the manual 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' => 'Alpha', 'position' => 0]);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Bravo', 'position' => 1]);
|
||||
|
||||
Livewire::test('pages::todos')
|
||||
->assertSeeInOrder(['Alpha', 'Bravo'])
|
||||
->assertSeeHtml('wire:sort="handleSort"')
|
||||
->assertSeeHtml('cursor-grab')
|
||||
->assertSeeHtml('wire:click="sort(\'description\')"')
|
||||
->call('sort', 'description')
|
||||
->assertSet('sortBy', 'description')
|
||||
->assertSet('sortDirection', 'asc')
|
||||
->assertSeeInOrder(['Alpha', 'Bravo'])
|
||||
->assertDontSeeHtml('cursor-grab')
|
||||
->call('sort', 'description')
|
||||
->assertSet('sortDirection', 'desc')
|
||||
->assertSeeInOrder(['Bravo', 'Alpha'])
|
||||
->call('sort', 'description')
|
||||
->assertSet('sortBy', null)
|
||||
->assertSet('sortDirection', 'asc')
|
||||
->assertSeeInOrder(['Alpha', 'Bravo'])
|
||||
->assertSeeHtml('cursor-grab');
|
||||
});
|
||||
|
||||
test('todos can be sorted by status workflow 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' => 'Completed task', 'status' => TodoStatus::Completed, 'position' => 0]);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Open task', 'status' => TodoStatus::Open, 'position' => 1]);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Blocked task', 'status' => TodoStatus::Blocked, 'position' => 2]);
|
||||
|
||||
Livewire::test('pages::todos')
|
||||
->call('sort', 'status')
|
||||
->assertSeeInOrder(['Open task', 'Blocked task', 'Completed task']);
|
||||
});
|
||||
|
||||
test('todos can be sorted by folder name', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$alpha = Folder::factory()->for($user)->create(['name' => 'Alpha']);
|
||||
$zulu = Folder::factory()->for($user)->create(['name' => 'Zulu']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($zulu)->create(['description' => 'Zulu task', 'position' => 0]);
|
||||
Todo::factory()->recycle($user)->for($alpha)->create(['description' => 'Alpha task', 'position' => 1]);
|
||||
|
||||
Livewire::test('pages::todos')
|
||||
->assertSeeInOrder(['Zulu task', 'Alpha task'])
|
||||
->call('sort', 'folder')
|
||||
->assertSeeInOrder(['Alpha task', 'Zulu task'])
|
||||
->call('sort', 'folder')
|
||||
->assertSeeInOrder(['Zulu task', 'Alpha task']);
|
||||
});
|
||||
|
||||
test('sorting resets the loaded batch', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$folder = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
|
||||
collect(range(1, 60))
|
||||
->each(fn (int $n) => Todo::factory()->recycle($user)->for($folder)->create([
|
||||
'description' => 'Todo '.$n,
|
||||
'position' => $n - 1,
|
||||
]));
|
||||
|
||||
Livewire::test('pages::todos')
|
||||
->call('loadMore')
|
||||
->assertSet('limit', 60)
|
||||
->call('sort', 'description')
|
||||
->assertSet('limit', 50);
|
||||
});
|
||||
|
||||
test('completed todos show their completion date and days to completion', function () {
|
||||
$this->travelTo('2026-09-10 09:00:00');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user