Skip to content

Commit

Permalink
fix(onboarding): run always hidden preset -> not erase progress
Browse files Browse the repository at this point in the history
  • Loading branch information
vanilla-wave committed Jul 2, 2024
1 parent 0e2244f commit c449b8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/plugins/wizard-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/wizard-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']) => {
Expand Down

0 comments on commit c449b8f

Please sign in to comment.