@@ -607,6 +607,57 @@ test('dragging accounts for the pagination offset', function () {
|
||||
expect($todoTwelve->fresh()->position)->toBe(10);
|
||||
});
|
||||
|
||||
test('the table re-renders in the new order after a drag', 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')
|
||||
->assertSeeInOrder(['First todo', 'Second todo', 'Third todo'])
|
||||
->call('handleSort', $first->id, 2)
|
||||
->assertSeeInOrder(['Second todo', 'Third todo', 'First todo']);
|
||||
});
|
||||
|
||||
test('the table re-renders in the new order after moving a todo', 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]);
|
||||
Todo::factory()->recycle($user)->for($folder)->create(['description' => 'Second todo', 'position' => 1]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['First todo', 'Second todo'])
|
||||
->call('moveTodo', $first->id, 'down')
|
||||
->assertSeeInOrder(['Second todo', 'First todo']);
|
||||
});
|
||||
|
||||
test('reordering while filtered keeps the order of the todos the filter hides', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$work = Folder::factory()->for($user)->create(['name' => 'Work']);
|
||||
$home = Folder::factory()->for($user)->create(['name' => 'Home']);
|
||||
|
||||
Todo::factory()->recycle($user)->for($home)->create(['description' => 'Home one', 'position' => 0]);
|
||||
Todo::factory()->recycle($user)->for($home)->create(['description' => 'Home two', 'position' => 1]);
|
||||
$workOne = Todo::factory()->recycle($user)->for($work)->create(['description' => 'Work one', 'position' => 2]);
|
||||
Todo::factory()->recycle($user)->for($work)->create(['description' => 'Work two', 'position' => 3]);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->set('folderId', $work->id)
|
||||
->call('handleSort', $workOne->id, 1);
|
||||
|
||||
Livewire::test('pages::dashboard')
|
||||
->assertSeeInOrder(['Home one', 'Home two', 'Work two', 'Work one']);
|
||||
});
|
||||
|
||||
test('completed todos sort last regardless of their position', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Reference in New Issue
Block a user