Skip to content

Commit

Permalink
chore(tests): enhance test robustness
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Lazar <[email protected]>
  • Loading branch information
cbr7 committed May 22, 2024
1 parent 2fb1dbe commit ad4165b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions tests/playwright/src/bootc-extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -51,6 +52,7 @@ beforeEach<RunnerTestContext>(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');
Expand Down
15 changes: 10 additions & 5 deletions tests/playwright/src/model/bootc-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand All @@ -68,11 +72,11 @@ export class BootcPage {
): Promise<boolean> {
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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ad4165b

Please sign in to comment.