test: fix playwright tests
This commit is contained in:
+11
-10
@@ -1,24 +1,25 @@
|
|||||||
import { defineConfig } from '@playwright/test';
|
/* eslint-env node */
|
||||||
|
import { defineConfig } from "@playwright/test";
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
reporter: process.env.CI ? 'github' : 'list',
|
reporter: process.env.CI ? "github" : "list",
|
||||||
webServer: [
|
webServer: [
|
||||||
{
|
{
|
||||||
command: 'yarn run start-prod',
|
command: "yarn run start-prod",
|
||||||
url: 'http://127.0.0.1:9990',
|
url: "http://127.0.0.1:9990",
|
||||||
timeout: 120 * 1000,
|
timeout: 120 * 1000,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'yarn run test-start-embed',
|
command: "yarn run test-start-embed",
|
||||||
url: 'http://127.0.0.1:8020',
|
url: "http://127.0.0.1:8020",
|
||||||
timeout: 120 * 1000,
|
timeout: 120 * 1000,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'yarn run test-start-sandbox',
|
command: "yarn run test-start-sandbox",
|
||||||
url: 'http://127.0.0.1:8030',
|
url: "http://127.0.0.1:8030",
|
||||||
timeout: 120 * 1000,
|
timeout: 120 * 1000,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
/* eslint-env worker */
|
||||||
importScripts("http://localhost:9990/sw.js");
|
importScripts("http://localhost:9990/sw.js");
|
||||||
|
|||||||
+29
-11
@@ -1,42 +1,60 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from "@playwright/test";
|
||||||
import { createServer } from "http-server";
|
|
||||||
|
|
||||||
|
|
||||||
test("same-domain embed is loading", async ({ page }) => {
|
test("same-domain embed is loading", async ({ page }) => {
|
||||||
await page.goto("http://localhost:9990/embed.html");
|
await page.goto("http://localhost:9990/embed.html");
|
||||||
|
|
||||||
const res = page.locator("replay-web-page").frameLocator("iframe").locator("replay-app-main wr-coll wr-coll-replay").frameLocator("iframe").frameLocator("iframe#twitter-widget-0").locator("body");
|
const res = page
|
||||||
|
.locator("replay-web-page")
|
||||||
|
.frameLocator("iframe")
|
||||||
|
.locator("replay-app-main wr-item wr-coll-replay")
|
||||||
|
.frameLocator("iframe")
|
||||||
|
.frameLocator("iframe#twitter-widget-0")
|
||||||
|
.locator("body");
|
||||||
|
|
||||||
await expect(res).toContainText("Want to help");
|
await expect(res).toContainText("Want to help");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("cross-domain embed is loading", async ({ page }) => {
|
test("cross-domain embed is loading", async ({ page }) => {
|
||||||
await page.goto("http://localhost:8020/");
|
await page.goto("http://localhost:8020/");
|
||||||
|
|
||||||
const res = page.locator("replay-web-page").frameLocator("iframe").locator("replay-app-main wr-coll wr-coll-replay").frameLocator("iframe").frameLocator("iframe#twitter-widget-0").locator("body");
|
const res = page
|
||||||
|
.locator("replay-web-page")
|
||||||
|
.frameLocator("iframe")
|
||||||
|
.locator("replay-app-main wr-item wr-coll-replay")
|
||||||
|
.frameLocator("iframe")
|
||||||
|
.frameLocator("iframe#twitter-widget-0")
|
||||||
|
.locator("body");
|
||||||
|
|
||||||
await expect(res).toContainText("Want to help");
|
await expect(res).toContainText("Want to help");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("sandbox + cross-domain embed is loading", async ({ page }) => {
|
test("sandbox + cross-domain embed is loading", async ({ page }) => {
|
||||||
await page.goto("http://localhost:8030/");
|
await page.goto("http://localhost:8030/");
|
||||||
|
|
||||||
const sandboxFrame = page.locator("iframe");
|
const sandboxFrame = page.locator("iframe");
|
||||||
await expect(await sandboxFrame.getAttribute("src")).toBe("http://localhost:8020/index-sandbox.html");
|
await expect(await sandboxFrame.getAttribute("src")).toBe(
|
||||||
|
"http://localhost:8020/index-sandbox.html",
|
||||||
|
);
|
||||||
|
|
||||||
const res = page.frameLocator("iframe").locator("replay-web-page").frameLocator("iframe").locator("replay-app-main wr-coll wr-coll-replay").frameLocator("iframe").frameLocator("iframe#twitter-widget-0").locator("body");
|
const res = page
|
||||||
|
.frameLocator("iframe")
|
||||||
|
.locator("replay-web-page")
|
||||||
|
.frameLocator("iframe")
|
||||||
|
.locator("replay-app-main wr-item wr-coll-replay")
|
||||||
|
.frameLocator("iframe")
|
||||||
|
.frameLocator("iframe#twitter-widget-0")
|
||||||
|
.locator("body");
|
||||||
|
|
||||||
await expect(res).toContainText("Want to help");
|
await expect(res).toContainText("Want to help");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("require subdomain iframe", async ({ page }) => {
|
test("require subdomain iframe", async ({ page }) => {
|
||||||
// load directly, should be blocked
|
// load directly, should be blocked
|
||||||
await page.goto("http://localhost:8020/index-sandbox.html");
|
await page.goto("http://localhost:8020/index-sandbox.html");
|
||||||
|
|
||||||
const res = page.locator("replay-web-page");
|
const res = page.locator("replay-web-page");
|
||||||
|
|
||||||
await expect(res).toContainText("Sorry, due to security settings, this ReplayWeb.page embed only be viewed within a subdomain iframe.");
|
await expect(res).toContainText(
|
||||||
|
"Sorry, due to security settings, this ReplayWeb.page embed only be viewed within a subdomain iframe.",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user