Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

test(home-e2e): match the tray File button by its accessible name

nirholasaf50eb0754b8
diff --git a/tests/e2e/home-connect-stubs.js b/tests/e2e/home-connect-stubs.js
index 4aaed803d..fe1909275 100644
--- a/tests/e2e/home-connect-stubs.js
+++ b/tests/e2e/home-connect-stubs.js
@@ -59,13 +59,27 @@ export function json(body, status = 200) {
return { status, contentType: 'application/json', body: JSON.stringify(body) };
}
-/** Everything the page reads, with the home list under the caller's control. */
+/**
+ * Everything the page reads, with the home list under the caller's control.
+ *
+ * `onConnect` is AWAITED, which is what makes state 5 reachable. A caller that
+ * wants to photograph the verifying screen holds the connect open by returning
+ * a promise that never settles, and awaiting it here simply never answers the
+ * route, which is a real hang. Passing that promise straight to `route.fulfill`
+ * instead, as this did, answered the request immediately with an empty 200: the
+ * page read no home, asked for the list, got an empty one, and landed on the
+ * EMPTY screen. State 5 then only appeared for as long as one round trip
+ * against a local stub takes, so the spec asserting it passed on a quiet
+ * machine and failed on a loaded one, and on the runs where it passed it was
+ * photographing a frame rather than the state.
+ */
export async function stub(page, { homes = [], onConnect } = {}) {
await page.route(CSRF, (route) => route.fulfill(json({ token: 'csrf-test-token', data: { token: 'csrf-test-token' } })));
await page.route(LIST, async (route) => {
if (route.request().method() === 'POST') {
const body = JSON.parse(route.request().postData() || '{}');
- return route.fulfill(onConnect ? onConnect(body) : json({ home: HOME, capabilities: HOME.capabilities }, 201));
+ if (!onConnect) return route.fulfill(json({ home: HOME, capabilities: HOME.capabilities }, 201));
+ return route.fulfill(await onConnect(body));
}
return route.fulfill(json({ homes }));
});
diff --git a/tests/e2e/home-floorplan.spec.js b/tests/e2e/home-floorplan.spec.js
index 3333ae9fe..c86a1407c 100644
--- a/tests/e2e/home-floorplan.spec.js
+++ b/tests/e2e/home-floorplan.spec.js
@@ -108,6 +108,23 @@ function watchConsole(page) {
return found;
}
+/**
+ * The tray's File button, by the accessible name it actually has.
+ *
+ * Not /^File$/. The button reads "File" on screen but carries an aria-label,
+ * "File <device> into a room", and an aria-label is the accessible name: the
+ * visible text loses. Matching the label rather than the text is also the
+ * stronger assertion, because it is the name a screen reader announces, and a
+ * device list where every button is called "File" is the thing that label
+ * exists to prevent.
+ *
+ * This locator matched nothing from the moment the label landed with the i18n
+ * pass, and journeys 9c and 9e both hunted it until they timed out. Neither
+ * reported it: 9c skipped before it got that far, and that is exactly what a
+ * skip-if-empty guard costs when it can also fire for the wrong reason.
+ */
+const FILE_BUTTON = /^File .+ into a room$/;
+
/**
* Open the plan view and wait for it to have actually loaded.
*
@@ -205,7 +222,7 @@ test('journey 9c: filing a device from the tray changes the area in Home Assista
// below it is the same one the drop handler calls.
const first = loose.first();
const label = (await first.getAttribute('title')) || '';
- await first.getByRole('button', { name: /^File$/ }).click();
+ await first.getByRole('button', { name: FILE_BUTTON }).click();
const target = page.locator('.hm-plan-filemenu-item').first();
await expect(target).toBeVisible();
@@ -300,7 +317,7 @@ test('journey 9e: a house with no areas at all reaches a full floorplan from the
const loose = page.locator('.hm-plan-tray-entity').first();
await expect(loose).toBeVisible({ timeout: 30_000 });
const filed = (await loose.getAttribute('title')) || '';
- await loose.getByRole('button', { name: /^File$/ }).click();
+ await loose.getByRole('button', { name: FILE_BUTTON }).click();
await page.locator('.hm-plan-filemenu-item').filter({ hasText: 'Plan kitchen' }).click();
await expect(page.getByText(/was written to your Home Assistant/i)).toBeVisible({ timeout: 30_000 });