Commit 59353a45 authored by Tom Quirk's avatar Tom Quirk

Address reviewer feedback

- remove _form.haml_spec
- use testid for test selector
parent fa7dbdb8
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
- if integration.operating? - if integration.operating?
= sprite_icon('check', css_class: 'gl-text-green-500') = sprite_icon('check', css_class: 'gl-text-green-500')
= render 'shared/service_settings', integration: integration = render 'shared/integration_settings', integration: integration
- if lookup_context.template_exists?('show', "projects/services/#{integration.to_param}", true) - if lookup_context.template_exists?('show', "projects/services/#{integration.to_param}", true)
%hr %hr
= render "projects/services/#{integration.to_param}/show", integration: integration = render "projects/services/#{integration.to_param}/show", integration: integration
= form_errors(integration) = form_errors(integration)
.service-settings %div{ data: { testid: "integration-settings-form" } }
- if @default_integration - if @default_integration
.js-vue-default-integration-settings{ data: integration_form_data(@default_integration, group: @group, project: @project) } .js-vue-default-integration-settings{ data: integration_form_data(@default_integration, group: @group, project: @project) }
.js-vue-integration-settings{ data: integration_form_data(integration, group: @group, project: @project) } .js-vue-integration-settings{ data: integration_form_data(integration, group: @group, project: @project) }
......
- integration = local_assigns.fetch(:integration)
= render 'shared/service_settings', integration: integration
...@@ -7,4 +7,4 @@ ...@@ -7,4 +7,4 @@
= @integration.title = @integration.title
= render 'shared/integrations/tabs', integration: @integration, active_tab: 'edit' do = render 'shared/integrations/tabs', integration: @integration, active_tab: 'edit' do
= render 'shared/integrations/form', integration: @integration = render 'shared/integration_settings', integration: @integration
...@@ -22,7 +22,7 @@ RSpec.describe 'Slack application' do ...@@ -22,7 +22,7 @@ RSpec.describe 'Slack application' do
it 'I can edit slack integration' do it 'I can edit slack integration' do
visit slack_application_form_path visit slack_application_form_path
within '.service-settings' do within '[data-testid="integration-settings-form"]' do
click_link 'Edit' click_link 'Edit'
end end
...@@ -31,7 +31,7 @@ RSpec.describe 'Slack application' do ...@@ -31,7 +31,7 @@ RSpec.describe 'Slack application' do
expect(page).to have_content('The project alias was updated successfully') expect(page).to have_content('The project alias was updated successfully')
within '.service-settings' do within '[data-testid="integration-settings-form"]' do
expect(page).to have_content('alias-edited') expect(page).to have_content('alias-edited')
end end
end end
......
...@@ -41,7 +41,7 @@ RSpec.describe 'User activates Jira', :js do ...@@ -41,7 +41,7 @@ RSpec.describe 'User activates Jira', :js do
fill_in 'service_password', with: 'password' fill_in 'service_password', with: 'password'
click_test_integration click_test_integration
page.within('.service-settings') do page.within('[data-testid="integration-settings-form"]') do
expect(page).to have_content('This field is required.') expect(page).to have_content('This field is required.')
end end
end end
......
...@@ -3,7 +3,7 @@ import axios from 'axios'; ...@@ -3,7 +3,7 @@ import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { setHTMLFixture } from 'helpers/fixtures'; import { setHTMLFixture } from 'helpers/fixtures';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import ActiveCheckbox from '~/integrations/edit/components/active_checkbox.vue'; import ActiveCheckbox from '~/integrations/edit/components/active_checkbox.vue';
import ConfirmationModal from '~/integrations/edit/components/confirmation_modal.vue'; import ConfirmationModal from '~/integrations/edit/components/confirmation_modal.vue';
...@@ -42,6 +42,7 @@ describe('IntegrationForm', () => { ...@@ -42,6 +42,7 @@ describe('IntegrationForm', () => {
featureFlags = {}, featureFlags = {},
initialState = {}, initialState = {},
props = {}, props = {},
mountFn = shallowMountExtended,
} = {}) => { } = {}) => {
const store = createStore({ const store = createStore({
customState: { ...mockIntegrationProps, ...customStateProps }, customState: { ...mockIntegrationProps, ...customStateProps },
...@@ -49,7 +50,7 @@ describe('IntegrationForm', () => { ...@@ -49,7 +50,7 @@ describe('IntegrationForm', () => {
}); });
dispatch = jest.spyOn(store, 'dispatch').mockImplementation(); dispatch = jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = mountExtended(IntegrationForm, { wrapper = mountFn(IntegrationForm, {
propsData: { ...props, formSelector: '.test' }, propsData: { ...props, formSelector: '.test' },
provide: { provide: {
glFeatures: featureFlags, glFeatures: featureFlags,
...@@ -218,6 +219,7 @@ describe('IntegrationForm', () => { ...@@ -218,6 +219,7 @@ describe('IntegrationForm', () => {
createComponent({ createComponent({
customStateProps: { type: 'jira', testPath: '/test' }, customStateProps: { type: 'jira', testPath: '/test' },
mountFn: mountExtended,
}); });
}); });
...@@ -378,6 +380,7 @@ describe('IntegrationForm', () => { ...@@ -378,6 +380,7 @@ describe('IntegrationForm', () => {
showActive: true, showActive: true,
initialActivated: false, initialActivated: false,
}, },
mountFn: mountExtended,
}); });
await findActiveCheckbox().vm.$emit('toggle-integration-active', formActive); await findActiveCheckbox().vm.$emit('toggle-integration-active', formActive);
...@@ -399,6 +402,7 @@ describe('IntegrationForm', () => { ...@@ -399,6 +402,7 @@ describe('IntegrationForm', () => {
canTest: true, canTest: true,
initialActivated: true, initialActivated: true,
}, },
mountFn: mountExtended,
}); });
await findProjectSaveButton().vm.$emit('click', new Event('click')); await findProjectSaveButton().vm.$emit('click', new Event('click'));
...@@ -428,6 +432,7 @@ describe('IntegrationForm', () => { ...@@ -428,6 +432,7 @@ describe('IntegrationForm', () => {
canTest: true, canTest: true,
initialActivated: integrationActive, initialActivated: integrationActive,
}, },
mountFn: mountExtended,
}); });
jest.spyOn(findGlForm().element, 'submit'); jest.spyOn(findGlForm().element, 'submit');
jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(checkValidityReturn); jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(checkValidityReturn);
...@@ -449,6 +454,7 @@ describe('IntegrationForm', () => { ...@@ -449,6 +454,7 @@ describe('IntegrationForm', () => {
canTest: true, canTest: true,
initialActivated: true, initialActivated: true,
}, },
mountFn: mountExtended,
}); });
jest.spyOn(findGlForm().element, 'submit'); jest.spyOn(findGlForm().element, 'submit');
jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(false); jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(false);
...@@ -482,6 +488,7 @@ describe('IntegrationForm', () => { ...@@ -482,6 +488,7 @@ describe('IntegrationForm', () => {
showActive: true, showActive: true,
canTest: true, canTest: true,
}, },
mountFn: mountExtended,
}); });
jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(false); jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(false);
...@@ -501,6 +508,7 @@ describe('IntegrationForm', () => { ...@@ -501,6 +508,7 @@ describe('IntegrationForm', () => {
canTest: true, canTest: true,
testPath: mockTestPath, testPath: mockTestPath,
}, },
mountFn: mountExtended,
}); });
jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(true); jest.spyOn(findGlForm().element, 'checkValidity').mockReturnValue(true);
}); });
......
...@@ -46,6 +46,7 @@ RSpec.describe IntegrationsHelper do ...@@ -46,6 +46,7 @@ RSpec.describe IntegrationsHelper do
:can_test, :can_test,
:test_path, :test_path,
:reset_path, :reset_path,
:form_path,
:redirect_to :redirect_to
] ]
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'projects/services/_form' do
let(:project) { create(:redmine_project) }
let(:user) { create(:admin) }
before do
assign(:project, project)
allow(controller).to receive(:current_user).and_return(user)
allow(view).to receive_messages(
current_user: user,
can?: true,
current_application_settings: Gitlab::CurrentSettings.current_application_settings,
integration: project.redmine_integration,
request: double(referer: '/services')
)
end
context 'commit_events and merge_request_events' do
it 'display merge_request_events and commit_events descriptions' do
allow(Integrations::Redmine).to receive(:supported_events).and_return(%w(commit merge_request))
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment