Add browser accessibility tests for the reports
Fixes found by axe: the chart axis captions are darker and larger, the period heading keeps its heading role with the live region inside it, and scrollable tables are focusable regions named by their table. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -97,14 +97,14 @@ new class extends Component
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
<h2 class="text-xl font-semibold" role="status" aria-live="polite">{{ $this->periodLabel() }}</h2>
|
<h2 class="text-xl font-semibold"><span role="status" aria-live="polite">{{ $this->periodLabel() }}</span></h2>
|
||||||
<x-button :href="$this->csv()" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
<x-button :href="$this->csv()" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if ($report->people === [])
|
@if ($report->people === [])
|
||||||
<p>{{ __('reports.hours.none') }}</p>
|
<p>{{ __('reports.hours.none') }}</p>
|
||||||
@else
|
@else
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.hours.table', ['period' => $this->periodLabel()]) }}">
|
||||||
<table class="w-full text-sm">
|
<table class="w-full text-sm">
|
||||||
<caption class="sr-only">{{ __('reports.hours.table', ['period' => $this->periodLabel()]) }}</caption>
|
<caption class="sr-only">{{ __('reports.hours.table', ['period' => $this->periodLabel()]) }}</caption>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ new class extends Component
|
|||||||
|
|
||||||
@if ($report !== null)
|
@if ($report !== null)
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
<h2 class="text-xl font-semibold" role="status" aria-live="polite">{{ $this->periodLabel() }}</h2>
|
<h2 class="text-xl font-semibold"><span role="status" aria-live="polite">{{ $this->periodLabel() }}</span></h2>
|
||||||
<x-button :href="$this->csvUrl('profitability', ['sisaiset' => $includeInternal ? '1' : ''])" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
<x-button :href="$this->csvUrl('profitability', ['sisaiset' => $includeInternal ? '1' : ''])" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ new class extends Component
|
|||||||
<h2 id="units-heading" class="text-xl font-semibold">{{ __('reports.profitability.by_service_unit') }}</h2>
|
<h2 id="units-heading" class="text-xl font-semibold">{{ __('reports.profitability.by_service_unit') }}</h2>
|
||||||
<p class="text-sm">{{ __('reports.profitability.split_note') }}</p>
|
<p class="text-sm">{{ __('reports.profitability.split_note') }}</p>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.profitability.units_table', ['period' => $this->periodLabel()]) }}">
|
||||||
<table class="w-full text-sm">
|
<table class="w-full text-sm">
|
||||||
<caption class="sr-only">{{ __('reports.profitability.units_table', ['period' => $this->periodLabel()]) }}</caption>
|
<caption class="sr-only">{{ __('reports.profitability.units_table', ['period' => $this->periodLabel()]) }}</caption>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -156,7 +156,7 @@ new class extends Component
|
|||||||
<section aria-labelledby="jobs-heading" class="space-y-4">
|
<section aria-labelledby="jobs-heading" class="space-y-4">
|
||||||
<h2 id="jobs-heading" class="text-xl font-semibold">{{ __('reports.profitability.by_job') }}</h2>
|
<h2 id="jobs-heading" class="text-xl font-semibold">{{ __('reports.profitability.by_job') }}</h2>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.profitability.jobs_table', ['period' => $this->periodLabel()]) }}">
|
||||||
<table class="w-full text-sm">
|
<table class="w-full text-sm">
|
||||||
<caption class="sr-only">{{ __('reports.profitability.jobs_table', ['period' => $this->periodLabel()]) }}</caption>
|
<caption class="sr-only">{{ __('reports.profitability.jobs_table', ['period' => $this->periodLabel()]) }}</caption>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ new class extends Component
|
|||||||
|
|
||||||
@if ($report !== null)
|
@if ($report !== null)
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
<h2 class="text-xl font-semibold" role="status" aria-live="polite">{{ $this->periodLabel() }}</h2>
|
<h2 class="text-xl font-semibold"><span role="status" aria-live="polite">{{ $this->periodLabel() }}</span></h2>
|
||||||
<div class="flex flex-wrap gap-2 print:hidden">
|
<div class="flex flex-wrap gap-2 print:hidden">
|
||||||
<x-button x-on:click="window.print()" subtle color="black" icon="printer" :text="__('reports.reimbursements.print')" />
|
<x-button x-on:click="window.print()" subtle color="black" icon="printer" :text="__('reports.reimbursements.print')" />
|
||||||
<x-button :href="$this->csvUrl('reimbursements')" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
<x-button :href="$this->csvUrl('reimbursements')" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
||||||
@@ -84,7 +84,7 @@ new class extends Component
|
|||||||
<section wire:key="person-{{ $person->userId }}" aria-labelledby="person-{{ $person->userId }}" class="space-y-2 break-inside-avoid">
|
<section wire:key="person-{{ $person->userId }}" aria-labelledby="person-{{ $person->userId }}" class="space-y-2 break-inside-avoid">
|
||||||
<h3 id="person-{{ $person->userId }}" class="text-lg font-semibold">{{ $person->name }}</h3>
|
<h3 id="person-{{ $person->userId }}" class="text-lg font-semibold">{{ $person->name }}</h3>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.reimbursements.table', ['name' => $person->name, 'period' => $this->periodLabel()]) }}">
|
||||||
<table class="w-full text-sm">
|
<table class="w-full text-sm">
|
||||||
<caption class="sr-only">{{ __('reports.reimbursements.table', ['name' => $person->name, 'period' => $this->periodLabel()]) }}</caption>
|
<caption class="sr-only">{{ __('reports.reimbursements.table', ['name' => $person->name, 'period' => $this->periodLabel()]) }}</caption>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ new class extends Component
|
|||||||
|
|
||||||
@if ($report !== null)
|
@if ($report !== null)
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
<h2 class="text-xl font-semibold" role="status" aria-live="polite">{{ $this->periodLabel() }}</h2>
|
<h2 class="text-xl font-semibold"><span role="status" aria-live="polite">{{ $this->periodLabel() }}</span></h2>
|
||||||
<x-button :href="$this->csvUrl('sales')" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
<x-button :href="$this->csvUrl('sales')" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ new class extends Component
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.sales.by_day') }}">
|
||||||
<table class="w-full text-sm">
|
<table class="w-full text-sm">
|
||||||
<caption class="mb-2 text-left text-base font-semibold">{{ __('reports.sales.by_day') }}</caption>
|
<caption class="mb-2 text-left text-base font-semibold">{{ __('reports.sales.by_day') }}</caption>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -112,14 +112,14 @@ new class extends Component
|
|||||||
</p>
|
</p>
|
||||||
@else
|
@else
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
<h2 class="text-xl font-semibold" role="status" aria-live="polite">{{ __('reports.unbilled.until', ['day' => $this->dateLabel($day)]) }}</h2>
|
<h2 class="text-xl font-semibold"><span role="status" aria-live="polite">{{ __('reports.unbilled.until', ['day' => $this->dateLabel($day)]) }}</span></h2>
|
||||||
<x-button :href="$this->csv()" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
<x-button :href="$this->csv()" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if ($report->jobs === [])
|
@if ($report->jobs === [])
|
||||||
<p>{{ __('reports.unbilled.none') }}</p>
|
<p>{{ __('reports.unbilled.none') }}</p>
|
||||||
@else
|
@else
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.unbilled.table', ['day' => $this->dateLabel($day)]) }}">
|
||||||
<table class="w-full text-sm">
|
<table class="w-full text-sm">
|
||||||
<caption class="sr-only">{{ __('reports.unbilled.table', ['day' => $this->dateLabel($day)]) }}</caption>
|
<caption class="sr-only">{{ __('reports.unbilled.table', ['day' => $this->dateLabel($day)]) }}</caption>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -69,5 +69,12 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
->select('native')
|
->select('native')
|
||||||
->block('error')
|
->block('error')
|
||||||
->replace('text-red-600!', 'text-red-700! dark:!text-red-400');
|
->replace('text-red-600!', 'text-red-700! dark:!text-red-400');
|
||||||
|
|
||||||
|
// Chart axis captions are gray-500 at 10 px, 4.4:1 on the page background.
|
||||||
|
foreach (['axis.y.label', 'axis.y.right.label', 'axis.x.label'] as $block) {
|
||||||
|
TallStackUi::customize('chart')
|
||||||
|
->block($block)
|
||||||
|
->replace(['text-gray-500' => 'text-gray-700', 'dark:text-dark-400' => 'dark:text-dark-200', 'text-[0.65rem]' => 'text-xs']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<x-chart
|
<x-chart
|
||||||
bar
|
bar
|
||||||
grid
|
grid
|
||||||
fit="rotate"
|
fit="thin"
|
||||||
:labels="$labels"
|
:labels="$labels"
|
||||||
:series="$values"
|
:series="$values"
|
||||||
:formatter="$formatter"
|
:formatter="$formatter"
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Modules\Catalog\Application\UseCases\SetInternalHourlyCost;
|
||||||
|
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ProductModel;
|
||||||
|
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\WorkTypeModel;
|
||||||
|
use App\Modules\Customers\Infrastructure\Persistence\Eloquent\CustomerModel;
|
||||||
|
use App\Modules\Expenses\Infrastructure\Persistence\Eloquent\ExpenseModel;
|
||||||
|
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||||||
|
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
|
||||||
|
use App\Modules\Sales\Infrastructure\Persistence\Eloquent\QuickSaleModel;
|
||||||
|
use App\Modules\TimeTracking\Infrastructure\Persistence\Eloquent\TimeEntryModel;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$this->actingAs(User::factory()->management()->create(['name' => 'Maija Johtaja']));
|
||||||
|
$worker = User::factory()->employee()->create(['name' => 'Aino Tekijä']);
|
||||||
|
|
||||||
|
app(SetInternalHourlyCost::class)->execute('40');
|
||||||
|
$editing = WorkTypeModel::factory()->create(['name' => 'Editointi', 'hourly_rate_cents' => 8000]);
|
||||||
|
$customer = CustomerModel::factory()->company()->create(['name' => 'Asiakas Oy']);
|
||||||
|
$job = CustomerJobModel::factory()->create(['name' => 'Mainosvideo', 'customer_id' => $customer->id, 'payment_basis' => 'hourly']);
|
||||||
|
$task = TaskModel::factory()->create(['customer_job_id' => $job->id, 'work_type_id' => $editing->id]);
|
||||||
|
|
||||||
|
TimeEntryModel::factory()->approved()->create(['user_id' => $worker->id, 'task_id' => $task->id, 'hours' => 6, 'worked_on' => now()->startOfMonth()->toDateString()]);
|
||||||
|
ExpenseModel::factory()->paidByEmployee()->mileage(12.5)->create(['user_id' => $worker->id, 'customer_job_id' => $job->id, 'spent_on' => now()->subMonthNoOverflow()->startOfMonth()->toDateString()]);
|
||||||
|
ExpenseModel::factory()->create(['customer_job_id' => $job->id, 'spent_on' => now()->startOfMonth()->toDateString(), 'description' => 'Muistikortti']);
|
||||||
|
QuickSaleModel::factory()->withLine(ProductModel::factory()->create(['name' => 'Passikuvat', 'price_cents' => 1990]), 2)->create(['user_id' => $worker->id]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has no accessibility issues on the report pages', function (string $report, string $device, string $colorScheme) {
|
||||||
|
$visit = visit(route('reports.'.$report));
|
||||||
|
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
||||||
|
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
||||||
|
|
||||||
|
$visit->assertSee(match ($report) {
|
||||||
|
'hours' => 'Aino Tekijä',
|
||||||
|
'unbilled' => 'Mainosvideo',
|
||||||
|
'profitability' => 'Kate palveluyksiköittäin',
|
||||||
|
'sales' => 'Passikuvat',
|
||||||
|
'reimbursements' => 'Tampere',
|
||||||
|
})
|
||||||
|
->assertNoJavaScriptErrors()
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
})->with(['hours', 'unbilled', 'profitability', 'sales', 'reimbursements'])->with([
|
||||||
|
'desktop, light' => ['desktop', 'light'],
|
||||||
|
'desktop, dark' => ['desktop', 'dark'],
|
||||||
|
'mobile, light' => ['mobile', 'light'],
|
||||||
|
'mobile, dark' => ['mobile', 'dark'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('changes the period with a quick choice and opens a breakdown with the keyboard', function () {
|
||||||
|
visit(route('reports.hours'))
|
||||||
|
->assertSee('Aino Tekijä')
|
||||||
|
->click('Edellinen vuosi')
|
||||||
|
->assertSee('Aikavälillä ei ole kirjattuja tunteja.')
|
||||||
|
->click('Tämä kuukausi')
|
||||||
|
->assertSee('Aino Tekijä')
|
||||||
|
->keys('details > summary', 'Enter')
|
||||||
|
->assertSee('Työtehtävittäin')
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user