2026-10-29 19:04:46 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Models\Tag;
|
|
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
|
|
|
|
|
|
describe('change-order blade component', function (): void {
|
|
|
|
|
it('shows down arrow on the last item of page 1 when there are multiple pages', function (): void {
|
|
|
|
|
// GIVEN
|
2026-10-29 19:13:31 +01:00
|
|
|
$tag = new Tag();
|
|
|
|
|
$tag->id = 1;
|
2026-10-29 19:04:46 +01:00
|
|
|
$tag->order = 15;
|
2026-10-29 19:13:31 +01:00
|
|
|
$paginator = new LengthAwarePaginator([$tag], 30, 15, 1);
|
2026-10-29 19:04:46 +01:00
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$html = view('bo.modules.change-order', [
|
|
|
|
|
'route' => 'bo.tags.change-order',
|
|
|
|
|
'model' => $tag,
|
|
|
|
|
'first' => false,
|
|
|
|
|
'last' => true,
|
|
|
|
|
'isFirstPage' => $paginator->onFirstPage(),
|
2026-10-29 19:13:31 +01:00
|
|
|
'isLastPage' => ! $paginator->hasMorePages(),
|
2026-10-29 19:04:46 +01:00
|
|
|
])->render();
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($html)->toContain('name="down_arrow"');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('shows up arrow on the first item of page 2 when there are multiple pages', function (): void {
|
|
|
|
|
// GIVEN
|
2026-10-29 19:13:31 +01:00
|
|
|
$tag = new Tag();
|
|
|
|
|
$tag->id = 2;
|
2026-10-29 19:04:46 +01:00
|
|
|
$tag->order = 16;
|
2026-10-29 19:13:31 +01:00
|
|
|
$paginator = new LengthAwarePaginator([$tag], 30, 15, 2);
|
2026-10-29 19:04:46 +01:00
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$html = view('bo.modules.change-order', [
|
|
|
|
|
'route' => 'bo.tags.change-order',
|
|
|
|
|
'model' => $tag,
|
|
|
|
|
'first' => true,
|
|
|
|
|
'last' => false,
|
|
|
|
|
'isFirstPage' => $paginator->onFirstPage(),
|
2026-10-29 19:13:31 +01:00
|
|
|
'isLastPage' => ! $paginator->hasMorePages(),
|
2026-10-29 19:04:46 +01:00
|
|
|
])->render();
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($html)->toContain('name="down_up"');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('hides up arrow on the first item of the first page', function (): void {
|
|
|
|
|
// GIVEN
|
2026-10-29 19:13:31 +01:00
|
|
|
$tag = new Tag();
|
|
|
|
|
$tag->id = 1;
|
2026-10-29 19:04:46 +01:00
|
|
|
$tag->order = 1;
|
2026-10-29 19:13:31 +01:00
|
|
|
$paginator = new LengthAwarePaginator([$tag], 30, 15, 1);
|
2026-10-29 19:04:46 +01:00
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$html = view('bo.modules.change-order', [
|
|
|
|
|
'route' => 'bo.tags.change-order',
|
|
|
|
|
'model' => $tag,
|
|
|
|
|
'first' => true,
|
|
|
|
|
'last' => false,
|
|
|
|
|
'isFirstPage' => $paginator->onFirstPage(),
|
2026-10-29 19:13:31 +01:00
|
|
|
'isLastPage' => ! $paginator->hasMorePages(),
|
2026-10-29 19:04:46 +01:00
|
|
|
])->render();
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($html)->not->toContain('name="down_up"');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('hides down arrow on the last item of the last page', function (): void {
|
|
|
|
|
// GIVEN
|
2026-10-29 19:13:31 +01:00
|
|
|
$tag = new Tag();
|
|
|
|
|
$tag->id = 2;
|
2026-10-29 19:04:46 +01:00
|
|
|
$tag->order = 30;
|
2026-10-29 19:13:31 +01:00
|
|
|
$paginator = new LengthAwarePaginator([$tag], 30, 15, 2);
|
2026-10-29 19:04:46 +01:00
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$html = view('bo.modules.change-order', [
|
|
|
|
|
'route' => 'bo.tags.change-order',
|
|
|
|
|
'model' => $tag,
|
|
|
|
|
'first' => false,
|
|
|
|
|
'last' => true,
|
|
|
|
|
'isFirstPage' => $paginator->onFirstPage(),
|
2026-10-29 19:13:31 +01:00
|
|
|
'isLastPage' => ! $paginator->hasMorePages(),
|
2026-10-29 19:04:46 +01:00
|
|
|
])->render();
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($html)->not->toContain('name="down_arrow"');
|
|
|
|
|
});
|
|
|
|
|
});
|