mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(editor): Don't wait for cloud plan store to initialize (no-changelog) (#17198)
This commit is contained in:
@@ -176,7 +176,7 @@ describe('Init', () => {
|
||||
typeof useUsersStore
|
||||
>);
|
||||
|
||||
await initializeAuthenticatedFeatures();
|
||||
await initializeAuthenticatedFeatures(false);
|
||||
expect(cloudStoreSpy).not.toHaveBeenCalled();
|
||||
expect(sourceControlSpy).not.toHaveBeenCalled();
|
||||
expect(nodeTranslationSpy).not.toHaveBeenCalled();
|
||||
@@ -184,7 +184,7 @@ describe('Init', () => {
|
||||
});
|
||||
|
||||
it('should init authenticated features only once if user is logged in', async () => {
|
||||
const cloudStoreSpy = vi.spyOn(cloudPlanStore, 'initialize');
|
||||
const cloudStoreSpy = vi.spyOn(cloudPlanStore, 'initialize').mockResolvedValue();
|
||||
const sourceControlSpy = vi.spyOn(sourceControlStore, 'getPreferences');
|
||||
const nodeTranslationSpy = vi.spyOn(nodeTypesStore, 'getNodeTranslationHeaders');
|
||||
const versionsSpy = vi.spyOn(versionsStore, 'checkForNewVersions');
|
||||
@@ -192,7 +192,7 @@ describe('Init', () => {
|
||||
typeof useUsersStore
|
||||
>);
|
||||
|
||||
await initializeAuthenticatedFeatures();
|
||||
await initializeAuthenticatedFeatures(false);
|
||||
|
||||
expect(cloudStoreSpy).toHaveBeenCalled();
|
||||
expect(sourceControlSpy).toHaveBeenCalled();
|
||||
@@ -204,7 +204,46 @@ describe('Init', () => {
|
||||
expect(cloudStoreSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should handle cloud plan initialization error', async () => {
|
||||
const cloudStoreSpy = vi
|
||||
.spyOn(cloudPlanStore, 'initialize')
|
||||
.mockRejectedValue(new AxiosError('Something went wrong', '404'));
|
||||
const sourceControlSpy = vi.spyOn(sourceControlStore, 'getPreferences');
|
||||
const nodeTranslationSpy = vi.spyOn(nodeTypesStore, 'getNodeTranslationHeaders');
|
||||
const versionsSpy = vi.spyOn(versionsStore, 'checkForNewVersions');
|
||||
vi.mocked(useUsersStore).mockReturnValue({ currentUser: { id: '123' } } as ReturnType<
|
||||
typeof useUsersStore
|
||||
>);
|
||||
|
||||
await initializeAuthenticatedFeatures(false);
|
||||
|
||||
expect(cloudStoreSpy).toHaveBeenCalled();
|
||||
expect(sourceControlSpy).toHaveBeenCalled();
|
||||
expect(nodeTranslationSpy).toHaveBeenCalled();
|
||||
expect(versionsSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should initialize even if cloud requests get stuck', async () => {
|
||||
const cloudStoreSpy = vi.spyOn(cloudPlanStore, 'initialize').mockImplementation(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10000));
|
||||
});
|
||||
const sourceControlSpy = vi.spyOn(sourceControlStore, 'getPreferences');
|
||||
const nodeTranslationSpy = vi.spyOn(nodeTypesStore, 'getNodeTranslationHeaders');
|
||||
const versionsSpy = vi.spyOn(versionsStore, 'checkForNewVersions');
|
||||
vi.mocked(useUsersStore).mockReturnValue({ currentUser: { id: '123' } } as ReturnType<
|
||||
typeof useUsersStore
|
||||
>);
|
||||
|
||||
await initializeAuthenticatedFeatures(false);
|
||||
|
||||
expect(cloudStoreSpy).toHaveBeenCalled();
|
||||
expect(sourceControlSpy).toHaveBeenCalled();
|
||||
expect(nodeTranslationSpy).toHaveBeenCalled();
|
||||
expect(versionsSpy).toHaveBeenCalled();
|
||||
}, 5000);
|
||||
|
||||
it('should handle source control initialization error', async () => {
|
||||
vi.spyOn(cloudPlanStore, 'initialize').mockResolvedValue();
|
||||
vi.mocked(useUsersStore).mockReturnValue({ currentUser: { id: '123' } } as ReturnType<
|
||||
typeof useUsersStore
|
||||
>);
|
||||
|
||||
@@ -148,21 +148,22 @@ export async function initializeAuthenticatedFeatures(
|
||||
}
|
||||
|
||||
if (settingsStore.isCloudDeployment) {
|
||||
try {
|
||||
await cloudPlanStore.initialize();
|
||||
|
||||
if (cloudPlanStore.userIsTrialing) {
|
||||
if (cloudPlanStore.trialExpired) {
|
||||
uiStore.pushBannerToStack('TRIAL_OVER');
|
||||
} else {
|
||||
uiStore.pushBannerToStack('TRIAL');
|
||||
void cloudPlanStore
|
||||
.initialize()
|
||||
.then(() => {
|
||||
if (cloudPlanStore.userIsTrialing) {
|
||||
if (cloudPlanStore.trialExpired) {
|
||||
uiStore.pushBannerToStack('TRIAL_OVER');
|
||||
} else {
|
||||
uiStore.pushBannerToStack('TRIAL');
|
||||
}
|
||||
} else if (cloudPlanStore.currentUserCloudInfo?.confirmed === false) {
|
||||
uiStore.pushBannerToStack('EMAIL_CONFIRMATION');
|
||||
}
|
||||
} else if (cloudPlanStore.currentUserCloudInfo?.confirmed === false) {
|
||||
uiStore.pushBannerToStack('EMAIL_CONFIRMATION');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to initialize cloud plan store:', e);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to initialize cloud plan store:', error);
|
||||
});
|
||||
}
|
||||
|
||||
if (insightsStore.isSummaryEnabled) {
|
||||
|
||||
@@ -130,7 +130,9 @@ export const useVersionsStore = defineStore(STORES.VERSIONS, () => {
|
||||
const versions = await versionsApi.getNextVersions(endpoint, current, instanceId);
|
||||
setVersions({ versions, currentVersion: current });
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch versions:', e);
|
||||
}
|
||||
};
|
||||
|
||||
const setVersions = (params: SetVersionParams) => {
|
||||
@@ -208,7 +210,9 @@ export const useVersionsStore = defineStore(STORES.VERSIONS, () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch Whats New section:', e);
|
||||
}
|
||||
};
|
||||
|
||||
const initialize = (settings: IVersionNotificationSettings) => {
|
||||
|
||||
Reference in New Issue
Block a user