Files
twenty/packages/twenty-server/test/integration/graphql/utils/get-onboarding-status.util.ts
T
Charles Bochet 39082cf787 Only show the install-apps onboarding step to workspace creators (#22990)
New users joining an existing workspace through an invite link were
routed through the "Install your first apps" onboarding step, which is
meant for workspace creation only.

#22347 set `ONBOARDING_INSTALL_APPS_PENDING` inside
`activateOnboardingForUser`, which is shared by both sign-up paths. Gate
it per path like the connect-account step: `true` on
`signUpOnNewWorkspace`, `false` on `signInUpOnExistingWorkspace`.

Verified locally: invited users now go straight from create-profile into
the workspace, and workspace creators still get the install-apps step.
Covered by a unit test on the invite path and integration tests
asserting the onboarding status per sign-up path (invite →
`PROFILE_CREATION`; workspace creation → `SYNC_EMAIL` then
`APPS_INSTALLATION`).
2026-07-17 15:33:42 +02:00

52 lines
1.5 KiB
TypeScript

import gql from 'graphql-tag';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
import { type OnboardingStatus } from 'src/engine/core-modules/onboarding/enums/onboarding-status.enum';
type GetOnboardingStatusUtilArgs = {
accessToken: string;
expectToFail?: boolean;
};
export const getOnboardingStatus = async ({
accessToken,
expectToFail,
}: GetOnboardingStatusUtilArgs): CommonResponseBody<{
currentUser: { onboardingStatus: OnboardingStatus | null };
}> => {
const query = gql`
query CurrentUserOnboardingStatus {
currentUser {
onboardingStatus
}
}
`;
const response = await makeMetadataAPIRequest(
{
query,
variables: {},
},
accessToken,
);
if (expectToFail === true) {
warnIfNoErrorButExpectedToFail({
response,
errorMessage: 'Get onboarding status should have failed but did not',
});
}
if (expectToFail === false) {
warnIfErrorButNotExpectedToFail({
response,
errorMessage: 'Get onboarding status has failed but should not',
});
}
return { data: response.body.data, errors: response.body.errors };
};