Skip to content

Commit

Permalink
SWED-2249 update E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenraphti committed Oct 10, 2023
1 parent 0795b38 commit 55d0107
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ test("Topbar page exist", async ({ page }) => {
})
.click();
await expect(page.getByRole("link", { name: "Topbar" })).toHaveCount(
page.viewportSize().width < 991 ? 1 : 2,
page.viewportSize().width < 991 ? 1 : 2
);
await page.getByText("call_to_actionTopbararrow_forward").click();
await expect(page).toHaveTitle(/Topbar/);
await expect(
page.getByRole("heading", { name: "Topbar", exact: true, level: 1 }),
page.getByRole("heading", { name: "Topbar", exact: true, level: 1 })
).toBeVisible();
});

Expand Down Expand Up @@ -44,7 +44,9 @@ let brand;
* @param {string} tabBtnText text of the doc preview container tab
*/
const clickDocPreviewTab = async (page, tabBtnText) => {
await page.getByRole("link", { name: tabBtnText, exact: true }).click();
await page
.getByRole("link", { name: tabBtnText, exact: true })
.click({ force: true });
};

test.describe("visual regressions topbar", () => {
Expand All @@ -56,14 +58,14 @@ test.describe("visual regressions topbar", () => {

test(`general UI closed`, async ({ page }) => {
await expect(
page.getByRole("heading", { name: "Topbar", exact: true }),
page.getByRole("heading", { name: "Topbar", exact: true })
).toBeVisible();

for (const topbarTab of topbarTabs) {
clickDocPreviewTab(page, topbarTab.btnText);

await expect(
page.locator(".component-preview-content > div"),
page.locator(".component-preview-content > div")
).toHaveScreenshot(`${brand}-topbar-${topbarTab.name}-closed.png`);
}
});
Expand All @@ -77,9 +79,9 @@ test.describe("visual regressions topbar", () => {

await page.locator("#demo-topbar").getByRole("link").nth(2).hover();
await expect(
page.locator("#demo-topbar").getByRole("navigation"),
page.locator("#demo-topbar").getByRole("navigation")
).toHaveScreenshot(
`${brand}-topbar-${topbarTab.name}-links-ui-feedbacks.png`,
`${brand}-topbar-${topbarTab.name}-links-ui-feedbacks.png`
);
}
});
Expand All @@ -96,7 +98,7 @@ test.describe("visual regressions topbar", () => {
: page.locator(".component-preview-content > div");

await expect(modalContainer).toHaveScreenshot(
`${brand}-topbar-${topbarTab.name}-opened.png`,
`${brand}-topbar-${topbarTab.name}-opened.png`
);
}
});
Expand All @@ -105,7 +107,7 @@ test.describe("visual regressions topbar", () => {
page,
}) => {
for (const topbarTab of topbarTabs.filter(
(tab) => tab.desktopTopbar && !tab.isLegacy,
(tab) => tab.desktopTopbar && !tab.isLegacy
)) {
clickDocPreviewTab(page, topbarTab.btnText);

Expand Down
34 changes: 24 additions & 10 deletions src/App/Identity/identity/Typography/typography.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,30 @@ test("Typography page exist", async ({ page }) => {
name: "Identity Learn about our fundamental principles",
})
.click();
await expect(
page.getByRole("link", {
name: "Typography",
})
).toHaveCount(page.viewportSize().width < 991 ? 1 : 2);
await page
.getByRole("link", {
name: "Typography See our fronts and sizing arrow_forward",
})
.click();

if (page.viewportSize().width > 991) {
await expect(
page.getByRole("link", {
name: "Typography",
})
).toHaveCount(1);
await page.getByRole("link", { name: "Typography" }).click();
} else {
await expect(
page.getByRole("link", {
name: "Typography",
})
).toHaveCount(0);
await page.getByLabel("Open menu").click();
await page.getByRole("button", { name: "Identity" }).click();

await expect(
page.getByRole("link", {
name: "Typography",
})
).toHaveCount(1);
await page.getByRole("link", { name: "Typography" }).click();
}
});

const viewportsVariants = [
Expand Down

0 comments on commit 55d0107

Please sign in to comment.