Skip to content

Commit c29315e

Browse files
committed
test(core): tighten canonical provider coverage
1 parent 499df39 commit c29315e

2 files changed

Lines changed: 31 additions & 53 deletions

File tree

src/core/task/__tests__/Task.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,7 @@ describe("Cline", () => {
19021902
expect(metadata!.abortSignal).toBe(task.currentRequestAbortController!.signal)
19031903
})
19041904

1905-
it("enables allowed function names through the canonical Gemini provider identifier", async () => {
1905+
it("uses the canonical Gemini identifier when configuring tool restrictions", async () => {
19061906
const identifiers = providerIdentifiers as Record<string, string>
19071907
const originalIdentifier = identifiers.gemini
19081908

@@ -1942,7 +1942,12 @@ describe("Cline", () => {
19421942
await task.attemptApiRequest(0).next()
19431943

19441944
const [, , metadata] = createMessageSpy.mock.calls[0]!
1945-
expect(metadata?.allowedFunctionNames).toEqual(expect.any(Array))
1945+
expect(metadata).toEqual(
1946+
expect.objectContaining({
1947+
tools: expect.any(Array),
1948+
allowedFunctionNames: expect.any(Array),
1949+
}),
1950+
)
19461951
} finally {
19471952
identifiers.gemini = originalIdentifier
19481953
}

src/core/webview/__tests__/webviewMessageHandler.spec.ts

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,55 +1495,12 @@ describe("zooCodeSignOut", () => {
14951495
vi.clearAllMocks()
14961496
})
14971497

1498-
it("disconnects Zoo Code and clears tokens from all zoo-gateway profiles", async () => {
1498+
it("disconnects Zoo Code and clears tokens from all profiles using the canonical Zoo Gateway identifier", async () => {
14991499
const { disconnectZooCode } = await import("../../../services/zoo-code-auth")
1500-
const upsertProviderProfile = vi.fn().mockResolvedValue(undefined)
1501-
const saveConfig = vi.fn().mockResolvedValue(undefined)
1502-
1503-
;(mockClineProvider as any).contextProxy = {
1504-
...mockClineProvider.contextProxy,
1505-
getProviderSettings: vi.fn().mockReturnValue({ apiProvider: "zoo-gateway" }),
1506-
getValues: vi.fn().mockReturnValue({ currentApiConfigName: "Zoo Gateway" }),
1507-
}
1508-
;(mockClineProvider as any).providerSettingsManager = {
1509-
listConfig: vi.fn().mockResolvedValue([
1510-
{ name: "Zoo Gateway", apiProvider: "zoo-gateway" },
1511-
{ name: "Backup Zoo", apiProvider: "zoo-gateway" },
1512-
]),
1513-
getProfile: vi
1514-
.fn()
1515-
.mockResolvedValueOnce({
1516-
apiProvider: "zoo-gateway",
1517-
zooSessionToken: "token-active",
1518-
zooGatewayModelId: "anthropic/claude-sonnet-4",
1519-
})
1520-
.mockResolvedValueOnce({
1521-
apiProvider: "zoo-gateway",
1522-
zooSessionToken: "token-backup",
1523-
}),
1524-
saveConfig,
1525-
}
1526-
;(mockClineProvider as any).upsertProviderProfile = upsertProviderProfile
1527-
1528-
await webviewMessageHandler(mockClineProvider, { type: "zooCodeSignOut" })
1529-
1530-
expect(disconnectZooCode).toHaveBeenCalled()
1531-
expect(upsertProviderProfile).toHaveBeenCalledWith(
1532-
"Zoo Gateway",
1533-
expect.not.objectContaining({ zooSessionToken: expect.anything() }),
1534-
true,
1535-
)
1536-
expect(saveConfig).toHaveBeenCalledWith(
1537-
"Backup Zoo",
1538-
expect.not.objectContaining({ zooSessionToken: expect.anything() }),
1539-
)
1540-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
1541-
})
1542-
1543-
it("clears tokens using the canonical Zoo Gateway provider identifier", async () => {
15441500
const identifiers = providerIdentifiers as Record<string, string>
15451501
const originalIdentifier = identifiers.zooGateway
15461502
const upsertProviderProfile = vi.fn().mockResolvedValue(undefined)
1503+
const saveConfig = vi.fn().mockResolvedValue(undefined)
15471504

15481505
try {
15491506
identifiers.zooGateway = "canonical-zoo-gateway"
@@ -1553,22 +1510,38 @@ describe("zooCodeSignOut", () => {
15531510
getValues: vi.fn().mockReturnValue({ currentApiConfigName: "Zoo Gateway" }),
15541511
}
15551512
;(mockClineProvider as any).providerSettingsManager = {
1556-
listConfig: vi.fn().mockResolvedValue([{ name: "Zoo Gateway", apiProvider: identifiers.zooGateway }]),
1557-
getProfile: vi.fn().mockResolvedValue({
1558-
apiProvider: identifiers.zooGateway,
1559-
zooSessionToken: "token-active",
1560-
}),
1561-
saveConfig: vi.fn(),
1513+
listConfig: vi.fn().mockResolvedValue([
1514+
{ name: "Zoo Gateway", apiProvider: identifiers.zooGateway },
1515+
{ name: "Backup Zoo", apiProvider: identifiers.zooGateway },
1516+
]),
1517+
getProfile: vi
1518+
.fn()
1519+
.mockResolvedValueOnce({
1520+
apiProvider: identifiers.zooGateway,
1521+
zooSessionToken: "token-active",
1522+
zooGatewayModelId: "anthropic/claude-sonnet-4",
1523+
})
1524+
.mockResolvedValueOnce({
1525+
apiProvider: identifiers.zooGateway,
1526+
zooSessionToken: "token-backup",
1527+
}),
1528+
saveConfig,
15621529
}
15631530
;(mockClineProvider as any).upsertProviderProfile = upsertProviderProfile
15641531

15651532
await webviewMessageHandler(mockClineProvider, { type: "zooCodeSignOut" })
15661533

1534+
expect(disconnectZooCode).toHaveBeenCalled()
15671535
expect(upsertProviderProfile).toHaveBeenCalledWith(
15681536
"Zoo Gateway",
15691537
expect.not.objectContaining({ zooSessionToken: expect.anything() }),
15701538
true,
15711539
)
1540+
expect(saveConfig).toHaveBeenCalledWith(
1541+
"Backup Zoo",
1542+
expect.not.objectContaining({ zooSessionToken: expect.anything() }),
1543+
)
1544+
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
15721545
} finally {
15731546
identifiers.zooGateway = originalIdentifier
15741547
}

0 commit comments

Comments
 (0)