-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clerk-js): Sign Out from multiple tabs at once (#2094)
* feat(clerk-js): Enable BroadcastChannel * chore(clerk-js): Remove object passed as it is the default value of the parameter * chore(repo): Add Clerk types in integrations tests * test(repo): Add tests for Sign Out functionality * chore(repo): Adds Changeset * fix(repo): Import expect form @playwright/test * test(repo): Check if user is signed out
- Loading branch information
Showing
7 changed files
with
64 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clerk/clerk-js': minor | ||
--- | ||
|
||
Introducing sign out from all open tabs at once. |
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
import { appConfigs } from '../presets'; | ||
import type { FakeUser } from '../testUtils'; | ||
import { createTestUtils, testAgainstRunningApps } from '../testUtils'; | ||
|
||
testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('sign out smoke test @generic', ({ app }) => { | ||
test.describe.configure({ mode: 'serial' }); | ||
|
||
let fakeUser: FakeUser; | ||
|
||
test.beforeAll(async () => { | ||
const u = createTestUtils({ app }); | ||
fakeUser = u.services.users.createFakeUser(); | ||
await u.services.users.createBapiUser(fakeUser); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await fakeUser.deleteIfExists(); | ||
await app.teardown(); | ||
}); | ||
|
||
test('sign out throught all open tabs at once', async ({ page, context }) => { | ||
const mainTab = createTestUtils({ app, page, context }); | ||
await mainTab.po.signIn.goTo(); | ||
await mainTab.po.signIn.setIdentifier(fakeUser.email); | ||
await mainTab.po.signIn.continue(); | ||
await mainTab.po.signIn.setPassword(fakeUser.password); | ||
await mainTab.po.signIn.continue(); | ||
await mainTab.po.expect.toBeSignedIn(); | ||
|
||
await mainTab.tabs.runInNewTab(async m => { | ||
await m.page.goToStart(); | ||
|
||
await m.page.waitForClerkJsLoaded(); | ||
|
||
await m.po.expect.toBeSignedIn(); | ||
|
||
await m.page.evaluate(async () => { | ||
await window.Clerk.signOut(); | ||
}); | ||
|
||
await m.po.expect.toBeSignedOut(); | ||
}); | ||
|
||
expect(await mainTab.page.evaluate('!window.Clerk.user')).toBe(false); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Clerk } from '@clerk/types'; | ||
|
||
declare global { | ||
interface Window { | ||
Clerk: Clerk; | ||
} | ||
} |
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