Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): use retryable playwright assertion #1183

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions springwolf-examples/e2e/tests/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
import { test, expect } from "@playwright/test";
import { locateChannelItems } from "../util/page_object";
import { locateChannelItems, pageIsReady } from "../util/page_object";
import { getExampleAsyncApi } from "../util/example";

test.beforeEach(async ({ page }) => {
Expand All @@ -14,6 +14,8 @@ test("has title", async ({ page }) => {
test("can click download and get original asyncapi.json in new tab", async ({
page,
}) => {
await pageIsReady(page);

const newPagePromise = page.waitForEvent("popup");

await page.click("text=AsyncAPI JSON");
Expand All @@ -28,5 +30,5 @@ test("can click download and get original asyncapi.json in new tab", async ({
});

test("has channels and channel item", async ({ page }) => {
expect(await locateChannelItems(page).count()).toBeGreaterThan(0);
await expect(locateChannelItems(page)).not.toHaveCount(0);
});
6 changes: 5 additions & 1 deletion springwolf-examples/e2e/util/page_object.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: Apache-2.0 */
import { Locator, Page } from "@playwright/test";
import { expect, Locator, Page } from "@playwright/test";

export function locateChannels(locator: Page | Locator) {
return locator.locator("article#channels article");
Expand Down Expand Up @@ -28,3 +28,7 @@ export function locatePublishButton(locator: Locator) {
export function locateSnackbar(locator: Page | Locator) {
return locator.locator("simple-snack-bar");
}

export async function pageIsReady(locator: Page | Locator) {
await expect(locateChannelItems(locator)).not.toHaveCount(0);
}
Loading