diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-11 21:10:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-11 21:10:36 +0300 |
commit | f020d5dc9bf42fe27b1451af34e7ab3a0c38d344 (patch) | |
tree | 99216543257785d4c444047bcc28d1c1f92db645 /spec/frontend | |
parent | e3042fc5ced749e693ccef81b3f5838c55d5480c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
9 files changed, 124 insertions, 57 deletions
diff --git a/spec/frontend/issues_list/mock_data.js b/spec/frontend/issues_list/mock_data.js index eede806c42f..d6a23c4dcff 100644 --- a/spec/frontend/issues_list/mock_data.js +++ b/spec/frontend/issues_list/mock_data.js @@ -16,6 +16,8 @@ export const locationSearch = [ 'confidential=no', 'iteration_title=season:+%234', 'not[iteration_title]=season:+%2320', + 'epic_id=12', + 'not[epic_id]=34', 'weight=1', 'not[weight]=3', ].join('&'); @@ -24,6 +26,7 @@ export const locationSearchWithSpecialValues = [ 'assignee_id=None', 'my_reaction_emoji=None', 'iteration_id=Current', + 'epic_id=None', 'weight=None', ].join('&'); @@ -42,6 +45,8 @@ export const filteredTokens = [ { type: 'confidential', value: { data: 'no', operator: OPERATOR_IS } }, { type: 'iteration', value: { data: 'season: #4', operator: OPERATOR_IS } }, { type: 'iteration', value: { data: 'season: #20', operator: OPERATOR_IS_NOT } }, + { type: 'epic_id', value: { data: '12', operator: OPERATOR_IS } }, + { type: 'epic_id', value: { data: '34', operator: OPERATOR_IS_NOT } }, { type: 'weight', value: { data: '1', operator: OPERATOR_IS } }, { type: 'weight', value: { data: '3', operator: OPERATOR_IS_NOT } }, { type: 'filtered-search-term', value: { data: 'find' } }, @@ -52,6 +57,7 @@ export const filteredTokensWithSpecialValues = [ { type: 'assignee_username', value: { data: 'None', operator: OPERATOR_IS } }, { type: 'my_reaction_emoji', value: { data: 'None', operator: OPERATOR_IS } }, { type: 'iteration', value: { data: 'Current', operator: OPERATOR_IS } }, + { type: 'epic_id', value: { data: 'None', operator: OPERATOR_IS } }, { type: 'weight', value: { data: 'None', operator: OPERATOR_IS } }, ]; @@ -68,6 +74,8 @@ export const apiParams = { confidential: 'no', iteration_title: 'season: #4', 'not[iteration_title]': 'season: #20', + epic_id: '12', + 'not[epic_id]': '34', weight: '1', 'not[weight]': '3', }; @@ -76,6 +84,7 @@ export const apiParamsWithSpecialValues = { assignee_id: 'None', my_reaction_emoji: 'None', iteration_id: 'Current', + epic_id: 'None', weight: 'None', }; @@ -92,6 +101,8 @@ export const urlParams = { confidential: ['no'], iteration_title: ['season: #4'], 'not[iteration_title]': ['season: #20'], + epic_id: ['12'], + 'not[epic_id]': ['34'], weight: ['1'], 'not[weight]': ['3'], }; @@ -100,5 +111,6 @@ export const urlParamsWithSpecialValues = { assignee_id: ['None'], my_reaction_emoji: ['None'], iteration_id: ['Current'], + epic_id: ['None'], weight: ['None'], }; diff --git a/spec/frontend/members/index_spec.js b/spec/frontend/members/index_spec.js index 751c4674a60..b07534ae4ed 100644 --- a/spec/frontend/members/index_spec.js +++ b/spec/frontend/members/index_spec.js @@ -2,7 +2,7 @@ import { createWrapper } from '@vue/test-utils'; import MembersApp from '~/members/components/app.vue'; import { MEMBER_TYPES } from '~/members/constants'; import { initMembersApp } from '~/members/index'; -import { membersJsonString, members, paginationJsonString, pagination } from './mock_data'; +import { members, pagination, dataAttribute } from './mock_data'; describe('initMembersApp', () => { let el; @@ -23,11 +23,7 @@ describe('initMembersApp', () => { beforeEach(() => { el = document.createElement('div'); - el.setAttribute('data-members', membersJsonString); - el.setAttribute('data-pagination', paginationJsonString); - el.setAttribute('data-source-id', '234'); - el.setAttribute('data-can-manage-members', 'true'); - el.setAttribute('data-member-path', '/groups/foo-bar/-/group_members/:id'); + el.setAttribute('data-members-data', dataAttribute); window.gon = { current_user_id: 123 }; }); diff --git a/spec/frontend/members/mock_data.js b/spec/frontend/members/mock_data.js index 6e1ee979839..d0a7c36349b 100644 --- a/spec/frontend/members/mock_data.js +++ b/spec/frontend/members/mock_data.js @@ -80,13 +80,13 @@ export const inheritedMember = { ...member, isDirectMember: false }; export const member2faEnabled = { ...member, user: { ...member.user, twoFactorEnabled: true } }; -export const paginationJsonString = JSON.stringify({ +export const paginationData = { current_page: 1, per_page: 5, total_items: 10, param_name: 'page', params: { search_groups: null }, -}); +}; export const pagination = { currentPage: 1, @@ -95,3 +95,12 @@ export const pagination = { paramName: 'page', params: { search_groups: null }, }; + +export const dataAttribute = JSON.stringify({ + members, + pagination: paginationData, + source_id: 234, + can_manage_members: true, + member_path: '/groups/foo-bar/-/group_members/:id', + ldap_override_path: '/groups/ldap-group/-/group_members/:id/override', +}); diff --git a/spec/frontend/members/utils_spec.js b/spec/frontend/members/utils_spec.js index 91e99876238..72696979722 100644 --- a/spec/frontend/members/utils_spec.js +++ b/spec/frontend/members/utils_spec.js @@ -20,10 +20,9 @@ import { member2faEnabled, group, invite, - membersJsonString, members, - paginationJsonString, pagination, + dataAttribute, } from './mock_data'; const IS_CURRENT_USER_ID = 123; @@ -260,22 +259,20 @@ describe('Members Utils', () => { beforeEach(() => { el = document.createElement('div'); - el.setAttribute('data-members', membersJsonString); - el.setAttribute('data-pagination', paginationJsonString); - el.setAttribute('data-source-id', '234'); - el.setAttribute('data-can-manage-members', 'true'); + el.setAttribute('data-members-data', dataAttribute); }); afterEach(() => { el = null; }); - it('correctly parses the data attributes', () => { - expect(parseDataAttributes(el)).toEqual({ + it('correctly parses the data attribute', () => { + expect(parseDataAttributes(el)).toMatchObject({ members, pagination, sourceId: 234, canManageMembers: true, + memberPath: '/groups/foo-bar/-/group_members/:id', }); }); }); diff --git a/spec/frontend/packages/details/components/__snapshots__/maven_installation_spec.js.snap b/spec/frontend/packages/details/components/__snapshots__/maven_installation_spec.js.snap index a6bb9e868ee..8a2793c0010 100644 --- a/spec/frontend/packages/details/components/__snapshots__/maven_installation_spec.js.snap +++ b/spec/frontend/packages/details/components/__snapshots__/maven_installation_spec.js.snap @@ -1,16 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`MavenInstallation gradle renders all the messages 1`] = ` +exports[`MavenInstallation groovy renders all the messages 1`] = ` <div> <installation-title-stub - options="[object Object],[object Object]" + options="[object Object],[object Object],[object Object]" packagetype="maven" /> <code-instruction-stub class="gl-mb-5" copytext="Copy Gradle Groovy DSL install command" - instruction="foo/gradle/install" + instruction="foo/gradle/groovy/install" label="Gradle Groovy DSL install command" trackingaction="copy_gradle_install_command" trackinglabel="code_instruction" @@ -18,7 +18,7 @@ exports[`MavenInstallation gradle renders all the messages 1`] = ` <code-instruction-stub copytext="Copy add Gradle Groovy DSL repository command" - instruction="foo/gradle/add/source" + instruction="foo/gradle/groovy/add/source" label="Add Gradle Groovy DSL repository command" multiline="true" trackingaction="copy_gradle_add_to_source_command" @@ -27,10 +27,37 @@ exports[`MavenInstallation gradle renders all the messages 1`] = ` </div> `; +exports[`MavenInstallation kotlin renders all the messages 1`] = ` +<div> + <installation-title-stub + options="[object Object],[object Object],[object Object]" + packagetype="maven" + /> + + <code-instruction-stub + class="gl-mb-5" + copytext="Copy Gradle Kotlin DSL install command" + instruction="foo/gradle/kotlin/install" + label="Gradle Kotlin DSL install command" + trackingaction="copy_kotlin_install_command" + trackinglabel="code_instruction" + /> + + <code-instruction-stub + copytext="Copy add Gradle Kotlin DSL repository command" + instruction="foo/gradle/kotlin/add/source" + label="Add Gradle Kotlin DSL repository command" + multiline="true" + trackingaction="copy_kotlin_add_to_source_command" + trackinglabel="code_instruction" + /> +</div> +`; + exports[`MavenInstallation maven renders all the messages 1`] = ` <div> <installation-title-stub - options="[object Object],[object Object]" + options="[object Object],[object Object],[object Object]" packagetype="maven" /> diff --git a/spec/frontend/packages/details/components/maven_installation_spec.js b/spec/frontend/packages/details/components/maven_installation_spec.js index d49a7c0b561..4972fe70a3d 100644 --- a/spec/frontend/packages/details/components/maven_installation_spec.js +++ b/spec/frontend/packages/details/components/maven_installation_spec.js @@ -17,8 +17,10 @@ describe('MavenInstallation', () => { const xmlCodeBlock = 'foo/xml'; const mavenCommandStr = 'foo/command'; const mavenSetupXml = 'foo/setup'; - const gradleGroovyInstallCommandText = 'foo/gradle/install'; - const gradleGroovyAddSourceCommandText = 'foo/gradle/add/source'; + const gradleGroovyInstallCommandText = 'foo/gradle/groovy/install'; + const gradleGroovyAddSourceCommandText = 'foo/gradle/groovy/add/source'; + const gradleKotlinInstallCommandText = 'foo/gradle/kotlin/install'; + const gradleKotlinAddSourceCommandText = 'foo/gradle/kotlin/add/source'; const store = new Vuex.Store({ state: { @@ -31,6 +33,8 @@ describe('MavenInstallation', () => { mavenSetupXml: () => mavenSetupXml, gradleGroovyInstalCommand: () => gradleGroovyInstallCommandText, gradleGroovyAddSourceCommand: () => gradleGroovyAddSourceCommandText, + gradleKotlinInstalCommand: () => gradleKotlinInstallCommandText, + gradleKotlinAddSourceCommand: () => gradleKotlinAddSourceCommandText, }, }); @@ -59,8 +63,9 @@ describe('MavenInstallation', () => { expect(findInstallationTitle().props()).toMatchObject({ packageType: 'maven', options: [ - { value: 'maven', label: 'Show Maven commands' }, - { value: 'groovy', label: 'Show Gradle Groovy DSL commands' }, + { value: 'maven', label: 'Maven XML' }, + { value: 'groovy', label: 'Gradle Groovy DSL' }, + { value: 'kotlin', label: 'Gradle Kotlin DSL' }, ], }); }); @@ -117,9 +122,9 @@ describe('MavenInstallation', () => { }); }); - describe('gradle', () => { + describe('groovy', () => { beforeEach(() => { - createComponent({ data: { instructionType: 'gradle' } }); + createComponent({ data: { instructionType: 'groovy' } }); }); it('renders all the messages', () => { @@ -146,4 +151,34 @@ describe('MavenInstallation', () => { }); }); }); + + describe('kotlin', () => { + beforeEach(() => { + createComponent({ data: { instructionType: 'kotlin' } }); + }); + + it('renders all the messages', () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + describe('installation commands', () => { + it('renders the gradle install command', () => { + expect(findCodeInstructions().at(0).props()).toMatchObject({ + instruction: gradleKotlinInstallCommandText, + multiline: false, + trackingAction: TrackingActions.COPY_KOTLIN_INSTALL_COMMAND, + }); + }); + }); + + describe('setup commands', () => { + it('renders the correct gradle command', () => { + expect(findCodeInstructions().at(1).props()).toMatchObject({ + instruction: gradleKotlinAddSourceCommandText, + multiline: true, + trackingAction: TrackingActions.COPY_KOTLIN_ADD_TO_SOURCE_COMMAND, + }); + }); + }); + }); }); diff --git a/spec/frontend/packages/details/store/getters_spec.js b/spec/frontend/packages/details/store/getters_spec.js index 005adece56e..8210511bf8f 100644 --- a/spec/frontend/packages/details/store/getters_spec.js +++ b/spec/frontend/packages/details/store/getters_spec.js @@ -19,6 +19,8 @@ import { groupExists, gradleGroovyInstalCommand, gradleGroovyAddSourceCommand, + gradleKotlinInstalCommand, + gradleKotlinAddSourceCommand, } from '~/packages/details/store/getters'; import { conanPackage, @@ -259,6 +261,24 @@ describe('Getters PackageDetails Store', () => { }); }); + describe('gradle kotlin string getters', () => { + it('gets the correct gradleKotlinInstalCommand', () => { + setupState(); + + expect(gradleKotlinInstalCommand(state)).toMatchInlineSnapshot( + `"implementation(\\"com.test.app:test-app:1.0-SNAPSHOT\\")"`, + ); + }); + + it('gets the correct gradleKotlinAddSourceCommand', () => { + setupState(); + + expect(gradleKotlinAddSourceCommand(state)).toMatchInlineSnapshot( + `"maven(\\"foo/registry\\")"`, + ); + }); + }); + describe('check if group', () => { it('is set', () => { setupState({ groupListUrl: '/groups/composer/-/packages' }); diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js b/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js index c49a1ab68b1..3b5d0dba195 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js @@ -139,8 +139,8 @@ export const mockEpicToken = { symbol: '&', token: EpicToken, operators: [{ value: '=', description: 'is', default: 'true' }], + idProperty: 'iid', fetchEpics: () => Promise.resolve({ data: mockEpics }), - fetchSingleEpic: () => Promise.resolve({ data: mockEpics[0] }), }; export const mockReactionEmojiToken = { diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/epic_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/epic_token_spec.js index 0c3f9e1363f..addc058f658 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/epic_token_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/epic_token_spec.js @@ -68,21 +68,6 @@ describe('EpicToken', () => { await wrapper.vm.$nextTick(); }); - describe('currentValue', () => { - it.each` - data | id - ${`${mockEpics[0].title}::&${mockEpics[0].iid}`} | ${mockEpics[0].iid} - ${mockEpics[0].iid} | ${mockEpics[0].iid} - ${'foobar'} | ${'foobar'} - `('$data returns $id', async ({ data, id }) => { - wrapper.setProps({ value: { data } }); - - await wrapper.vm.$nextTick(); - - expect(wrapper.vm.currentValue).toBe(id); - }); - }); - describe('activeEpic', () => { it('returns object for currently present `value.data`', async () => { wrapper.setProps({ @@ -140,20 +125,6 @@ describe('EpicToken', () => { expect(wrapper.vm.loading).toBe(false); }); }); - - describe('fetchSingleEpic', () => { - it('calls `config.fetchSingleEpic` with provided iid param', async () => { - jest.spyOn(wrapper.vm.config, 'fetchSingleEpic'); - - wrapper.vm.fetchSingleEpic(1); - - expect(wrapper.vm.config.fetchSingleEpic).toHaveBeenCalledWith(1); - - await waitForPromises(); - - expect(wrapper.vm.epics).toEqual([mockEpics[0]]); - }); - }); }); describe('template', () => { |