Skip to content

Commit

Permalink
Updated test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe committed Oct 1, 2024
1 parent 8c299ab commit e9b70e1
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
@aware(['tableName'])
<div
{{
<div {{
$attributes->merge($this->getPerPageWrapperAttributes())
->class([
'ml-0 ml-md-2' => $this->isBootstrap4 && ($this->getPerPageWrapperAttributes()['default-styling'] ?? true),
'ms-0 ms-md-2' => $this->isBootstrap5 && ($this->getPerPageWrapperAttributes()['default-styling'] ?? true),
])
->except(['default','default-styling','default-colors'])
}}
>
<select wire:model.live="perPage" id="{{ $tableName }}-perPage"
{{
}}>
<select wire:model.live="perPage" id="{{ $tableName }}-perPage" {{
$attributes->merge($this->getPerPageFieldAttributes())
->class([
'form-control' => $this->isBootstrap4 && ($this->getPerPageFieldAttributes()['default-styling'] ?? true),
Expand All @@ -19,13 +16,10 @@
'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)),
])
->except(['default','default-styling','default-colors'])
}}
>
}}>

@foreach ($this->getPerPageAccepted() as $item)
<option
value="{{ $item }}"
wire:key="{{ $tableName }}-per-page-{{ $item }}"
>
<option value="{{ $item }}" wire:key="{{ $tableName }}-per-page-{{ $item }}">
{{ $item === -1 ? __('livewire-tables::All') : $item }}
</option>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/specific/bootstrap-4/pagination.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@if ($paginator->hasPages())
@php(isset($this->numberOfPaginatorsRendered[$paginator->getPageName()]) ? $this->numberOfPaginatorsRendered[$paginator->getPageName()]++ : $this->numberOfPaginatorsRendered[$paginator->getPageName()] = 1)

<nav>
<nav role="navigation" aria-label="Pagination Navigation">
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>
@if ($paginator->hasPages())
<nav>
<nav role="navigation" aria-label="Pagination Navigation" >
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\Bootstrap4;

use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\ThemedTestCase;

final class BS4PaginationVisualsTest extends ThemedTestCase
{
protected function setupBasicTableForBrowsing()
{
return $this->setupBasicTableForLivewire()
->call('setTheme', 'bootstrap-4');
}

protected function setupBasicTableSingleRecord()
{
return $this->setupSingleRecordBasicTable()
->call('setTheme', 'bootstrap-4');
}


public function test_pagination_shows_by_default(): void
{
$this->setupBasicTableSingleRecord()
->assertSeeHtml('<nav role="navigation" aria-label="Pagination Navigation">')
->assertSeeHtml('<ul class="pagination">');
}

public function test_per_page_shows_by_default(): void
{
$this->setupBasicTableForBrowsing()
->assertSeeHtml('<select wire:model.live="perPage" id="table-perPage" class="form-control">');
}

public function test_detailed_pagination_is_displayed_standard_bs4(): void
{
$this->tableWithStandardDetailedPagination()
->assertSeeHtmlInOrder([
'<div class="col-12 col-md-6 text-center text-md-right text-muted">',
'<span>Showing</span>',
'<strong>1</strong>',
'<span>to</span>',
'<span>of</span>',
]);
}

public function test_detailed_pagination_is_displayed_simple_bs4(): void
{
$this->tableWithSimpleDetailedPagination()
->assertSeeHtmlInOrder([
'<div class="col-12 col-md-6 overflow-auto">',
'<span>Showing</span>',
'<strong>1</strong>',
'<span>to</span>',
])
->assertDontSeeHtml('<span>of</span>');
}

public function test_detailed_pagination_is_not_displayed_standard_bs4(): void
{
$this->setupBasicTableForBrowsing()
->call('disableDetailedPagination', 'standard')
->assertDontSeeHtml('<span>Showing</span>')
->assertDontSeeHtml('<span>to</span>')
->assertDontSeeHtml('<span>of</span>');
}

public function test_detailed_pagination_is_not_displayed_simple_bs4(): void
{
$this->setupBasicTableForBrowsing()
->call('disableDetailedPagination', 'simple')
->assertDontSeeHtml('<span>Showing</span>')
->assertDontSeeHtml('<span>to</span>');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\Bootstrap5;

use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable};
use Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Themed\ThemedTestCase;

final class BS5PaginationVisualsTest extends ThemedTestCase
{

protected function setupBasicTableForBrowsing()
{
return $this->setupBasicTableForLivewire()
->call('setTheme', 'bootstrap-5');
}

protected function setupBasicTableSingleRecord()
{
return $this->setupSingleRecordBasicTable()
->call('setTheme', 'bootstrap-5');
}

public function test_pagination_shows_by_default(): void
{
$this->setupBasicTableSingleRecord()
->assertSeeHtml('<nav role="navigation" aria-label="Pagination Navigation">')
->assertSeeHtml('<ul class="pagination">');
}

public function test_per_page_shows_by_default(): void
{
$this->setupBasicTableForBrowsing()
->assertSeeHtml('<select wire:model.live="perPage" id="table-perPage" class="form-select">');
}


public function test_detailed_pagination_is_displayed_standard_bs5(): void
{
$this->tableWithStandardDetailedPagination()
->assertSeeHtmlInOrder([
'<div class="col-12 col-md-6 text-center text-md-end text-muted">',
'<span>Showing</span>',
'<strong>1</strong>',
'<span>to</span>',
'<span>of</span>',
]);
}

public function test_detailed_pagination_is_displayed_simple(): void
{
$this->tableWithSimpleDetailedPagination()
->assertSeeHtmlInOrder([
'<div class="col-12 col-md-6 text-center text-md-end text-muted">',
'<span>Showing</span>',
'<strong>1</strong>',
'<span>to</span>',
])
->assertDontSeeHtml('<span>of</span>');
}

public function test_detailed_pagination_is_not_displayed_standard_bs5(): void
{
$this->setupBasicTableForBrowsing()
->call('disableDetailedPagination', 'standard')
->assertDontSeeHtml('<span>Showing</span>')
->assertDontSeeHtml('<span>to</span>')
->assertDontSeeHtml('<span>of</span>');
}

public function test_detailed_pagination_is_not_displayed_simple_bs5(): void
{
$this->setupBasicTableForBrowsing()
->call('disableDetailedPagination', 'simple')
->assertDontSeeHtml('<span>Showing</span>')
->assertDontSeeHtml('<span>to</span>');
}

}
Loading

0 comments on commit e9b70e1

Please sign in to comment.