snapshot of https://github.com/twentyhq/twenty.git (main, 2026-09-17; blobs > 131072B omitted)
Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-17 23:28:13 +05:00
commit e7da97194a
32688 changed files with 4208681 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
import { type ConfigVariableValue } from 'twenty-shared/types';
import { createConfigVariable } from 'test/integration/twenty-config/utils/create-config-variable.util';
import { deleteConfigVariable } from 'test/integration/twenty-config/utils/delete-config-variable.util';
import { getConfigVariable } from 'test/integration/twenty-config/utils/get-config-variable.util';
import { updateConfigVariable } from 'test/integration/twenty-config/utils/update-config-variable.util';
// Registers beforeAll/afterAll hooks that apply a database config override for
// the suite and restore the previous state afterwards, rather than blindly
// deleting: a suite must not erase an override another suite (or the
// environment) had in place.
export const setupDatabaseConfigOverrideForSuite = (
key: string,
value: ConfigVariableValue,
): void => {
let previousOverrideValue: ConfigVariableValue;
let hadPreviousOverride = false;
beforeAll(async () => {
const { data } = await getConfigVariable({ input: { key } });
hadPreviousOverride = data.getDatabaseConfigVariable.source === 'DATABASE';
if (hadPreviousOverride) {
previousOverrideValue = data.getDatabaseConfigVariable.value;
await updateConfigVariable({ input: { key, value } });
} else {
await createConfigVariable({ input: { key, value } });
}
});
afterAll(async () => {
try {
if (hadPreviousOverride) {
await updateConfigVariable({
input: { key, value: previousOverrideValue },
});
} else {
await deleteConfigVariable({ input: { key } });
}
} catch (error) {
// Reported rather than rethrown: a passing suite should not go red over
// its own teardown. But a swallowed failure leaves the override in place
// and the next suite fails for reasons that point nowhere near here, so
// it has to be visible.
process.stderr.write(
`[config-override] failed to restore ${key}, later suites may see a stale value: ${
error instanceof Error ? error.message : String(error)
}\n`,
);
}
});
};

View File

