49 lines
1.9 KiB
JavaScript
49 lines
1.9 KiB
JavaScript
import { test, expect } from "@playwright/test";
|
|
test.use({ video: { mode: "on", size: { width: 1280, height: 800 } } });
|
|
test("deployed assets respect the base path and all three Robot Packages boot", async ({
|
|
page,
|
|
}, info) => {
|
|
const failures = [],
|
|
errors = [],
|
|
requests = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
page.on("response", (r) => {
|
|
if (
|
|
r.status() >= 400 &&
|
|
new URL(r.url()).origin === new URL(page.url()).origin
|
|
)
|
|
failures.push(`${r.status()} ${r.url()}`);
|
|
});
|
|
page.on("request", (r) => requests.push(r.url()));
|
|
const prefix = process.env.DEPLOY_PATH || "/";
|
|
await page.goto(prefix);
|
|
await expect(
|
|
page.getByRole("button", { name: "Pause", exact: true }),
|
|
).toBeEnabled();
|
|
await page.waitForTimeout(500); // capture after the ball's existing appear FX
|
|
await page.screenshot({ path: info.outputPath("microduck.png") });
|
|
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
|
|
await expect
|
|
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
|
.toBe("microban");
|
|
await expect(page.getByRole("status")).toContainText("Simplified actuation");
|
|
await page.waitForTimeout(500);
|
|
await page.screenshot({ path: info.outputPath("microban.png") });
|
|
await page.getByLabel("Robot", { exact: true }).selectOption("rp1");
|
|
await expect
|
|
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
|
.toBe("rp1");
|
|
await expect(page.getByRole("status")).toContainText("Skill: walk");
|
|
await page.screenshot({ path: info.outputPath("rp1.png") });
|
|
expect(errors).toEqual([]);
|
|
expect(failures).toEqual([]);
|
|
const origin = new URL(page.url()).origin;
|
|
expect(requests.filter((url) => new URL(url).origin !== origin)).toEqual([]);
|
|
expect(
|
|
requests.filter(
|
|
(url) =>
|
|
url.startsWith(origin) && !new URL(url).pathname.startsWith(prefix),
|
|
),
|
|
).toEqual([]);
|
|
});
|