Skip to content

Commit

Permalink
Fix module application duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
DamnClin committed Aug 28, 2022
1 parent cf6ae9a commit ac42e2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ export class ComponentLandscape {

private selectModuleAndDependencies(module: ElementSlug): void {
this.selectModule(module);

this.moduleSelectionTree(module).forEach(moduleDependency => this.selectModule(moduleDependency));
}

public selectModule(module: ElementSlug): void {
if (this.unknownElement(module)) {
if (this.unknownElement(module) || this.selectedModules.includes(module)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApplicationListener } from '@/common/primary/applicationlistener/ApplicationListener';
import { ModuleSlug } from '@/module/domain/ModuleSlug';
import { ModulesRepository } from '@/module/domain/ModulesRepository';
import { ModulesToApply } from '@/module/domain/ModulesToApply';
import { LandscapeVue } from '@/module/primary/landscape';
import { flushPromises, mount, VueWrapper } from '@vue/test-utils';
import sinon, { SinonStub } from 'sinon';
Expand Down Expand Up @@ -468,9 +469,17 @@ describe('Landscape', () => {
const wrapper = wrap({ modules });
await flushPromises();

await validateInitApplication(wrapper);
await wrapper.find(wrappedElement('folder-path-field')).setValue('test');
await clickModule('init', wrapper);
await clickModule('vue', wrapper);
await wrapper.find(wrappedElement('parameter-baseName-field')).setValue('base');

expect(modules.applyAll.calledOnce).toBe(true);
await wrapper.find(wrappedElement('modules-application-button')).trigger('click');

await flushPromises();

const [appliedModules] = modules.applyAll.lastCall.args as ModulesToApply[];
expect(appliedModules.modules.map(slug => slug.get())).toEqual(['init', 'vue']);
expect(wrapper.find(wrappedElement('modules-application-button')).attributes('disabled')).toBeUndefined();

const [message] = alertBus.success.lastCall.args;
Expand Down

0 comments on commit ac42e2d

Please sign in to comment.