diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/frontend/import_entities/import_groups/components/import_table_spec.js | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/frontend/import_entities/import_groups/components/import_table_spec.js')
-rw-r--r-- | spec/frontend/import_entities/import_groups/components/import_table_spec.js | 107 |
1 files changed, 97 insertions, 10 deletions
diff --git a/spec/frontend/import_entities/import_groups/components/import_table_spec.js b/spec/frontend/import_entities/import_groups/components/import_table_spec.js index 6e3df21e30a..b17ff2e0f52 100644 --- a/spec/frontend/import_entities/import_groups/components/import_table_spec.js +++ b/spec/frontend/import_entities/import_groups/components/import_table_spec.js @@ -1,4 +1,4 @@ -import { GlEmptyState, GlLoadingIcon } from '@gitlab/ui'; +import { GlAlert, GlEmptyState, GlLoadingIcon } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; @@ -33,13 +33,23 @@ describe('import table', () => { generateFakeEntry({ id: 2, status: STATUSES.FINISHED }), ]; const FAKE_PAGE_INFO = { page: 1, perPage: 20, total: 40, totalPages: 2 }; + const FAKE_VERSION_VALIDATION = { + features: { + projectMigration: { available: false, minVersion: '14.8.0' }, + sourceInstanceVersion: '14.6.0', + }, + }; const findImportSelectedButton = () => wrapper.findAll('button').wrappers.find((w) => w.text() === 'Import selected'); const findImportButtons = () => wrapper.findAll('button').wrappers.filter((w) => w.text() === 'Import'); - const findPaginationDropdown = () => wrapper.find('[aria-label="Page size"]'); + const findPaginationDropdown = () => wrapper.find('[data-testid="page-size"]'); const findPaginationDropdownText = () => findPaginationDropdown().find('button').text(); + const findSelectionCount = () => wrapper.find('[data-test-id="selection-count"]'); + + const triggerSelectAllCheckbox = () => + wrapper.find('thead input[type=checkbox]').trigger('click'); const selectRow = (idx) => wrapper.findAll('tbody td input[type=checkbox]').at(idx).trigger('click'); @@ -104,6 +114,7 @@ describe('import table', () => { bulkImportSourceGroups: () => ({ nodes: [], pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); await waitForPromises(); @@ -117,6 +128,7 @@ describe('import table', () => { bulkImportSourceGroups: () => ({ nodes: FAKE_GROUPS, pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); await waitForPromises(); @@ -129,6 +141,7 @@ describe('import table', () => { bulkImportSourceGroups: jest.fn().mockResolvedValue({ nodes: [], pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); await waitForPromises(); @@ -138,7 +151,11 @@ describe('import table', () => { it('invokes importGroups mutation when row button is clicked', async () => { createComponent({ - bulkImportSourceGroups: () => ({ nodes: [FAKE_GROUP], pageInfo: FAKE_PAGE_INFO }), + bulkImportSourceGroups: () => ({ + nodes: [FAKE_GROUP], + pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, + }), }); jest.spyOn(apolloProvider.defaultClient, 'mutate'); @@ -162,7 +179,11 @@ describe('import table', () => { it('displays error if importing group fails', async () => { createComponent({ - bulkImportSourceGroups: () => ({ nodes: [FAKE_GROUP], pageInfo: FAKE_PAGE_INFO }), + bulkImportSourceGroups: () => ({ + nodes: [FAKE_GROUP], + pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, + }), importGroups: () => { throw new Error(); }, @@ -182,9 +203,11 @@ describe('import table', () => { }); describe('pagination', () => { - const bulkImportSourceGroupsQueryMock = jest - .fn() - .mockResolvedValue({ nodes: [FAKE_GROUP], pageInfo: FAKE_PAGE_INFO }); + const bulkImportSourceGroupsQueryMock = jest.fn().mockResolvedValue({ + nodes: [FAKE_GROUP], + pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, + }); beforeEach(() => { createComponent({ @@ -205,7 +228,13 @@ describe('import table', () => { const otherOption = findPaginationDropdown().findAll('li p').at(1); expect(otherOption.text()).toMatchInterpolatedText('50 items per page'); + bulkImportSourceGroupsQueryMock.mockResolvedValue({ + nodes: [FAKE_GROUP], + pageInfo: { ...FAKE_PAGE_INFO, perPage: 50 }, + versionValidation: FAKE_VERSION_VALIDATION, + }); await otherOption.trigger('click'); + await waitForPromises(); expect(findPaginationDropdownText()).toMatchInterpolatedText('50 items per page'); @@ -234,6 +263,7 @@ describe('import table', () => { perPage: 20, totalPages: 2, }, + versionValidation: FAKE_VERSION_VALIDATION, }); wrapper.find(PaginationLinks).props().change(REQUESTED_PAGE); await waitForPromises(); @@ -243,9 +273,11 @@ describe('import table', () => { }); describe('filters', () => { - const bulkImportSourceGroupsQueryMock = jest - .fn() - .mockResolvedValue({ nodes: [FAKE_GROUP], pageInfo: FAKE_PAGE_INFO }); + const bulkImportSourceGroupsQueryMock = jest.fn().mockResolvedValue({ + nodes: [FAKE_GROUP], + pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, + }); beforeEach(() => { createComponent({ @@ -313,11 +345,28 @@ describe('import table', () => { }); describe('bulk operations', () => { + it('import all button correctly selects/deselects all groups', async () => { + createComponent({ + bulkImportSourceGroups: () => ({ + nodes: FAKE_GROUPS, + pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, + }), + }); + await waitForPromises(); + expect(findSelectionCount().text()).toMatchInterpolatedText('0 selected'); + await triggerSelectAllCheckbox(); + expect(findSelectionCount().text()).toMatchInterpolatedText('2 selected'); + await triggerSelectAllCheckbox(); + expect(findSelectionCount().text()).toMatchInterpolatedText('0 selected'); + }); + it('import selected button is disabled when no groups selected', async () => { createComponent({ bulkImportSourceGroups: () => ({ nodes: FAKE_GROUPS, pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); await waitForPromises(); @@ -330,6 +379,7 @@ describe('import table', () => { bulkImportSourceGroups: () => ({ nodes: FAKE_GROUPS, pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); await waitForPromises(); @@ -346,6 +396,7 @@ describe('import table', () => { bulkImportSourceGroups: () => ({ nodes: NEW_GROUPS, pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); await waitForPromises(); @@ -368,6 +419,7 @@ describe('import table', () => { bulkImportSourceGroups: () => ({ nodes: NEW_GROUPS, pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); await waitForPromises(); @@ -391,6 +443,7 @@ describe('import table', () => { bulkImportSourceGroups: () => ({ nodes: NEW_GROUPS, pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, }), }); jest.spyOn(apolloProvider.defaultClient, 'mutate'); @@ -421,4 +474,38 @@ describe('import table', () => { }); }); }); + + describe('unavailable features warning', () => { + it('renders alert when there are unavailable features', async () => { + createComponent({ + bulkImportSourceGroups: () => ({ + nodes: FAKE_GROUPS, + pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, + }), + }); + await waitForPromises(); + + expect(wrapper.find(GlAlert).exists()).toBe(true); + expect(wrapper.find(GlAlert).text()).toContain('projects (require v14.8.0)'); + }); + + it('does not renders alert when there are no unavailable features', async () => { + createComponent({ + bulkImportSourceGroups: () => ({ + nodes: FAKE_GROUPS, + pageInfo: FAKE_PAGE_INFO, + versionValidation: { + features: { + projectMigration: { available: true, minVersion: '14.8.0' }, + sourceInstanceVersion: '14.6.0', + }, + }, + }), + }); + await waitForPromises(); + + expect(wrapper.find(GlAlert).exists()).toBe(false); + }); + }); }); |