test(ui): harden device token revoke flow (#103016)

This commit is contained in:
Peter Steinberger
2026-07-09 18:12:14 +01:00
committed by GitHub
parent f1e7081b4d
commit 5013f4a166
2 changed files with 21 additions and 4 deletions
+17 -4
View File
@@ -240,12 +240,25 @@ describeControlUiE2e("Control UI device-token reconnect E2E", () => {
route: "nodes",
});
expect(requireConnectAuth(wilfredNodes.connect).token).toBe(WILFRED_DEVICE_TOKEN);
const revokeButton = wilfredNodes.page.getByRole("button", { name: "Revoke" });
await revokeButton.waitFor();
await wilfredNodes.gateway.waitForRequest("device.pair.list");
const deviceEntry = wilfredNodes.page.locator(".nodes-entry").filter({
has: wilfredNodes.page.getByText("This browser", { exact: true }),
});
await deviceEntry.waitFor();
await deviceEntry.locator("details.nodes-entry__details > summary").click();
const revokeButton = deviceEntry.getByRole("button", { name: "Revoke", exact: true });
await revokeButton.waitFor({ state: "visible" });
await revokeButton.scrollIntoViewIfNeeded();
await captureProof(wilfredNodes.page, "wilfred-before-revoke.png");
wilfredNodes.page.once("dialog", (dialog) => void dialog.accept());
await revokeButton.click();
const dialogPromise = wilfredNodes.page.waitForEvent("dialog");
await Promise.all([
dialogPromise.then(async (dialog) => {
expect(dialog.type()).toBe("confirm");
expect(dialog.message()).toBe(`Revoke token for ${deviceId} (operator)?`);
await dialog.accept();
}),
revokeButton.click(),
]);
const revoke = await wilfredNodes.gateway.waitForRequest("device.token.revoke");
expect(revoke.params).toEqual({ deviceId, role: "operator" });
const wilfredStoreKey =
+4
View File
@@ -292,6 +292,7 @@ describe("nodes inventory rendering", () => {
it("shows token rows with rotate and revoke inside entry details", () => {
const rotations: Array<{ deviceId: string; role: string }> = [];
const revocations: Array<{ deviceId: string; role: string }> = [];
const container = renderNodesContainer({
devicesList: {
pending: [],
@@ -305,12 +306,15 @@ describe("nodes inventory rendering", () => {
],
},
onDeviceRotate: (deviceId, role) => rotations.push({ deviceId, role }),
onDeviceRevoke: (deviceId, role) => revocations.push({ deviceId, role }),
});
const card = getInventoryCard(container);
expect(card.textContent).toContain("operator · active · scopes: operator.read");
findButton(card, "Rotate").click();
expect(rotations).toEqual([{ deviceId: "device-1", role: "operator" }]);
findButton(card, "Revoke").click();
expect(revocations).toEqual([{ deviceId: "device-1", role: "operator" }]);
});
});