Skip to content

The open alternative to Salesforce, designed for AI.

fix(front): make logout navigate once (unbreaks the invite e2e) (#24128)

Charles Bochet34c71647bb93
diff --git a/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.ts b/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.ts
index bec2aae4762..b998bc23c1e 100644
--- a/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.ts
+++ b/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.ts
@@ -25,12 +25,11 @@ test('Sign up with invite link via email', async ({
await test.step('Go to invite link', async () => {
await settingsPage.logout();
+ // Logging out replaces the document, which would interrupt the goto below.
+ await page.waitForURL('**/welcome');
- await Promise.all([
- expect(page.getByText(/Join .+ team/)).toBeVisible(),
-
- page.goto(inviteLink),
- ]);
+ await page.goto(inviteLink);
+ await expect(page.getByText(/Join .+ team/)).toBeVisible();
});
await test.step('Create new account', async () => {
diff --git a/packages/twenty-front/src/modules/auth/hooks/useAuth.ts b/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
index ea014a4f58b..312cabc7087 100644
--- a/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
@@ -118,6 +118,9 @@ export const useAuth = () => {
const navigate = useNavigate();
const clearSession = useCallback(() => {
+ // The assign below is the only navigation: keep the redirect effect from
+ // racing it to the sign-in page once the session is cleared.
+ store.set(isAppEffectRedirectEnabledState.atom, false);
sessionStorage.clear();
store.set(tokenPairState.atom, null);
store.set(isCookieAuthActiveState.atom, false);