@checkstack/integration-teams-backend 0.0.35 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,250 @@
1
1
  # @checkstack/integration-teams-backend
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [270ef29]
8
+ - Updated dependencies [b995afb]
9
+ - Updated dependencies [b995afb]
10
+ - Updated dependencies [b995afb]
11
+ - Updated dependencies [270ef29]
12
+ - Updated dependencies [270ef29]
13
+ - Updated dependencies [270ef29]
14
+ - Updated dependencies [270ef29]
15
+ - Updated dependencies [270ef29]
16
+ - Updated dependencies [270ef29]
17
+ - Updated dependencies [270ef29]
18
+ - Updated dependencies [270ef29]
19
+ - Updated dependencies [b995afb]
20
+ - Updated dependencies [b995afb]
21
+ - Updated dependencies [270ef29]
22
+ - Updated dependencies [b995afb]
23
+ - Updated dependencies [270ef29]
24
+ - Updated dependencies [b995afb]
25
+ - Updated dependencies [b995afb]
26
+ - Updated dependencies [270ef29]
27
+ - Updated dependencies [b995afb]
28
+ - Updated dependencies [b995afb]
29
+ - Updated dependencies [b995afb]
30
+ - Updated dependencies [b995afb]
31
+ - Updated dependencies [b995afb]
32
+ - Updated dependencies [b995afb]
33
+ - Updated dependencies [270ef29]
34
+ - Updated dependencies [270ef29]
35
+ - Updated dependencies [270ef29]
36
+ - Updated dependencies [270ef29]
37
+ - Updated dependencies [270ef29]
38
+ - Updated dependencies [270ef29]
39
+ - Updated dependencies [270ef29]
40
+ - Updated dependencies [270ef29]
41
+ - Updated dependencies [270ef29]
42
+ - Updated dependencies [270ef29]
43
+ - Updated dependencies [b995afb]
44
+ - Updated dependencies [b995afb]
45
+ - @checkstack/backend-api@0.19.0
46
+ - @checkstack/automation-backend@0.3.0
47
+ - @checkstack/integration-backend@0.3.0
48
+
49
+ ## 0.1.0
50
+
51
+ ### Minor Changes
52
+
53
+ - e2d6f25: feat(automation): connection picker for integration actions + restore Integrations menu
54
+
55
+ Connection-backed automation actions (Jira, Teams, Webex) now render a
56
+ working connection picker plus cascading provider dropdowns in the
57
+ visual editor, and the Integrations entry is back in the user menu.
58
+
59
+ **Contract.** `ActionDefinition` gained an optional
60
+ `connectionProviderId` (and it is surfaced on `ActionInfoSchema` and
61
+ mapped in the `listActions` router). It carries the integration
62
+ provider's fully-qualified id, derived from the provider plugin's own
63
+ `pluginMetadata.pluginId` (never a hardcoded string), so the editor
64
+ knows which provider backs an action's dropdowns and it matches the
65
+ `qualifiedId` the integration provider registry assigns.
66
+
67
+ **Providers.** Jira, Teams and Webex each export
68
+ `*_PROVIDER_LOCAL_ID` / `*_PROVIDER_QUALIFIED_ID`, register their
69
+ provider with the local id, and add a `CONNECTION_OPTIONS`
70
+ (`"connectionOptions"`) resolver name. Their `post_message` /
71
+ issue actions set `connectionProviderId` and expose `connectionId`
72
+ as an `x-options-resolver` dropdown instead of a hidden field.
73
+
74
+ **Frontend bridge.** A new `useConnectionOptionResolvers` hook
75
+ (`@checkstack/automation-frontend`, which now depends on
76
+ `@checkstack/integration-common`) turns an action's
77
+ `x-options-resolver` schema fields into live data: the
78
+ `connectionOptions` resolver lists the provider's connections via
79
+ `listConnections`, and every other resolver name is forwarded to
80
+ `getConnectionOptions` for the selected `connectionId`, passing the
81
+ live form values as `context` for dependent fields. `ProviderActionBody`
82
+ now passes this map to `DynamicForm` (it was previously missing
83
+ entirely, so connection-backed actions had no working dropdowns).
84
+
85
+ **frontend-api.** `usePluginClient` procedures now also expose a typed
86
+ imperative `.call(input)` alongside `.useQuery` / `.useMutation`, for
87
+ async callbacks that cannot host a hook (such as a `DynamicForm`
88
+ options resolver). Additive, non-breaking.
89
+
90
+ **Integrations menu.** Re-added `IntegrationMenuItem` and a new
91
+ `IntegrationsLandingPage`, wired into `integration-frontend` as a list
92
+ route and a `UserMenuItemsSlot` entry under the "Configuration" group.
93
+
94
+ **Action card polish.** The action editor's secondary metadata (id,
95
+ description, failure behaviour) is now grouped into one quiet settings
96
+ panel with consistent small uppercase "eyebrow" labels, so the action's
97
+ own configuration stays the focal point. The raw failure checkbox was
98
+ replaced with the standard `Checkbox` control, and the provider action
99
+ picker / configuration sections gained consistent section headers and a
100
+ divider. The per-step "type" dropdown was removed: an action's kind is
101
+ fixed at creation, so changing it now means adding a new step and
102
+ deleting the old one (avoids the surprising full-config reset that
103
+ switching kinds used to trigger).
104
+
105
+ **Add-step picker.** Adding a step now opens a Home-Assistant-style
106
+ dialog where the operator decides the step type up front: an "Actions"
107
+ tab lists the registered provider actions grouped by category
108
+ (searchable; picking one presets the step's `action`), and a "Blocks"
109
+ tab lists the structural building blocks (choose / parallel / repeat /
110
+ etc.). Because the concrete action is chosen here, the in-card action
111
+ switcher was removed - a step's action is fixed once created. Composite
112
+ blocks now start with an empty child list (filled via the nested
113
+ add-step picker) instead of seeding an unconfigurable empty action.
114
+
115
+ - 41c77f4: feat(automation): one-time migration of webhook subscriptions + remove legacy integration backend
116
+
117
+ **BREAKING CHANGES** (platform is in BETA — no major bump):
118
+
119
+ - `IntegrationProvider` no longer carries `config` (subscription
120
+ config) or `deliver`. The interface now models a connection provider
121
+ only: connection schema + `getConnectionOptions` + `testConnection`.
122
+ - The legacy subscription / delivery-log / event endpoints
123
+ (`listSubscriptions`, `createSubscription`, `getDeliveryLogs`,
124
+ `listEventTypes`, …) are removed from `integrationContract`.
125
+ - `delivery-coordinator`, `hook-subscriber`, `event-registry`, and the
126
+ `integrationEventExtensionPoint` are deleted. Plugins that
127
+ previously called `integrationEvents.registerEvent(...)` now
128
+ register their hooks as automation triggers via
129
+ `automationTriggerExtensionPoint.registerTrigger(...)`.
130
+ - Frontend pages `IntegrationsPage` and `DeliveryLogsPage` are gone;
131
+ the integration plugin's only remaining UI is connection
132
+ management. Subscription management lives under `/automation/...`.
133
+ - `webhook_subscriptions` and `delivery_logs` tables stay in the
134
+ database for one release as a safety net (no code reads or writes
135
+ them), and will be dropped in a follow-up migration.
136
+
137
+ **New**:
138
+
139
+ - `jira.create_issue`, `teams.post_message`, `webex.post_message`,
140
+ `webhook.send`, `integration-script.run_shell`, and
141
+ `integration-script.run_script` actions registered against the
142
+ Automation Platform with matching `*.message`, `*.delivery`,
143
+ `shell.result`, and `script.result` artifact types. The script
144
+ plugin exposes **two** actions — `run_shell` runs bash via the
145
+ shared `ShellScriptRunner` (Monaco `shell` editor), `run_script`
146
+ runs an ESM module in a Bun subprocess via `EsmScriptRunner`
147
+ (Monaco `typescript` editor + `defineIntegration` helper) — to
148
+ preserve the legacy provider split. `jira.create_issue` keeps the
149
+ dynamic field-mapping dropdown (driven by
150
+ `JIRA_RESOLVERS.FIELD_OPTIONS`).
151
+ - One-time data migration runs on boot in
152
+ `automation-backend.afterPluginsReady`. It reads
153
+ `webhook_subscriptions` via a new service RPC
154
+ `IntegrationApi.listLegacySubscriptions`, translates each row into
155
+ a single-trigger / single-action automation (marked with
156
+ `managed_by = "migrated-subscription:<id>"`), and is idempotent
157
+ across restarts.
158
+ - Failed translations are recorded in a new
159
+ `automation_migration_failures` table and surfaced via
160
+ `AutomationApi.listMigrationFailures` /
161
+ `acknowledgeMigrationFailure` so admins can review and re-create
162
+ failed entries by hand.
163
+
164
+ - 41c77f4: fix(automation): qualify action `produces` / `consumes` with the owning plugin id
165
+
166
+ `context.artifacts` showed up untyped (no fields) in the script editor
167
+ because action `produces` / `consumes` were hand-written full strings
168
+ (`"jira.issue"`) that did not match the artifact-type registry's
169
+ qualified id. The registry derives `${pluginId}.${id}`, and the plugin's
170
+ id is the package name `integration-jira`, so the artifact type actually
171
+ registers as `integration-jira.issue` — the editor's schema lookup
172
+ (`produces` vs registered `qualifiedId`) missed, leaving the artifact's
173
+ fields unknown. (Runtime store/consume happened to agree with each other
174
+ on the short string, so it "worked" but typed nothing.)
175
+
176
+ The action registry now qualifies `produces` with the owning plugin id,
177
+ exactly as it already qualifies the action's own `id` and as the
178
+ artifact-type registry qualifies the artifact type id — so the three can
179
+ never drift. Actions declare the **local** artifact id:
180
+
181
+ - `produces: "issue"` → registered as `integration-jira.issue`,
182
+ - `consumes: ["issue"]` → resolved against the owning plugin's namespace
183
+ at run time; `consumedArtifacts` is keyed by the local id, so an
184
+ action's `execute` reads `consumedArtifacts["issue"]`.
185
+
186
+ All five artifact-producing integration plugins (jira / teams / webex /
187
+ webhook / script) now declare local ids. With `produces` matching the
188
+ registered artifact type, the editor types `context.artifacts[...]` with
189
+ the real schema (e.g. `issueKey`, `projectKey`, `issueUrl`).
190
+
191
+ **BREAKING (beta):** the fully-qualified artifact type ids change from
192
+ the short form to the plugin-prefixed form, e.g. `jira.issue` →
193
+ `integration-jira.issue`. This affects how artifacts are referenced in
194
+ templates (`{{ artifact.integration-jira.issue.issueKey }}`), the TS
195
+ script `context.artifacts["integration-jira.issue"]`, and shell env names
196
+ (`$CHECKSTACK_ARTIFACT_INTEGRATION_JIRA_ISSUE_ISSUEKEY`). Artifacts are
197
+ per-run and ephemeral, so no stored-data migration is needed.
198
+
199
+ Note: this keeps the same-plugin produce→consume handoff (the current
200
+ pattern). Cross-plugin artifact consumption would need a follow-up to
201
+ allow a fully-qualified `consumes` ref.
202
+
203
+ ### Patch Changes
204
+
205
+ - 41c77f4: fix(integration): resolve `connectionStoreRef` lazily inside action `execute`
206
+
207
+ The Phase 6/7/8 refactor wired every integration backend's
208
+ `registerInit` deps to include `connectionStore: connectionStoreRef`,
209
+ expecting `integration-backend` to register the service before the
210
+ sort. But `integration-backend` calls `env.registerService(connection
211
+ StoreRef, ...)` from inside its own `init()`, not at `register()`
212
+ time — so at topological-sort time the `providedBy` map doesn't know
213
+ the service exists yet, and the sort can put a consumer (e.g.
214
+ `integration-teams`) ahead of `integration-backend`. The dev server
215
+ then fails at boot with:
216
+
217
+ > Service 'integration.connectionStore' not found for plugin
218
+ > 'integration-teams'
219
+
220
+ This change drops the init-time dep from every integration plugin and
221
+ resolves the connection store **lazily at action-execute time** via
222
+ `context.getService(connectionStoreRef)`. By the time any action's
223
+ `execute` runs, every plugin has finished init + afterPluginsReady,
224
+ so the service is always available. Tests updated to thread a mock
225
+ store through a typed `getService` stub in the action context.
226
+
227
+ No behaviour change at runtime — the actions hit the connection store
228
+ at the same moment they always did (just inside `execute` rather than
229
+ through a captured init-time closure).
230
+
231
+ - Updated dependencies [e2d6f25]
232
+ - Updated dependencies [41c77f4]
233
+ - Updated dependencies [e1a2077]
234
+ - Updated dependencies [41c77f4]
235
+ - Updated dependencies [41c77f4]
236
+ - Updated dependencies [41c77f4]
237
+ - Updated dependencies [41c77f4]
238
+ - Updated dependencies [41c77f4]
239
+ - Updated dependencies [41c77f4]
240
+ - Updated dependencies [6d52276]
241
+ - Updated dependencies [6d52276]
242
+ - Updated dependencies [35bc682]
243
+ - @checkstack/automation-backend@0.2.0
244
+ - @checkstack/integration-backend@0.2.0
245
+ - @checkstack/common@0.12.0
246
+ - @checkstack/backend-api@0.18.0
247
+
3
248
  ## 0.0.35
4
249
 
5
250
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/integration-teams-backend",
3
- "version": "0.0.35",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "checkstack": {
@@ -11,18 +11,21 @@
11
11
  "typecheck": "tsgo -b",
12
12
  "lint": "bun run lint:code",
13
13
  "lint:code": "eslint . --max-warnings 0",
14
+ "test": "bun test",
14
15
  "pack": "bunx @checkstack/scripts plugin-pack"
15
16
  },
16
17
  "dependencies": {
17
- "@checkstack/backend-api": "0.17.0",
18
- "@checkstack/integration-backend": "0.1.29",
19
- "@checkstack/common": "0.11.0",
18
+ "@checkstack/backend-api": "0.18.0",
19
+ "@checkstack/integration-backend": "0.2.0",
20
+ "@checkstack/automation-backend": "0.2.0",
21
+ "@checkstack/common": "0.12.0",
20
22
  "zod": "^4.2.1"
21
23
  },
22
24
  "devDependencies": {
23
25
  "@types/bun": "^1.0.0",
24
26
  "typescript": "^5.0.0",
25
- "@checkstack/tsconfig": "0.0.7"
27
+ "@checkstack/tsconfig": "0.0.7",
28
+ "@checkstack/test-utils-backend": "0.1.31"
26
29
  },
27
30
  "description": "Checkstack integration-teams-backend plugin",
28
31
  "author": {
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Behaviour tests for the Teams automation action.
3
+ *
4
+ * The ConnectionStore is faked; fetch is stubbed in-process so we can
5
+ * drive `teams.post_message.execute` through:
6
+ * 1. OAuth client-credentials token fetch
7
+ * 2. Microsoft Graph POST to `/teams/.../channels/.../messages`
8
+ *
9
+ * The action wraps the operator-authored body in a minimal Adaptive
10
+ * Card before posting — we assert that wrapping here.
11
+ */
12
+ import { describe, it, expect, beforeEach, mock } from "bun:test";
13
+ import type { Logger } from "@checkstack/backend-api";
14
+ import { createMockLogger } from "@checkstack/test-utils-backend";
15
+ import {
16
+ connectionStoreRef,
17
+ type ConnectionStore,
18
+ } from "@checkstack/integration-backend";
19
+ import type { ServiceRef } from "@checkstack/backend-api";
20
+
21
+ import {
22
+ createTeamsActions,
23
+ teamsMessageArtifactType,
24
+ } from "./automations";
25
+
26
+ const logger = createMockLogger() as Logger;
27
+
28
+ interface CapturedFetchCall {
29
+ url: string;
30
+ init: RequestInit;
31
+ }
32
+
33
+ interface StagedResponse {
34
+ body?: unknown;
35
+ status?: number;
36
+ raw?: string;
37
+ }
38
+
39
+ function setupFetchSequence(responses: StagedResponse[]) {
40
+ const calls: CapturedFetchCall[] = [];
41
+ const originalFetch = globalThis.fetch;
42
+ let i = 0;
43
+ globalThis.fetch = (async (
44
+ input: string | URL | Request,
45
+ init?: RequestInit,
46
+ ) => {
47
+ calls.push({ url: String(input), init: init ?? {} });
48
+ const next = responses[i++] ?? { body: {}, status: 200 };
49
+ return new Response(
50
+ next.raw !== undefined ? next.raw : JSON.stringify(next.body ?? {}),
51
+ {
52
+ status: next.status ?? 200,
53
+ headers: { "Content-Type": "application/json" },
54
+ },
55
+ );
56
+ }) as typeof fetch;
57
+ return {
58
+ calls,
59
+ restore: () => {
60
+ globalThis.fetch = originalFetch;
61
+ },
62
+ };
63
+ }
64
+
65
+ function makeConnectionStore(): ConnectionStore {
66
+ return {
67
+ listConnections: mock(async () => []),
68
+ getConnection: mock(async () => undefined),
69
+ getConnectionWithCredentials: mock(async (id: string) =>
70
+ id === "conn-1"
71
+ ? {
72
+ id: "conn-1",
73
+ providerId: "teams",
74
+ name: "Tenant",
75
+ config: {
76
+ tenantId: "tenant-1",
77
+ clientId: "client-1",
78
+ clientSecret: "client-secret",
79
+ },
80
+ createdAt: new Date(),
81
+ updatedAt: new Date(),
82
+ }
83
+ : undefined,
84
+ ),
85
+ createConnection: mock(async () => {
86
+ throw new Error("not implemented in stub");
87
+ }),
88
+ updateConnection: mock(async () => {
89
+ throw new Error("not implemented in stub");
90
+ }),
91
+ deleteConnection: mock(async () => false),
92
+ findConnectionProvider: mock(async () => undefined),
93
+ } as unknown as ConnectionStore;
94
+ }
95
+
96
+ let fetchFixture: ReturnType<typeof setupFetchSequence> | undefined;
97
+
98
+ beforeEach(() => {
99
+ fetchFixture?.restore();
100
+ fetchFixture = undefined;
101
+ });
102
+
103
+ function makeCtx(store: ConnectionStore) {
104
+ return {
105
+ runId: "run-1",
106
+ automationId: "auto-1",
107
+ contextKey: null,
108
+ logger,
109
+ getService: async <T,>(ref: ServiceRef<T>): Promise<T> => {
110
+ if (ref.id === connectionStoreRef.id) {
111
+ return store as unknown as T;
112
+ }
113
+ throw new Error(`Unstubbed service requested: ${ref.id}`);
114
+ },
115
+ };
116
+ }
117
+
118
+ const ctxBase = makeCtx(makeConnectionStore());
119
+
120
+ describe("teamsMessageArtifactType", () => {
121
+ it("validates the canonical artifact shape", () => {
122
+ const ok = teamsMessageArtifactType.schema.safeParse({
123
+ messageId: "msg-1",
124
+ teamId: "team-1",
125
+ channelId: "ch-1",
126
+ });
127
+ expect(ok.success).toBe(true);
128
+ });
129
+
130
+ it("rejects when teamId is missing", () => {
131
+ const bad = teamsMessageArtifactType.schema.safeParse({
132
+ messageId: "msg-1",
133
+ channelId: "ch-1",
134
+ });
135
+ expect(bad.success).toBe(false);
136
+ });
137
+ });
138
+
139
+ describe("teams.post_message", () => {
140
+ it("posts an adaptive card and emits a teams.message artifact", async () => {
141
+ fetchFixture = setupFetchSequence([
142
+ { body: { access_token: "tok-1", expires_in: 3600 } },
143
+ { body: { id: "msg-42" } },
144
+ ]);
145
+ const actions = createTeamsActions();
146
+ const post = actions[0]!;
147
+ const result = await post.execute({
148
+ ...ctxBase,
149
+ consumedArtifacts: {},
150
+ config: {
151
+ connectionId: "conn-1",
152
+ teamId: "team-1",
153
+ channelId: "ch-1",
154
+ title: "Heads up",
155
+ body: "Something happened",
156
+ } as never,
157
+ });
158
+ expect(result.success).toBe(true);
159
+ if (!result.success) return;
160
+ expect(result.externalId).toBe("msg-42");
161
+ const artifact = result.artifact as {
162
+ messageId: string;
163
+ teamId: string;
164
+ channelId: string;
165
+ };
166
+ expect(artifact).toEqual({
167
+ messageId: "msg-42",
168
+ teamId: "team-1",
169
+ channelId: "ch-1",
170
+ });
171
+
172
+ // First call: token endpoint.
173
+ const tokenCall = fetchFixture.calls[0]!;
174
+ expect(tokenCall.url).toContain(
175
+ "https://login.microsoftonline.com/tenant-1/oauth2/v2.0/token",
176
+ );
177
+ expect(tokenCall.init.method).toBe("POST");
178
+
179
+ // Second call: Graph messages endpoint with the bearer token.
180
+ const graphCall = fetchFixture.calls[1]!;
181
+ expect(graphCall.url).toBe(
182
+ "https://graph.microsoft.com/v1.0/teams/team-1/channels/ch-1/messages",
183
+ );
184
+ const headers = graphCall.init.headers as Record<string, string>;
185
+ expect(headers.Authorization).toBe("Bearer tok-1");
186
+ const body = JSON.parse(graphCall.init.body as string) as {
187
+ attachments: Array<{ content: string }>;
188
+ };
189
+ const card = JSON.parse(body.attachments[0]!.content) as {
190
+ type: string;
191
+ body: Array<{ text: string }>;
192
+ };
193
+ expect(card.type).toBe("AdaptiveCard");
194
+ expect(card.body[0]!.text).toBe("Heads up");
195
+ expect(card.body[1]!.text).toBe("Something happened");
196
+ });
197
+
198
+ it("omits the title TextBlock when title is not provided", async () => {
199
+ fetchFixture = setupFetchSequence([
200
+ { body: { access_token: "tok-1", expires_in: 3600 } },
201
+ { body: { id: "msg-99" } },
202
+ ]);
203
+ const actions = createTeamsActions();
204
+ const post = actions[0]!;
205
+ const result = await post.execute({
206
+ ...ctxBase,
207
+ consumedArtifacts: {},
208
+ config: {
209
+ connectionId: "conn-1",
210
+ teamId: "team-1",
211
+ channelId: "ch-1",
212
+ body: "Just the body",
213
+ } as never,
214
+ });
215
+ expect(result.success).toBe(true);
216
+ const graphCall = fetchFixture.calls[1]!;
217
+ const body = JSON.parse(graphCall.init.body as string) as {
218
+ attachments: Array<{ content: string }>;
219
+ };
220
+ const card = JSON.parse(body.attachments[0]!.content) as {
221
+ body: Array<{ text: string }>;
222
+ };
223
+ expect(card.body).toHaveLength(1);
224
+ expect(card.body[0]!.text).toBe("Just the body");
225
+ });
226
+
227
+ it("returns failure when the connection is missing", async () => {
228
+ const actions = createTeamsActions();
229
+ const post = actions[0]!;
230
+ const result = await post.execute({
231
+ ...ctxBase,
232
+ consumedArtifacts: {},
233
+ config: {
234
+ connectionId: "missing",
235
+ teamId: "team-1",
236
+ channelId: "ch-1",
237
+ body: "x",
238
+ } as never,
239
+ });
240
+ expect(result.success).toBe(false);
241
+ if (result.success) return;
242
+ expect(result.error).toMatch(/connection not found/i);
243
+ });
244
+
245
+ it("returns failure when the token request fails", async () => {
246
+ fetchFixture = setupFetchSequence([
247
+ { status: 401, raw: "invalid_client" },
248
+ ]);
249
+ const actions = createTeamsActions();
250
+ const post = actions[0]!;
251
+ const result = await post.execute({
252
+ ...ctxBase,
253
+ consumedArtifacts: {},
254
+ config: {
255
+ connectionId: "conn-1",
256
+ teamId: "team-1",
257
+ channelId: "ch-1",
258
+ body: "x",
259
+ } as never,
260
+ });
261
+ expect(result.success).toBe(false);
262
+ if (result.success) return;
263
+ expect(result.error).toMatch(/Authentication failed/);
264
+ expect(result.error).toMatch(/Token request failed \(401\)/);
265
+ });
266
+
267
+ it("returns failure when the Graph POST responds non-OK", async () => {
268
+ fetchFixture = setupFetchSequence([
269
+ { body: { access_token: "tok-1", expires_in: 3600 } },
270
+ { status: 403, raw: "forbidden" },
271
+ ]);
272
+ const actions = createTeamsActions();
273
+ const post = actions[0]!;
274
+ const result = await post.execute({
275
+ ...ctxBase,
276
+ consumedArtifacts: {},
277
+ config: {
278
+ connectionId: "conn-1",
279
+ teamId: "team-1",
280
+ channelId: "ch-1",
281
+ body: "x",
282
+ } as never,
283
+ });
284
+ expect(result.success).toBe(false);
285
+ if (result.success) return;
286
+ expect(result.error).toMatch(/Graph API error \(403\)/);
287
+ expect(result.error).toMatch(/forbidden/);
288
+ });
289
+ });