mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-19 07:36:52 +00:00
fix(editor): Dismiss what's new call out on load (no-changelog) (#32415)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -17,10 +17,12 @@ vi.mock('vue-router', async (importOriginal) => ({
|
||||
|
||||
vi.mock('@/app/composables/useToast', () => {
|
||||
const showToast = vi.fn();
|
||||
const showMessage = vi.fn();
|
||||
return {
|
||||
useToast: () => {
|
||||
return {
|
||||
showToast,
|
||||
showMessage,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -139,6 +141,27 @@ describe('versions.store', () => {
|
||||
expect(versionsStore.whatsNewArticles).toEqual([whatsNewArticle]);
|
||||
});
|
||||
|
||||
it('should dismiss the callout as soon as it is shown', async () => {
|
||||
vi.spyOn(versionsApi, 'getWhatsNewSection').mockResolvedValue(whatsNew);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
vi.mocked(useUsersStore).mockReturnValue({ currentUser: null } as any);
|
||||
|
||||
const rootStore = useRootStore();
|
||||
rootStore.setVersionCli(currentVersionName);
|
||||
rootStore.setInstanceId(instanceId);
|
||||
|
||||
const versionsStore = useVersionsStore();
|
||||
versionsStore.initialize(settings);
|
||||
|
||||
await versionsStore.fetchWhatsNew();
|
||||
|
||||
// The callout has been shown ...
|
||||
expect(toast.showMessage).toHaveBeenCalled();
|
||||
// ... and is immediately marked as dismissed so it does not reappear on the
|
||||
// next load, even though the user never explicitly closed it.
|
||||
expect(versionsStore.shouldShowWhatsNewCallout()).toBe(false);
|
||||
});
|
||||
|
||||
it("should not fetch What's new articles if version notifications are disabled", async () => {
|
||||
vi.spyOn(versionsApi, 'getWhatsNewSection');
|
||||
|
||||
|
||||
@@ -218,10 +218,11 @@ export const useVersionsStore = defineStore(STORES.VERSIONS, () => {
|
||||
data: { articleId },
|
||||
});
|
||||
},
|
||||
onClose: () => {
|
||||
dismissWhatsNewCallout();
|
||||
},
|
||||
});
|
||||
|
||||
// Mark the callout as dismissed as soon as it is shown, so it does not
|
||||
// keep reappearing on subsequent loads for users who simply ignore it.
|
||||
dismissWhatsNewCallout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user