feat(web): add global settings and simplify sidebar

This commit is contained in:
2026-11-12 15:25:12 -08:00
parent b7fdf7a89c
commit d88018fd64
13 changed files with 853 additions and 242 deletions
+12 -4
View File
@@ -71,10 +71,14 @@ await context.routeWebSocket("**/api/v1/agent/ws", socket => {
});
});
const page = await context.newPage(); page.on("pageerror", error => errors.push(error.message));
const openSettings = async () => {
await page.getByRole("button", { name: "Open app settings", exact: true }).click();
await page.getByText("Troubleshooting", { exact: true }).click();
};
const expectEventually = async predicate => { for (let i = 0; i < 100; i++) { if (await predicate()) return; await new Promise(resolve => setTimeout(resolve, 50)); } assert.fail("Condition did not settle"); };
try {
await page.goto(target.href, { waitUntil: "networkidle" });
await page.getByText("Agent notifications", { exact: true }).click();
await openSettings();
await page.getByText(/The Agent notification source is not ready yet/).waitFor();
assert.equal(await page.getByRole("button", { name: "Enable notifications", exact: true }).isDisabled(), true, "unknown source cannot opt in");
assert.deepEqual(await page.evaluate(() => window.__pushCalls), []);
@@ -165,6 +169,7 @@ try {
// The rendered room belongs to source A. A B read frame must stop the room,
// preserving A's cursor instead of relabeling old queued reads with B.
await second.close();
await page.getByRole("button", { name: "Close settings", exact: true }).click();
await page.locator('[data-testid="agent-sidebar-item"]').click();
sockets[0].socket.send(JSON.stringify({ type: "read_state", sourceId: replacementSourceId, cursor: "0", updatedAt: null }));
await page.getByText("Agent history changed. Reload the page before marking messages read.", { exact: true }).waitFor();
@@ -177,6 +182,7 @@ try {
const oldConsent = await page.evaluate(() => JSON.parse(localStorage.getItem("sybil.agent.push.v1")));
const registrationCount = requests.filter(request => request.path.includes("/push/installations/") && request.method === "PUT").length;
config.sourceId = replacementSourceId; readSourceId = replacementSourceId; readCursor = "0";
await openSettings();
await page.getByRole("button", { name: "Refresh", exact: true }).click();
await expectEventually(() => page.getByRole("button", { name: "Enable notifications", exact: true }).isEnabled());
const retiredConsent = await page.evaluate(() => JSON.parse(localStorage.getItem("sybil.agent.push.v1")));
@@ -190,10 +196,11 @@ try {
assert.equal(replacementConsent.scope, oldConsent.scope); assert.notEqual(replacementConsent.installationId, oldConsent.installationId);
assert.ok((await page.evaluate(() => window.__pushCalls.filter(call => call.type === "permission"))).every(call => call.gesture === true));
const socketCount = sockets.length;
await page.getByRole("button", { name: "Close settings", exact: true }).click();
await page.getByRole("button", { name: "Retry", exact: true }).click();
await expectEventually(() => sockets.length > socketCount);
assert.equal(await page.getByText("Agent history changed. Reload the page before marking messages read.", { exact: true }).count(), 0, "explicit reload binds a fresh room to B");
await page.getByText("Agent notifications", { exact: true }).click();
await openSettings();
await page.getByRole("button", { name: "Turn off notifications", exact: true }).waitFor();
// Credential rotation is a new authority scope. The old UUID remains queued
@@ -201,7 +208,7 @@ try {
const originalAuthority = await page.evaluate(() => JSON.parse(localStorage.getItem("sybil.agent.push.v1")));
await page.evaluate(() => localStorage.setItem("sybil_admin_token", "browser-fixture-rotated-token"));
await page.reload({ waitUntil: "networkidle" });
await page.getByText("Agent notifications", { exact: true }).click();
await openSettings();
await expectEventually(() => page.getByRole("button", { name: "Enable notifications", exact: true }).isEnabled());
const rotatedOff = await page.evaluate(() => JSON.parse(localStorage.getItem("sybil.agent.push.v1")));
assert.deepEqual(rotatedOff.pendingRevocations, [{ installationId: originalAuthority.installationId, scope: originalAuthority.scope }]);
@@ -215,7 +222,7 @@ try {
assert.notEqual(rotatedOn.installationId, originalAuthority.installationId); assert.deepEqual(rotatedOn.pendingRevocations, rotatedOff.pendingRevocations);
await page.evaluate(() => localStorage.setItem("sybil_admin_token", "browser-fixture-token"));
await page.reload({ waitUntil: "networkidle" });
await page.getByText("Agent notifications", { exact: true }).click();
await openSettings();
await expectEventually(() => page.getByRole("button", { name: "Enable notifications", exact: true }).isEnabled());
const returned = await page.evaluate(() => JSON.parse(localStorage.getItem("sybil.agent.push.v1")));
assert.deepEqual(returned.pendingRevocations, [{ installationId: rotatedOn.installationId, scope: rotatedOn.scope }]);
@@ -227,6 +234,7 @@ try {
// Offline sign-out still removes the local subscription and leaves a tombstone.
failDelete = true;
await page.getByRole("button", { name: "Connection & session", exact: true }).click();
await page.getByRole("button", { name: "Sign out", exact: true }).click();
await page.getByRole("button", { name: /Sign in/i }).waitFor();
const local = await page.evaluate(() => ({ token: localStorage.getItem("sybil_admin_token"), subscription: localStorage.getItem("fixture-subscription"), consent: JSON.parse(localStorage.getItem("sybil.agent.push.v1")) }));