Files
replayweb.page/tests/embeds.spec.js
T
Ilya Kreymer adeefc64dd Add initial set of Playwright integration tests, for testing embeds (#254)
* add first pass on playwright integration tests!
- test embed loading via localhost:9990/embed.html as well as cross-domain with embed on localhost:8020/
while RWP + data on localhost:9990/
- add --ignore-optional to most ci runs
- add playwright ci test
- add playwright and playwright-test to dev dependencies
- add 'test-start-embed' to start test harness for localhost:8020/ embed
- add 'test-start-sandbox' to start test harndess for localhost:8030/ sandbox
- add additional tests for loading with sandbox + requiresubdomainiframe, ensure 'requiresubdomainiframe' works, doesn't allow loading directly
2023-10-06 20:06:04 -07:00

43 lines
1.7 KiB
JavaScript

import { test, expect } from '@playwright/test';
import { createServer } from "http-server";
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-coll 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-coll 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-coll 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.");
});