|
2 | 2 | /* @vitest-environment-options {"url":"http://chat-pane-sharing.test/"} */ |
3 | 3 |
|
4 | 4 | import { describe, expect, it, vi } from "vitest"; |
| 5 | +import type { SessionSuggestion } from "../../../../packages/gateway-protocol/src/index.js"; |
5 | 6 | import { createDeferred } from "../../../../test/helpers/promise.js"; |
6 | 7 | import type { GatewayBrowserClient } from "../../api/gateway.ts"; |
7 | 8 | import type { |
@@ -152,6 +153,48 @@ const mutations = [ |
152 | 153 | ] as const; |
153 | 154 |
|
154 | 155 | describe("chat pane sharing authorization", () => { |
| 156 | + it.each(["draft", "shared"] as const)( |
| 157 | + "loads selected-global Work suggestions after visibility changes to %s", |
| 158 | + async (visibility) => { |
| 159 | + const pending: SessionSuggestion = { |
| 160 | + id: `pending-${visibility}`, |
| 161 | + sessionKey: "agent:work:main", |
| 162 | + agentId: "work", |
| 163 | + author: { type: "human", id: "alice", label: "Alice" }, |
| 164 | + text: "still needs review", |
| 165 | + createdAt: 1, |
| 166 | + state: "pending", |
| 167 | + }; |
| 168 | + const request = vi.fn(async () => ({ suggestions: [pending], role: "owner" as const })); |
| 169 | + const { pane, state } = createTestChatPane({ |
| 170 | + client: createGatewayBrowserClientFixture({ request }), |
| 171 | + sessions: {} as SessionCapability, |
| 172 | + }); |
| 173 | + state.sessionKey = "agent:work:main"; |
| 174 | + state.assistantAgentId = "work"; |
| 175 | + state.agentsList = { defaultId: "main", mainKey: "main", scope: "global", agents: [] }; |
| 176 | + state.sessionsResultAgentId = "work"; |
| 177 | + state.sessionsResult = sharingSessionsResult({ |
| 178 | + ...sessionRow(), |
| 179 | + key: "global", |
| 180 | + kind: "global", |
| 181 | + visibility, |
| 182 | + }); |
| 183 | + pane.presencePayload = { |
| 184 | + presence: [{ user: { id: "owner" } }, { user: { id: "alice" } }], |
| 185 | + }; |
| 186 | + |
| 187 | + await pane.refreshSessionSuggestions(); |
| 188 | + |
| 189 | + expect(request).toHaveBeenCalledWith("session.suggestions.list", { |
| 190 | + sessionKey: "agent:work:main", |
| 191 | + agentId: "work", |
| 192 | + }); |
| 193 | + expect(pane.sessionSuggestions).toEqual([pending]); |
| 194 | + expect(pane.sessionSuggestionRole).toBe("owner"); |
| 195 | + }, |
| 196 | + ); |
| 197 | + |
155 | 198 | it("allows read-scoped owners to load sharing data but not mutate it", async () => { |
156 | 199 | const row = sessionRow(); |
157 | 200 | const request = vi.fn(async (method: string) => { |
|
0 commit comments