diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-22 12:18:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-22 12:18:00 +0300 |
commit | 932d504aaadc03b978eccad962a12be93f84be47 (patch) | |
tree | da6fba1cb0b34d8a5c8ecd57f85b23fc3ee9ed63 /spec | |
parent | c123291db91a8c54865779ee29ddebaad159d147 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
9 files changed, 114 insertions, 13 deletions
diff --git a/spec/features/incidents/incident_details_spec.rb b/spec/features/incidents/incident_details_spec.rb index b704a0515c8..dbcd524cad0 100644 --- a/spec/features/incidents/incident_details_spec.rb +++ b/spec/features/incidents/incident_details_spec.rb @@ -21,7 +21,7 @@ RSpec.describe 'Incident details', :js do context 'when a developer+ displays the incident' do it 'shows the incident' do page.within('.issuable-details') do - expect(find('h2')).to have_content(incident.title) + expect(find('h1')).to have_content(incident.title) end end @@ -33,7 +33,7 @@ RSpec.describe 'Incident details', :js do page.within('.issuable-details') do incident_tabs = find('[data-testid="incident-tabs"]') - expect(find('h2')).to have_content(incident.title) + expect(find('h1')).to have_content(incident.title) expect(incident_tabs).to have_content('Summary') expect(incident_tabs).to have_content(incident.description) end diff --git a/spec/features/issues/incident_issue_spec.rb b/spec/features/issues/incident_issue_spec.rb index 3033a138551..2956ddede2e 100644 --- a/spec/features/issues/incident_issue_spec.rb +++ b/spec/features/issues/incident_issue_spec.rb @@ -38,7 +38,7 @@ RSpec.describe 'Incident Detail', :js do incident_tabs = find('[data-testid="incident-tabs"]') aggregate_failures 'shows title and Summary tab' do - expect(find('h2')).to have_content(incident.title) + expect(find('h1')).to have_content(incident.title) expect(incident_tabs).to have_content('Summary') expect(incident_tabs).to have_content(incident.description) end diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index b37c8e9d1cf..88709d66887 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'Issue Detail', :js do it 'shows the issue' do page.within('.issuable-details') do - expect(find('h2')).to have_content(issue.title) + expect(find('h1')).to have_content(issue.title) end end end @@ -85,7 +85,7 @@ RSpec.describe 'Issue Detail', :js do it 'shows the issue' do page.within('.issuable-details') do - expect(find('h2')).to have_content(issue.reload.title) + expect(find('h1')).to have_content(issue.reload.title) end end end diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb index 70d7deadec3..de9888295b9 100644 --- a/spec/features/issues/spam_issues_spec.rb +++ b/spec/features/issues/spam_issues_spec.rb @@ -66,7 +66,7 @@ RSpec.describe 'New issue', :js do it 'allows issue creation' do click_button 'Create issue' - expect(page.find('.issue-details h2.title')).to have_content('issue title') + expect(page.find('.issue-details h1.title')).to have_content('issue title') expect(page.find('.issue-details .description')).to have_content('issue description') end @@ -111,7 +111,7 @@ RSpec.describe 'New issue', :js do click_button 'Create issue' - expect(page.find('.issue-details h2.title')).to have_content('issue title') + expect(page.find('.issue-details h1.title')).to have_content('issue title') expect(page.find('.issue-details .description')).to have_content('issue description') end end @@ -126,7 +126,7 @@ RSpec.describe 'New issue', :js do click_button 'Create issue' expect(page).not_to have_css('.recaptcha') - expect(page.find('.issue-details h2.title')).to have_content('issue title') + expect(page.find('.issue-details h1.title')).to have_content('issue title') expect(page.find('.issue-details .description')).to have_content('issue description') end @@ -152,7 +152,7 @@ RSpec.describe 'New issue', :js do click_button 'Create issue' expect(page).not_to have_css('.recaptcha') - expect(page.find('.issue-details h2.title')).to have_content('issue title') + expect(page.find('.issue-details h1.title')).to have_content('issue title') expect(page.find('.issue-details .description')).to have_content('issue description') end @@ -181,7 +181,7 @@ RSpec.describe 'New issue', :js do click_button 'Create issue' - expect(page.find('.issue-details h2.title')).to have_content('issue title') + expect(page.find('.issue-details h1.title')).to have_content('issue title') expect(page.find('.issue-details .description')).to have_content('issue description') end end diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb index a064eef5cc8..479199b72b7 100644 --- a/spec/features/labels_hierarchy_spec.rb +++ b/spec/features/labels_hierarchy_spec.rb @@ -160,7 +160,7 @@ RSpec.describe 'Labels Hierarchy', :js do find('.btn-confirm').click - expect(page.find('.issue-details h2.title')).to have_content('new created issue') + expect(page.find('.issue-details h1.title')).to have_content('new created issue') expect(page).to have_selector('span.gl-label-text', text: grandparent_group_label.title) expect(page).to have_selector('span.gl-label-text', text: parent_group_label.title) expect(page).to have_selector('span.gl-label-text', text: project_label_1.title) 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 18c9ada6bde..4d92f0cca22 100644 --- a/spec/frontend/security_configuration/components/training_provider_list_spec.js +++ b/spec/frontend/security_configuration/components/training_provider_list_spec.js @@ -8,6 +8,8 @@ import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { TRACK_TOGGLE_TRAINING_PROVIDER_ACTION, TRACK_TOGGLE_TRAINING_PROVIDER_LABEL, + TRACK_PROVIDER_LEARN_MORE_CLICK_ACTION, + TRACK_PROVIDER_LEARN_MORE_CLICK_LABEL, } from '~/security_configuration/constants'; import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue'; import securityTrainingProvidersQuery from '~/security_configuration/graphql/security_training_providers.query.graphql'; @@ -244,6 +246,24 @@ describe('TrainingProviderList component', () => { }, }); }); + + it(`tracks when a provider's "Learn more" link is clicked`, () => { + const firstProviderLink = findLinks().at(0); + const [{ id: firstProviderId }] = securityTrainingProviders; + + expect(trackingSpy).not.toHaveBeenCalled(); + + firstProviderLink.vm.$emit('click'); + + expect(trackingSpy).toHaveBeenCalledWith( + undefined, + TRACK_PROVIDER_LEARN_MORE_CLICK_ACTION, + { + label: TRACK_PROVIDER_LEARN_MORE_CLICK_LABEL, + property: firstProviderId, + }, + ); + }); }); }); diff --git a/spec/frontend/vue_mr_widget/components/extensions/child_content_spec.js b/spec/frontend/vue_mr_widget/components/extensions/child_content_spec.js new file mode 100644 index 00000000000..198a4c2823a --- /dev/null +++ b/spec/frontend/vue_mr_widget/components/extensions/child_content_spec.js @@ -0,0 +1,40 @@ +import { shallowMount } from '@vue/test-utils'; +import ChildContent from '~/vue_merge_request_widget/components/extensions/child_content.vue'; + +let wrapper; +const mockData = () => ({ + header: 'Test header', + text: 'Test content', + icon: { + name: 'error', + }, +}); + +function factory(propsData) { + wrapper = shallowMount(ChildContent, { + propsData: { + ...propsData, + widgetLabel: 'Test', + }, + }); +} + +describe('MR widget extension child content', () => { + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + it('renders child components', () => { + factory({ + data: { + ...mockData(), + children: [mockData()], + }, + level: 2, + }); + + expect(wrapper.find('[data-testid="child-content"]').exists()).toBe(true); + expect(wrapper.find('[data-testid="child-content"]').props('level')).toBe(3); + }); +}); diff --git a/spec/frontend/vue_shared/issuable/show/components/issuable_title_spec.js b/spec/frontend/vue_shared/issuable/show/components/issuable_title_spec.js index 93de6dbe306..11e3302d409 100644 --- a/spec/frontend/vue_shared/issuable/show/components/issuable_title_spec.js +++ b/spec/frontend/vue_shared/issuable/show/components/issuable_title_spec.js @@ -66,10 +66,12 @@ describe('IssuableTitle', () => { }); await nextTick(); - const titleEl = wrapperWithTitle.find('h2'); + const titleEl = wrapperWithTitle.find('[data-testid="title"]'); expect(titleEl.exists()).toBe(true); - expect(titleEl.html()).toBe('<h2 dir="auto" class="title qa-title"><b>Sample</b> title</h2>'); + expect(titleEl.html()).toBe( + '<h1 dir="auto" data-testid="title" class="title qa-title"><b>Sample</b> title</h1>', + ); wrapperWithTitle.destroy(); }); diff --git a/spec/requests/api/topics_spec.rb b/spec/requests/api/topics_spec.rb index fd9f306128f..5c17ca9581e 100644 --- a/spec/requests/api/topics_spec.rb +++ b/spec/requests/api/topics_spec.rb @@ -255,4 +255,43 @@ RSpec.describe API::Topics do end end end + + describe 'DELETE /topics', :aggregate_failures do + context 'as administrator' do + it 'deletes a topic' do + delete api("/topics/#{topic_3.id}", admin), params: { name: 'my-topic' } + + expect(response).to have_gitlab_http_status(:no_content) + end + + it 'returns 404 for non existing id' do + delete api("/topics/#{non_existing_record_id}", admin), params: { name: 'my-topic' } + + expect(response).to have_gitlab_http_status(:not_found) + end + + it 'returns 400 for invalid `id` parameter' do + delete api('/topics/invalid', admin), params: { name: 'my-topic' } + + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['error']).to eql('id is invalid') + end + end + + context 'as normal user' do + it 'returns 403 Forbidden' do + delete api("/topics/#{topic_3.id}", user), params: { name: 'my-topic' } + + expect(response).to have_gitlab_http_status(:forbidden) + end + end + + context 'as anonymous' do + it 'returns 401 Unauthorized' do + delete api("/topics/#{topic_3.id}"), params: { name: 'my-topic' } + + expect(response).to have_gitlab_http_status(:unauthorized) + end + end + end end |