Skip to content

Commit

Permalink
Merge pull request #60 from LowerRockLabs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
lrljoe authored Mar 18, 2023
2 parents c546db4 + 577b858 commit 9636ce0
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 183 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ build/coverage.txt
build/report.junit.xml
clover.xml
resources/views/components/buttons/popover-open.blade copy.php
tests/Dusk/Web/screenshots/
tests/Dusk/Web/console/
phpunit.dusk.xml
9 changes: 9 additions & 0 deletions phpunit.dusk.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false">

<php>
<env name="APP_KEY" value="1IAkQlj4R/ayOse4lpu36GmRHSDHBdWy4fjXa8jEYy0=" />
<env name="APP_URL" value="http://laravel.test" force="true" />
<env name="DUSK_DRIVER_URL" value="selenium:4444" />
<env name="DEBUGBAR_ENABLED" value="false" force="true" />

</php>

<testsuites>
<testsuite name="Browser Test Suite">
<directory suffix="Test.php">./tests/Dusk/</directory>
Expand Down
22 changes: 19 additions & 3 deletions resources/views/components/tools/filters/datePicker.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@
}
for (let i = 0; i < this.twMenuElements.length; i++) {
if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.twMenuElements.item(i).hasAttribute('x-data'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
Expand All @@ -57,10 +62,13 @@
@if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5')
if (parentLabelElement === null) {
let parentLabelContainer = document.getElementById('{{ $filterContainerName }}{{ $filterKey }}').parentElement.firstElementChild;
if (parentLabelContainer !== null) {
parentLabelContainer.classList.add('hidden');
parentLabelContainer.classList.add('d-none');
}
} else {
parentLabelElement.classList.add('hidden');
parentLabelElement.classList.add('d-none');
}
Expand All @@ -69,11 +77,19 @@
}
for (let i = 0; i < this.bsMenuElements.length; i++) {
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.bsMenuElements.item(i).hasAttribute('x-data'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else
{
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
}
}
@endif
},
Expand Down Expand Up @@ -144,7 +160,7 @@
<x-livewiretablesadvancedfilters::elements.labelInternal :theme="$theme" :filterLabelPath="$filterLabelPath"
:filterName="$filterName" />

<div x-on:click="flatpickrInstance.toggle()" class="d-inline-block w-100 mb-3 mb-md-0 input-group"
<div class="d-inline-block w-100 mb-3 mb-md-0 input-group"
placeholder="{{ __('app.enter') }} {{ __('app.date') }}">

<x-livewiretablesadvancedfilters::forms.datePicker-textinput :filterKey="$filterKey" :theme="$theme"
Expand Down
18 changes: 16 additions & 2 deletions resources/views/components/tools/filters/dateRange.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@
}
for (let i = 0; i < this.twMenuElements.length; i++) {
if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.twMenuElements.item(i).hasAttribute('x-data'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
Expand All @@ -76,6 +81,7 @@
@if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5')
if (parentLabelElement === null) {
let parentLabelContainer = document.getElementById('{{ $filterContainerName }}{{ $filterKey }}').parentElement.firstElementChild;
if (parentLabelContainer !== null) {
parentLabelContainer.classList.add('d-none');
}
Expand All @@ -88,11 +94,19 @@
}
for (let i = 0; i < this.bsMenuElements.length; i++) {
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.bsMenuElements.item(i).hasAttribute('x-data'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else
{
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
}
}
@endif
},
Expand Down
18 changes: 16 additions & 2 deletions resources/views/components/tools/filters/numberRange.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@
}
for (let i = 0; i < this.twMenuElements.length; i++) {
if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.twMenuElements.item(i).hasAttribute('x-data'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
Expand All @@ -72,6 +77,7 @@
@if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5')
if (parentLabelElement === null) {
let parentLabelContainer = document.getElementById('{{ $filterContainerName }}{{ $filterKey }}').parentElement.firstElementChild;
if (parentLabelContainer !== null) {
parentLabelContainer.classList.add('d-none');
}
Expand All @@ -84,11 +90,19 @@
}
for (let i = 0; i < this.bsMenuElements.length; i++) {
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.bsMenuElements.item(i).hasAttribute('x-data'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else
{
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
}
}
@endif
},
Expand Down
18 changes: 16 additions & 2 deletions resources/views/components/tools/filters/slimSelect.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@
}
for (let i = 0; i < this.twMenuElements.length; i++) {
if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.twMenuElements.item(i).hasAttribute('x-data'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
Expand All @@ -58,6 +63,7 @@
@if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5')
if (parentLabelElement === null) {
let parentLabelContainer = document.getElementById('{{ $filterContainerName }}{{ $filterKey }}').parentElement.firstElementChild;
if (parentLabelContainer !== null) {
parentLabelContainer.classList.add('d-none');
}
Expand All @@ -70,11 +76,19 @@
}
for (let i = 0; i < this.bsMenuElements.length; i++) {
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.bsMenuElements.item(i).hasAttribute('x-data'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else
{
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
}
}
@endif
},
Expand Down
19 changes: 17 additions & 2 deletions resources/views/components/tools/filters/smartSelect.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
}
for (let i = 0; i < this.twMenuElements.length; i++) {
if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.twMenuElements.item(i).hasAttribute('x-data'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }');
this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
Expand All @@ -61,6 +66,8 @@
@if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5')
if (parentLabelElement === null) {
let parentLabelContainer = document.getElementById('{{ $filterContainerName }}{{ $filterKey }}').parentElement.firstElementChild;
if (parentLabelContainer !== null) {
parentLabelContainer.classList.add('d-none');
}
Expand All @@ -73,11 +80,19 @@
}
for (let i = 0; i < this.bsMenuElements.length; i++) {
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
if (!this.bsMenuElements.item(i).hasAttribute('x-data'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
else
{
if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen'))
{
this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }');
this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }');
}
}
}
@endif
Expand Down
137 changes: 137 additions & 0 deletions tests/Dusk/Web/DatePickerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php

namespace LowerRockLabs\LaravelLivewireTablesAdvancedFilters\Tests\Dusk\Web;

use Carbon\Carbon;
use Laravel\Dusk\Browser;
use LowerRockLabs\LaravelLivewireTablesAdvancedFilters\Tests\Dusk\DuskTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

final class DatePickerTest extends DuskTestCase
{
public static function urlProvider(): array
{
return [
'TW2' => [
'/tailwind',
],
'TW3' => [
'/tailwind3',
],
'TW2-slidedown' => [
'/tailwind-slidedown',
],
'TW3-slidedown' => [
'/tailwind3-slidedown',
],


'BS4' => [
'/bootstrap-4',
],/*
'BS5' => [
'/bootstrap-5',
],*/
/*
'BS4-slidedown' => [
'/bootstrap-4-slidedown',
],
'BS5-slidedown' => [
'/bootstrap-5-slidedown',
], */
];
}

/**
* testDatepickerFilterOpens
*/
#[DataProvider('urlProvider')]
public function testDatepickerFilterOpens($baseURL): void
{
$this->browse(function (Browser $browser) use ($baseURL) {
$browser->visit($baseURL);

$browser->pause(1000);

$browser->press('@filtBtn');

$browser->pause(1000);

$browser->assertDontSee('Wed');

$browser->pause(1000);

$browser->click('#users2-filter-verified_before_date');

$browser->pause(1000);

$browser->screenshot(trim($baseURL, '//')."_flatpickrDatepicker-testDatepickerFilterOpens-click-verified_before_date".date('Y-m-d H'));

$browser->assertSee('Sun')->assertSee('Mon')->assertSee('Tue')->assertSee('Wed')->assertSee('Thu')->assertSee('Fri')->assertSee('Sat');

$browser->assertSee('28')->assertSee('15')->assertSee('1')->assertSee('7')->assertSee('25');

$browser->assertSee(date('F'));

$browser->screenshot(trim($baseURL, '//')."_flatpickrDatepicker-testDatepickerFilterOpens-click-verified_before_date-seeYear".date('Y-m-d H'));

$browser->assertVisible('div.flatpickr-calendar.animate.arrowBottom.arrowLeft.open > div.flatpickr-innerContainer > div > div.flatpickr-days > div > span:nth-child(10)');

$currentDate = $browser->attribute('div.flatpickr-calendar.animate.arrowBottom.arrowLeft.open > div.flatpickr-innerContainer > div > div.flatpickr-days > div > span:nth-child(10)', 'aria-label');

$browser->click('div.flatpickr-calendar.animate.arrowBottom.arrowLeft.open > div.flatpickr-innerContainer > div > div.flatpickr-days > div > span:nth-child(10)');

$browser->pause(1000);

$browser->screenshot(trim($baseURL, '//')."_flatpickrDatepicker-testDatepickerFilterOpens-AssetSeeDates".date('Y-m-d H'));

$browser->press('@filtBtn');

$browser->pause(1000);

$browser->assertSee($currentDate);

$browser->assertDontSee(date('F j, Y'));

$browser->pause(1000);

$browser->screenshot(trim($baseURL, '//')."_flatpickrDatepicker-testDatepickerFilterOpens-".date('Y-m-d H'));

$browser->assertAttribute('.today', 'aria-label', date('F j, Y'));

$this->assertEquals($browser->attribute('.today', 'aria-label'), date('F j, Y'));

$this->assertNotEquals($browser->attribute('.today', 'aria-label'), Carbon::tomorrow()->format('F j, Y'));
});
}
/*
#[DataProvider('urlProvider')]
public function testTodayIsDefaultDate($baseURL): void
{
$this->browse(function (Browser $browser) use ($baseURL) {
$browser->visit($baseURL);
$browser->pause(1000);
$browser->press('@filtBtn');
$browser->pause(2000);
$browser->assertDontSee('Wed');
$browser->pause(1000);
$browser->click('#users2-filter-verified_before_date');
$browser->pause(3000);
$browser->assertAttribute('.today','aria-label',date('F j, Y'));
$this->assertEquals($browser->attribute('.today','aria-label'),date('F j, Y'));
$this->assertNotEquals($browser->attribute('.today','aria-label'),Carbon::tomorrow()->format('F j, Y'));
});
}
*/
}
Loading

0 comments on commit 9636ce0

Please sign in to comment.