Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

test(web): isolate shared UI fixtures (#568)

Gustavo Yef4f6167a5fc5
diff --git a/src/web/src/test/e2e-ui/13-mentions.spec.ts b/src/web/src/test/e2e-ui/13-mentions.spec.ts
index a3771e763..e7dd3a485 100644
--- a/src/web/src/test/e2e-ui/13-mentions.spec.ts
+++ b/src/web/src/test/e2e-ui/13-mentions.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect, userId } from "./_fixtures/community-fixture"
+import { test, expect, userId, userName } from "./_fixtures/community-fixture"
import { tid } from "./_fixtures/testids"
import { composerEditable } from "./_fixtures/actions"
import {
@@ -21,6 +21,7 @@ import {
// its own auto-assigned discriminator — so the same journey exercises the
// spaced-name pill and the same-name disambiguation.
test.describe.serial("mentions — mandatory discriminator", () => {
+ const identityKeys = ["alice", "bob", "carol"] as const
let serverId: string
let channelId: string
let bob: { id: string; discriminator: string }
@@ -40,6 +41,26 @@ test.describe.serial("mentions — mandatory discriminator", () => {
expect(bob.discriminator).not.toBe(carol.discriminator)
})
+ test.afterAll(async () => {
+ const restorations = await Promise.allSettled(identityKeys.map(async (key) => {
+ await renameUser(key, userName(key))
+ return key
+ }))
+ const verifiedMembers = await Promise.allSettled(identityKeys.map(async (key) => {
+ const member = await memberInfo("alice", serverId, userId(key))
+ return { key, name: member.name }
+ }))
+
+ expect(restorations).toEqual(identityKeys.map((key) => ({
+ status: "fulfilled",
+ value: key,
+ })))
+ expect(verifiedMembers).toEqual(identityKeys.map((key) => ({
+ status: "fulfilled",
+ value: { key, name: userName(key) },
+ })))
+ })
+
// Types `@John`, waits for the popup, and picks the member whose row id is
// `memberId` (the popup option testid keys off the row id — labels are
// identical for two "John Doe"s, so text can't disambiguate). Verifies the
diff --git a/src/web/src/test/e2e-ui/29-multi-device-read-state.spec.ts b/src/web/src/test/e2e-ui/29-multi-device-read-state.spec.ts
index b8d4a72e4..d85f769bf 100644
--- a/src/web/src/test/e2e-ui/29-multi-device-read-state.spec.ts
+++ b/src/web/src/test/e2e-ui/29-multi-device-read-state.spec.ts
@@ -77,6 +77,11 @@ test("one human account converges read state across two browser profiles", async
await expect(deviceB.page.getByTestId(tid.inboxUnreadDm(dmId))).toBeVisible({ timeout: 20_000 })
await expect(deviceB.page.getByTestId(tid.inboxUnreadChannel(channelId))).toBeVisible({ timeout: 20_000 })
+ const expectJourneyUnreadsCleared = async () => {
+ await expect(deviceB.page.getByTestId(tid.inboxUnreadChannel(channelId))).toHaveCount(0)
+ await expect(deviceB.page.getByTestId(tid.inboxUnreadDm(dmId))).toHaveCount(0)
+ }
+
const accountSnapshot = async () => await (await deviceB.page.request.get(
"/api/community/users/me/read-state",
)).json() as {
@@ -149,8 +154,7 @@ test("one human account converges read state across two browser profiles", async
await expect.poll(() => readStateEventsSince(proxyB.frames, dmFrameStart).length,
{ timeout: 20_000 }).toBeGreaterThan(0)
expect((await dmRepair).status()).toBe(200)
- await expect(deviceB.page.getByTestId(tid.inboxUnreadDm(dmId))).toHaveCount(0)
- await expect(deviceB.page.getByText("Caught up", { exact: true })).toBeVisible()
+ await expectJourneyUnreadsCleared()
await deviceA.page.waitForTimeout(1_200) // duplicate DM-read repair exclusion window
expect(dmResponses).toEqual([200])
const afterDmRead = await accountSnapshot()
@@ -164,7 +168,7 @@ test("one human account converges read state across two browser profiles", async
const firstReadFrame = orderedReadFrames[0]
expect(firstReadFrame).toBeTruthy()
proxyB.replay(firstReadFrame!)
- await expect(deviceB.page.getByText("Caught up", { exact: true })).toBeVisible()
+ await expectJourneyUnreadsCleared()
await seedMessage("alice", channelId, `offline channel ${stamp}`)
await seedDmMessage("alice", dmId, `offline dm ${stamp}`)
@@ -239,7 +243,9 @@ test("one human account converges read state across two browser profiles", async
.slice(start)
.flatMap((frame) => communityFrameEvents(frame))
.filter((event): event is CapturedReadStateEvent => (
- isCapturedReadStateEvent(event) && event.type === "community:inbox.changed"
+ isCapturedReadStateEvent(event)
+ && event.type === "community:inbox.changed"
+ && event.reason === "read_all"
))
await expect.poll(() => readAllEvents(proxyA.frames, readAllFrameStarts[0]!).length, {
timeout: 20_000,