Remember for each user which Kanban cards have their task list open
The open cards are kept in the user's board preferences (expanded_cards, at most 500), saved without redrawing the board and restored on return. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -193,6 +193,25 @@ it('scrolls only the body of the job editor when a task has many comments', func
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
});
|
||||
|
||||
it('keeps the task list of a card open when the board is opened again', function () {
|
||||
$this->job->update(['status' => 'in_production']);
|
||||
TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Leikkaus']);
|
||||
$toggle = '[aria-controls="tasks-job-'.$this->job->id.'"]';
|
||||
$panel = 'document.getElementById("tasks-job-'.$this->job->id.'")';
|
||||
|
||||
visit(route('jobs.board'))
|
||||
->on()->desktop()
|
||||
->click($toggle)
|
||||
->assertScript($panel.'.offsetParent !== null', true)
|
||||
->wait(1);
|
||||
|
||||
visit(route('jobs.board'))
|
||||
->on()->desktop()
|
||||
->assertAttribute($toggle, 'aria-expanded', 'true')
|
||||
->assertScript($panel.'.offsetParent !== null', true)
|
||||
->assertNoAccessibilityIssues(level: 2);
|
||||
});
|
||||
|
||||
it('marks a task done from the task panel of a card', function () {
|
||||
$this->job->update(['status' => 'in_production']);
|
||||
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Leikkaus', 'status' => 'in_progress']);
|
||||
|
||||
@@ -266,3 +266,23 @@ it('shows a subcontractor only their cards, without moving or changing colours',
|
||||
|
||||
expect($theirs->fresh()->status->value)->toBe('order');
|
||||
});
|
||||
|
||||
it('remembers for each user which cards have their tasks open', function () {
|
||||
$job = CustomerJobModel::factory()->create(['status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||
TaskModel::factory()->create(['customer_job_id' => $job->id, 'title' => 'Vedos']);
|
||||
|
||||
Livewire::test('jobs::board')
|
||||
->assertSeeHtml('aria-controls="tasks-job-'.$job->id.'"')
|
||||
->assertDontSeeHtml('aria-expanded="true"')
|
||||
->call('setCardExpanded', 'job-'.$job->id, true)
|
||||
->call('setCardExpanded', 'job-999', true);
|
||||
|
||||
expect(json_decode((string) DB::table('job_board_preferences')->where('user_id', $this->employee->id)->value('expanded_cards')))->toBe(['job-'.$job->id]);
|
||||
|
||||
Livewire::test('jobs::board')->assertSeeHtml('aria-expanded="true"');
|
||||
|
||||
$colleague = User::factory()->create();
|
||||
$job->update(['responsible_user_id' => $colleague->id]);
|
||||
$this->actingAs($colleague);
|
||||
Livewire::test('jobs::board')->assertDontSeeHtml('aria-expanded="true"');
|
||||
});
|
||||
|
||||
@@ -237,3 +237,27 @@ describe('moving cards', function () {
|
||||
$this->pin->execute($jobId, $taskId, true);
|
||||
})->throws(TaskCannotBePinned::class);
|
||||
});
|
||||
|
||||
describe('open cards', function () {
|
||||
it('remembers which cards are open', function () {
|
||||
$preferences = BoardPreferences::defaults()
|
||||
->withCardExpanded('job-12', true)
|
||||
->withCardExpanded('task-34', true)
|
||||
->withCardExpanded('job-12', false)
|
||||
->withCardExpanded('nonsense', true);
|
||||
|
||||
expect($preferences->isCardExpanded('task-34'))->toBeTrue()
|
||||
->and($preferences->isCardExpanded('job-12'))->toBeFalse()
|
||||
->and($preferences->expandedCards)->toBe(['task-34']);
|
||||
});
|
||||
|
||||
it('keeps only valid keys and the latest cards from stored settings', function () {
|
||||
$stored = array_map(fn (int $id): string => 'job-'.$id, range(1, BoardPreferences::MAX_EXPANDED_CARDS + 10));
|
||||
$preferences = BoardPreferences::fromStored(null, null, [], [], [...$stored, 'drop table', 42, 'job-1']);
|
||||
|
||||
expect($preferences->expandedCards)->toHaveCount(BoardPreferences::MAX_EXPANDED_CARDS)
|
||||
->and($preferences->isCardExpanded('job-1'))->toBeFalse()
|
||||
->and($preferences->isCardExpanded('job-'.(BoardPreferences::MAX_EXPANDED_CARDS + 10)))->toBeTrue()
|
||||
->and($preferences->isCardExpanded('drop table'))->toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user