Repository navigation
Expand file tree
/
Copy pathJoinedQueryKeyTest.php
More file actions
62 lines (46 loc) · 2.74 KB
/
Copy pathJoinedQueryKeyTest.php
File metadata and controls
62 lines (46 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\DB;
use Livewire\Livewire;
use Relaticle\Flowforge\Tests\Fixtures\Task;
use Relaticle\Flowforge\Tests\Fixtures\TestQueryShapeBoard;
function labelledClassicTask(string $title, string $status, string $position, bool $labelled = true): Task
{
$task = Task::create(['title' => $title, 'status' => $status, 'order_position' => $position]);
if ($labelled) {
DB::table('task_labels')->insert(['id' => $task->id + 100000, 'task_id' => $task->id, 'label' => 'bug']);
}
return $task;
}
test('a board whose query joins a labelled table renders', function () {
labelledClassicTask('Joined card', 'todo', '65535.0000000000');
Livewire::test(TestQueryShapeBoard::class, ['shape' => 'labelled'])
->assertSee('Joined card');
})->group('pgsql');
test('a card moves to the bottom of a column on a board that joins a labelled table', function () {
labelledClassicTask('Existing', 'in_progress', '1000.0000000000');
$card = labelledClassicTask('Moving', 'todo', '65535.0000000000', labelled: false);
Livewire::test(TestQueryShapeBoard::class, ['shape' => 'labelled'])
->call('moveCard', (string) $card->id, 'in_progress')
->assertDispatched('kanban-card-moved');
expect($card->fresh()->status)->toBe('in_progress')
->and((float) $card->fresh()->order_position)->toBeGreaterThan(1000.0);
})->group('pgsql');
test('a card moves between two cards of a board that joins a labelled table', function () {
$above = labelledClassicTask('Above', 'in_progress', '1000.0000000000');
$below = labelledClassicTask('Below', 'in_progress', '2000.0000000000', labelled: false);
$card = labelledClassicTask('Moving', 'todo', '65535.0000000000');
Livewire::test(TestQueryShapeBoard::class, ['shape' => 'labelled'])
->call('moveCard', (string) $card->id, 'in_progress', (string) $above->id, (string) $below->id)
->assertDispatched('kanban-card-moved');
expect((float) $card->fresh()->order_position)->toBeGreaterThan(1000.0)->toBeLessThan(2000.0);
})->group('pgsql');
test('a column rebalances on a board that joins a labelled table', function () {
$above = labelledClassicTask('Above', 'in_progress', '1000.0000000000');
$below = labelledClassicTask('Below', 'in_progress', '1000.0000500000', labelled: false);
$card = labelledClassicTask('Moving', 'todo', '65535.0000000000');
Livewire::test(TestQueryShapeBoard::class, ['shape' => 'labelled'])
->call('moveCard', (string) $card->id, 'in_progress', (string) $above->id, (string) $below->id)
->assertDispatched('kanban-card-moved');
expect((float) $below->fresh()->order_position - (float) $above->fresh()->order_position)->toBeGreaterThan(1.0);
})->group('pgsql');