mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-18 04:54:04 +00:00
Co-authored-by: Prasanna <106952318+Prasanna721@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: ved015 <vedant.04.mahajan@gmail.com> Co-authored-by: ved015 <ved015@users.noreply.github.com> Co-authored-by: Ishaan Gupta <ishaankone@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
75 lines
2 KiB
TypeScript
75 lines
2 KiB
TypeScript
import { afterAll, beforeAll, describe, expect, it } from "vitest"
|
|
import {
|
|
OAUTH_CREDENTIALS_AVAILABLE,
|
|
callTool,
|
|
connect,
|
|
type Session,
|
|
textOf,
|
|
} from "./helpers"
|
|
|
|
describe.skipIf(!OAUTH_CREDENTIALS_AVAILABLE)(
|
|
"MCP - on-demand widget permissions",
|
|
() => {
|
|
let session: Session
|
|
|
|
beforeAll(async () => {
|
|
session = await connect()
|
|
})
|
|
|
|
afterAll(async () => {
|
|
await session?.close()
|
|
})
|
|
|
|
it("loads visible spaces and effective permissions on demand", async () => {
|
|
const result = await callTool(session.client, "select-space")
|
|
expect(result.isError).toBeFalsy()
|
|
const content = result.structuredContent as {
|
|
view?: string
|
|
containerTags?: Array<{ containerTag: string }>
|
|
assignedTags?: Array<{
|
|
containerTag: string
|
|
permission: "read" | "write"
|
|
}>
|
|
}
|
|
expect(content.view).toBe("picker")
|
|
expect(Array.isArray(content.containerTags)).toBe(true)
|
|
expect(content.assignedTags).toHaveLength(
|
|
content.containerTags?.length ?? 0,
|
|
)
|
|
expect(
|
|
content.assignedTags?.every((tag) =>
|
|
["read", "write"].includes(tag.permission),
|
|
),
|
|
).toBe(true)
|
|
})
|
|
|
|
it("shares the selected space across MCP transport sessions", async () => {
|
|
const picker = await callTool(session.client, "select-space")
|
|
const pickerContent = picker.structuredContent as {
|
|
containerTags?: Array<{ containerTag: string }>
|
|
}
|
|
const firstTag = pickerContent.containerTags?.[0]?.containerTag
|
|
expect(firstTag).toBeTruthy()
|
|
|
|
const result = await callTool(session.client, "set-active-tag", {
|
|
containerTag: firstTag,
|
|
})
|
|
expect(result.isError).toBeFalsy()
|
|
expect(result.structuredContent).toMatchObject({
|
|
view: "confirmation",
|
|
containerTag: firstTag,
|
|
})
|
|
|
|
const separateSession = await connect()
|
|
try {
|
|
const identity = await callTool(separateSession.client, "whoAmI")
|
|
expect(identity.isError).toBeFalsy()
|
|
expect(JSON.parse(textOf(identity))).toMatchObject({
|
|
activeSpace: firstTag,
|
|
})
|
|
} finally {
|
|
await separateSession.close()
|
|
}
|
|
})
|
|
},
|
|
)
|