|
| 1 | +/** |
| 2 | + * Screenshots documenting the focused Inbox behavior for PR #2045. |
| 3 | + * |
| 4 | + * These replace the hand-generated shots posted earlier in that PR, which went |
| 5 | + * stale twice: once when the surface was briefly renamed to "Activity", and |
| 6 | + * again when the Projects filter landed. Keeping them in a spec means the next |
| 7 | + * round regenerates instead of drifting. |
| 8 | + * |
| 9 | + * Run: pnpm build:e2e && pnpm exec playwright test --project=smoke \ |
| 10 | + * tests/e2e/inbox-refactor-screenshots.spec.ts |
| 11 | + * Output: test-results/inbox-refactor/ |
| 12 | + */ |
| 13 | +import { expect, test } from "@playwright/test"; |
| 14 | + |
| 15 | +import { waitForAnimations } from "../helpers/animations"; |
| 16 | +import { installMockBridge, TEST_IDENTITIES } from "../helpers/bridge"; |
| 17 | + |
| 18 | +const SHOTS = "test-results/inbox-refactor"; |
| 19 | + |
| 20 | +const GENERAL_CHANNEL_ID = "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50"; |
| 21 | +const AGENTS_CHANNEL_ID = "94a444a4-c0a3-5966-ab05-530c6ddc2301"; |
| 22 | +const DM_CHANNEL_ID = "f48efb06-0c93-5025-aac9-2e646bb6bfa8"; |
| 23 | + |
| 24 | +// Mock bridge default pubkey — must match DEFAULT_MOCK_PUBKEY in bridge.ts. |
| 25 | +const MOCK_PUBKEY = "deadbeef".repeat(8); |
| 26 | +const DRAFT_STORE_KEY = `buzz-drafts.v1:${MOCK_PUBKEY}`; |
| 27 | + |
| 28 | +// Fixed timestamps so draft ordering renders deterministically. |
| 29 | +const DRAFT_CREATED_AT_1 = "2026-07-01T10:00:00.000Z"; |
| 30 | +const DRAFT_CREATED_AT_2 = "2026-07-02T14:30:00.000Z"; |
| 31 | + |
| 32 | +type MockFeedWindow = Window & { |
| 33 | + __BUZZ_E2E_EMIT_MOCK_MESSAGE__?: (input: { |
| 34 | + channelName: string; |
| 35 | + content: string; |
| 36 | + createdAt?: number; |
| 37 | + id?: string; |
| 38 | + parentEventId?: string; |
| 39 | + pubkey?: string; |
| 40 | + }) => { |
| 41 | + content: string; |
| 42 | + created_at: number; |
| 43 | + id: string; |
| 44 | + kind: number; |
| 45 | + pubkey: string; |
| 46 | + tags: string[][]; |
| 47 | + }; |
| 48 | + __BUZZ_E2E_PUSH_MOCK_FEED_ITEM__?: (item: { |
| 49 | + category: "mention" | "needs_action" | "activity" | "agent_activity"; |
| 50 | + channel_id: string | null; |
| 51 | + channel_name: string; |
| 52 | + channel_type?: string | null; |
| 53 | + content: string; |
| 54 | + created_at: number; |
| 55 | + id: string; |
| 56 | + kind: number; |
| 57 | + pubkey: string; |
| 58 | + tags: string[][]; |
| 59 | + }) => void; |
| 60 | +}; |
| 61 | + |
| 62 | +/** |
| 63 | + * The mock community is seeded without a pubkey, which initDraftStore needs on |
| 64 | + * startup. Init scripts run in registration order, so this patches the seed |
| 65 | + * installMockBridge already wrote. |
| 66 | + */ |
| 67 | +async function patchCommunityPubkey(page: import("@playwright/test").Page) { |
| 68 | + await page.addInitScript( |
| 69 | + ({ pubkey }) => { |
| 70 | + const raw = window.localStorage.getItem("buzz-communities"); |
| 71 | + const communities = raw |
| 72 | + ? (JSON.parse(raw) as Array<Record<string, unknown>>) |
| 73 | + : []; |
| 74 | + if (communities[0]) { |
| 75 | + communities[0].pubkey = pubkey; |
| 76 | + window.localStorage.setItem( |
| 77 | + "buzz-communities", |
| 78 | + JSON.stringify(communities), |
| 79 | + ); |
| 80 | + } |
| 81 | + }, |
| 82 | + { pubkey: MOCK_PUBKEY }, |
| 83 | + ); |
| 84 | +} |
| 85 | + |
| 86 | +/** Two active drafts so the Drafts filter renders its count badge. */ |
| 87 | +async function seedTwoDrafts(page: import("@playwright/test").Page) { |
| 88 | + await page.addInitScript( |
| 89 | + ({ storeKey, channelId, agentsChannelId, createdAt1, createdAt2 }) => { |
| 90 | + const draft = (content: string, channel: string, timestamp: string) => ({ |
| 91 | + content, |
| 92 | + selectionStart: content.length, |
| 93 | + selectionEnd: content.length, |
| 94 | + channelId: channel, |
| 95 | + createdAt: timestamp, |
| 96 | + updatedAt: timestamp, |
| 97 | + pendingImeta: [], |
| 98 | + spoileredAttachmentUrls: [], |
| 99 | + status: "active" as const, |
| 100 | + }); |
| 101 | + |
| 102 | + window.localStorage.setItem( |
| 103 | + storeKey, |
| 104 | + JSON.stringify({ |
| 105 | + [`channel:${channelId}`]: draft( |
| 106 | + "Drafting the release notes — will post once the checklist is signed off.", |
| 107 | + channelId, |
| 108 | + createdAt1, |
| 109 | + ), |
| 110 | + [`channel:${agentsChannelId}`]: draft( |
| 111 | + "Following up on the harness rollout.", |
| 112 | + agentsChannelId, |
| 113 | + createdAt2, |
| 114 | + ), |
| 115 | + }), |
| 116 | + ); |
| 117 | + }, |
| 118 | + { |
| 119 | + storeKey: DRAFT_STORE_KEY, |
| 120 | + channelId: GENERAL_CHANNEL_ID, |
| 121 | + agentsChannelId: AGENTS_CHANNEL_ID, |
| 122 | + createdAt1: DRAFT_CREATED_AT_1, |
| 123 | + createdAt2: DRAFT_CREATED_AT_2, |
| 124 | + }, |
| 125 | + ); |
| 126 | +} |
| 127 | + |
| 128 | +/** Wait for the live mock-feed helpers the seeding below depends on. */ |
| 129 | +async function waitForMockFeedHelpers(page: import("@playwright/test").Page) { |
| 130 | + await expect(page.getByTestId("home-inbox-list")).toBeVisible({ |
| 131 | + timeout: 10_000, |
| 132 | + }); |
| 133 | + await page.waitForFunction(() => { |
| 134 | + const win = window as MockFeedWindow; |
| 135 | + return ( |
| 136 | + typeof win.__BUZZ_E2E_EMIT_MOCK_MESSAGE__ === "function" && |
| 137 | + typeof win.__BUZZ_E2E_PUSH_MOCK_FEED_ITEM__ === "function" |
| 138 | + ); |
| 139 | + }); |
| 140 | +} |
| 141 | + |
| 142 | +test.describe("inbox refactor screenshots", () => { |
| 143 | + test.use({ viewport: { width: 1280, height: 900 } }); |
| 144 | + |
| 145 | + test.beforeEach(async ({ page }) => { |
| 146 | + page.on("pageerror", (err) => console.error("PAGE ERROR:", err.message)); |
| 147 | + page.on("console", (msg) => { |
| 148 | + if (msg.type() === "error") { |
| 149 | + console.error("CONSOLE ERROR:", msg.text().slice(0, 300)); |
| 150 | + } |
| 151 | + }); |
| 152 | + }); |
| 153 | + |
| 154 | + test("01 — filter menu with Reminders/Drafts divider and counts", async ({ |
| 155 | + page, |
| 156 | + }) => { |
| 157 | + await patchCommunityPubkey(page); |
| 158 | + await seedTwoDrafts(page); |
| 159 | + await installMockBridge(page, { mode: "mock" }); |
| 160 | + |
| 161 | + await page.goto("/", { waitUntil: "domcontentloaded" }); |
| 162 | + await expect(page.getByTestId("home-inbox")).toBeVisible({ |
| 163 | + timeout: 10_000, |
| 164 | + }); |
| 165 | + |
| 166 | + await page.getByTestId("inbox-filter-trigger").click(); |
| 167 | + const menu = page.getByRole("menu"); |
| 168 | + await expect(menu).toBeVisible(); |
| 169 | + await expect( |
| 170 | + menu.getByRole("menuitemradio", { name: "Projects" }), |
| 171 | + ).toBeVisible(); |
| 172 | + await waitForAnimations(page); |
| 173 | + |
| 174 | + await page.screenshot({ path: `${SHOTS}/01-current-filters.png` }); |
| 175 | + }); |
| 176 | + |
| 177 | + test("02 — Inbox label, bell icon, and overflow controls", async ({ |
| 178 | + page, |
| 179 | + }) => { |
| 180 | + await installMockBridge(page, { mode: "mock" }); |
| 181 | + |
| 182 | + await page.goto("/", { waitUntil: "domcontentloaded" }); |
| 183 | + await expect(page.getByTestId("home-inbox")).toBeVisible({ |
| 184 | + timeout: 10_000, |
| 185 | + }); |
| 186 | + |
| 187 | + // The sidebar must be in frame — the label is the point of this shot. |
| 188 | + await expect( |
| 189 | + page |
| 190 | + .getByTestId("sidebar-primary-menu") |
| 191 | + .getByRole("button", { name: "Inbox", exact: true }), |
| 192 | + ).toBeVisible(); |
| 193 | + |
| 194 | + await page.getByTestId("inbox-options-trigger").click(); |
| 195 | + await expect(page.getByText("Show unread only")).toBeVisible(); |
| 196 | + await expect(page.getByText("Mark all as read")).toBeVisible(); |
| 197 | + await waitForAnimations(page); |
| 198 | + |
| 199 | + await page.screenshot({ path: `${SHOTS}/02-current-controls.png` }); |
| 200 | + }); |
| 201 | + |
| 202 | + test("03 — consecutive DMs group into one conversation row", async ({ |
| 203 | + page, |
| 204 | + }) => { |
| 205 | + await installMockBridge(page, { mode: "mock" }); |
| 206 | + |
| 207 | + await page.goto("/", { waitUntil: "domcontentloaded" }); |
| 208 | + await waitForMockFeedHelpers(page); |
| 209 | + |
| 210 | + const dmIds = ["shot-dm-first", "shot-dm-second", "shot-dm-third"]; |
| 211 | + await page.evaluate( |
| 212 | + ({ channelId, createdAt, ids, senderPubkey }) => { |
| 213 | + const win = window as MockFeedWindow; |
| 214 | + const emitMessage = win.__BUZZ_E2E_EMIT_MOCK_MESSAGE__; |
| 215 | + const pushFeedItem = win.__BUZZ_E2E_PUSH_MOCK_FEED_ITEM__; |
| 216 | + if (!emitMessage || !pushFeedItem) { |
| 217 | + throw new Error("Mock bridge helpers are not installed."); |
| 218 | + } |
| 219 | + |
| 220 | + [ |
| 221 | + "Quick update: the staging deploy is ready.", |
| 222 | + "I ran the smoke tests and everything passed.", |
| 223 | + "Can you take a final look before we release?", |
| 224 | + ].forEach((content, index) => { |
| 225 | + const event = emitMessage({ |
| 226 | + channelName: "alice-tyler", |
| 227 | + content, |
| 228 | + createdAt: createdAt + index, |
| 229 | + id: ids[index], |
| 230 | + pubkey: senderPubkey, |
| 231 | + }); |
| 232 | + pushFeedItem({ |
| 233 | + category: "activity", |
| 234 | + channel_id: channelId, |
| 235 | + channel_name: "alice-tyler", |
| 236 | + channel_type: null, |
| 237 | + content: event.content, |
| 238 | + created_at: event.created_at, |
| 239 | + id: event.id, |
| 240 | + kind: event.kind, |
| 241 | + pubkey: event.pubkey, |
| 242 | + tags: event.tags, |
| 243 | + }); |
| 244 | + }); |
| 245 | + }, |
| 246 | + { |
| 247 | + channelId: DM_CHANNEL_ID, |
| 248 | + createdAt: Math.floor(Date.now() / 1000), |
| 249 | + ids: dmIds, |
| 250 | + senderPubkey: TEST_IDENTITIES.alice.pubkey, |
| 251 | + }, |
| 252 | + ); |
| 253 | + |
| 254 | + const firstDmRow = page.getByTestId(`home-inbox-item-${dmIds[0]}`); |
| 255 | + await expect(firstDmRow).toBeVisible(); |
| 256 | + // The grouping claim: three DMs, one row. |
| 257 | + await expect(page.getByTestId(`home-inbox-item-${dmIds[1]}`)).toHaveCount( |
| 258 | + 0, |
| 259 | + ); |
| 260 | + await expect(page.getByTestId(`home-inbox-item-${dmIds[2]}`)).toHaveCount( |
| 261 | + 0, |
| 262 | + ); |
| 263 | + |
| 264 | + await firstDmRow.click(); |
| 265 | + const detail = page.getByTestId("home-inbox-detail"); |
| 266 | + await expect(detail.getByRole("heading")).toHaveText("DM with alice"); |
| 267 | + await expect(detail.getByTestId("message-unread-divider")).toBeVisible(); |
| 268 | + await waitForAnimations(page); |
| 269 | + |
| 270 | + await page.screenshot({ path: `${SHOTS}/03-grouped-dms.png` }); |
| 271 | + }); |
| 272 | + |
| 273 | + test("04 — thread opens at the oldest unread reply", async ({ page }) => { |
| 274 | + await installMockBridge(page, { mode: "mock" }); |
| 275 | + |
| 276 | + await page.goto("/", { waitUntil: "domcontentloaded" }); |
| 277 | + await waitForMockFeedHelpers(page); |
| 278 | + |
| 279 | + const replyIds = [ |
| 280 | + "shot-reply-first", |
| 281 | + "shot-reply-second", |
| 282 | + "shot-reply-third", |
| 283 | + ]; |
| 284 | + await page.evaluate( |
| 285 | + ({ agentPubkeys, channelId, currentPubkey, ids }) => { |
| 286 | + const win = window as MockFeedWindow; |
| 287 | + const emitMessage = win.__BUZZ_E2E_EMIT_MOCK_MESSAGE__; |
| 288 | + const pushFeedItem = win.__BUZZ_E2E_PUSH_MOCK_FEED_ITEM__; |
| 289 | + if (!emitMessage || !pushFeedItem) { |
| 290 | + throw new Error("Mock bridge helpers are not installed."); |
| 291 | + } |
| 292 | + |
| 293 | + const createdAt = Math.floor(Date.now() / 1000) + 60; |
| 294 | + const root = emitMessage({ |
| 295 | + channelName: "general", |
| 296 | + content: "Release checklist for the desktop build", |
| 297 | + createdAt: createdAt - 10, |
| 298 | + id: "shot-thread-root", |
| 299 | + pubkey: currentPubkey, |
| 300 | + }); |
| 301 | + |
| 302 | + [ |
| 303 | + "Started on the changelog — first pass is up.", |
| 304 | + "Verified the signed build on macOS.", |
| 305 | + "One open question on the version suffix.", |
| 306 | + ].forEach((content, index) => { |
| 307 | + const event = emitMessage({ |
| 308 | + channelName: "general", |
| 309 | + content, |
| 310 | + createdAt: createdAt + index, |
| 311 | + id: ids[index], |
| 312 | + parentEventId: root.id, |
| 313 | + pubkey: agentPubkeys[index % agentPubkeys.length], |
| 314 | + }); |
| 315 | + pushFeedItem({ |
| 316 | + category: "activity", |
| 317 | + channel_id: channelId, |
| 318 | + channel_name: "general", |
| 319 | + channel_type: "stream", |
| 320 | + content: event.content, |
| 321 | + created_at: event.created_at, |
| 322 | + id: event.id, |
| 323 | + kind: event.kind, |
| 324 | + pubkey: event.pubkey, |
| 325 | + tags: event.tags, |
| 326 | + }); |
| 327 | + }); |
| 328 | + }, |
| 329 | + { |
| 330 | + agentPubkeys: [ |
| 331 | + TEST_IDENTITIES.alice.pubkey, |
| 332 | + TEST_IDENTITIES.charlie.pubkey, |
| 333 | + ], |
| 334 | + channelId: GENERAL_CHANNEL_ID, |
| 335 | + currentPubkey: MOCK_PUBKEY, |
| 336 | + ids: replyIds, |
| 337 | + }, |
| 338 | + ); |
| 339 | + |
| 340 | + const firstUnreadRow = page.getByTestId(`home-inbox-item-${replyIds[0]}`); |
| 341 | + await expect(firstUnreadRow).toBeVisible(); |
| 342 | + await firstUnreadRow.click(); |
| 343 | + |
| 344 | + const detail = page.getByTestId("home-inbox-detail"); |
| 345 | + // The anchoring claim: full thread present, selection on the oldest unread. |
| 346 | + await expect(detail).toContainText( |
| 347 | + "Release checklist for the desktop build", |
| 348 | + ); |
| 349 | + await expect(detail.getByTestId("message-unread-divider")).toBeVisible(); |
| 350 | + await expect(page.getByTestId("home-inbox-selected-message")).toContainText( |
| 351 | + "Started on the changelog — first pass is up.", |
| 352 | + ); |
| 353 | + await waitForAnimations(page); |
| 354 | + |
| 355 | + await page.screenshot({ path: `${SHOTS}/04-thread-context.png` }); |
| 356 | + }); |
| 357 | +}); |
0 commit comments