Skip to content

Commit

Permalink
chore: wait for images being displayed
Browse files Browse the repository at this point in the history
The current test is checking that we have a promise
(it does not wait the end of the promise)

and we were not waiting that image was displayed in the list to
return true

Signed-off-by: Florent Benoit <[email protected]>
  • Loading branch information
benoitf committed Aug 16, 2023
1 parent e4f4d88 commit bb745f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion tests/src/model/pages/images-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { Locator, Page } from 'playwright';
import { PodmanDesktopPage } from './base-page';
import { ImageDetailsPage } from './image-details-page';
import { PullImagePage } from './pull-image-page';
import { waitUntil } from '../../utility/wait';

export class ImagesPage extends PodmanDesktopPage {
readonly heading: Locator;
Expand Down Expand Up @@ -89,6 +90,12 @@ export class ImagesPage extends PodmanDesktopPage {
}

async imageExists(name: string): Promise<boolean> {
return (await this.getImageRowByName(name)) !== undefined ? true : false;
const result = await this.getImageRowByName(name);
return result !== undefined;
}

async waitForImageExists(name: string): Promise<boolean> {
await waitUntil(async () => await this.imageExists(name), 3000, 900);
return true;
}
}
5 changes: 3 additions & 2 deletions tests/src/pull-image-smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import type { Page } from 'playwright';
import type { RunnerTestContext } from './testContext/runner-test-context';
import { afterAll, beforeAll, test, describe, beforeEach } from 'vitest';
import { afterAll, beforeAll, test, describe, beforeEach, expect } from 'vitest';
import { expect as playExpect } from '@playwright/test';
import { PodmanDesktopRunner } from './runner/podman-desktop-runner';
import { WelcomePage } from './model/pages/welcome-page';
Expand Down Expand Up @@ -52,7 +52,8 @@ describe('Image pull verification', async () => {
const pullImagePage = await imagesPage.openPullImage();
const updatedImages = await pullImagePage.pullImage('quay.io/podman/hello');

playExpect(updatedImages.imageExists('quay.io/podman/hello')).toBeTruthy();
const exists = await updatedImages.waitForImageExists('quay.io/podman/hello');
expect(exists, 'quay.io/podman/hello image not present in the list of images').toBeTruthy();
});

test('Check image details', async () => {
Expand Down

0 comments on commit bb745f1

Please sign in to comment.