Fix onboarding status (#4019)
* Fix onboarding status * Add comment * Fix jest tests
This commit is contained in:
@ -16,16 +16,7 @@ describe('getOnboardingStatus', () => {
|
||||
currentWorkspaceMember: null,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
displayName: null,
|
||||
} as CurrentWorkspace,
|
||||
});
|
||||
|
||||
const ongoingWorkspaceActivationPreviouslyActive = getOnboardingStatus({
|
||||
isLoggedIn: true,
|
||||
currentWorkspaceMember: null,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
displayName: 'My Workspace',
|
||||
activationStatus: 'inactive',
|
||||
} as CurrentWorkspace,
|
||||
});
|
||||
|
||||
@ -37,7 +28,7 @@ describe('getOnboardingStatus', () => {
|
||||
} as WorkspaceMember,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
displayName: 'My Workspace',
|
||||
activationStatus: 'active',
|
||||
} as CurrentWorkspace,
|
||||
});
|
||||
|
||||
@ -52,7 +43,7 @@ describe('getOnboardingStatus', () => {
|
||||
} as WorkspaceMember,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
displayName: 'My Workspace',
|
||||
activationStatus: 'active',
|
||||
} as CurrentWorkspace,
|
||||
});
|
||||
|
||||
@ -67,7 +58,7 @@ describe('getOnboardingStatus', () => {
|
||||
} as WorkspaceMember,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
displayName: 'My Workspace',
|
||||
activationStatus: 'active',
|
||||
subscriptionStatus: 'incomplete',
|
||||
} as CurrentWorkspace,
|
||||
isBillingEnabled: true,
|
||||
@ -84,7 +75,7 @@ describe('getOnboardingStatus', () => {
|
||||
} as WorkspaceMember,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
displayName: 'My Workspace',
|
||||
activationStatus: 'active',
|
||||
subscriptionStatus: 'incomplete',
|
||||
} as CurrentWorkspace,
|
||||
});
|
||||
@ -100,7 +91,7 @@ describe('getOnboardingStatus', () => {
|
||||
} as WorkspaceMember,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
displayName: 'My Workspace',
|
||||
activationStatus: 'active',
|
||||
subscriptionStatus: 'canceled',
|
||||
} as CurrentWorkspace,
|
||||
isBillingEnabled: true,
|
||||
@ -108,9 +99,6 @@ describe('getOnboardingStatus', () => {
|
||||
|
||||
expect(ongoingUserCreation).toBe('ongoing_user_creation');
|
||||
expect(ongoingWorkspaceActivation).toBe('ongoing_workspace_activation');
|
||||
expect(ongoingWorkspaceActivationPreviouslyActive).toBe(
|
||||
'ongoing_workspace_activation',
|
||||
);
|
||||
expect(ongoingProfileCreation).toBe('ongoing_profile_creation');
|
||||
expect(completed).toBe('completed');
|
||||
expect(incomplete).toBe('incomplete');
|
||||
|
||||
@ -28,18 +28,24 @@ export const getOnboardingStatus = ({
|
||||
return OnboardingStatus.OngoingUserCreation;
|
||||
}
|
||||
|
||||
// After SignInUp, the user should have a current workspace assigned.
|
||||
// If not, it indicates that the data is still being requested.
|
||||
if (!currentWorkspace) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (
|
||||
isBillingEnabled &&
|
||||
currentWorkspace?.subscriptionStatus === 'incomplete'
|
||||
currentWorkspace.subscriptionStatus === 'incomplete'
|
||||
) {
|
||||
return OnboardingStatus.Incomplete;
|
||||
}
|
||||
|
||||
if (isBillingEnabled && currentWorkspace?.subscriptionStatus === 'canceled') {
|
||||
if (isBillingEnabled && currentWorkspace.subscriptionStatus === 'canceled') {
|
||||
return OnboardingStatus.Canceled;
|
||||
}
|
||||
|
||||
if (currentWorkspace?.activationStatus !== 'active') {
|
||||
if (currentWorkspace.activationStatus !== 'active') {
|
||||
return OnboardingStatus.OngoingWorkspaceActivation;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user