summaryrefslogtreecommitdiff
path: root/spec/frontend/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/integrations')
-rw-r--r--spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js59
1 files changed, 49 insertions, 10 deletions
diff --git a/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js b/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js
index c6e7ee44355..6a8ab02a69a 100644
--- a/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js
+++ b/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js
@@ -30,14 +30,21 @@ describe('JiraTriggerFields', () => {
const findCommentSettings = () => wrapper.find('[data-testid="comment-settings"]');
const findCommentDetail = () => wrapper.find('[data-testid="comment-detail"]');
const findCommentSettingsCheckbox = () => findCommentSettings().find(GlFormCheckbox);
+ const findIssueTransitionSettings = () =>
+ wrapper.find('[data-testid="issue-transition-settings"]');
+ const findIssueTransitionModeRadios = () =>
+ findIssueTransitionSettings().findAll('input[type="radio"]');
+ const findIssueTransitionIdsField = () =>
+ wrapper.find('input[type="text"][name="service[jira_issue_transition_id]"]');
describe('template', () => {
describe('initialTriggerCommit and initialTriggerMergeRequest are false', () => {
- it('does not show comment settings', () => {
+ it('does not show trigger settings', () => {
createComponent();
expect(findCommentSettings().isVisible()).toBe(false);
expect(findCommentDetail().isVisible()).toBe(false);
+ expect(findIssueTransitionSettings().isVisible()).toBe(false);
});
});
@@ -48,9 +55,10 @@ describe('JiraTriggerFields', () => {
});
});
- it('shows comment settings', () => {
+ it('shows trigger settings', () => {
expect(findCommentSettings().isVisible()).toBe(true);
expect(findCommentDetail().isVisible()).toBe(false);
+ expect(findIssueTransitionSettings().isVisible()).toBe(true);
});
// As per https://vuejs.org/v2/guide/forms.html#Checkbox-1,
@@ -73,13 +81,14 @@ describe('JiraTriggerFields', () => {
});
describe('initialTriggerMergeRequest is true', () => {
- it('shows comment settings', () => {
+ it('shows trigger settings', () => {
createComponent({
initialTriggerMergeRequest: true,
});
expect(findCommentSettings().isVisible()).toBe(true);
expect(findCommentDetail().isVisible()).toBe(false);
+ expect(findIssueTransitionSettings().isVisible()).toBe(true);
});
});
@@ -95,7 +104,41 @@ describe('JiraTriggerFields', () => {
});
});
- it('disables checkboxes and radios if inheriting', () => {
+ describe('initialJiraIssueTransitionId is not set', () => {
+ it('uses automatic transitions', () => {
+ createComponent({
+ initialTriggerCommit: true,
+ });
+
+ const [radio1, radio2] = findIssueTransitionModeRadios().wrappers;
+ expect(radio1.element.checked).toBe(true);
+ expect(radio2.element.checked).toBe(false);
+
+ expect(findIssueTransitionIdsField().exists()).toBe(false);
+ });
+ });
+
+ describe('initialJiraIssueTransitionId is set', () => {
+ it('uses custom transitions', () => {
+ createComponent({
+ initialJiraIssueTransitionId: '1, 2, 3',
+ initialTriggerCommit: true,
+ });
+
+ const [radio1, radio2] = findIssueTransitionModeRadios().wrappers;
+ expect(radio1.element.checked).toBe(false);
+ expect(radio2.element.checked).toBe(true);
+
+ const field = findIssueTransitionIdsField();
+ expect(field.isVisible()).toBe(true);
+ expect(field.element).toMatchObject({
+ type: 'text',
+ value: '1, 2, 3',
+ });
+ });
+ });
+
+ it('disables input fields if inheriting', () => {
createComponent(
{
initialTriggerCommit: true,
@@ -104,12 +147,8 @@ describe('JiraTriggerFields', () => {
true,
);
- wrapper.findAll('[type=checkbox]').wrappers.forEach((checkbox) => {
- expect(checkbox.attributes('disabled')).toBe('disabled');
- });
-
- wrapper.findAll('[type=radio]').wrappers.forEach((radio) => {
- expect(radio.attributes('disabled')).toBe('disabled');
+ wrapper.findAll('[type=text], [type=checkbox], [type=radio]').wrappers.forEach((input) => {
+ expect(input.attributes('disabled')).toBe('disabled');
});
});
});