diff --git a/src/controller.ts b/src/controller.ts index f8c8419..14065b8 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -473,7 +473,10 @@ export class Controller { + resetPresetProgress = async ( + presetArg: string | string[], + {removeFromSuggested} = {removeFromSuggested: false}, + ) => { this.logger.debug('Reset progress for', presetArg); await this.ensureRunning(); this.assertProgressLoaded(); @@ -494,9 +497,11 @@ export class Controller !presets.includes(preset as Presets), ); - this.state.base.suggestedPresets = this.state.base.activePresets.filter( - (preset) => !presets.includes(preset as Presets), - ); + if (removeFromSuggested) { + this.state.base.suggestedPresets = this.state.base.activePresets.filter( + (preset) => !presets.includes(preset as Presets), + ); + } await this.updateBaseState(); await this.updateProgress(); diff --git a/src/promo-manager/core/controller.ts b/src/promo-manager/core/controller.ts index 390f0e7..30c2bab 100644 --- a/src/promo-manager/core/controller.ts +++ b/src/promo-manager/core/controller.ts @@ -301,7 +301,9 @@ export class Controller { this.state.progress = JSON.parse(JSON.stringify(defaultProgressState)) as ProgressState; if (this.options.onboarding) { - await this.options.onboarding.getInstance().resetPresetProgress([...this.promoPresets]); + await this.options.onboarding + .getInstance() + .resetPresetProgress([...this.promoPresets], {removeFromSuggested: true}); } this.emitChange(); diff --git a/src/tests/commonPresets.test.ts b/src/tests/commonPresets.test.ts index 3e32f46..4d2b3d5 100644 --- a/src/tests/commonPresets.test.ts +++ b/src/tests/commonPresets.test.ts @@ -318,18 +318,25 @@ describe('preset management', function () { const controller = new Controller(options); await controller.resetPresetProgress(['createProject', 'createQueue']); - const newProgressState = options.onSave.progress.mock.calls[0][0]; - // remove createQueue from finished - expect(newProgressState.finishedPresets).toEqual([]); + expect(controller.state.progress?.finishedPresets).toEqual([]); // remove createProject passed steps - expect(newProgressState.presetPassedSteps.createProject).toBeUndefined(); + expect(controller.state.progress?.presetPassedSteps.createProject).toBeUndefined(); - const newBaseState = options.onSave.state.mock.calls[0][0]; - // remove createProject from active and suggested presets - expect(newBaseState.activePresets).toEqual([]); - expect(newBaseState.suggestedPresets).toEqual([]); + // remove createProject from active presets + expect(controller.state.base.activePresets).toEqual([]); + }); + + it('removeFromSuggested=true, remove from suggested', async function () { + const options = getOptions({}, {finishedPresets: ['createQueue']}); + + const controller = new Controller(options); + await controller.resetPresetProgress(['createProject', 'createQueue'], { + removeFromSuggested: true, + }); + + expect(controller.state.base.suggestedPresets).toEqual([]); }); }); });