Skip to content

Commit e9b70e1

Browse files
committed
Updated test suite
1 parent 8c299ab commit e9b70e1

File tree

7 files changed

+265
-145
lines changed

7 files changed

+265
-145
lines changed

resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
@aware(['tableName'])
2-
<div
3-
{{
2+
<div {{
43
$attributes->merge($this->getPerPageWrapperAttributes())
54
->class([
65
'ml-0 ml-md-2' => $this->isBootstrap4 && ($this->getPerPageWrapperAttributes()['default-styling'] ?? true),
76
'ms-0 ms-md-2' => $this->isBootstrap5 && ($this->getPerPageWrapperAttributes()['default-styling'] ?? true),
87
])
98
->except(['default','default-styling','default-colors'])
10-
}}
11-
>
12-
<select wire:model.live="perPage" id="{{ $tableName }}-perPage"
13-
{{
9+
}}>
10+
<select wire:model.live="perPage" id="{{ $tableName }}-perPage" {{
1411
$attributes->merge($this->getPerPageFieldAttributes())
1512
->class([
1613
'form-control' => $this->isBootstrap4 && ($this->getPerPageFieldAttributes()['default-styling'] ?? true),
@@ -19,13 +16,10 @@
1916
'border-gray-300 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-700 dark:text-white dark:border-gray-600' => $this->isTailwind && (($this->getPerPageFieldAttributes()['default'] ?? false) || ($this->getPerPageFieldAttributes()['default-colors'] ?? true)),
2017
])
2118
->except(['default','default-styling','default-colors'])
22-
}}
23-
>
19+
}}>
20+
2421
@foreach ($this->getPerPageAccepted() as $item)
25-
<option
26-
value="{{ $item }}"
27-
wire:key="{{ $tableName }}-per-page-{{ $item }}"
28-
>
22+
<option value="{{ $item }}" wire:key="{{ $tableName }}-per-page-{{ $item }}">
2923
{{ $item === -1 ? __('livewire-tables::All') : $item }}
3024
</option>
3125
@endforeach

resources/views/specific/bootstrap-4/pagination.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@if ($paginator->hasPages())
33
@php(isset($this->numberOfPaginatorsRendered[$paginator->getPageName()]) ? $this->numberOfPaginatorsRendered[$paginator->getPageName()]++ : $this->numberOfPaginatorsRendered[$paginator->getPageName()] = 1)
44

5-
<nav>
5+
<nav role="navigation" aria-label="Pagination Navigation">
66
<ul class="pagination">
77
{{-- Previous Page Link --}}
88
@if ($paginator->onFirstPage())

