2021-01-03 14:25:43 +05:30
|
|
|
import { GlFormInput, GlButton } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import Vuex from 'vuex';
|
2019-07-07 11:18:12 +05:30
|
|
|
import ErrorTrackingForm from '~/error_tracking_settings/components/error_tracking_form.vue';
|
2019-12-26 22:10:19 +05:30
|
|
|
import createStore from '~/error_tracking_settings/store';
|
2019-07-07 11:18:12 +05:30
|
|
|
import { defaultProps } from '../mock';
|
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
|
|
|
describe('error tracking settings form', () => {
|
|
|
|
let wrapper;
|
2019-12-26 22:10:19 +05:30
|
|
|
let store;
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
function mountComponent() {
|
|
|
|
wrapper = shallowMount(ErrorTrackingForm, {
|
|
|
|
localVue,
|
2019-12-26 22:10:19 +05:30
|
|
|
store,
|
2019-07-07 11:18:12 +05:30
|
|
|
propsData: defaultProps,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-12-26 22:10:19 +05:30
|
|
|
store = createStore();
|
2019-07-07 11:18:12 +05:30
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('an empty form', () => {
|
|
|
|
it('is rendered', () => {
|
|
|
|
expect(wrapper.findAll(GlFormInput).length).toBe(2);
|
|
|
|
expect(wrapper.find(GlFormInput).attributes('id')).toBe('error-tracking-api-host');
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(wrapper.findAll(GlFormInput).at(1).attributes('id')).toBe('error-tracking-token');
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(wrapper.findAll(GlButton).exists()).toBe(true);
|
2019-07-07 11:18:12 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('is rendered with labels and placeholders', () => {
|
|
|
|
const pageText = wrapper.text();
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(pageText).toContain(
|
2021-04-29 21:17:54 +05:30
|
|
|
"If you self-host Sentry, enter your Sentry instance's full URL. If you use Sentry's hosted solution, enter https://sentry.io",
|
2020-01-01 13:55:28 +05:30
|
|
|
);
|
2019-07-07 11:18:12 +05:30
|
|
|
expect(pageText).toContain(
|
2021-04-29 21:17:54 +05:30
|
|
|
'After adding your Auth Token, select the Connect button to load projects.',
|
2019-07-07 11:18:12 +05:30
|
|
|
);
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(pageText).not.toContain('Connection failed. Check Auth Token and try again.');
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(wrapper.findAll(GlFormInput).at(0).attributes('placeholder')).toContain(
|
|
|
|
'https://mysentryserver.com',
|
|
|
|
);
|
2019-07-07 11:18:12 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
describe('loading projects', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
store.state.isLoadingProjects = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows loading spinner', () => {
|
2021-01-03 14:25:43 +05:30
|
|
|
const buttonEl = wrapper.find(GlButton);
|
|
|
|
|
|
|
|
expect(buttonEl.props('loading')).toBe(true);
|
|
|
|
expect(buttonEl.text()).toBe('Connecting');
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
describe('after a successful connection', () => {
|
|
|
|
beforeEach(() => {
|
2019-12-26 22:10:19 +05:30
|
|
|
store.state.connectSuccessful = true;
|
2019-07-07 11:18:12 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('shows the success checkmark', () => {
|
|
|
|
expect(wrapper.find('.js-error-tracking-connect-success').isVisible()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show an error', () => {
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(wrapper.text()).not.toContain('Connection failed. Check Auth Token and try again.');
|
2019-07-07 11:18:12 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('after an unsuccessful connection', () => {
|
|
|
|
beforeEach(() => {
|
2019-12-26 22:10:19 +05:30
|
|
|
store.state.connectError = true;
|
2019-07-07 11:18:12 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show the check mark', () => {
|
|
|
|
expect(wrapper.find('.js-error-tracking-connect-success').isVisible()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows an error', () => {
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(wrapper.text()).toContain('Connection failed. Check Auth Token and try again.');
|
2019-07-07 11:18:12 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|