diff --git a/playwright.config.ts b/playwright.config.ts index 80ba367bf..8087b19c8 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -37,20 +37,54 @@ export default defineConfig({ }, { name: "firefox", - use: { ...devices["Desktop Firefox"] }, + use: { + ...devices["Desktop Firefox"], + launchOptions: { + firefoxUserPrefs: { + "security.fileuri.strict_origin_policy": false, + "network.http.referer.XOriginPolicy": 0, + "network.http.referer.trimmingPolicy": 0, + "privacy.file_unique_origin": false, + "security.csp.enable": false, + "network.cors_preflight.allow_client_cert": true, + "dom.security.https_first": false, + "network.http.cross-origin-embedder-policy": false, + "network.http.cross-origin-opener-policy": false, + "browser.tabs.remote.useCrossOriginPolicy": false, + "browser.tabs.remote.useCORP": false, + }, + args: ["--disable-web-security"], + }, + }, }, { name: "webkit", - use: { ...devices["Desktop Safari"] }, + use: { + ...devices["Desktop Safari"], + launchOptions: { + args: ["--disable-web-security"], + }, + }, }, - /* Test against branded browsers. */ { name: "Google Chrome", - use: { ...devices["Desktop Chrome"], channel: "chrome" }, // or 'chrome-beta' + use: { + ...devices["Desktop Chrome"], + channel: "chrome", + launchOptions: { + args: ["--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"], + }, + }, }, { name: "Microsoft Edge", - use: { ...devices["Desktop Edge"], channel: "msedge" }, // or 'msedge-dev' + use: { + ...devices["Desktop Edge"], + channel: "msedge", + launchOptions: { + args: ["--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"], + }, + }, }, ], diff --git a/test/CORSBypass.ts b/test/CORSBypass.ts new file mode 100644 index 000000000..be52c95fa --- /dev/null +++ b/test/CORSBypass.ts @@ -0,0 +1,23 @@ +import { Page } from "@playwright/test"; + +export async function setupCORSBypass(page: Page) { + await page.route("**/api/mongo/explorer{,/**}", async (route) => { + const response = await route.fetch({ + headers: { + ...route.request().headers(), + }, + }); + + await route.fulfill({ + status: response.status(), + headers: { + ...response.headers(), + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "*", + "Access-Control-Allow-Headers": "*", + "Access-Control-Allow-Credentials": "*", + }, + body: await response.body(), + }); + }); +} diff --git a/test/mongo/document.spec.ts b/test/mongo/document.spec.ts index 747e63783..e02279801 100644 --- a/test/mongo/document.spec.ts +++ b/test/mongo/document.spec.ts @@ -1,5 +1,6 @@ import { expect, test } from "@playwright/test"; +import { setupCORSBypass } from "../CORSBypass"; import { DataExplorer, DocumentsTab, TestAccount } from "../fx"; import { retry, serializeMongoToJson, setPartitionKeys } from "../testData"; import { documentTestCases } from "./testCases"; @@ -11,6 +12,7 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) { test.describe(`Test MongoRU Documents with ${name}`, () => { test.skip(true, "Temporarily disabling all tests in this spec file"); test.beforeEach("Open documents tab", async ({ page }) => { + await setupCORSBypass(page); explorer = await DataExplorer.open(page, TestAccount.MongoReadonly); const containerNode = await explorer.waitForContainerNode(databaseId, containerId);