|
6 | 6 | allowsIdentificationCreation, |
7 | 7 | getEnabledOAuthStrategies, |
8 | 8 | getRecovery, |
| 9 | + getRetry, |
9 | 10 | projectConnectedAccounts, |
10 | 11 | useUserProfileConnectedAccountsModel, |
11 | 12 | } from './user-profile-connected-accounts-section.model'; |
@@ -281,17 +282,17 @@ describe('projectConnectedAccounts', () => { |
281 | 282 | ]); |
282 | 283 | }); |
283 | 284 |
|
284 | | - it('offers enabled providers without a verified account, keyed by strategy', () => { |
| 285 | + it('offers enabled providers that have no account row, keyed by strategy', () => { |
285 | 286 | const projection = projectConnectedAccounts({ |
286 | 287 | user: userWith([ |
287 | 288 | account({ id: 'idn_google', provider: 'google' }), |
288 | 289 | account({ id: 'idn_github', provider: 'github', status: 'unverified', errorCode: 'oauth_access_denied' }), |
| 290 | + account({ id: 'idn_acme', provider: 'custom_acme', status: 'unverified' }), |
289 | 291 | ]), |
290 | 292 | social: social('oauth_google', 'oauth_github', 'oauth_custom_acme'), |
291 | 293 | allowCreation: true, |
292 | 294 | }); |
293 | 295 | expect(projection.status === 'ready' && projection.availableProviders.map(p => p.id)).toEqual([ |
294 | | - 'oauth_github', |
295 | 296 | 'oauth_custom_acme', |
296 | 297 | ]); |
297 | 298 | }); |
@@ -435,3 +436,24 @@ describe('allowsIdentificationCreation', () => { |
435 | 436 | expect(allowsIdentificationCreation(active, { enabled: false } as EnterpriseSSOSettings)).toBe(true); |
436 | 437 | }); |
437 | 438 | }); |
| 439 | + |
| 440 | +describe('getRetry', () => { |
| 441 | + it('retries a failed connection with its strategy and missing scopes', () => { |
| 442 | + expect( |
| 443 | + getRetry( |
| 444 | + account({ |
| 445 | + id: 'idn_1', |
| 446 | + provider: 'google', |
| 447 | + status: 'unverified', |
| 448 | + errorCode: 'oauth_access_denied', |
| 449 | + approvedScopes: '', |
| 450 | + }), |
| 451 | + { google: ['calendar'] }, |
| 452 | + ), |
| 453 | + ).toEqual({ kind: 'create', strategy: 'oauth_google', additionalScopes: ['calendar'] }); |
| 454 | + }); |
| 455 | + |
| 456 | + it('does not retry an account without an error', () => { |
| 457 | + expect(getRetry(account({ id: 'idn_1', provider: 'google' }), undefined)).toBeNull(); |
| 458 | + }); |
| 459 | +}); |
0 commit comments