Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/pipeline_wizard/components')
-rw-r--r--spec/frontend/pipeline_wizard/components/commit_spec.js4
-rw-r--r--spec/frontend/pipeline_wizard/components/editor_spec.js20
-rw-r--r--spec/frontend/pipeline_wizard/components/widgets/list_spec.js21
-rw-r--r--spec/frontend/pipeline_wizard/components/wrapper_spec.js29
4 files changed, 56 insertions, 18 deletions
diff --git a/spec/frontend/pipeline_wizard/components/commit_spec.js b/spec/frontend/pipeline_wizard/components/commit_spec.js
index d7e019c642e..fa30b9c2b97 100644
--- a/spec/frontend/pipeline_wizard/components/commit_spec.js
+++ b/spec/frontend/pipeline_wizard/components/commit_spec.js
@@ -211,7 +211,7 @@ describe('Pipeline Wizard - Commit Page', () => {
}) => {
let consoleSpy;
- beforeAll(async () => {
+ beforeEach(async () => {
createComponent(
{
filename,
@@ -246,7 +246,7 @@ describe('Pipeline Wizard - Commit Page', () => {
await waitForPromises();
});
- afterAll(() => {
+ afterEach(() => {
wrapper.destroy();
});
diff --git a/spec/frontend/pipeline_wizard/components/editor_spec.js b/spec/frontend/pipeline_wizard/components/editor_spec.js
index 26e4b8eb0ea..dd0a609043a 100644
--- a/spec/frontend/pipeline_wizard/components/editor_spec.js
+++ b/spec/frontend/pipeline_wizard/components/editor_spec.js
@@ -3,12 +3,20 @@ import { Document } from 'yaml';
import YamlEditor from '~/pipeline_wizard/components/editor.vue';
describe('Pages Yaml Editor wrapper', () => {
+ let wrapper;
+
const defaultOptions = {
propsData: { doc: new Document({ foo: 'bar' }), filename: 'foo.yml' },
};
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
describe('mount hook', () => {
- const wrapper = mount(YamlEditor, defaultOptions);
+ beforeEach(() => {
+ wrapper = mount(YamlEditor, defaultOptions);
+ });
it('editor is mounted', () => {
expect(wrapper.vm.editor).not.toBeUndefined();
@@ -19,16 +27,11 @@ describe('Pages Yaml Editor wrapper', () => {
describe('watchers', () => {
describe('doc', () => {
const doc = new Document({ baz: ['bar'] });
- let wrapper;
beforeEach(() => {
wrapper = mount(YamlEditor, defaultOptions);
});
- afterEach(() => {
- wrapper.destroy();
- });
-
it("causes the editor's value to be set to the stringified document", async () => {
await wrapper.setProps({ doc });
expect(wrapper.vm.editor.getValue()).toEqual(doc.toString());
@@ -48,7 +51,10 @@ describe('Pages Yaml Editor wrapper', () => {
describe('highlight', () => {
const highlight = 'foo';
- const wrapper = mount(YamlEditor, defaultOptions);
+
+ beforeEach(() => {
+ wrapper = mount(YamlEditor, defaultOptions);
+ });
it('calls editor.highlight(path, keep=true)', async () => {
const highlightSpy = jest.spyOn(wrapper.vm.yamlEditorExtension.obj, 'highlight');
diff --git a/spec/frontend/pipeline_wizard/components/widgets/list_spec.js b/spec/frontend/pipeline_wizard/components/widgets/list_spec.js
index 796356634bc..c9e9f5caebe 100644
--- a/spec/frontend/pipeline_wizard/components/widgets/list_spec.js
+++ b/spec/frontend/pipeline_wizard/components/widgets/list_spec.js
@@ -22,6 +22,9 @@ describe('Pipeline Wizard - List Widget', () => {
const setValueOnInputField = (value, atIndex = 0) => {
return findGlFormInputGroupByIndex(atIndex).vm.$emit('input', value);
};
+ const getValueOfInputField = (atIndex = 0) => {
+ return findGlFormInputGroupByIndex(atIndex).get('input').element.value;
+ };
const findAddStepButton = () => wrapper.findByTestId('add-step-button');
const addStep = () => findAddStepButton().vm.$emit('click');
@@ -103,6 +106,24 @@ describe('Pipeline Wizard - List Widget', () => {
expect(addStepBtn.text()).toBe('add another step');
});
+ it('deletes the correct input item', async () => {
+ createComponent({}, mountExtended);
+
+ await addStep();
+ await addStep();
+ setValueOnInputField('foo', 0);
+ setValueOnInputField('bar', 1);
+ setValueOnInputField('baz', 2);
+
+ const button = findAllGlFormInputGroups().at(1).find('[data-testid="remove-step-button"]');
+
+ button.vm.$emit('click');
+ await nextTick();
+
+ expect(getValueOfInputField(0)).toBe('foo');
+ expect(getValueOfInputField(1)).toBe('baz');
+ });
+
it('the "add step" button increases the number of input fields', async () => {
createComponent();
diff --git a/spec/frontend/pipeline_wizard/components/wrapper_spec.js b/spec/frontend/pipeline_wizard/components/wrapper_spec.js
index f064bf01c86..d5b78cebcb3 100644
--- a/spec/frontend/pipeline_wizard/components/wrapper_spec.js
+++ b/spec/frontend/pipeline_wizard/components/wrapper_spec.js
@@ -132,7 +132,7 @@ describe('Pipeline Wizard - wrapper.vue', () => {
expectStepDef,
expectProgressBarValue,
}) => {
- beforeAll(async () => {
+ beforeEach(async () => {
createComponent();
for (const emittedValue of navigationEventChain) {
@@ -145,7 +145,7 @@ describe('Pipeline Wizard - wrapper.vue', () => {
}
});
- afterAll(() => {
+ afterEach(() => {
wrapper.destroy();
});
@@ -184,11 +184,11 @@ describe('Pipeline Wizard - wrapper.vue', () => {
});
describe('editor overlay', () => {
- beforeAll(() => {
+ beforeEach(() => {
createComponent();
});
- afterAll(() => {
+ afterEach(() => {
wrapper.destroy();
});
@@ -236,11 +236,11 @@ describe('Pipeline Wizard - wrapper.vue', () => {
});
describe('line highlights', () => {
- beforeAll(() => {
+ beforeEach(() => {
createComponent();
});
- afterAll(() => {
+ afterEach(() => {
wrapper.destroy();
});
@@ -266,7 +266,7 @@ describe('Pipeline Wizard - wrapper.vue', () => {
});
describe('integration test', () => {
- beforeAll(async () => {
+ beforeEach(async () => {
createComponent({}, mountExtended);
});
@@ -290,14 +290,25 @@ describe('Pipeline Wizard - wrapper.vue', () => {
describe('navigating back', () => {
let inputField;
- beforeAll(async () => {
+ beforeEach(async () => {
+ createComponent({}, mountExtended);
+
+ findFirstInputFieldForTarget('$FOO').setValue('fooVal');
+ await nextTick();
+
+ findFirstVisibleStep().vm.$emit('next');
+ await nextTick();
+
+ findFirstInputFieldForTarget('$BAR').setValue('barVal');
+ await nextTick();
+
findFirstVisibleStep().vm.$emit('back');
await nextTick();
inputField = findFirstInputFieldForTarget('$FOO');
});
- afterAll(() => {
+ afterEach(() => {
wrapper.destroy();
inputField = undefined;
});