feat(frontend): expose owned session scopes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { http, HttpResponse } from "msw";
|
||||
import { server } from "../test/msw";
|
||||
import { createSession, listSessions, prewarmRuntime, resumeSession } from "./sessions";
|
||||
import { createSession, getMe, listSessions, prewarmRuntime, resumeSession } from "./sessions";
|
||||
import {
|
||||
renameSession, setSessionGroup, archiveSession, unarchiveSession,
|
||||
deleteSession, getSessionDocuments,
|
||||
@@ -30,10 +30,34 @@ test.each([202, 204])("prewarmRuntime accepts a body-less %s response", async (s
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
|
||||
test("listSessions GETs the array", async () => {
|
||||
server.use(http.get("http://localhost:8787/sessions", () => HttpResponse.json([{ id: "s1", status: "open", question: "q", summary: null, created_at: "t", updated_at: null, author: null }])));
|
||||
test("listSessions defaults to the current user's scope", async () => {
|
||||
let scope: string | null = null;
|
||||
server.use(http.get("http://localhost:8787/sessions", ({ request }) => {
|
||||
scope = new URL(request.url).searchParams.get("scope");
|
||||
return HttpResponse.json([{ id: "s1", status: "open", question: "q", summary: null, created_at: "t", updated_at: null, author: null }]);
|
||||
}));
|
||||
const rows = await listSessions();
|
||||
expect(rows[0].id).toBe("s1");
|
||||
expect(scope).toBe("mine");
|
||||
});
|
||||
|
||||
test("listSessions requests the selected administrator scope", async () => {
|
||||
let scope: string | null = null;
|
||||
server.use(http.get("http://localhost:8787/sessions", ({ request }) => {
|
||||
scope = new URL(request.url).searchParams.get("scope");
|
||||
return HttpResponse.json([]);
|
||||
}));
|
||||
await listSessions("all");
|
||||
expect(scope).toBe("all");
|
||||
});
|
||||
|
||||
test("getMe fetches the typed authenticated principal", async () => {
|
||||
server.use(http.get("http://localhost:8787/me", () =>
|
||||
HttpResponse.json({ issuer: "portal", subject: "42", displayName: "Alice", isAdmin: true }),
|
||||
));
|
||||
await expect(getMe()).resolves.toEqual({
|
||||
issuer: "portal", subject: "42", displayName: "Alice", isAdmin: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("resumeSession returns the typed runtime disposition", async () => {
|
||||
|
||||
Reference in New Issue
Block a user