Skip to content

Commit

Permalink
Merge pull request #37 from gravity-ui/fix-duplicate-suggested-presets
Browse files Browse the repository at this point in the history
fix: not duplicate suggested presets
  • Loading branch information
vanilla-wave authored Oct 4, 2023
2 parents f72a946 + cb33543 commit 9a42c1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ export class Controller<HintParams, Presets extends string, Steps extends string
}

this.state.base.activePresets.push(presetSlug);
this.state.base.suggestedPresets.push(presetSlug);

if (!this.state.base.suggestedPresets.includes(presetSlug)) {
this.state.base.suggestedPresets.push(presetSlug);
}

this.hintStore.closeHint();

Expand Down
2 changes: 2 additions & 0 deletions src/tests/presets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ describe('preset management', function () {
it('run same preset -> not duplicate', async function () {
const controller = new Controller(options);
await controller.runPreset('createQueue');
await controller.finishPreset('createQueue');
await controller.runPreset('createQueue');

const newState =
options.onSave.state.mock.calls[options.onSave.state.mock.calls.length - 1][0];

expect(newState.activePresets).toEqual(['createProject', 'createQueue']);
expect(newState.suggestedPresets).toEqual(['createProject', 'createQueue']);
});

it('preset not from config -> nothing', async function () {
Expand Down

0 comments on commit 9a42c1f

Please sign in to comment.