resources/views/specific/bootstrap-4/simple-pagination.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
22
@if ($paginator->hasPages())
3-
<nav>
3+
<nav role="navigation" aria-label="Pagination Navigation" >
44
<ul class="pagination">
55
{{-- Previous Page Link --}}
66
@if ($paginator->onFirstPage())
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\Bootstrap4;
4+
5+
use Livewire\Livewire;
6+
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
7+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
8+
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\ThemedTestCase;
9+
10+
final class BS4PaginationVisualsTest extends ThemedTestCase
11+
{
12+
protected function setupBasicTableForBrowsing()
13+
{
14+
return $this->setupBasicTableForLivewire()
15+
->call('setTheme', 'bootstrap-4');
16+
}
17+
18+
protected function setupBasicTableSingleRecord()
19+
{
20+
return $this->setupSingleRecordBasicTable()
21+
->call('setTheme', 'bootstrap-4');
22+
}
23+
24+
25+
public function test_pagination_shows_by_default(): void
26+
{
27+
$this->setupBasicTableSingleRecord()
28+
->assertSeeHtml('<nav role="navigation" aria-label="Pagination Navigation">')
29+
->assertSeeHtml('<ul class="pagination">');
30+
}
31+
32+
public function test_per_page_shows_by_default(): void
33+
{
34+
$this->setupBasicTableForBrowsing()
35+
->assertSeeHtml('<select wire:model.live="perPage" id="table-perPage" class="form-control">');
36+
}
37+
38+
public function test_detailed_pagination_is_displayed_standard_bs4(): void
39+
{
40+
$this->tableWithStandardDetailedPagination()
41+
->assertSeeHtmlInOrder([
42+
'<div class="col-12 col-md-6 text-center text-md-right text-muted">',
43+
'<span>Showing</span>',
44+
'<strong>1</strong>',
45+
'<span>to</span>',
46+
'<span>of</span>',
47+
]);
48+
}
49+
50+
public function test_detailed_pagination_is_displayed_simple_bs4(): void
51+
{
52+
$this->tableWithSimpleDetailedPagination()
53+
->assertSeeHtmlInOrder([
54+
'<div class="col-12 col-md-6 overflow-auto">',
55+
'<span>Showing</span>',
56+
'<strong>1</strong>',
57+
'<span>to</span>',
58+
])
59+
->assertDontSeeHtml('<span>of</span>');
60+
}
61+
62+
public function test_detailed_pagination_is_not_displayed_standard_bs4(): void
63+
{
64+
$this->setupBasicTableForBrowsing()
65+
->call('disableDetailedPagination', 'standard')
66+
->assertDontSeeHtml('<span>Showing</span>')
67+
->assertDontSeeHtml('<span>to</span>')
68+
->assertDontSeeHtml('<span>of</span>');
69+
}
70+
71+
public function test_detailed_pagination_is_not_displayed_simple_bs4(): void
72+
{
73+
$this->setupBasicTableForBrowsing()
74+
->call('disableDetailedPagination', 'simple')
75+
->assertDontSeeHtml('<span>Showing</span>')
76+
->assertDontSeeHtml('<span>to</span>');
77+
}
78+
79+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\Bootstrap5;
4+
5+
use Livewire\Livewire;
6+
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
7+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
8+
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\ThemedTestCase;
9+
10+
final class BS5PaginationVisualsTest extends ThemedTestCase
11+
{
12+
13+
protected function setupBasicTableForBrowsing()
14+
{
15+
return $this->setupBasicTableForLivewire()
16+
->call('setTheme', 'bootstrap-5');
17+
}
18+
19+
protected function setupBasicTableSingleRecord()
20+
{
21+
return $this->setupSingleRecordBasicTable()
22+
->call('setTheme', 'bootstrap-5');
23+
}
24+
25+
public function test_pagination_shows_by_default(): void
26+
{
27+
$this->setupBasicTableSingleRecord()
28+
->assertSeeHtml('<nav role="navigation" aria-label="Pagination Navigation">')
29+
->assertSeeHtml('<ul class="pagination">');
30+
}
31+
32+
public function test_per_page_shows_by_default(): void
33+
{
34+
$this->setupBasicTableForBrowsing()
35+
->assertSeeHtml('<select wire:model.live="perPage" id="table-perPage" class="form-select">');
36+
}
37+
38+
39+
public function test_detailed_pagination_is_displayed_standard_bs5(): void
40+
{
41+
$this->tableWithStandardDetailedPagination()
42+
->assertSeeHtmlInOrder([
43+
'<div class="col-12 col-md-6 text-center text-md-end text-muted">',
44+
'<span>Showing</span>',
45+
'<strong>1</strong>',
46+
'<span>to</span>',
47+
'<span>of</span>',
48+
]);
49+
}
50+
51+
public function test_detailed_pagination_is_displayed_simple(): void
52+
{
53+
$this->tableWithSimpleDetailedPagination()
54+
->assertSeeHtmlInOrder([
55+
'<div class="col-12 col-md-6 text-center text-md-end text-muted">',
56+
'<span>Showing</span>',
57+
'<strong>1</strong>',
58+
'<span>to</span>',
59+
])
60+
->assertDontSeeHtml('<span>of</span>');
61+
}
62+
63+
public function test_detailed_pagination_is_not_displayed_standard_bs5(): void
64+
{
65+
$this->setupBasicTableForBrowsing()
66+
->call('disableDetailedPagination', 'standard')
67+
->assertDontSeeHtml('<span>Showing</span>')
68+
->assertDontSeeHtml('<span>to</span>')
69+
->assertDontSeeHtml('<span>of</span>');
70+
}
71+
72+
public function test_detailed_pagination_is_not_displayed_simple_bs5(): void
73+
{
74+
$this->setupBasicTableForBrowsing()
75+
->call('disableDetailedPagination', 'simple')
76+
->assertDontSeeHtml('<span>Showing</span>')
77+
->assertDontSeeHtml('<span>to</span>');
78+
}
79+
80+
}

0 commit comments

Comments
 (0)