1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
import '~/commons';
import { nextTick } from 'vue';
import { GlPopover, GlButton } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import RunnerInstructionsModal from '~/vue_shared/components/runner_instructions/runner_instructions_modal.vue';
import IosTemplates from '~/ci/pipelines_page/components/empty_state/ios_templates.vue';
import CiTemplates from '~/ci/pipelines_page/components/empty_state/ci_templates.vue';
const pipelineEditorPath = '/-/ci/editor';
const registrationToken = 'SECRET_TOKEN';
const iOSTemplateName = 'iOS-Fastlane';
describe('iOS Templates', () => {
let wrapper;
const createWrapper = (providedPropsData = {}) => {
return shallowMountExtended(IosTemplates, {
provide: {
pipelineEditorPath,
iosRunnersAvailable: true,
...providedPropsData,
},
propsData: {
registrationToken,
},
stubs: {
GlButton,
},
});
};
const findIosTemplate = () => wrapper.findComponent(CiTemplates);
const findRunnerInstructionsModal = () => wrapper.findComponent(RunnerInstructionsModal);
const findRunnerInstructionsPopover = () => wrapper.findComponent(GlPopover);
const findRunnerSetupTodoEmoji = () => wrapper.findByTestId('runner-setup-marked-todo');
const findRunnerSetupCompletedEmoji = () => wrapper.findByTestId('runner-setup-marked-completed');
const findSetupRunnerLink = () => wrapper.findByText('Set up a runner');
const configurePipelineLink = () => wrapper.findByTestId('configure-pipeline-link');
describe('when ios runners are not available', () => {
beforeEach(() => {
wrapper = createWrapper({ iosRunnersAvailable: false });
});
describe('the runner setup section', () => {
it('marks the section as todo', () => {
expect(findRunnerSetupTodoEmoji().isVisible()).toBe(true);
expect(findRunnerSetupCompletedEmoji().isVisible()).toBe(false);
});
it('renders the setup runner link', () => {
expect(findSetupRunnerLink().exists()).toBe(true);
});
it('renders the runner instructions modal with a popover once clicked', async () => {
findSetupRunnerLink().element.parentElement.click();
await nextTick();
expect(findRunnerInstructionsModal().exists()).toBe(true);
expect(findRunnerInstructionsModal().props('registrationToken')).toBe(registrationToken);
expect(findRunnerInstructionsModal().props('defaultPlatformName')).toBe('osx');
findRunnerInstructionsModal().vm.$emit('shown');
await nextTick();
expect(findRunnerInstructionsPopover().exists()).toBe(true);
});
});
describe('the configure pipeline section', () => {
it('has a disabled link button', () => {
expect(configurePipelineLink().props('disabled')).toBe(true);
});
});
describe('the ios-Fastlane template', () => {
it('renders the template', () => {
expect(findIosTemplate().props('filterTemplates')).toStrictEqual([iOSTemplateName]);
});
it('has a disabled link button', () => {
expect(findIosTemplate().props('disabled')).toBe(true);
});
});
});
describe('when ios runners are available', () => {
beforeEach(() => {
wrapper = createWrapper();
});
describe('the runner setup section', () => {
it('marks the section as completed', () => {
expect(findRunnerSetupTodoEmoji().isVisible()).toBe(false);
expect(findRunnerSetupCompletedEmoji().isVisible()).toBe(true);
});
it('does not render the setup runner link', () => {
expect(findSetupRunnerLink().exists()).toBe(false);
});
});
describe('the configure pipeline section', () => {
it('has an enabled link button', () => {
expect(configurePipelineLink().props('disabled')).toBe(false);
});
it('links to the pipeline editor with the right template', () => {
expect(configurePipelineLink().attributes('href')).toBe(
`${pipelineEditorPath}?template=${iOSTemplateName}`,
);
});
});
describe('the ios-Fastlane template', () => {
it('renders the template', () => {
expect(findIosTemplate().props('filterTemplates')).toStrictEqual([iOSTemplateName]);
});
it('has an enabled link button', () => {
expect(findIosTemplate().props('disabled')).toBe(false);
});
it('links to the pipeline editor with the right template', () => {
expect(configurePipelineLink().attributes('href')).toBe(
`${pipelineEditorPath}?template=${iOSTemplateName}`,
);
});
});
});
});
|