Fix onboarding status (#4019)
* Fix onboarding status * Add comment * Fix jest tests
This commit is contained in:
@ -18,7 +18,7 @@ const billing = {
|
||||
isBillingEnabled: true,
|
||||
};
|
||||
const currentWorkspace = {
|
||||
displayName: 'testing',
|
||||
activationStatus: 'active',
|
||||
id: '1',
|
||||
allowImpersonation: true,
|
||||
};
|
||||
@ -119,25 +119,7 @@ describe('useOnboardingStatus', () => {
|
||||
setBilling(billing);
|
||||
setCurrentWorkspace({
|
||||
...currentWorkspace,
|
||||
displayName: '',
|
||||
subscriptionStatus: 'active',
|
||||
});
|
||||
});
|
||||
|
||||
expect(result.current.onboardingStatus).toBe(
|
||||
'ongoing_workspace_activation',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return "ongoing_workspace_activation"', async () => {
|
||||
const { result } = renderHooks();
|
||||
const { setTokenPair, setBilling, setCurrentWorkspace } = result.current;
|
||||
|
||||
act(() => {
|
||||
setTokenPair(tokenPair);
|
||||
setBilling(billing);
|
||||
setCurrentWorkspace({
|
||||
...currentWorkspace,
|
||||
activationStatus: 'inactive',
|
||||
subscriptionStatus: 'active',
|
||||
});
|
||||
});
|
||||
|
||||
@ -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