From c449b8fac988f5954ac027ee6cf0d59b3d668530 Mon Sep 17 00:00:00 2001 From: vanilla-wave Date: Tue, 2 Jul 2024 22:50:50 +0200 Subject: [PATCH] fix(onboarding): run always hidden preset -> not erase progress --- src/plugins/wizard-plugin.test.ts | 17 +++++++++++++++++ src/plugins/wizard-plugin.ts | 10 ++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/plugins/wizard-plugin.test.ts b/src/plugins/wizard-plugin.test.ts index 9cfd314..dc95977 100644 --- a/src/plugins/wizard-plugin.test.ts +++ b/src/plugins/wizard-plugin.test.ts @@ -176,6 +176,23 @@ describe('run preset', function () { expect(controller.state.progress?.presetPassedSteps.createProject).toBe(undefined); }); + + it('run always hidden preset -> NOT reset progress', async function () { + const options = getOptions(); + options.plugins = [new WizardPlugin()]; + // @ts-ignore + options.config.presets.createQueue.visibility = 'alwaysHidden'; + const controller = new Controller(options); + + await controller.stepElementReached({ + stepSlug: 'createSprint', + element: getAnchorElement(), + }); + + await controller.runPreset('createQueue'); + + expect(controller.state.progress?.presetPassedSteps.createProject).not.toBe(undefined); + }); }); describe('finish preset', function () { diff --git a/src/plugins/wizard-plugin.ts b/src/plugins/wizard-plugin.ts index 988627a..d339645 100644 --- a/src/plugins/wizard-plugin.ts +++ b/src/plugins/wizard-plugin.ts @@ -48,14 +48,20 @@ export class WizardPlugin implements OnboardingPlugin { } }; - onRunPreset = async () => { + onRunPreset = async ({preset}: EventsMap['runPreset']) => { if (!this.onboardingInstance) { return; } this.onboardingInstance?.closeHintByUser(); - await this.eraseCommonPresetsProgress(); + const currentPreset = this.onboardingInstance?.options.config.presets[preset]; + const presetVisibility = + 'visibility' in currentPreset ? currentPreset.visibility : undefined; + + if (presetVisibility !== 'alwaysHidden') { + await this.eraseCommonPresetsProgress(); + } }; onFinishPreset = ({preset}: EventsMap['finishPreset']) => {