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,
|
isBillingEnabled: true,
|
||||||
};
|
};
|
||||||
const currentWorkspace = {
|
const currentWorkspace = {
|
||||||
displayName: 'testing',
|
activationStatus: 'active',
|
||||||
id: '1',
|
id: '1',
|
||||||
allowImpersonation: true,
|
allowImpersonation: true,
|
||||||
};
|
};
|
||||||
@ -119,25 +119,7 @@ describe('useOnboardingStatus', () => {
|
|||||||
setBilling(billing);
|
setBilling(billing);
|
||||||
setCurrentWorkspace({
|
setCurrentWorkspace({
|
||||||
...currentWorkspace,
|
...currentWorkspace,
|
||||||
displayName: '',
|
activationStatus: 'inactive',
|
||||||
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,
|
|
||||||
subscriptionStatus: 'active',
|
subscriptionStatus: 'active',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -16,16 +16,7 @@ describe('getOnboardingStatus', () => {
|
|||||||
currentWorkspaceMember: null,
|
currentWorkspaceMember: null,
|
||||||
currentWorkspace: {
|
currentWorkspace: {
|
||||||
id: '1',
|
id: '1',
|
||||||
displayName: null,
|
activationStatus: 'inactive',
|
||||||
} as CurrentWorkspace,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ongoingWorkspaceActivationPreviouslyActive = getOnboardingStatus({
|
|
||||||
isLoggedIn: true,
|
|
||||||
currentWorkspaceMember: null,
|
|
||||||
currentWorkspace: {
|
|
||||||
id: '1',
|
|
||||||
displayName: 'My Workspace',
|
|
||||||
} as CurrentWorkspace,
|
} as CurrentWorkspace,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,7 +28,7 @@ describe('getOnboardingStatus', () => {
|
|||||||
} as WorkspaceMember,
|
} as WorkspaceMember,
|
||||||
currentWorkspace: {
|
currentWorkspace: {
|
||||||
id: '1',
|
id: '1',
|
||||||
displayName: 'My Workspace',
|
activationStatus: 'active',
|
||||||
} as CurrentWorkspace,
|
} as CurrentWorkspace,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,7 +43,7 @@ describe('getOnboardingStatus', () => {
|
|||||||
} as WorkspaceMember,
|
} as WorkspaceMember,
|
||||||
currentWorkspace: {
|
currentWorkspace: {
|
||||||
id: '1',
|
id: '1',
|
||||||
displayName: 'My Workspace',
|
activationStatus: 'active',
|
||||||
} as CurrentWorkspace,
|
} as CurrentWorkspace,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,7 +58,7 @@ describe('getOnboardingStatus', () => {
|
|||||||
} as WorkspaceMember,
|
} as WorkspaceMember,
|
||||||
currentWorkspace: {
|
currentWorkspace: {
|
||||||
id: '1',
|
id: '1',
|
||||||
displayName: 'My Workspace',
|
activationStatus: 'active',
|
||||||
subscriptionStatus: 'incomplete',
|
subscriptionStatus: 'incomplete',
|
||||||
} as CurrentWorkspace,
|
} as CurrentWorkspace,
|
||||||
isBillingEnabled: true,
|
isBillingEnabled: true,
|
||||||
@ -84,7 +75,7 @@ describe('getOnboardingStatus', () => {
|
|||||||
} as WorkspaceMember,
|
} as WorkspaceMember,
|
||||||
currentWorkspace: {
|
currentWorkspace: {
|
||||||
id: '1',
|
id: '1',
|
||||||
displayName: 'My Workspace',
|
activationStatus: 'active',
|
||||||
subscriptionStatus: 'incomplete',
|
subscriptionStatus: 'incomplete',
|
||||||
} as CurrentWorkspace,
|
} as CurrentWorkspace,
|
||||||
});
|
});
|
||||||
@ -100,7 +91,7 @@ describe('getOnboardingStatus', () => {
|
|||||||
} as WorkspaceMember,
|
} as WorkspaceMember,
|
||||||
currentWorkspace: {
|
currentWorkspace: {
|
||||||
id: '1',
|
id: '1',
|
||||||
displayName: 'My Workspace',
|
activationStatus: 'active',
|
||||||
subscriptionStatus: 'canceled',
|
subscriptionStatus: 'canceled',
|
||||||
} as CurrentWorkspace,
|
} as CurrentWorkspace,
|
||||||
isBillingEnabled: true,
|
isBillingEnabled: true,
|
||||||
@ -108,9 +99,6 @@ describe('getOnboardingStatus', () => {
|
|||||||
|
|
||||||
expect(ongoingUserCreation).toBe('ongoing_user_creation');
|
expect(ongoingUserCreation).toBe('ongoing_user_creation');
|
||||||
expect(ongoingWorkspaceActivation).toBe('ongoing_workspace_activation');
|
expect(ongoingWorkspaceActivation).toBe('ongoing_workspace_activation');
|
||||||
expect(ongoingWorkspaceActivationPreviouslyActive).toBe(
|
|
||||||
'ongoing_workspace_activation',
|
|
||||||
);
|
|
||||||
expect(ongoingProfileCreation).toBe('ongoing_profile_creation');
|
expect(ongoingProfileCreation).toBe('ongoing_profile_creation');
|
||||||
expect(completed).toBe('completed');
|
expect(completed).toBe('completed');
|
||||||
expect(incomplete).toBe('incomplete');
|
expect(incomplete).toBe('incomplete');
|
||||||
|
|||||||
@ -28,18 +28,24 @@ export const getOnboardingStatus = ({
|
|||||||
return OnboardingStatus.OngoingUserCreation;
|
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 (
|
if (
|
||||||
isBillingEnabled &&
|
isBillingEnabled &&
|
||||||
currentWorkspace?.subscriptionStatus === 'incomplete'
|
currentWorkspace.subscriptionStatus === 'incomplete'
|
||||||
) {
|
) {
|
||||||
return OnboardingStatus.Incomplete;
|
return OnboardingStatus.Incomplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBillingEnabled && currentWorkspace?.subscriptionStatus === 'canceled') {
|
if (isBillingEnabled && currentWorkspace.subscriptionStatus === 'canceled') {
|
||||||
return OnboardingStatus.Canceled;
|
return OnboardingStatus.Canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentWorkspace?.activationStatus !== 'active') {
|
if (currentWorkspace.activationStatus !== 'active') {
|
||||||
return OnboardingStatus.OngoingWorkspaceActivation;
|
return OnboardingStatus.OngoingWorkspaceActivation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user