-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: can not sign out if not signed in yet COMPASS-7787 (#5617)
- Loading branch information
1 parent
84fd461
commit 7e5d6ae
Showing
3 changed files
with
44 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ describe('Atlas Login', function () { | |
let oidcMockProvider: OIDCMockProvider; | ||
let getTokenPayload: OIDCMockProviderConfig['getTokenPayload']; | ||
let stopMockAtlasServer: () => Promise<void>; | ||
let numberOfOIDCAuthRequests = 0; | ||
|
||
before(async function () { | ||
skipForWeb(this, 'atlas-login not supported in compass-web'); | ||
|
@@ -71,6 +72,9 @@ describe('Atlas Login', function () { | |
res.setHeader('Location', url.searchParams.get('fromURI') ?? ''); | ||
res.end(); | ||
break; | ||
case '/authorize': | ||
numberOfOIDCAuthRequests += 1; | ||
break; | ||
case '/v1/userinfo': | ||
if (isAuthorised(req)) { | ||
res.statusCode = 200; | ||
|
@@ -104,6 +108,8 @@ describe('Atlas Login', function () { | |
}); | ||
|
||
beforeEach(async function () { | ||
numberOfOIDCAuthRequests = 0; | ||
|
||
getTokenPayload = () => { | ||
return DEFAULT_TOKEN_PAYLOAD; | ||
}; | ||
|
@@ -152,6 +158,7 @@ describe('Atlas Login', function () { | |
'Logged in with Atlas account [email protected]' | ||
); | ||
}); | ||
expect(numberOfOIDCAuthRequests).to.eq(1); | ||
}); | ||
|
||
describe('telemetry', () => { | ||
|
@@ -218,6 +225,35 @@ describe('Atlas Login', function () { | |
}); | ||
}); | ||
|
||
it('should sign in user when disconnected and clicking again on "Log in with Atlas" button', async function () { | ||
await browser.openSettingsModal('Feature Preview'); | ||
|
||
await browser.openSettingsModal('Feature Preview'); | ||
await browser.clickVisible(Selectors.LogInWithAtlasButton); | ||
|
||
let loginStatus = browser.$(Selectors.AtlasLoginStatus); | ||
|
||
await browser.waitUntil(async () => { | ||
return ( | ||
(await loginStatus.getText()).trim() === | ||
'Logged in with Atlas account [email protected]' | ||
); | ||
}); | ||
|
||
await browser.clickVisible(Selectors.DisconnectAtlasAccountButton); | ||
|
||
await browser.clickVisible(Selectors.LogInWithAtlasButton); | ||
|
||
loginStatus = browser.$(Selectors.AtlasLoginStatus); | ||
await browser.waitUntil(async () => { | ||
return ( | ||
(await loginStatus.getText()).trim() === | ||
'Logged in with Atlas account [email protected]' | ||
); | ||
}); | ||
expect(numberOfOIDCAuthRequests).to.eq(2); | ||
}); | ||
|
||
it('should show toast with error if sign in failed', async function () { | ||
getTokenPayload = () => { | ||
return Promise.reject(new Error('Auth failed')); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters