diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-16 00:07:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-16 00:07:57 +0300 |
commit | 512177dcc7369c6c3f4ae54cc8a0abcb73828f71 (patch) | |
tree | 3ceb4aba221a235c570f6f7e5398b88a381e3ead /spec | |
parent | 7f08e6916d8259a8ed1549cb54460f0b746d9d8b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
8 files changed, 70 insertions, 22 deletions
diff --git a/spec/features/admin/admin_broadcast_messages_spec.rb b/spec/features/admin/admin_broadcast_messages_spec.rb index 94111841562..e40f4c4678c 100644 --- a/spec/features/admin/admin_broadcast_messages_spec.rb +++ b/spec/features/admin/admin_broadcast_messages_spec.rb @@ -26,8 +26,8 @@ RSpec.describe 'Admin Broadcast Messages' do fill_in 'broadcast_message_target_path', with: '*/user_onboarded' fill_in 'broadcast_message_font', with: '#b94a48' select Date.today.next_year.year, from: 'broadcast_message_ends_at_1i' - select 'Guest', from: 'broadcast_message_target_access_levels' - select 'Owner', from: 'broadcast_message_target_access_levels' + check 'Guest' + check 'Owner' click_button 'Add broadcast message' expect(page).to have_current_path admin_broadcast_messages_path, ignore_query: true @@ -43,9 +43,9 @@ RSpec.describe 'Admin Broadcast Messages' do fill_in 'broadcast_message_target_path', with: '*/user_onboarded' select 'Notification', from: 'broadcast_message_broadcast_type' select Date.today.next_year.year, from: 'broadcast_message_ends_at_1i' - select 'Reporter', from: 'broadcast_message_target_access_levels' - select 'Developer', from: 'broadcast_message_target_access_levels' - select 'Maintainer', from: 'broadcast_message_target_access_levels' + check 'Reporter' + check 'Developer' + check 'Maintainer' click_button 'Add broadcast message' expect(page).to have_current_path admin_broadcast_messages_path, ignore_query: true @@ -59,7 +59,7 @@ RSpec.describe 'Admin Broadcast Messages' do it 'edit an existing broadcast message' do click_link 'Edit' fill_in 'broadcast_message_message', with: 'Application update RIGHT NOW' - select 'Reporter', from: 'broadcast_message_target_access_levels' + check 'Reporter' click_button 'Update broadcast message' expect(page).to have_current_path admin_broadcast_messages_path, ignore_query: true diff --git a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb index 8343e04aef1..231722c166d 100644 --- a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb +++ b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb @@ -140,7 +140,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do describe 'reply form' do before do - click_button 'Toggle thread' + click_button _('Show thread') end it 'allows user to comment' do @@ -362,7 +362,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do it 'displays next thread even if hidden' do page.all('.note-discussion', count: 2).each do |discussion| page.within discussion do - click_button 'Toggle thread' + click_button _('Hide thread') end end @@ -549,13 +549,13 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do it 'shows resolved icon' do expect(page).to have_content 'All threads resolved' - click_button 'Toggle thread' + click_button _('Show thread') expect(page).to have_selector('.line-resolve-btn.is-active') end it 'does not allow user to click resolve button' do expect(page).to have_selector('.line-resolve-btn.is-active') - click_button 'Toggle thread' + click_button _('Show thread') expect(page).to have_selector('.line-resolve-btn.is-active') end diff --git a/spec/frontend/lib/utils/array_utility_spec.js b/spec/frontend/lib/utils/array_utility_spec.js index b95286ff254..64ddd400114 100644 --- a/spec/frontend/lib/utils/array_utility_spec.js +++ b/spec/frontend/lib/utils/array_utility_spec.js @@ -29,4 +29,17 @@ describe('array_utility', () => { }, ); }); + + describe('getDuplicateItemsFromArray', () => { + it.each` + array | result + ${[]} | ${[]} + ${[1, 2, 2, 3, 3, 4]} | ${[2, 3]} + ${[1, 2, 3, 2, 3, 4]} | ${[2, 3]} + ${['foo', 'bar', 'bar', 'foo', 'baz']} | ${['bar', 'foo']} + ${['foo', 'foo', 'bar', 'foo', 'bar']} | ${['foo', 'bar']} + `('given $array will return $result', ({ array, result }) => { + expect(arrayUtils.getDuplicateItemsFromArray(array)).toEqual(result); + }); + }); }); diff --git a/spec/frontend/notes/components/note_header_spec.js b/spec/frontend/notes/components/note_header_spec.js index 8d82cf3d2c7..4671d33219d 100644 --- a/spec/frontend/notes/components/note_header_spec.js +++ b/spec/frontend/notes/components/note_header_spec.js @@ -1,7 +1,7 @@ import { GlSprintf } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import NoteHeader from '~/notes/components/note_header.vue'; import { AVAILABILITY_STATUS } from '~/set_status_modal/utils'; import UserNameWithStatus from '~/sidebar/components/assignees/user_name_with_status.vue'; @@ -16,11 +16,12 @@ describe('NoteHeader component', () => { let wrapper; const findActionsWrapper = () => wrapper.find({ ref: 'discussionActions' }); + const findToggleThreadButton = () => wrapper.findByTestId('thread-toggle'); const findChevronIcon = () => wrapper.find({ ref: 'chevronIcon' }); const findActionText = () => wrapper.find({ ref: 'actionText' }); const findTimestampLink = () => wrapper.find({ ref: 'noteTimestampLink' }); const findTimestamp = () => wrapper.find({ ref: 'noteTimestamp' }); - const findConfidentialIndicator = () => wrapper.find('[data-testid="confidentialIndicator"]'); + const findConfidentialIndicator = () => wrapper.findByTestId('confidentialIndicator'); const findSpinner = () => wrapper.find({ ref: 'spinner' }); const findAuthorStatus = () => wrapper.find({ ref: 'authorStatus' }); @@ -40,7 +41,7 @@ describe('NoteHeader component', () => { }; const createComponent = (props) => { - wrapper = shallowMount(NoteHeader, { + wrapper = shallowMountExtended(NoteHeader, { store: new Vuex.Store({ actions, }), @@ -98,6 +99,19 @@ describe('NoteHeader component', () => { expect(findChevronIcon().props('name')).toBe('chevron-down'); }); + + it.each` + text | expanded + ${NoteHeader.i18n.showThread} | ${false} + ${NoteHeader.i18n.hideThread} | ${true} + `('toggle button has text $text is expanded is $expanded', ({ text, expanded }) => { + createComponent({ + includeToggle: true, + expanded, + }); + + expect(findToggleThreadButton().text()).toBe(text); + }); }); it('renders an author link if author is passed to props', () => { diff --git a/spec/frontend/releases/components/asset_links_form_spec.js b/spec/frontend/releases/components/asset_links_form_spec.js index c0f7738bec5..17f079ba5a6 100644 --- a/spec/frontend/releases/components/asset_links_form_spec.js +++ b/spec/frontend/releases/components/asset_links_form_spec.js @@ -256,9 +256,7 @@ describe('Release edit component', () => { }, }); - expect(findUrlValidationMessage().text()).toBe( - 'This URL is already used for another link; duplicate URLs are not allowed', - ); + expect(findUrlValidationMessage().text()).toBe('This URL already exists.'); }); it('shows a validation error message when a URL has a bad format', () => { diff --git a/spec/frontend/releases/stores/modules/detail/getters_spec.js b/spec/frontend/releases/stores/modules/detail/getters_spec.js index 66f24ac9559..c32969c131e 100644 --- a/spec/frontend/releases/stores/modules/detail/getters_spec.js +++ b/spec/frontend/releases/stores/modules/detail/getters_spec.js @@ -134,6 +134,14 @@ describe('Release edit/new getters', () => { // Missing title { id: 7, url: 'https://example.com/valid/1', name: '' }, { id: 8, url: 'https://example.com/valid/2', name: ' ' }, + + // Duplicate title + { id: 9, url: 'https://example.com/1', name: 'Link 7' }, + { id: 10, url: 'https://example.com/2', name: 'Link 7' }, + + // title validation ignores leading/trailing whitespace + { id: 11, url: 'https://example.com/3', name: ' Link 7\t ' }, + { id: 12, url: 'https://example.com/4', name: ' Link 7\n\r\n ' }, ], }, }, @@ -201,6 +209,21 @@ describe('Release edit/new getters', () => { expect(actualErrors).toMatchObject(expectedErrors); }); + + it('returns a validation error if links share a title', () => { + const expectedErrors = { + assets: { + links: { + 9: { isTitleDuplicate: true }, + 10: { isTitleDuplicate: true }, + 11: { isTitleDuplicate: true }, + 12: { isTitleDuplicate: true }, + }, + }, + }; + + expect(actualErrors).toMatchObject(expectedErrors); + }); }); }); diff --git a/spec/frontend/security_configuration/components/training_provider_list_spec.js b/spec/frontend/security_configuration/components/training_provider_list_spec.js index 5e2efa2425c..db56f77b60e 100644 --- a/spec/frontend/security_configuration/components/training_provider_list_spec.js +++ b/spec/frontend/security_configuration/components/training_provider_list_spec.js @@ -89,7 +89,7 @@ describe('TrainingProviderList component', () => { const findPrimaryProviderRadios = () => wrapper.findAllByTestId('primary-provider-radio'); const findLoader = () => wrapper.findComponent(GlSkeletonLoader); const findErrorAlert = () => wrapper.findComponent(GlAlert); - const findLogos = () => wrapper.findAll('img'); + const findLogos = () => wrapper.findAllByTestId('provider-logo'); const toggleFirstProvider = () => findFirstToggle().vm.$emit('change', testProviderIds[0]); @@ -205,15 +205,15 @@ describe('TrainingProviderList component', () => { const providerIndexArray = [0, 1]; it.each(providerIndexArray)('displays the correct width for provider %s', (provider) => { - expect(findLogos().at(provider).attributes('width')).toBe('18'); + expect(findLogos().at(provider).attributes('style')).toBe('width: 18px;'); }); it.each(providerIndexArray)('has a11y decorative attribute for provider %s', (provider) => { expect(findLogos().at(provider).attributes('role')).toBe('presentation'); }); - it.each(providerIndexArray)('displays the correct svg path for provider %s', (provider) => { - expect(findLogos().at(provider).attributes('src')).toBe( + it.each(providerIndexArray)('renders the svg content for provider %s', (provider) => { + expect(findLogos().at(provider).html()).toContain( tempProviderLogos[testProviderName[provider]].svg, ); }); diff --git a/spec/frontend/security_configuration/mock_data.js b/spec/frontend/security_configuration/mock_data.js index 21d7140bf89..55f5c20e45d 100644 --- a/spec/frontend/security_configuration/mock_data.js +++ b/spec/frontend/security_configuration/mock_data.js @@ -105,9 +105,9 @@ export const updateSecurityTrainingProvidersErrorResponse = { // https://gitlab.com/gitlab-org/gitlab/-/issues/346899 export const tempProviderLogos = { [testProviderName[0]]: { - svg: '/assets/illustrations/vulnerability/vendor-1.svg', + svg: `<svg>${[testProviderName[0]]}</svg>`, }, [testProviderName[1]]: { - svg: '/assets/illustrations/vulnerability/vendor-2.svg', + svg: `<svg>${[testProviderName[1]]}</svg>`, }, }; |