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); // let the physical toys settle const toys = await page.evaluate(() => { const r = window.rl; return { count: r.interactiveProps.length, visible: r.scene.getObjectByName("interactive-props").visible, hasBall: r.mujoco.mj_name2id( r.model, r.mujoco.mjtObj.mjOBJ_BODY.value, "ball", ) >= 0, }; }); expect(toys.count).toBeGreaterThanOrEqual(5); expect(toys.count).toBeLessThanOrEqual(7); expect(toys.visible).toBe(true); expect(toys.hasBall).toBe(false); 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([]); });