mirror of
https://github.com/twentyhq/twenty.git
synced 2026-09-21 04:56:22 -04:00
## What Logout performed two navigations to `/welcome`. It now performs one. This also unbreaks `signup_invite_email`, the last spec failing `CI E2E Main` on `main` (run [31687111270](https://github.com/twentyhq/twenty/actions/runs/31687111270), failed all 3 attempts). ## Why `clearSession` resets the session atoms and then calls `window.location.assign(AppPath.SignInUp)`. Clearing the atoms flips the still-mounted app to logged out, so the redirect effect routes it to `/welcome` client-side while the browser is still fetching the document that `assign` asked for. Traced on a production build: ``` === clicking logout RESP 200 SignOut errors=false NAVCALL pushState /welcome <- react-router, from the redirect effect COMMITTED /welcome <- that pushState COMMITTED /welcome <- the document load, ~600ms later ``` So the URL reads as arrived at `/welcome` while a full page load is still in flight, and anything that navigates in that window is interrupted. The invite spec did exactly that and died with `Navigation to .../invite/... is interrupted by another navigation to .../welcome`. `isAppEffectRedirectEnabledState` already exists for this situation and is used the same way around the verify and SSO flows: a deliberate navigation is in flight, so the effect must not route. Setting it in `clearSession` leaves the `assign` as the only navigation. The session teardown is unchanged — the atoms still get cleared, several of them are persisted (the token pair, the workspace-domain cookie) and dropping that would leave the user signed in after the reload. After the fix, same trace: ``` === clicking logout RESP 200 SignOut errors=false COMMITTED /welcome <- one navigation NAVCALL replaceState undefined <- react-router booting in the new document ``` With logout deterministic, the spec just waits for `/welcome` and navigates; no retry loop. ## Tests Against a local server serving the front build the way CI does: - `signup_invite_email` `--repeat-each=5`: 5/5 green. Before the fix it failed roughly 1 run in 4, and 3/3 on CI. - Full e2e suite: 9/9 green. - `useAuth.test.tsx`: 8/8, including `should handle sign-out`, which asserts the session atoms are cleared.
Twenty end-to-end (E2E) Testing
Prerequisite
Installing the browsers:
npx nx setup twenty-e2e-testing
Run end-to-end tests
npx nx test twenty-e2e-testing
Start the interactive UI mode
npx nx test:ui twenty-e2e-testing
Run test in specific file
npx nx test twenty-e2e-testing <filename>
Example (location of the test must be specified from the root of twenty-e2e-testing package):
npx nx test twenty-e2e-testing tests/login.spec.ts
Runs the tests in debug mode.
npx nx test:debug twenty-e2e-testing
Show report after tests
npx nx test:report twenty-e2e-testing
Q&A
Why there's path.resolve() everywhere?
That's thanks to differences in root directory when running tests using commands and using IDE. When running tests with commands,
the root directory is twenty/packages/twenty-e2e-testing, for IDE it depends on how someone sets the configuration. This way, it
ensures that no matter which IDE or OS Shell is used, the result will be the same.