Files
twenty/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.ts
Parship Chowdhury 4899f00bc7 fix: frontend build failing after code formatting library update (#21519)
Starting the frontend(`nx start twenty-front`) was failing because one
of its dependencies - the client SDK - can not be built. A recent update
made the sdk compatible with a newer version of Prettier. That update
started using parts of prettier that the build setup did not recognize,
so the build stopped with an error about a missing module. This PR
updated the SDK’s build configuration, so it correctly handles those
prettier imports.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21519?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

---------

Signed-off-by: Parship Chowdhury <parshipchowdhury@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2026-06-13 10:49:10 +02:00

23 lines
854 B
TypeScript

import { type Page } from '@playwright/test';
// Mirrors TOKEN_PAIR_LOCAL_STORAGE_KEY from twenty-front
// (packages/twenty-front/src/modules/auth/states/tokenPairState.ts).
// Since #21507 the frontend stores the auth token pair in localStorage
// instead of a cookie.
const TOKEN_PAIR_LOCAL_STORAGE_KEY = 'tokenPairState';
export const getAccessAuthToken = async (page: Page) => {
const storageState = await page.context().storageState();
const tokenPairItem = storageState.origins
.flatMap((origin) => origin.localStorage)
.find((item) => item.name === TOKEN_PAIR_LOCAL_STORAGE_KEY);
if (tokenPairItem === undefined) {
throw new Error('No auth token pair found in local storage');
}
const { accessOrWorkspaceAgnosticToken } = JSON.parse(tokenPairItem.value);
return { authToken: accessOrWorkspaceAgnosticToken.token };
};