@@ -0,0 +1,152 @@
import { type Response } from 'supertest';
import { buildWorkspaceOriginForSubdomain } from 'test/integration/graphql/utils/build-apple-workspace-origin.util';
import { getAuthTokensFromLoginTokenQueryFactory } from 'test/integration/graphql/utils/get-auth-tokens-from-login-token.query-factory.util';
import { getLoginTokenFromCredentialsQueryFactory } from 'test/integration/graphql/utils/get-login-token-from-credentials.query-factory.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { USER_SESSION_COOKIE_NAME } from 'src/engine/core-modules/user-session/constants/user-session-cookie-name.constant';
import { USER_SESSION_SECURE_COOKIE_NAME } from 'src/engine/core-modules/user-session/constants/user-session-secure-cookie-name.constant';
type RequestHeaders = {
originHeader?: string;
cookieHeader?: string;
};
// Supertest requests dispatch lazily, so Origin and Cookie can be set on the
// request makeMetadataAPIRequest already built. The explicit null token keeps
// these requests off Bearer authentication, which would bypass both the
// cookie auth path and the CSRF middleware; undefined would fall back to the
// util's default admin token.
export const postMetadataOperationWithHeaders = (
graphqlOperation: Parameters<typeof makeMetadataAPIRequest>[0],
{ originHeader, cookieHeader }: RequestHeaders,
expectedStatus = 200,
) => {
const graphqlRequest = makeMetadataAPIRequest(graphqlOperation, null);
if (originHeader !== undefined) {
graphqlRequest.set('Origin', originHeader);
}
if (cookieHeader !== undefined) {
graphqlRequest.set('Cookie', cookieHeader);
}
return graphqlRequest.expect(expectedStatus);
};
type SignInOptions = RequestHeaders & {
email?: string;
password?: string;
workspaceSubdomain?: string;
};
// Runs the full credentials exchange (credentials -> login token -> auth
// tokens) and returns the raw supertest response of the final exchange, so
// callers can assert on set-cookie headers, not just the GraphQL body.
export const signInWithCookieCapture = async ({
email = 'tim@apple.dev',
password = 'tim@apple.dev',
workspaceSubdomain = 'apple',
originHeader,
cookieHeader,
}: SignInOptions = {}): Promise<Response> => {
const workspaceOrigin = buildWorkspaceOriginForSubdomain(workspaceSubdomain);
const loginTokenResponse = await postMetadataOperationWithHeaders(
getLoginTokenFromCredentialsQueryFactory({
email,
password,
origin: workspaceOrigin,
}),
{ originHeader, cookieHeader },
);
const loginToken =
loginTokenResponse.body.data?.getLoginTokenFromCredentials?.loginToken
?.token;
expect(loginToken).toBeDefined();
return await postMetadataOperationWithHeaders(
getAuthTokensFromLoginTokenQueryFactory({
loginToken,
origin: workspaceOrigin,
}),
{ originHeader, cookieHeader },
);
};
// Redacts the two dynamic parts (token value, expiry timestamp) so the rest of
// the set-cookie header can be snapshot: name, attribute list and order are
// deterministic, and the snapshot also pins the absence of Domain and Secure.
export const normalizeSessionCookieForSnapshot = (rawCookie: string): string =>
rawCookie
.replace(/=sess_[A-Za-z0-9_-]+/, '=sess_<redacted>')
.replace(/Expires=[^;]+/, 'Expires=<redacted>');
export const getSetCookieHeaders = (response: Response): string[] =>
Array.isArray(response.headers['set-cookie'])
? response.headers['set-cookie']
: [];
// Which of the two names the server issues depends on SERVER_URL and
// AUTH_COOKIE_SAME_SITE, so callers match on both by default and read the name
// back off the response rather than assuming the insecure deployment. Specs
// that assert one specific variant pass the name explicitly.
const SESSION_COOKIE_NAMES = [
USER_SESSION_SECURE_COOKIE_NAME,
USER_SESSION_COOKIE_NAME,
];
// startsWith keeps the plain and __Host- names distinct: the prefixed name
// does not start with the plain one.
export const extractSessionCookie = (
response: Response,
cookieName?: string,
):
| { rawCookie: string; cookieName: string; cookieHeader: string; sessionToken: string }
| undefined => {
const candidateNames =
cookieName === undefined ? SESSION_COOKIE_NAMES : [cookieName];
for (const candidateName of candidateNames) {
const rawCookie = getSetCookieHeaders(response).find((cookie) =>
cookie.startsWith(`${candidateName}=sess_`),
);
if (rawCookie === undefined) {
continue;
}
const sessionToken = rawCookie
.split(';')[0]
.slice(`${candidateName}=`.length);
return {
rawCookie,
cookieName: candidateName,
cookieHeader: `${candidateName}=${sessionToken}`,
sessionToken,
};
}
return undefined;
};
// A deletion cookie is the name with an empty value and an epoch expiry; the
// extractor above will not match it because the value lacks the sess_ prefix.
export const hasClearingCookie = (
response: Response,
cookieName?: string,
): boolean => {
const candidateNames =
cookieName === undefined ? SESSION_COOKIE_NAMES : [cookieName];
return getSetCookieHeaders(response).some((cookie) =>
candidateNames.some(
(candidateName) =>
cookie.startsWith(`${candidateName}=;`) &&
cookie.includes('Expires=Thu, 01 Jan 1970'),
),
);
};

View File

@@ -0,0 +1,95 @@
import { gql } from 'graphql-tag';
export const currentUserIdentityQueryFactory = () => {
return {
query: gql`
query CurrentUser {
currentUser {
id
email
}
}
`,
variables: {},
};
};
export const currentUserWorkspaceContextQueryFactory = () => {
return {
query: gql`
query CurrentUserWorkspaceContext {
currentUser {
id
email
currentWorkspace {
id
}
currentUserWorkspace {
id
}
}
}
`,
variables: {},
};
};
export const currentUserSessionsQueryFactory = () => {
return {
query: gql`
query CurrentUserSessions {
currentUserSessions {
id
workspaceId
authProvider
isImpersonating
isCurrent
lastActiveAt
expiresAt
}
}
`,
variables: {},
};
};
export const revokeUserSessionQueryFactory = ({
userSessionId,
}: {
userSessionId: string;
}) => {
return {
query: gql`
mutation RevokeUserSession($userSessionId: UUID!) {
revokeUserSession(userSessionId: $userSessionId)
}
`,
variables: { userSessionId },
};
};
export const revokeAllOtherUserSessionsQueryFactory = () => {
return {
query: gql`
mutation RevokeAllOtherUserSessions {
revokeAllOtherUserSessions
}
`,
variables: {},
};
};
export const signOutQueryFactory = ({
refreshToken,
}: {
refreshToken?: string;
} = {}) => {
return {
query: gql`
mutation SignOut($refreshToken: String) {
signOut(refreshToken: $refreshToken)
}
`,
variables: { refreshToken },
};
};