summaryrefslogtreecommitdiff
path: root/spec/frontend/pages
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/pages')
-rw-r--r--spec/frontend/pages/import/bulk_imports/history/components/bulk_imports_history_app_spec.js42
-rw-r--r--spec/frontend/pages/projects/forks/new/components/fork_form_spec.js19
-rw-r--r--spec/frontend/pages/projects/forks/new/components/project_namespace_spec.js42
-rw-r--r--spec/frontend/pages/projects/graphs/__snapshots__/code_coverage_spec.js.snap14
-rw-r--r--spec/frontend/pages/projects/graphs/code_coverage_spec.js12
-rw-r--r--spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js12
-rw-r--r--spec/frontend/pages/projects/pipeline_schedules/shared/components/interval_pattern_input_spec.js2
-rw-r--r--spec/frontend/pages/shared/wikis/components/wiki_content_spec.js6
8 files changed, 90 insertions, 59 deletions
diff --git a/spec/frontend/pages/import/bulk_imports/history/components/bulk_imports_history_app_spec.js b/spec/frontend/pages/import/bulk_imports/history/components/bulk_imports_history_app_spec.js
index 1790a9c9bf5..1a157beebe4 100644
--- a/spec/frontend/pages/import/bulk_imports/history/components/bulk_imports_history_app_spec.js
+++ b/spec/frontend/pages/import/bulk_imports/history/components/bulk_imports_history_app_spec.js
@@ -1,4 +1,4 @@
-import { GlEmptyState, GlLoadingIcon, GlTable } from '@gitlab/ui';
+import { GlEmptyState, GlLoadingIcon, GlTableLite } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
@@ -23,7 +23,9 @@ describe('BulkImportsHistoryApp', () => {
id: 1,
bulk_import_id: 1,
status: 'finished',
+ entity_type: 'group',
source_full_path: 'top-level-group-12',
+ destination_full_path: 'h5bp/top-level-group-12',
destination_name: 'top-level-group-12',
destination_namespace: 'h5bp',
created_at: '2021-07-08T10:03:44.743Z',
@@ -33,8 +35,10 @@ describe('BulkImportsHistoryApp', () => {
id: 2,
bulk_import_id: 2,
status: 'failed',
+ entity_type: 'project',
source_full_path: 'autodevops-demo',
destination_name: 'autodevops-demo',
+ destination_full_path: 'some-group/autodevops-demo',
destination_namespace: 'flightjs',
parent_id: null,
namespace_id: null,
@@ -74,6 +78,7 @@ describe('BulkImportsHistoryApp', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
+ mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
});
afterEach(() => {
@@ -97,11 +102,10 @@ describe('BulkImportsHistoryApp', () => {
});
it('renders table with data when history is available', async () => {
- mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
createComponent();
await axios.waitForAll();
- const table = wrapper.findComponent(GlTable);
+ const table = wrapper.findComponent(GlTableLite);
expect(table.exists()).toBe(true);
// can't use .props() or .attributes() here
expect(table.vm.$attrs.items).toHaveLength(DUMMY_RESPONSE.length);
@@ -110,7 +114,6 @@ describe('BulkImportsHistoryApp', () => {
it('changes page when requested by pagination bar', async () => {
const NEW_PAGE = 4;
- mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
createComponent();
await axios.waitForAll();
mock.resetHistory();
@@ -126,7 +129,6 @@ describe('BulkImportsHistoryApp', () => {
it('changes page size when requested by pagination bar', async () => {
const NEW_PAGE_SIZE = 4;
- mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
createComponent();
await axios.waitForAll();
mock.resetHistory();
@@ -143,7 +145,6 @@ describe('BulkImportsHistoryApp', () => {
it('sets up the local storage sync correctly', async () => {
const NEW_PAGE_SIZE = 4;
- mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
createComponent();
await axios.waitForAll();
mock.resetHistory();
@@ -155,12 +156,37 @@ describe('BulkImportsHistoryApp', () => {
});
it('renders correct url for destination group when relative_url is empty', async () => {
- mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
createComponent({ shallow: false });
await axios.waitForAll();
expect(wrapper.find('tbody tr a').attributes().href).toBe(
- `/${DUMMY_RESPONSE[0].destination_namespace}/${DUMMY_RESPONSE[0].destination_name}`,
+ `/${DUMMY_RESPONSE[0].destination_full_path}`,
+ );
+ });
+
+ it('renders loading icon when destination namespace is not defined', async () => {
+ const RESPONSE = [{ ...DUMMY_RESPONSE[0], destination_full_path: null }];
+
+ mock.onGet(API_URL).reply(200, RESPONSE, DEFAULT_HEADERS);
+ createComponent({ shallow: false });
+ await axios.waitForAll();
+
+ expect(wrapper.find('tbody tr').findComponent(GlLoadingIcon).exists()).toBe(true);
+ });
+
+ it('adds slash to group urls', async () => {
+ createComponent({ shallow: false });
+ await axios.waitForAll();
+
+ expect(wrapper.find('tbody tr a').text()).toBe(`${DUMMY_RESPONSE[0].destination_full_path}/`);
+ });
+
+ it('does not prefixes project urls with slash', async () => {
+ createComponent({ shallow: false });
+ await axios.waitForAll();
+
+ expect(wrapper.findAll('tbody tr a').at(1).text()).toBe(
+ DUMMY_RESPONSE[1].destination_full_path,
);
});
diff --git a/spec/frontend/pages/projects/forks/new/components/fork_form_spec.js b/spec/frontend/pages/projects/forks/new/components/fork_form_spec.js
index 9718d847ed5..aee56247209 100644
--- a/spec/frontend/pages/projects/forks/new/components/fork_form_spec.js
+++ b/spec/frontend/pages/projects/forks/new/components/fork_form_spec.js
@@ -33,6 +33,7 @@ describe('ForkForm component', () => {
const DEFAULT_PROVIDE = {
newGroupPath: 'some/groups/path',
visibilityHelpPath: 'some/visibility/help/path',
+ cancelPath: '/some/project-full-path',
projectFullPath: '/some/project-full-path',
projectId: '10',
projectName: 'Project Name',
@@ -124,13 +125,13 @@ describe('ForkForm component', () => {
const findVisibilityRadioGroup = () =>
wrapper.find('[data-testid="fork-visibility-radio-group"]');
- it('will go to projectFullPath when click cancel button', () => {
+ it('will go to cancelPath when click cancel button', () => {
createComponent();
- const { projectFullPath } = DEFAULT_PROVIDE;
+ const { cancelPath } = DEFAULT_PROVIDE;
const cancelButton = wrapper.find('[data-testid="cancel-button"]');
- expect(cancelButton.attributes('href')).toBe(projectFullPath);
+ expect(cancelButton.attributes('href')).toBe(cancelPath);
});
const selectedMockNamespace = {
@@ -463,16 +464,12 @@ describe('ForkForm component', () => {
expect(urlUtility.redirectTo).not.toHaveBeenCalled();
});
- it('does not make POST request if no visbility is checked', async () => {
+ it('does not make POST request if no visibility is checked', async () => {
jest.spyOn(axios, 'post');
- setupComponent({
- fields: {
- visibility: {
- value: null,
- },
- },
- });
+ setupComponent();
+ wrapper.vm.form.fields.visibility.value = null;
+ await nextTick();
await submitForm();
diff --git a/spec/frontend/pages/projects/forks/new/components/project_namespace_spec.js b/spec/frontend/pages/projects/forks/new/components/project_namespace_spec.js
index f6d3957115f..82f451ed6ef 100644
--- a/spec/frontend/pages/projects/forks/new/components/project_namespace_spec.js
+++ b/spec/frontend/pages/projects/forks/new/components/project_namespace_spec.js
@@ -1,11 +1,4 @@
-import {
- GlButton,
- GlDropdown,
- GlDropdownItem,
- GlDropdownSectionHeader,
- GlSearchBoxByType,
- GlTruncate,
-} from '@gitlab/ui';
+import { GlButton, GlListboxItem, GlCollapsibleListbox } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
@@ -80,17 +73,16 @@ describe('ProjectNamespace component', () => {
};
const findButtonLabel = () => wrapper.findComponent(GlButton);
- const findDropdown = () => wrapper.findComponent(GlDropdown);
- const findDropdownText = () => wrapper.findComponent(GlTruncate);
- const findInput = () => wrapper.findComponent(GlSearchBoxByType);
+ const findListBox = () => wrapper.findComponent(GlCollapsibleListbox);
+ const findListBoxText = () => findListBox().props('toggleText');
- const clickDropdownItem = async () => {
- wrapper.findComponent(GlDropdownItem).vm.$emit('click');
+ const clickListBoxItem = async (value = '') => {
+ wrapper.findComponent(GlListboxItem).vm.$emit('select', value);
await nextTick();
};
const showDropdown = () => {
- findDropdown().vm.$emit('shown');
+ findListBox().vm.$emit('shown');
};
beforeAll(() => {
@@ -115,7 +107,7 @@ describe('ProjectNamespace component', () => {
});
it('renders placeholder text', () => {
- expect(findDropdownText().props('text')).toBe('Select a namespace');
+ expect(findListBoxText()).toBe('Select a namespace');
});
});
@@ -127,24 +119,18 @@ describe('ProjectNamespace component', () => {
showDropdown();
});
- it('focuses on the input when the dropdown is opened', () => {
- const spy = jest.spyOn(findInput().vm, 'focusInput');
- showDropdown();
- expect(spy).toHaveBeenCalledTimes(1);
- });
-
it('displays fetched namespaces', () => {
const listItems = wrapper.findAll('li');
- expect(listItems).toHaveLength(3);
- expect(listItems.at(0).findComponent(GlDropdownSectionHeader).text()).toBe('Namespaces');
- expect(listItems.at(1).text()).toBe(data.project.forkTargets.nodes[0].fullPath);
- expect(listItems.at(2).text()).toBe(data.project.forkTargets.nodes[1].fullPath);
+ expect(listItems).toHaveLength(2);
+ expect(listItems.at(0).text()).toBe(data.project.forkTargets.nodes[0].fullPath);
+ expect(listItems.at(1).text()).toBe(data.project.forkTargets.nodes[1].fullPath);
});
it('sets the selected namespace', async () => {
const { fullPath } = data.project.forkTargets.nodes[0];
- await clickDropdownItem();
- expect(findDropdownText().props('text')).toBe(fullPath);
+ await clickListBoxItem(fullPath);
+
+ expect(findListBoxText()).toBe(fullPath);
});
});
@@ -155,7 +141,7 @@ describe('ProjectNamespace component', () => {
});
it('renders `No matches found`', () => {
- expect(wrapper.find('li').text()).toBe('No matches found');
+ expect(findListBox().text()).toContain('No matches found');
});
});
diff --git a/spec/frontend/pages/projects/graphs/__snapshots__/code_coverage_spec.js.snap b/spec/frontend/pages/projects/graphs/__snapshots__/code_coverage_spec.js.snap
index e7c7ec0d336..d67f842d011 100644
--- a/spec/frontend/pages/projects/graphs/__snapshots__/code_coverage_spec.js.snap
+++ b/spec/frontend/pages/projects/graphs/__snapshots__/code_coverage_spec.js.snap
@@ -45,6 +45,7 @@ exports[`Code Coverage when fetching data is successful matches the snapshot 1`]
toggletext="rspec"
variant="default"
>
+
<!---->
<!---->
@@ -57,22 +58,31 @@ exports[`Code Coverage when fetching data is successful matches the snapshot 1`]
tabindex="-1"
>
<gl-listbox-item-stub
+ data-testid="listbox-item-0"
isselected="true"
>
rspec
</gl-listbox-item-stub>
- <gl-listbox-item-stub>
+ <gl-listbox-item-stub
+ data-testid="listbox-item-1"
+ >
cypress
</gl-listbox-item-stub>
- <gl-listbox-item-stub>
+ <gl-listbox-item-stub
+ data-testid="listbox-item-2"
+ >
karma
</gl-listbox-item-stub>
+
+ <!---->
+
+ <!---->
</ul>
<!---->
diff --git a/spec/frontend/pages/projects/graphs/code_coverage_spec.js b/spec/frontend/pages/projects/graphs/code_coverage_spec.js
index e99734963e3..2ff45266a07 100644
--- a/spec/frontend/pages/projects/graphs/code_coverage_spec.js
+++ b/spec/frontend/pages/projects/graphs/code_coverage_spec.js
@@ -6,7 +6,7 @@ import MockAdapter from 'axios-mock-adapter';
import { nextTick } from 'vue';
import waitForPromises from 'helpers/wait_for_promises';
import axios from '~/lib/utils/axios_utils';
-import httpStatusCodes from '~/lib/utils/http_status';
+import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status';
import CodeCoverage from '~/pages/projects/graphs/components/code_coverage.vue';
import { codeCoverageMockData, sortedDataByDates } from './mock_data';
@@ -49,7 +49,7 @@ describe('Code Coverage', () => {
describe('when fetching data is successful', () => {
beforeEach(() => {
mockAxios = new MockAdapter(axios);
- mockAxios.onGet().replyOnce(httpStatusCodes.OK, codeCoverageMockData);
+ mockAxios.onGet().replyOnce(HTTP_STATUS_OK, codeCoverageMockData);
createComponent();
@@ -84,7 +84,7 @@ describe('Code Coverage', () => {
describe('when fetching data fails', () => {
beforeEach(() => {
mockAxios = new MockAdapter(axios);
- mockAxios.onGet().replyOnce(httpStatusCodes.BAD_REQUEST);
+ mockAxios.onGet().replyOnce(HTTP_STATUS_BAD_REQUEST);
createComponent();
@@ -108,7 +108,7 @@ describe('Code Coverage', () => {
describe('when fetching data succeed but returns an empty state', () => {
beforeEach(() => {
mockAxios = new MockAdapter(axios);
- mockAxios.onGet().replyOnce(httpStatusCodes.OK, []);
+ mockAxios.onGet().replyOnce(HTTP_STATUS_OK, []);
createComponent();
@@ -136,7 +136,7 @@ describe('Code Coverage', () => {
describe('dropdown options', () => {
beforeEach(() => {
mockAxios = new MockAdapter(axios);
- mockAxios.onGet().replyOnce(httpStatusCodes.OK, codeCoverageMockData);
+ mockAxios.onGet().replyOnce(HTTP_STATUS_OK, codeCoverageMockData);
createComponent();
@@ -153,7 +153,7 @@ describe('Code Coverage', () => {
describe('interactions', () => {
beforeEach(() => {
mockAxios = new MockAdapter(axios);
- mockAxios.onGet().replyOnce(httpStatusCodes.OK, codeCoverageMockData);
+ mockAxios.onGet().replyOnce(HTTP_STATUS_OK, codeCoverageMockData);
createComponent();
diff --git a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js
index 897cbf5eaa4..29335308370 100644
--- a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js
+++ b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_section_link_spec.js
@@ -85,6 +85,9 @@ describe('Learn GitLab Section Link', () => {
it('renders a popover trigger with question icon', () => {
expect(findPopoverTrigger().exists()).toBe(true);
expect(findPopoverTrigger().props('icon')).toBe('question-o');
+ expect(findPopoverTrigger().attributes('aria-label')).toBe(
+ LearnGitlabSectionLink.i18n.contactAdmin,
+ );
});
it('renders a popover', () => {
@@ -95,6 +98,15 @@ describe('Learn GitLab Section Link', () => {
});
});
+ it('renders default disabled message', () => {
+ expect(findPopover().text()).toContain(LearnGitlabSectionLink.i18n.contactAdmin);
+ });
+
+ it('renders custom disabled message if provided', () => {
+ createWrapper('trialStarted', { enabled: false, message: 'Custom message' });
+ expect(findPopover().text()).toContain('Custom message');
+ });
+
it('renders a link inside the popover', () => {
expect(findPopoverLink().exists()).toBe(true);
expect(findPopoverLink().attributes('href')).toBe(defaultProps.url);
diff --git a/spec/frontend/pages/projects/pipeline_schedules/shared/components/interval_pattern_input_spec.js b/spec/frontend/pages/projects/pipeline_schedules/shared/components/interval_pattern_input_spec.js
index 99df5b58d90..2d3b9afa8f6 100644
--- a/spec/frontend/pages/projects/pipeline_schedules/shared/components/interval_pattern_input_spec.js
+++ b/spec/frontend/pages/projects/pipeline_schedules/shared/components/interval_pattern_input_spec.js
@@ -138,7 +138,7 @@ describe('Interval Pattern Input Component', () => {
'Every day (at 4:00am)',
'Every week (Monday at 4:00am)',
'Every month (Day 1 at 4:00am)',
- 'Custom ( Cron syntax )',
+ 'Custom ( Learn more. )',
]);
});
});
diff --git a/spec/frontend/pages/shared/wikis/components/wiki_content_spec.js b/spec/frontend/pages/shared/wikis/components/wiki_content_spec.js
index 7c9aae13d25..c8e9a31b526 100644
--- a/spec/frontend/pages/shared/wikis/components/wiki_content_spec.js
+++ b/spec/frontend/pages/shared/wikis/components/wiki_content_spec.js
@@ -5,7 +5,7 @@ import MockAdapter from 'axios-mock-adapter';
import WikiContent from '~/pages/shared/wikis/components/wiki_content.vue';
import { renderGFM } from '~/behaviors/markdown/render_gfm';
import axios from '~/lib/utils/axios_utils';
-import httpStatus from '~/lib/utils/http_status';
+import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status';
import waitForPromises from 'helpers/wait_for_promises';
import { handleLocationHash } from '~/lib/utils/common_utils';
@@ -59,7 +59,7 @@ describe('pages/shared/wikis/components/wiki_content', () => {
const content = 'content';
beforeEach(() => {
- mock.onGet(PATH, { params: { render_html: true } }).replyOnce(httpStatus.OK, { content });
+ mock.onGet(PATH, { params: { render_html: true } }).replyOnce(HTTP_STATUS_OK, { content });
buildWrapper();
return waitForPromises();
});
@@ -88,7 +88,7 @@ describe('pages/shared/wikis/components/wiki_content', () => {
describe('when loading content fails', () => {
beforeEach(() => {
- mock.onGet(PATH).replyOnce(httpStatus.INTERNAL_SERVER_ERROR, '');
+ mock.onGet(PATH).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR, '');
buildWrapper();
return waitForPromises();
});