diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-05 00:10:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-05 00:10:01 +0300 |
commit | 4f49d2c8cd9b0c54c1055480df5cde2e13d7c76d (patch) | |
tree | 95bf867b726c30a822c1564a05f6785b4add156a /spec | |
parent | 24f8aa38dc0ddd3489f0c98d5dd0517096caf05e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap | 2 | ||||
-rw-r--r-- | spec/frontend/jira_connect/components/groups_list_spec.js | 64 |
2 files changed, 64 insertions, 2 deletions
diff --git a/spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap b/spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap index 5796b3fa44e..85d21f231b1 100644 --- a/spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap +++ b/spec/frontend/incidents_settings/components/__snapshots__/alerts_form_spec.js.snap @@ -90,7 +90,7 @@ exports[`Alert integration settings form default state should match the default checked="true" > <span> - Automatically close incidents when the associated Prometheus alert resolves. + Automatically close associated incident when a recovery alert notification resolves an alert </span> </gl-form-checkbox-stub> </gl-form-group-stub> diff --git a/spec/frontend/jira_connect/components/groups_list_spec.js b/spec/frontend/jira_connect/components/groups_list_spec.js index f354cfe6a9b..71eb01db7d7 100644 --- a/spec/frontend/jira_connect/components/groups_list_spec.js +++ b/spec/frontend/jira_connect/components/groups_list_spec.js @@ -1,12 +1,24 @@ -import { GlAlert, GlLoadingIcon, GlSearchBoxByType } from '@gitlab/ui'; +import { GlAlert, GlLoadingIcon, GlSearchBoxByType, GlPagination } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { fetchGroups } from '~/jira_connect/api'; import GroupsList from '~/jira_connect/components/groups_list.vue'; import GroupsListItem from '~/jira_connect/components/groups_list_item.vue'; +import { DEFAULT_GROUPS_PER_PAGE } from '~/jira_connect/constants'; import { mockGroup1, mockGroup2 } from '../mock_data'; +const createMockGroup = (groupId) => { + return { + ...mockGroup1, + id: groupId, + }; +}; + +const createMockGroups = (count) => { + return [...new Array(count)].map((_, idx) => createMockGroup(idx)); +}; + jest.mock('~/jira_connect/api', () => { return { fetchGroups: jest.fn(), @@ -42,6 +54,7 @@ describe('GroupsList', () => { const findSecondItem = () => findAllItems().at(1); const findSearchBox = () => wrapper.findComponent(GlSearchBoxByType); const findGroupsList = () => wrapper.findByTestId('groups-list'); + const findPagination = () => wrapper.findComponent(GlPagination); describe('when groups are loading', () => { it('renders loading icon', async () => { @@ -167,4 +180,53 @@ describe('GroupsList', () => { }); }); }); + + describe('pagination', () => { + it.each` + scenario | totalItems | shouldShowPagination + ${'renders pagination'} | ${DEFAULT_GROUPS_PER_PAGE + 1} | ${true} + ${'does not render pagination'} | ${DEFAULT_GROUPS_PER_PAGE} | ${false} + ${'does not render pagination'} | ${2} | ${false} + ${'does not render pagination'} | ${0} | ${false} + `('$scenario with $totalItems groups', async ({ totalItems, shouldShowPagination }) => { + const mockGroups = createMockGroups(totalItems); + fetchGroups.mockResolvedValue({ + headers: { 'X-TOTAL': totalItems, 'X-PAGE': 1 }, + data: mockGroups, + }); + createComponent(); + + await waitForPromises(); + + const paginationEl = findPagination(); + + expect(paginationEl.exists()).toBe(shouldShowPagination); + if (shouldShowPagination) { + expect(paginationEl.props('totalItems')).toBe(totalItems); + } + }); + + describe('when `input` event triggered', () => { + beforeEach(async () => { + const MOCK_TOTAL_ITEMS = DEFAULT_GROUPS_PER_PAGE + 1; + fetchGroups.mockResolvedValue({ + headers: { 'X-TOTAL': MOCK_TOTAL_ITEMS, 'X-PAGE': 1 }, + data: createMockGroups(MOCK_TOTAL_ITEMS), + }); + + createComponent(); + await waitForPromises(); + }); + + it('executes `fetchGroups` with correct arguments', async () => { + const paginationEl = findPagination(); + paginationEl.vm.$emit('input', 2); + + expect(fetchGroups).toHaveBeenCalledWith(mockGroupsPath, { + page: 2, + perPage: 10, + }); + }); + }); + }); }); |