Skip to content

Commit

Permalink
replace msedge conditionals with msedge & msedge beta
Browse files Browse the repository at this point in the history
  • Loading branch information
mnholtz committed Aug 8, 2024
1 parent 7573303 commit adf71b2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 14 deletions.
63 changes: 51 additions & 12 deletions end-to-end-tests/tests/regressions/sidebarLinks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from "@playwright/test";
import { ensureVisibility, getBrowserOs, getSidebarPage } from "../../utils";
import { getBaseExtensionConsoleUrl } from "../../pageObjects/constants";
import { SupportedChannels } from "../../../playwright.config";

async function openSidebar(page: Page, extensionId: string) {
// The mod contains a trigger to open the sidebar on h1. If the sidePanel is already open, it's a NOP
Expand Down Expand Up @@ -53,7 +54,11 @@ async function clickLinkInSidebarAndWaitForPage(
chromiumChannel: string,
) {
const pagePromise = context.waitForEvent("page");
if (chromiumChannel === "msedge") {
if (
[SupportedChannels.MSEDGE, SupportedChannels.MSEDGE_BETA].includes(
chromiumChannel,
)
) {
// On MS Edge, opening a new tab closes the sidebar. The click steps fail because MS Edge closes the sidebar when the new tab is opened
// Error: locator.click: Target page, context or browser has been closed.
// Even though it errors, the link is still opened in a new tab.
Expand Down Expand Up @@ -99,7 +104,11 @@ test("#8206: clicking links from the sidebar doesn't crash browser", async ({
);

// eslint-disable-next-line playwright/no-conditional-in-test -- msedge bug
if (chromiumChannel === "msedge") {
if (
[SupportedChannels.MSEDGE, SupportedChannels.MSEDGE_BETA].includes(
chromiumChannel,
)
) {
// Another msedge bug causes the browser to fail to open the extension console page from the sidebar until you refresh the page.
// "Error: This script should only be loaded in a browser extension."
await extensionConsolePage.reload();
Expand All @@ -113,10 +122,16 @@ test("#8206: clicking links from the sidebar doesn't crash browser", async ({
});

await test.step("Clicking markdown text link", async () => {
// eslint-disable-next-line playwright/no-conditional-in-test -- msedge and linux bug that causes the sidebar to close on clicking a link
if (browserOSName === "Linux" || chromiumChannel === "msedge") {
/* eslint-disable playwright/no-conditional-in-test -- msedge and linux bug that causes the sidebar to close on clicking a link */
if (
browserOSName === "Linux" ||
[SupportedChannels.MSEDGE, SupportedChannels.MSEDGE_BETA].includes(
chromiumChannel,
)
) {
sideBarPage = await reopenSidebar(page, extensionId);
}
/* eslint-enable playwright/no-conditional-in-test */

const markdownTextLinkPage = await clickLinkInSidebarAndWaitForPage(
context,
Expand All @@ -127,10 +142,16 @@ test("#8206: clicking links from the sidebar doesn't crash browser", async ({
});

await test.step("Clicking react bootstrap link", async () => {
// eslint-disable-next-line playwright/no-conditional-in-test -- msedge/linux bug
if (browserOSName === "Linux" || chromiumChannel === "msedge") {
/* eslint-disable playwright/no-conditional-in-test -- msedge/linux bug */
if (
browserOSName === "Linux" ||
[SupportedChannels.MSEDGE, SupportedChannels.MSEDGE_BETA].includes(
chromiumChannel,
)
) {
sideBarPage = await reopenSidebar(page, extensionId);
}
/* eslint-enable playwright/no-conditional-in-test */

const reactBootstrapLinkPage = await clickLinkInSidebarAndWaitForPage(
context,
Expand All @@ -141,10 +162,16 @@ test("#8206: clicking links from the sidebar doesn't crash browser", async ({
});

await test.step("Clicking html renderer link", async () => {
// eslint-disable-next-line playwright/no-conditional-in-test -- msedge/linux bug
if (browserOSName === "Linux" || chromiumChannel === "msedge") {
/* eslint-disable playwright/no-conditional-in-test -- msedge/linux bug */
if (
browserOSName === "Linux" ||
[SupportedChannels.MSEDGE, SupportedChannels.MSEDGE_BETA].includes(
chromiumChannel,
)
) {
sideBarPage = await reopenSidebar(page, extensionId);
}
/* eslint-enable playwright/no-conditional-in-test */

const htmlRendererLinkPage = await clickLinkInSidebarAndWaitForPage(
context,
Expand All @@ -155,10 +182,16 @@ test("#8206: clicking links from the sidebar doesn't crash browser", async ({
});

await test.step("Clicking embedded form link", async () => {
// eslint-disable-next-line playwright/no-conditional-in-test -- msedge/linux bug
if (browserOSName === "Linux" || chromiumChannel === "msedge") {
/* eslint-disable playwright/no-conditional-in-test -- msedge/linux bug */
if (
browserOSName === "Linux" ||
[SupportedChannels.MSEDGE, SupportedChannels.MSEDGE_BETA].includes(
chromiumChannel,
)
) {
sideBarPage = await reopenSidebar(page, extensionId);
}
/* eslint-enable playwright/no-conditional-in-test */

const embeddedFormLinkPage = await clickLinkInSidebarAndWaitForPage(
context,
Expand All @@ -171,8 +204,13 @@ test("#8206: clicking links from the sidebar doesn't crash browser", async ({
// Clicking link in IFrame will crash MS Edge until the issue is fixed
// https://github.com/microsoft/MicrosoftEdge-Extensions/issues/145
// For some reason this also happens in Chrome/Linux in the CI github workflow.
// eslint-disable-next-line playwright/no-conditional-in-test -- see above comment
if (browserOSName !== "Linux" && chromiumChannel !== "msedge") {
/* eslint-disable playwright/no-conditional-in-test -- see above comment */
if (
browserOSName !== "Linux" &&
![SupportedChannels.MSEDGE, SupportedChannels.MSEDGE_BETA].includes(
chromiumChannel,
)
) {
await test.step("Clicking link in IFrame", async () => {
// PixieBrix uses 2 layers of frames to get around the host page CSP. Test page has 2 layers
const pixiebrixFrame = sideBarPage.frameLocator("iframe").first();
Expand All @@ -184,4 +222,5 @@ test("#8206: clicking links from the sidebar doesn't crash browser", async ({
await srcdocFrame.getByRole("link", { name: "IFrame Link" }).click();
});
}
/* eslint-enable playwright/no-conditional-in-test */
});
4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "@playwright/test";
import { CI, E2E_CHROMIUM_CHANNELS } from "./end-to-end-tests/env";
import { type ValueOf } from "type-fest";

const SupportedChannels: Record<
export const SupportedChannels: Record<
string,
"chrome" | "msedge" | "chrome-beta" | "msedge-beta" | "chromium"
> = {
Expand All @@ -13,7 +13,7 @@ const SupportedChannels: Record<
CHROMIUM: "chromium",
};

type SupportedChannel = ValueOf<typeof SupportedChannels>;
export type SupportedChannel = ValueOf<typeof SupportedChannels>;

const channels: SupportedChannel[] = (() => {
if (!E2E_CHROMIUM_CHANNELS) {
Expand Down

0 comments on commit adf71b2

Please sign in to comment.