Files
Toiminnanohjaus/tests/Browser/AccessibilityTest.php
T
petriandClaude Sonnet 5.5 487a7d34ba Replace the demo home page with a dashboard
Everyone sees their open tasks on an agenda, their open jobs, this
week's hours and quick links. Admin and management also get a lazily
loaded management panel: things to do, the month so far against the
previous month, jobs and late work, and everyone's workload.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-25 09:20:02 +02:00

43 lines
1.4 KiB
PHP

<?php
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function () {
$this->actingAs(User::factory()->admin()->create());
});
it('has no accessibility issues on the home page', function (string $device, string $colorScheme) {
$page = visit(route('home'));
$page = $device === 'mobile' ? $page->on()->mobile() : $page->on()->desktop();
$page = $colorScheme === 'dark' ? $page->inDarkMode() : $page->inLightMode();
$page->assertSee('Toiminnanohjaus')
->assertNoJavaScriptErrors()
->assertNoAccessibilityIssues(level: 2);
})->with([
'desktop, light' => ['desktop', 'light'],
'desktop, dark' => ['desktop', 'dark'],
'mobile, light' => ['mobile', 'light'],
'mobile, dark' => ['mobile', 'dark'],
]);
it('can be operated with the keyboard alone', function () {
$page = visit(route('home'));
$page->keys('html > body', 'Tab')
->assertScript('document.activeElement.textContent.trim()', 'Siirry pääsisältöön')
->keys('a[href="#main-content"]', 'Enter')
->keys('#main-content', 'Tab')
->assertScript('document.activeElement.textContent.trim()', 'Pikavastaanotto');
});
it('reaches the main menu with the keyboard', function () {
visit(route('home'))
->keys('html > body', ['Tab', 'Tab', 'Tab'])
->assertScript('document.activeElement.closest("nav")?.getAttribute("aria-label")', 'Päävalikko');
});