From ad4165be9691c0abbfad46a858a84d811bf8e3b7 Mon Sep 17 00:00:00 2001 From: Vladimir Lazar Date: Wed, 22 May 2024 12:58:41 +0200 Subject: [PATCH] chore(tests): enhance test robustness Signed-off-by: Vladimir Lazar --- tests/playwright/src/bootc-extension.spec.ts | 2 ++ tests/playwright/src/model/bootc-page.ts | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/playwright/src/bootc-extension.spec.ts b/tests/playwright/src/bootc-extension.spec.ts index a7da7656..097a7632 100644 --- a/tests/playwright/src/bootc-extension.spec.ts +++ b/tests/playwright/src/bootc-extension.spec.ts @@ -24,6 +24,7 @@ import { PodmanDesktopRunner, WelcomePage, deleteImage, + removeFolderIfExists, } from '@podman-desktop/tests-playwright'; import { expect as playExpect } from '@playwright/test'; import { RunnerTestContext } from '@podman-desktop/tests-playwright'; @@ -51,6 +52,7 @@ beforeEach(async ctx => { }); beforeAll(async () => { + await removeFolderIfExists('tests/output/images'); pdRunner = new PodmanDesktopRunner({ customFolder: 'bootc-tests-pd', autoUpdate: false, autoCheckUpdate: false }); page = await pdRunner.start(); pdRunner.setVideoAndTraceName('bootc-e2e'); diff --git a/tests/playwright/src/model/bootc-page.ts b/tests/playwright/src/model/bootc-page.ts index cce3822f..ab7b6b9d 100644 --- a/tests/playwright/src/model/bootc-page.ts +++ b/tests/playwright/src/model/bootc-page.ts @@ -39,6 +39,8 @@ export class BootcPage { readonly rowGroup: Locator; readonly latestBuiltImage: Locator; readonly getCurrentStatusOfLatestBuildImage: Locator; + readonly bootcListPage: Locator; + readonly bootcBuildDiskPage: Locator; constructor(page: Page, webview: Page) { this.page = page; @@ -53,8 +55,10 @@ export class BootcPage { 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.bootcListPage = webview.getByRole('region', { name: 'Bootable Containers', exact: true }); + this.bootcBuildDiskPage = webview.getByRole('region', { name: 'Build Disk Image', exact: true }); + this.buildButton = webview.getByRole('button', { name: 'Build', exact: true }); + this.goBackButton = webview.getByRole('button', { name: 'Go back', exact: true }); this.rowGroup = webview.getByRole('rowgroup').nth(1); this.latestBuiltImage = this.rowGroup.getByRole('row').first(); this.getCurrentStatusOfLatestBuildImage = this.latestBuiltImage.getByRole('status'); @@ -68,11 +72,11 @@ export class BootcPage { ): Promise { let result = false; - if (await this.buildButton.isEnabled()) { + if (await this.bootcListPage.isVisible()) { await this.buildButton.click(); + await playExpect(this.bootcBuildDiskPage).toBeVisible(); } - await playExpect(this.buildButton).toBeDisabled(); await this.imageSelect.selectOption({ label: imageName }); await this.outputFolderPath.fill(pathToStore); @@ -117,11 +121,12 @@ export class BootcPage { } await playExpect(this.buildButton).toBeEnabled(); + await this.buildButton.focus(); await this.buildButton.click(); await playExpect(this.goBackButton).toBeEnabled(); await this.goBackButton.click(); - await playExpect(this.buildButton).toBeEnabled(); + await playExpect(this.bootcListPage).toBeVisible(); await this.waitUntilCurrentBuildIsFinished(); if ((await this.getCurrentStatusOfLatestEntry()) === 'error') return false;