fix(editor): Disable email confirmation banner for trialing users (#7340)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
committed by
GitHub
parent
5e6c1d4f4b
commit
6d3d1789db
@@ -10,6 +10,7 @@ import {
|
||||
getTrialExpiredUserResponse,
|
||||
getTrialingUserResponse,
|
||||
getUserCloudInfo,
|
||||
getNotTrialingUserResponse,
|
||||
} from './utils/cloudStoreUtils';
|
||||
|
||||
let uiStore: ReturnType<typeof useUIStore>;
|
||||
@@ -128,6 +129,8 @@ describe('UI store', () => {
|
||||
expect(fetchCloudSpy).toHaveBeenCalled();
|
||||
expect(fetchUserCloudAccountSpy).toHaveBeenCalled();
|
||||
expect(uiStore.bannerStack).toContain('TRIAL');
|
||||
// There should be no email confirmation banner for trialing users
|
||||
expect(uiStore.bannerStack).not.toContain('EMAIL_CONFIRMATION');
|
||||
});
|
||||
|
||||
it('should add trial over banner to the the stack', async () => {
|
||||
@@ -143,12 +146,14 @@ describe('UI store', () => {
|
||||
expect(fetchCloudSpy).toHaveBeenCalled();
|
||||
expect(fetchUserCloudAccountSpy).toHaveBeenCalled();
|
||||
expect(uiStore.bannerStack).toContain('TRIAL_OVER');
|
||||
// There should be no email confirmation banner for trialing users
|
||||
expect(uiStore.bannerStack).not.toContain('EMAIL_CONFIRMATION');
|
||||
});
|
||||
|
||||
it('should add email confirmation banner to the the stack', async () => {
|
||||
const fetchCloudSpy = vi
|
||||
.spyOn(cloudPlanApi, 'getCurrentPlan')
|
||||
.mockResolvedValue(getTrialExpiredUserResponse());
|
||||
.mockResolvedValue(getNotTrialingUserResponse());
|
||||
const fetchUserCloudAccountSpy = vi
|
||||
.spyOn(cloudPlanApi, 'getCloudUserInfo')
|
||||
.mockResolvedValue(getUserCloudInfo(false));
|
||||
@@ -157,7 +162,6 @@ describe('UI store', () => {
|
||||
await cloudPlanStore.fetchUserCloudAccount();
|
||||
expect(fetchCloudSpy).toHaveBeenCalled();
|
||||
expect(fetchUserCloudAccountSpy).toHaveBeenCalled();
|
||||
expect(uiStore.bannerStack).toContain('TRIAL_OVER');
|
||||
expect(uiStore.bannerStack).toContain('EMAIL_CONFIRMATION');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Cloud } from '@/Interface';
|
||||
|
||||
// Mocks cloud plan API responses with different trial expiration dates
|
||||
function getUserPlanData(trialExpirationDate: Date): Cloud.PlanData {
|
||||
function getUserPlanData(trialExpirationDate: Date, isTrial = true): Cloud.PlanData {
|
||||
return {
|
||||
planId: 0,
|
||||
monthlyExecutionsLimit: 1000,
|
||||
@@ -10,7 +10,7 @@ function getUserPlanData(trialExpirationDate: Date): Cloud.PlanData {
|
||||
isActive: true,
|
||||
displayName: 'Trial',
|
||||
metadata: {
|
||||
group: 'trial',
|
||||
group: isTrial ? 'trial' : 'pro',
|
||||
slug: 'trial-1',
|
||||
trial: {
|
||||
gracePeriod: 3,
|
||||
@@ -42,3 +42,9 @@ export function getTrialExpiredUserResponse(): Cloud.PlanData {
|
||||
dateInThePast.setDate(dateInThePast.getDate() - 3);
|
||||
return getUserPlanData(dateInThePast);
|
||||
}
|
||||
|
||||
export function getNotTrialingUserResponse(): Cloud.PlanData {
|
||||
const inThreeDays = new Date();
|
||||
inThreeDays.setDate(inThreeDays.getDate() + 3);
|
||||
return getUserPlanData(inThreeDays, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user