|
| 1 | +import type { ConversationSummaryReport } from "@sentry/junior/api/schema"; |
| 2 | + |
1 | 3 | import { conversationMenuRow, viewAsParticipant } from "./conversationMenu"; |
2 | 4 | import { desktop, mobile, screenshot } from "./screenshot"; |
3 | 5 | import { expect, test } from "./test"; |
4 | 6 |
|
5 | | -const BILLING = "/spaces/6f1c2a7e-3b4d-4e5f-8a6b-7c8d9e0f1a21"; |
| 7 | +const BILLING_ID = "6f1c2a7e-3b4d-4e5f-8a6b-7c8d9e0f1a21"; |
| 8 | +const BILLING = `/spaces/${BILLING_ID}`; |
6 | 9 | const DOCS = "/spaces/6f1c2a7e-3b4d-4e5f-8a6b-7c8d9e0f1a23"; |
7 | 10 | const MOBILE_APP_ID = "6f1c2a7e-3b4d-4e5f-8a6b-7c8d9e0f1a22"; |
8 | 11 | // A private Space that the viewer and Avery are in. |
@@ -76,7 +79,7 @@ test("the pane lists the viewer's Spaces, and a Space page shows its details", a |
76 | 79 | await expect(page).toHaveURL(`${dashboard.baseURL}${BILLING}`); |
77 | 80 | }); |
78 | 81 |
|
79 | | -test("each pane row shows what its Space's Conversations need", async ({ |
| 82 | +test("each pane row shows what its Space's Conversations need, and the Space's page lists them in order", async ({ |
80 | 83 | dashboard, |
81 | 84 | page, |
82 | 85 | }) => { |
@@ -130,6 +133,113 @@ test("each pane row shows what its Space's Conversations need", async ({ |
130 | 133 | lightTheme: true, |
131 | 134 | view: "mobile", |
132 | 135 | }); |
| 136 | + |
| 137 | + // The Space's page lists its Conversations in In flight's order: pins, |
| 138 | + // then what waits on the viewer, then the rest, then done. Each group |
| 139 | + // runs newest Message first. |
| 140 | + await page.route( |
| 141 | + (url) => |
| 142 | + url.pathname === "/api/conversations" && |
| 143 | + url.searchParams.get("spaceId") === BILLING_ID, |
| 144 | + async (route) => { |
| 145 | + const response = await route.fetch(); |
| 146 | + const feed = await response.json(); |
| 147 | + // Row `index` had its last Message `index` hours before the first. |
| 148 | + const newest = Date.parse(feed.conversations[0].lastSeenAt); |
| 149 | + const row = ( |
| 150 | + index: number, |
| 151 | + displayTitle: string, |
| 152 | + fields: Partial<ConversationSummaryReport>, |
| 153 | + ) => { |
| 154 | + const at = new Date(newest - index * 3_600_000).toISOString(); |
| 155 | + return { |
| 156 | + ...feed.conversations[0], |
| 157 | + conversationId: `internal:space-order-${index}`, |
| 158 | + displayTitle, |
| 159 | + lastMessageAt: at, |
| 160 | + lastSeenAt: at, |
| 161 | + latestTurnFailed: false, |
| 162 | + pinnedAt: null, |
| 163 | + status: "done", |
| 164 | + threads: undefined, |
| 165 | + treeState: "done", |
| 166 | + turnActive: false, |
| 167 | + watching: false, |
| 168 | + ...fields, |
| 169 | + }; |
| 170 | + }; |
| 171 | + await route.fulfill({ |
| 172 | + json: { |
| 173 | + ...feed, |
| 174 | + conversations: [ |
| 175 | + row(0, "Done recently", {}), |
| 176 | + row(1, "Running", { |
| 177 | + status: "working", |
| 178 | + treeState: "working", |
| 179 | + turnActive: true, |
| 180 | + }), |
| 181 | + row(2, "Failed", { latestTurnFailed: true }), |
| 182 | + row(3, "Asks you", { |
| 183 | + status: "needs_input", |
| 184 | + treeState: "needs_you", |
| 185 | + }), |
| 186 | + row(4, "Pinned", { pinnedAt: "2026-08-01T10:00:00.000Z" }), |
| 187 | + row(5, "Done earlier", {}), |
| 188 | + ], |
| 189 | + nextCursor: undefined, |
| 190 | + }, |
| 191 | + response, |
| 192 | + }); |
| 193 | + }, |
| 194 | + ); |
| 195 | + await page.setViewportSize(desktop); |
| 196 | + await page.goto(`${dashboard.baseURL}${BILLING}`); |
| 197 | + const conversations = page |
| 198 | + .getByRole("complementary", { name: "Space details" }) |
| 199 | + .getByRole("region", { exact: true, name: "Conversations" }); |
| 200 | + await conversations.getByRole("button", { name: "Show 3 more" }).click(); |
| 201 | + const rows = conversations.getByRole("listitem"); |
| 202 | + await expect(rows).toHaveText([ |
| 203 | + /Pinned/, |
| 204 | + /Asks you/, |
| 205 | + /Running/, |
| 206 | + /Failed/, |
| 207 | + /Done recently/, |
| 208 | + /Done earlier/, |
| 209 | + /Show fewer/, |
| 210 | + ]); |
| 211 | + // Rows carry In flight's icons, and a failed Turn. Done rows show none. |
| 212 | + await expect(rows.nth(0).getByRole("img", { name: "Pinned" })).toBeVisible(); |
| 213 | + await expect( |
| 214 | + rows.nth(1).getByRole("img", { name: "Waiting on you" }), |
| 215 | + ).toBeVisible(); |
| 216 | + await expect( |
| 217 | + rows.nth(2).getByRole("status", { name: "Working" }), |
| 218 | + ).toBeVisible(); |
| 219 | + await expect(rows.nth(3).getByRole("img", { name: "Failed" })).toBeVisible(); |
| 220 | + await expect(rows.nth(4).getByRole("img")).toHaveCount(0); |
| 221 | + // No row shows its hover fill in the shot. |
| 222 | + await page.mouse.move(0, 0); |
| 223 | + await screenshot(page, "space-page-conversations", { |
| 224 | + lightTheme: true, |
| 225 | + target: conversations, |
| 226 | + view: "desktop", |
| 227 | + }); |
| 228 | + |
| 229 | + // A phone shows the same order in the details sheet. |
| 230 | + await page.setViewportSize(mobile); |
| 231 | + await page.goto(`${dashboard.baseURL}${BILLING}`); |
| 232 | + await page.getByRole("button", { name: "Space details" }).click(); |
| 233 | + const sheet = page.getByRole("dialog", { name: "Space details" }); |
| 234 | + await expect( |
| 235 | + sheet |
| 236 | + .getByRole("region", { exact: true, name: "Conversations" }) |
| 237 | + .getByRole("listitem"), |
| 238 | + ).toHaveText([/Pinned/, /Asks you/, /Running/, /Show 3 more/]); |
| 239 | + await screenshot(page, "space-page-conversations", { |
| 240 | + lightTheme: true, |
| 241 | + view: "mobile", |
| 242 | + }); |
133 | 243 | }); |
134 | 244 |
|
135 | 245 | test("a Space's page shows its settings when they are opened", async ({ |
|
0 commit comments