From bf212430d1edf962c80d61abf8345712b0ebab8e Mon Sep 17 00:00:00 2001 From: Dotta Date: Tue, 27 Oct 2026 06:04:17 -0500 Subject: [PATCH] test(e2e): require complete observed Notion choice metadata --- .../external-provider-choice.test.ts | 16 +++++++++++- .../external-provider-choice.ts | 26 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/tests/runner-e2e/chat-catalog-domains/external-provider-choice.test.ts b/tests/runner-e2e/chat-catalog-domains/external-provider-choice.test.ts index 016489d2a36..cbc5a940d62 100644 --- a/tests/runner-e2e/chat-catalog-domains/external-provider-choice.test.ts +++ b/tests/runner-e2e/chat-catalog-domains/external-provider-choice.test.ts @@ -27,7 +27,10 @@ function valid() { links: [], humanQueries: [], state: { - advertisedChoices: { service: "notion" }, + advertisedChoices: notionSetupChoices({ + apps: [getConnectableAppDefinition("notion")!], + credentialSources: { vercelConnect: { available: false, reason } }, + }).advertisedChoices, catalogChoicesIndependentlyMatched: true, choiceExplanation: { runId: "source-run", @@ -122,6 +125,17 @@ describe("actual source attribution and supported choice lanes", () => { it("rejects lost catalog, invisible explanation, wrong source run and unbound selection", () => { for (const change of [ { catalogChoicesIndependentlyMatched: false }, + { advertisedChoices: { service: "notion" } }, + { + advertisedChoices: { + ...valid().state.advertisedChoices, + alternative: { + source: "vercel_connect", + available: true, + reason: null, + }, + }, + }, { choiceExplanationVisible: false }, { selectionAttributionMatched: false }, { diff --git a/tests/runner-e2e/chat-catalog-domains/external-provider-choice.ts b/tests/runner-e2e/chat-catalog-domains/external-provider-choice.ts index 1a0cb0833b8..a7a8525b132 100644 --- a/tests/runner-e2e/chat-catalog-domains/external-provider-choice.ts +++ b/tests/runner-e2e/chat-catalog-domains/external-provider-choice.ts @@ -196,6 +196,27 @@ async function observeChoiceExplanation( state.choiceExplanationVisible = true; } } +export function completeAdvertisedNotionChoices( + value: unknown, + reason: unknown, +) { + const c = record(value), + a = record(c.alternative); + return ( + c.service === "notion" && + c.methodKey === "mcp-oauth" && + c.auth === "oauth" && + c.transport === "mcp_remote" && + c.serverUrl === "https://mcp.notion.com/mcp" && + typeof c.whenToUse === "string" && + !!c.whenToUse.trim() && + a.source === "vercel_connect" && + a.available === false && + typeof reason === "string" && + !!reason.trim() && + a.reason === reason + ); +} export function gradeProviderChoice(value: unknown) { const c = checks(), o = externalObservation(value); @@ -210,7 +231,10 @@ export function gradeProviderChoice(value: unknown) { c.add( "real-catalog-and-truthful-choices", o.state.catalogChoicesIndependentlyMatched === true && - !!o.state.advertisedChoices && + completeAdvertisedNotionChoices( + o.state.advertisedChoices, + o.state.unavailableReason, + ) && typeof o.state.unavailableReason === "string" && truthfulNotionChoices(body, o.state.unavailableReason) && o.state.choiceExplanationVisible === true &&