110 lines
3.1 KiB
PHP
110 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Browser\Pages;
|
|
|
|
use Laravel\Dusk\Browser;
|
|
|
|
class SchedulePage extends Page
|
|
{
|
|
public function url(): string
|
|
{
|
|
return '/schedule';
|
|
}
|
|
|
|
public function assert(Browser $browser): void
|
|
{
|
|
$browser->assertPathIs($this->url())
|
|
->assertSee('SCHEDULE');
|
|
}
|
|
|
|
public function elements(): array
|
|
{
|
|
return [
|
|
'@generate-button' => 'button[wire\\:click="generate"]',
|
|
'@clear-month-button' => 'button[wire\\:click="clearMonth"]',
|
|
'@previous-month' => 'button[wire\\:click="previousMonth"]',
|
|
'@next-month' => 'button[wire\\:click="nextMonth"]',
|
|
'@month-select' => 'select[wire\\:model="selectedMonth"]',
|
|
'@year-select' => 'select[wire\\:model="selectedYear"]',
|
|
'@clear-existing-checkbox' => 'input[wire\\:model="clearExisting"]',
|
|
'@calendar-grid' => '.grid.grid-cols-7',
|
|
];
|
|
}
|
|
|
|
public function clickGenerate(Browser $browser): void
|
|
{
|
|
$browser->waitFor('@generate-button')
|
|
->click('@generate-button')
|
|
->pause(2000); // Wait for generation
|
|
}
|
|
|
|
public function clickClearMonth(Browser $browser): void
|
|
{
|
|
$browser->waitFor('@clear-month-button')
|
|
->click('@clear-month-button')
|
|
->pause(1000);
|
|
}
|
|
|
|
public function goToPreviousMonth(Browser $browser): void
|
|
{
|
|
$browser->waitFor('@previous-month')
|
|
->click('@previous-month')
|
|
->pause(500);
|
|
}
|
|
|
|
public function goToNextMonth(Browser $browser): void
|
|
{
|
|
$browser->waitFor('@next-month')
|
|
->click('@next-month')
|
|
->pause(500);
|
|
}
|
|
|
|
public function selectMonth(Browser $browser, int $month): void
|
|
{
|
|
$browser->waitFor('@month-select')
|
|
->select('@month-select', $month)
|
|
->pause(500);
|
|
}
|
|
|
|
public function selectYear(Browser $browser, int $year): void
|
|
{
|
|
$browser->waitFor('@year-select')
|
|
->select('@year-select', $year)
|
|
->pause(500);
|
|
}
|
|
|
|
public function toggleClearExisting(Browser $browser): void
|
|
{
|
|
$browser->waitFor('@clear-existing-checkbox')
|
|
->click('@clear-existing-checkbox');
|
|
}
|
|
|
|
public function selectUser(Browser $browser, string $userName): void
|
|
{
|
|
$browser->check("input[type='checkbox'][value]", $userName);
|
|
}
|
|
|
|
public function assertSuccessMessage(Browser $browser, string $message = null): void
|
|
{
|
|
if ($message) {
|
|
$browser->assertSee($message);
|
|
} else {
|
|
$browser->assertPresent('.border-success');
|
|
}
|
|
}
|
|
|
|
public function assertDishScheduled(Browser $browser, string $dishName): void
|
|
{
|
|
$browser->assertSee($dishName);
|
|
}
|
|
|
|
public function assertNoDishesScheduled(Browser $browser): void
|
|
{
|
|
$browser->assertSee('No dishes scheduled');
|
|
}
|
|
|
|
public function assertMonthDisplayed(Browser $browser, string $monthYear): void
|
|
{
|
|
$browser->assertSee($monthYear);
|
|
}
|
|
}
|