Files
replayweb.page/tests/embeds.spec.js
T
Ilya Kreymer 92343d59f7 Site reorg: Remove site/ subpath (#306)
Unfortunately, for proper package pathing, need to remove the `site/`
subpath. This includes:
- Moving everything back into root
- Adding a `copy-site.sh` script to copy resources into `mkdocs/site/`
before building the site with mkdocs.
- Also update examples to ensure all are loading the local sw.js / ui.js
- Consolidate examples in `docs/examples`
- Consolidate assets under src/assets/
- Move `favicons` to root
- Reformat and relint
- Tests: update playwright tests to use mkdocs output, add test for
embed in docs
- bump to 2.0.0-beta.2
2024-04-09 23:07:23 -07:00

75 lines
2.1 KiB
JavaScript

import { test, expect } from "@playwright/test";
test("same-domain embed is loading", async ({ page }) => {
await page.goto("http://localhost:9990/embed.html");
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");
});
test("docs page embed is loading", async ({ page }) => {
await page.goto("http://localhost:9990/docs/embedding/");
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");
});
test("cross-domain embed is loading", async ({ page }) => {
await page.goto("http://localhost:8020/");
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");
});
test("sandbox + cross-domain embed is loading", async ({ page }) => {
await page.goto("http://localhost:8030/");
const sandboxFrame = page.locator("iframe");
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-item wr-coll-replay")
.frameLocator("iframe")
.frameLocator("iframe#twitter-widget-0")
.locator("body");
await expect(res).toContainText("Want to help");
});
test("require subdomain iframe", async ({ page }) => {
// load directly, should be blocked
await page.goto("http://localhost:8020/index-sandbox.html");
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.",
);
});