feat(clerk-js): Sign Out from multiple tabs at once#2094
Conversation
🦋 Changeset detectedLatest commit: 3391990 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
2f0d78b to
1601f5d
Compare
dimkl
left a comment
There was a problem hiding this comment.
I think this is a good candidate for adding a test to our suite.
nikosdouvlis
left a comment
There was a problem hiding this comment.
Welcome back LocalStorageBroadcastChannel :)
| this.#broadcastChannel?.addEventListener('message', ({ data }) => { | ||
| if (data.type === 'signout') { | ||
| void this.handleUnauthenticated({ broadcast: false }); | ||
| void this.handleUnauthenticated({ broadcast: true }); |
There was a problem hiding this comment.
It's necessary to have broadcast to default to enable post the sign-out message to the BroadcastChannel, but it's not necessary to fill the this. handleUnauthenticated as broadcast prop is always true.
|
@octoper good job on this! I've approved as I don't want to block, but this is the perfect case for an e2e test. Let's write one before merging. |
|
@nikosdouvlis Already on it's way! |
1601f5d to
e334c0a
Compare
da6936f to
4294999
Compare
ec2e590 to
d017be1
Compare
| }); | ||
| }); | ||
|
|
||
| expect(await mainTab.page.evaluate('!window.Clerk.user')).toBe(false); |
There was a problem hiding this comment.
🙃 let's add a await m.po.expect.toBeSignedOut(); test helper and use it here.
There was a problem hiding this comment.
The helper exists but there is a problem with it, the page.waitFucntion that is underneath mainTab.po.expect.toBeSignedOut() helper is getting a timeout at this point, I'm not exactly sure why is that, but it's probably has something to do with with the new tab we are opening.
There was a problem hiding this comment.
let's add a comment about why we cannot use the helper and fix this later.
e883e80 to
93278c7
Compare
93278c7 to
3391990
Compare
| await m.po.expect.toBeSignedOut(); | ||
| }); | ||
|
|
||
| expect(await mainTab.page.evaluate('!window.Clerk.user')).toBe(false); |
There was a problem hiding this comment.
❓ shouldn't this be toBe(true)? If we're trying to replicate toBeSignedOut().
There was a problem hiding this comment.
You are right! Just opened a PR for that #2125
Description
This PR enables the BrodcastChannel functionallity, that is going to allow us to signout from multiple tabs at once.
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/backend@clerk/chrome-extension@clerk/clerk-js@clerk/clerk-expo@clerk/fastifygatsby-plugin-clerk@clerk/localizations@clerk/nextjs@clerk/clerk-react@clerk/remix@clerk/clerk-sdk-node@clerk/shared@clerk/themes@clerk/typesbuild/tooling/chore