summaryrefslogtreecommitdiff
path: root/spec/frontend/error_tracking_settings/components/app_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
commit41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch)
tree9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/frontend/error_tracking_settings/components/app_spec.js
parent0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff)
downloadgitlab-ce-7fd8f62e898848bf3d8f058077d7756742ae3bb0.tar.gz
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/frontend/error_tracking_settings/components/app_spec.js')
-rw-r--r--spec/frontend/error_tracking_settings/components/app_spec.js141
1 files changed, 96 insertions, 45 deletions
diff --git a/spec/frontend/error_tracking_settings/components/app_spec.js b/spec/frontend/error_tracking_settings/components/app_spec.js
index 4d19ec047ef..4a0bbb1acbe 100644
--- a/spec/frontend/error_tracking_settings/components/app_spec.js
+++ b/spec/frontend/error_tracking_settings/components/app_spec.js
@@ -18,19 +18,27 @@ describe('error tracking settings app', () => {
let store;
let wrapper;
- function mountComponent() {
+ const defaultProps = {
+ initialEnabled: 'true',
+ initialIntegrated: 'false',
+ initialApiHost: TEST_HOST,
+ initialToken: 'someToken',
+ initialProject: null,
+ listProjectsEndpoint: TEST_HOST,
+ operationsSettingsEndpoint: TEST_HOST,
+ gitlabDsn: TEST_GITLAB_DSN,
+ };
+
+ function mountComponent({
+ glFeatures = { integratedErrorTracking: false },
+ props = defaultProps,
+ } = {}) {
wrapper = extendedWrapper(
shallowMount(ErrorTrackingSettings, {
store, // Override the imported store
- propsData: {
- initialEnabled: 'true',
- initialIntegrated: 'false',
- initialApiHost: TEST_HOST,
- initialToken: 'someToken',
- initialProject: null,
- listProjectsEndpoint: TEST_HOST,
- operationsSettingsEndpoint: TEST_HOST,
- gitlabDsn: TEST_GITLAB_DSN,
+ propsData: { ...props },
+ provide: {
+ glFeatures,
},
stubs: {
GlFormInputGroup, // we need this non-shallow to query for a component within a slot
@@ -47,6 +55,7 @@ describe('error tracking settings app', () => {
const findElementWithText = (wrappers, text) => wrappers.filter((item) => item.text() === text);
const findSentrySettings = () => wrapper.findByTestId('sentry-setting-form');
const findDsnSettings = () => wrapper.findByTestId('gitlab-dsn-setting-form');
+ const findEnabledCheckbox = () => wrapper.findByTestId('error-tracking-enabled');
const enableGitLabErrorTracking = async () => {
findBackendSettingsRadioGroup().vm.$emit('change', true);
@@ -88,62 +97,104 @@ describe('error tracking settings app', () => {
});
describe('tracking-backend settings', () => {
- it('contains a form-group with the correct label', () => {
- expect(findBackendSettingsSection().attributes('label')).toBe('Error tracking backend');
+ it('does not contain backend settings section', () => {
+ expect(findBackendSettingsSection().exists()).toBe(false);
});
- it('contains a radio group', () => {
- expect(findBackendSettingsRadioGroup().exists()).toBe(true);
+ it('shows the sentry form', () => {
+ expect(findSentrySettings().exists()).toBe(true);
});
- it('contains the correct radio buttons', () => {
- expect(findBackendSettingsRadioButtons()).toHaveLength(2);
+ describe('enabled setting is true', () => {
+ describe('integrated setting is true', () => {
+ beforeEach(() => {
+ mountComponent({
+ props: { ...defaultProps, initialEnabled: 'true', initialIntegrated: 'true' },
+ });
+ });
+
+ it('displays enabled as false', () => {
+ expect(findEnabledCheckbox().attributes('checked')).toBeUndefined();
+ });
+ });
+
+ describe('integrated setting is false', () => {
+ beforeEach(() => {
+ mountComponent({
+ props: { ...defaultProps, initialEnabled: 'true', initialIntegrated: 'false' },
+ });
+ });
- expect(findElementWithText(findBackendSettingsRadioButtons(), 'Sentry')).toHaveLength(1);
- expect(findElementWithText(findBackendSettingsRadioButtons(), 'GitLab')).toHaveLength(1);
+ it('displays enabled as true', () => {
+ expect(findEnabledCheckbox().attributes('checked')).toBe('true');
+ });
+ });
});
- it('hides the Sentry settings when GitLab is selected as a tracking-backend', async () => {
- expect(findSentrySettings().exists()).toBe(true);
+ describe('integrated_error_tracking feature flag enabled', () => {
+ beforeEach(() => {
+ mountComponent({
+ glFeatures: { integratedErrorTracking: true },
+ });
+ });
- await enableGitLabErrorTracking();
+ it('contains a form-group with the correct label', () => {
+ expect(findBackendSettingsSection().attributes('label')).toBe('Error tracking backend');
+ });
- expect(findSentrySettings().exists()).toBe(false);
- });
+ it('contains a radio group', () => {
+ expect(findBackendSettingsRadioGroup().exists()).toBe(true);
+ });
- describe('GitLab DSN section', () => {
- it('is visible when GitLab is selected as a tracking-backend and DSN is present', async () => {
- expect(findDsnSettings().exists()).toBe(false);
+ it('contains the correct radio buttons', () => {
+ expect(findBackendSettingsRadioButtons()).toHaveLength(2);
+
+ expect(findElementWithText(findBackendSettingsRadioButtons(), 'Sentry')).toHaveLength(1);
+ expect(findElementWithText(findBackendSettingsRadioButtons(), 'GitLab')).toHaveLength(1);
+ });
+
+ it('hides the Sentry settings when GitLab is selected as a tracking-backend', async () => {
+ expect(findSentrySettings().exists()).toBe(true);
await enableGitLabErrorTracking();
- expect(findDsnSettings().exists()).toBe(true);
+ expect(findSentrySettings().exists()).toBe(false);
});
- it('contains copy-to-clipboard functionality for the GitLab DSN string', async () => {
- await enableGitLabErrorTracking();
+ describe('GitLab DSN section', () => {
+ it('is visible when GitLab is selected as a tracking-backend and DSN is present', async () => {
+ expect(findDsnSettings().exists()).toBe(false);
+
+ await enableGitLabErrorTracking();
+
+ expect(findDsnSettings().exists()).toBe(true);
+ });
- const clipBoardInput = findDsnSettings().findComponent(GlFormInputGroup);
- const clipBoardButton = findDsnSettings().findComponent(ClipboardButton);
+ it('contains copy-to-clipboard functionality for the GitLab DSN string', async () => {
+ await enableGitLabErrorTracking();
- expect(clipBoardInput.props('value')).toBe(TEST_GITLAB_DSN);
- expect(clipBoardInput.attributes('readonly')).toBeTruthy();
- expect(clipBoardButton.props('text')).toBe(TEST_GITLAB_DSN);
+ const clipBoardInput = findDsnSettings().findComponent(GlFormInputGroup);
+ const clipBoardButton = findDsnSettings().findComponent(ClipboardButton);
+
+ expect(clipBoardInput.props('value')).toBe(TEST_GITLAB_DSN);
+ expect(clipBoardInput.attributes('readonly')).toBeTruthy();
+ expect(clipBoardButton.props('text')).toBe(TEST_GITLAB_DSN);
+ });
});
- });
- it.each([true, false])(
- 'calls the `updateIntegrated` action when the setting changes to `%s`',
- (integrated) => {
- jest.spyOn(store, 'dispatch').mockImplementation();
+ it.each([true, false])(
+ 'calls the `updateIntegrated` action when the setting changes to `%s`',
+ (integrated) => {
+ jest.spyOn(store, 'dispatch').mockImplementation();
- expect(store.dispatch).toHaveBeenCalledTimes(0);
+ expect(store.dispatch).toHaveBeenCalledTimes(0);
- findBackendSettingsRadioGroup().vm.$emit('change', integrated);
+ findBackendSettingsRadioGroup().vm.$emit('change', integrated);
- expect(store.dispatch).toHaveBeenCalledTimes(1);
- expect(store.dispatch).toHaveBeenCalledWith('updateIntegrated', integrated);
- },
- );
+ expect(store.dispatch).toHaveBeenCalledTimes(1);
+ expect(store.dispatch).toHaveBeenCalledWith('updateIntegrated', integrated);
+ },
+ );
+ });
});
});