You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test('relayfileIntegrationResolver connect opens a session and polls until connected',async()=>{
35
62
letpolls=0;
36
63
constopened: string[]=[];
@@ -169,6 +196,136 @@ test('relayfileIntegrationResolver surfaces the agentworkforce-native error on 4
169
196
);
170
197
});
171
198
199
+
test('connectIntegrations prompts auth recovery on unauthorized status checks and retries',async()=>{
200
+
constio=createBufferedIO();
201
+
letchecks=0;
202
+
letrecoverCalled=false;
203
+
letconnectCalled=false;
204
+
205
+
constresult=awaitconnectIntegrations({
206
+
persona: {
207
+
id: 'essay',
208
+
intent: 'essay',
209
+
description: 'test persona',
210
+
tags: ['implementation'],
211
+
integrations: {notion: {}}
212
+
}asnever,
213
+
workspace: 'ws-1',
214
+
noConnect: false,
215
+
io,
216
+
integrations: {
217
+
asyncisConnected(){
218
+
checks+=1;
219
+
if(checks===1){
220
+
thrownewError(
221
+
'cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.'
222
+
);
223
+
}
224
+
returntrue;
225
+
},
226
+
asyncconnect(){
227
+
connectCalled=true;
228
+
thrownewError('connect should not be called after auth recovery');
test('connectIntegrations does not prompt auth recovery when --no-prompt is set',async()=>{
248
+
constio=createBufferedIO();
249
+
letrecoverCalled=false;
250
+
251
+
constresult=awaitconnectIntegrations({
252
+
persona: {
253
+
id: 'essay',
254
+
intent: 'essay',
255
+
description: 'test persona',
256
+
tags: ['implementation'],
257
+
integrations: {notion: {}}
258
+
}asnever,
259
+
workspace: 'ws-1',
260
+
noConnect: true,
261
+
noPrompt: true,
262
+
io,
263
+
integrations: {
264
+
asyncisConnected(){
265
+
thrownewError(
266
+
'cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.'
267
+
);
268
+
},
269
+
asyncconnect(){
270
+
thrownewError('connect should not be called after auth failure');
271
+
}
272
+
},
273
+
authRecovery: {
274
+
asyncrecover(){
275
+
recoverCalled=true;
276
+
returntrue;
277
+
}
278
+
}
279
+
});
280
+
281
+
assert.equal(recoverCalled,false);
282
+
assert.deepEqual(result.outcomes,[
283
+
{
284
+
provider: 'notion',
285
+
status: 'failed',
286
+
message:
287
+
'cloud integration request failed: unauthorized. Your active workspace session is invalid or expired. Run `agentworkforce login --workspace <id-or-slug>` to refresh, then retry.'
288
+
}
289
+
]);
290
+
});
291
+
292
+
test('connectIntegrations fails status-check errors without opening a connect flow',async()=>{
293
+
constio=createBufferedIO();
294
+
letconnectCalled=false;
295
+
296
+
constresult=awaitconnectIntegrations({
297
+
persona: {
298
+
id: 'essay',
299
+
intent: 'essay',
300
+
description: 'test persona',
301
+
tags: ['implementation'],
302
+
integrations: {notion: {}}
303
+
}asnever,
304
+
workspace: 'ws-1',
305
+
noConnect: false,
306
+
io,
307
+
integrations: {
308
+
asyncisConnected(){
309
+
thrownewError('cloud integration request failed: 503 Service Unavailable');
310
+
},
311
+
asyncconnect(){
312
+
connectCalled=true;
313
+
thrownewError('connect should not be called after status-check failure');
314
+
}
315
+
}
316
+
});
317
+
318
+
assert.equal(connectCalled,false);
319
+
assert.deepEqual(result.outcomes,[
320
+
{
321
+
provider: 'notion',
322
+
status: 'failed',
323
+
message: 'cloud integration request failed: 503 Service Unavailable'
324
+
}
325
+
]);
326
+
assert.ok(io.messages.some((message)=>message.level==='error'&&message.message.includes('failed while checking connection status')));
327
+
});
328
+
172
329
test('connectIntegrations honors --no-prompt for subscription provider setup',async()=>{
0 commit comments