Skip to content

Commit

Permalink
chore(tests): add aria labels
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Lazar <[email protected]>
  • Loading branch information
cbr7 committed May 21, 2024
1 parent 889e3cf commit 6598849
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
20 changes: 10 additions & 10 deletions packages/frontend/src/Build.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ $: if (availableArchitectures) {
<div class="mb-2">
<span class="text-md font-semibold mb-2 block">Disk image type</span>
<div class="flex items-center mb-3">
<label for="raw" class="ml-1 flex items-center cursor-pointer">
<label for="raw" class="ml-1 flex items-center cursor-pointer" aria-label="raw-checkbox">
<input
bind:group="{buildType}"
type="checkbox"
Expand All @@ -392,7 +392,7 @@ $: if (availableArchitectures) {
</label>
</div>
<div class="flex items-center mb-3">
<label for="qcow2" class="ml-1 flex items-center cursor-pointer">
<label for="qcow2" class="ml-1 flex items-center cursor-pointer" aria-label="qcow2-checkbox">
<input
bind:group="{buildType}"
type="checkbox"
Expand All @@ -411,7 +411,7 @@ $: if (availableArchitectures) {
</label>
</div>
<div class="flex items-center mb-3">
<label for="iso" class="ml-1 flex items-center cursor-pointer">
<label for="iso" class="ml-1 flex items-center cursor-pointer" aria-label="iso-checkbox">
<input
bind:group="{buildType}"
type="checkbox"
Expand All @@ -430,7 +430,7 @@ $: if (availableArchitectures) {
</label>
</div>
<div class="flex items-center mb-3">
<label for="vmdk" class="ml-1 flex items-center cursor-pointer">
<label for="vmdk" class="ml-1 flex items-center cursor-pointer" aria-label="vmdk-checkbox">
<input
bind:group="{buildType}"
type="checkbox"
Expand All @@ -449,7 +449,7 @@ $: if (availableArchitectures) {
</label>
</div>
<div class="flex items-center mb-3">
<label for="ami" class="ml-1 flex items-center cursor-pointer">
<label for="ami" class="ml-1 flex items-center cursor-pointer" aria-label="ami-checkbox">
<input
bind:group="{buildType}"
type="checkbox"
Expand All @@ -471,7 +471,7 @@ $: if (availableArchitectures) {
<div>
<span class="text-md font-semibold mb-2 block">Filesystem</span>
<div class="flex items-center mb-3 space-x-3">
<label for="defaultFs" class="ml-1 flex items-center cursor-pointer">
<label for="defaultFs" class="ml-1 flex items-center cursor-pointer" aria-label="default-radio">
<input
bind:group="{buildFilesystem}"
type="radio"
Expand All @@ -485,7 +485,7 @@ $: if (availableArchitectures) {
</div>
<span class="text-sm text-white">Default</span>
</label>
<label for="xfsFs" class="ml-1 flex items-center cursor-pointer">
<label for="xfsFs" class="ml-1 flex items-center cursor-pointer" aria-label="xfs-radio">
<input
bind:group="{buildFilesystem}"
type="radio"
Expand All @@ -499,7 +499,7 @@ $: if (availableArchitectures) {
</div>
<span class="text-sm text-white">XFS</span>
</label>
<label for="ext4Fs" class="ml-1 flex items-center cursor-pointer">
<label for="ext4Fs" class="ml-1 flex items-center cursor-pointer" aria-label="ext4-radio">
<input
bind:group="{buildFilesystem}"
type="radio"
Expand Down Expand Up @@ -538,7 +538,7 @@ $: if (availableArchitectures) {
'arm64',
)
? 'cursor-pointer hover:border-violet-500'
: 'ring-0 opacity-50'}">
: 'ring-0 opacity-50'}" aria-label="arm64-button">
<i class="fab fa-linux fa-2x"></i>
<br />
<span class="ml-2 text-sm">ARM® aarch64 systems</span>
Expand All @@ -560,7 +560,7 @@ $: if (availableArchitectures) {
'amd64',
)
? 'cursor-pointer hover:border-violet-500'
: 'ring-0 opacity-50'}">
: 'ring-0 opacity-50'}" aria-label="amd64-button">
<i class="fab fa-linux fa-2x"></i>
<br />
<span class="ml-2 text-sm">Intel and AMD x86_64 systems</span>
Expand Down
26 changes: 19 additions & 7 deletions tests/playwright/src/model/bootc-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ export class BootcPage {
this.heading = webview.getByLabel('Build Disk Image');
this.outputFolderPath = webview.getByLabel('folder-select');
this.imageSelect = webview.getByLabel('image-select');
this.rawCheckbox = webview.locator('label[for="raw"]');
this.qcow2Checkbox = webview.locator('label[for="qcow2"]');
this.isoCheckbox = webview.locator('label[for="iso"]');
this.vmdkCheckbox = webview.locator('label[for="vmdk"]');
this.amiCheckbox = webview.locator('label[for="ami"]');
this.amd64Button = webview.locator('label[for="amd64"]');
this.arm64Button = webview.locator('label[for="arm64"]');
this.rawCheckbox = webview.getByLabel('raw-checkbox');
this.qcow2Checkbox = webview.getByLabel('qcow2-checkbox');
this.isoCheckbox = webview.getByLabel('iso-checkbox');
this.vmdkCheckbox = webview.getByLabel('vmdk-checkbox');
this.amiCheckbox = webview.getByLabel('ami-checkbox');
this.amd64Button = webview.getByLabel('amd64-button');
this.arm64Button = webview.getByLabel('arm64-button');
this.buildButton = webview.getByRole('button', { name: 'Build' });
this.goBackButton = webview.getByRole('button', { name: 'Go Back' });
this.rowGroup = webview.getByRole('rowgroup').nth(1);
Expand Down Expand Up @@ -81,18 +81,23 @@ export class BootcPage {
switch (type.toLocaleLowerCase()) {
case 'raw':
await this.rawCheckbox.check();
await playExpect(this.rawCheckbox).toBeChecked();
break;
case 'qcow2':
await this.qcow2Checkbox.check();
await playExpect(this.qcow2Checkbox).toBeChecked();
break;
case 'iso':
await this.isoCheckbox.check();
await playExpect(this.isoCheckbox).toBeChecked();
break;
case 'vmdk':
await this.vmdkCheckbox.check();
await playExpect(this.vmdkCheckbox).toBeChecked();
break;
case 'ami':
await this.amiCheckbox.check();
await playExpect(this.amiCheckbox).toBeChecked();
break;
default:
throw new Error(`Unknown type: ${type}`);
Expand All @@ -116,6 +121,8 @@ export class BootcPage {

await playExpect(this.goBackButton).toBeEnabled();
await this.goBackButton.click();
await playExpect(this.buildButton).toBeEnabled();
await this.page.waitForTimeout(1000);

await this.waitUntilCurrentBuildIsFinished();
if ((await this.getCurrentStatusOfLatestEntry()) === 'error') return false;
Expand All @@ -131,10 +138,15 @@ export class BootcPage {

private async uncheckedAllCheckboxes(): Promise<void> {
await this.rawCheckbox.uncheck();
await playExpect(this.rawCheckbox).not.toBeChecked();
await this.qcow2Checkbox.uncheck();
await playExpect(this.qcow2Checkbox).not.toBeChecked();
await this.isoCheckbox.uncheck();
await playExpect(this.isoCheckbox).not.toBeChecked();
await this.vmdkCheckbox.uncheck();
await playExpect(this.vmdkCheckbox).not.toBeChecked();
await this.amiCheckbox.uncheck();
await playExpect(this.amiCheckbox).not.toBeChecked();
}

async getCurrentStatusOfLatestEntry(): Promise<string> {
Expand Down

0 comments on commit 6598849

Please sign in to comment.