Skip to content

Commit

Permalink
Merge pull request #113 from gravity-ui/turn-on-onboarding
Browse files Browse the repository at this point in the history
fix(onboarding): wizard-plugin fix turn on behavior
  • Loading branch information
vanilla-wave authored Sep 12, 2024
2 parents 2d93e7c + 73b727e commit 023cbd0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class Controller<HintParams, Presets extends string, Steps extends string
const allowRun = await this.events.emit('beforeShowHint', {stepData});

if (!this.state.base.enabled) {
this.logger.debug('Wizard is not active', preset, stepSlug);
this.logger.debug('Onboarding is not enabled', preset, stepSlug);
return;
}

Expand Down
26 changes: 26 additions & 0 deletions src/plugins/wizard-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,32 @@ describe('open wizard', function () {
expect(options.getProgressState).toHaveBeenCalled();
});

it('onboarding disabled, wizard hidden -> turn on onboarding', async function () {
const options = getOptions({enabled: false, wizardState: 'hidden'});
options.plugins = [new WizardPlugin()];

const controller = new Controller(options);

await controller.setWizardState('visible');

expect(controller.state.base.enabled).toBe(true);
});

it('onboarding disabled, wizard hidden -> can show hint', async function () {
const options = getOptions({enabled: false, wizardState: 'hidden'});
options.plugins = [new WizardPlugin()];

const controller = new Controller(options);

await controller.stepElementReached({
stepSlug: 'createSprint',
element: getAnchorElement(),
});
await controller.setWizardState('visible');

expect(controller.hintStore.state.open).toBe(true);
});

it('onboarding enabled, wizard hidden -> load progress on open', async function () {
const options = getOptions({wizardState: 'hidden'});
options.plugins = [new WizardPlugin()];
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/wizard-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export class WizardPlugin implements OnboardingPlugin {
}

if (wizardState === 'visible' || wizardState === 'collapsed') {
this.onboardingInstance.state.base.enabled = true;
this.onboardingInstance.emitStateChange();

await this.onboardingInstance.ensureRunning();
this.onboardingInstance.checkReachedHints();
}

if (wizardState === 'hidden') {
Expand Down

0 comments on commit 023cbd0

Please sign in to comment.