diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-08 09:09:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-08 09:09:13 +0300 |
commit | 0a319374e7784aa5c2d1c30dd832d2a0509edbab (patch) | |
tree | 123c5bac601b85d60cbaba541b25aed8c981c529 /spec | |
parent | 5683a027b79d2236bf9b3d1eb5303075584894d7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
37 files changed, 266 insertions, 244 deletions
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 21dfca134e3..6cd18f2755c 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -38,7 +38,7 @@ RSpec.describe "Admin::Users" do end describe "view extra user information" do - it 'shows the user popover on hover', :js, :quarantine do + it 'shows the user popover on hover', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/11290' do expect(page).not_to have_selector('#__BV_popover_1__') first_user_link = page.first('.js-user-link') diff --git a/spec/features/discussion_comments/commit_spec.rb b/spec/features/discussion_comments/commit_spec.rb index 5a744e43bb6..32c0ba2a9a7 100644 --- a/spec/features/discussion_comments/commit_spec.rb +++ b/spec/features/discussion_comments/commit_spec.rb @@ -24,7 +24,7 @@ RSpec.describe 'Thread Comments Commit', :js do expect(page).to have_css('.js-note-emoji') end - it 'adds award to the correct note', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/207973' do + it 'adds award to the correct note', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/207973' do find("#note_#{commit_discussion_note2.id} .js-note-emoji").click first('.emoji-menu .js-emoji-btn').click diff --git a/spec/features/issuables/issuable_list_spec.rb b/spec/features/issuables/issuable_list_spec.rb index 1481c4d07a2..8cf4dac9afe 100644 --- a/spec/features/issuables/issuable_list_spec.rb +++ b/spec/features/issuables/issuable_list_spec.rb @@ -28,8 +28,8 @@ RSpec.describe 'issuable list', :js do it "counts upvotes, downvotes and notes count for each #{issuable_type.to_s.humanize}" do visit_issuable_list(issuable_type) - expect(first('.fa-thumbs-up').find(:xpath, '..')).to have_content(1) - expect(first('.fa-thumbs-down').find(:xpath, '..')).to have_content(1) + expect(first('.issuable-upvotes')).to have_content(1) + expect(first('.issuable-downvotes')).to have_content(1) expect(first('.fa-comments').find(:xpath, '..')).to have_content(2) end diff --git a/spec/features/issues/filtered_search/search_bar_spec.rb b/spec/features/issues/filtered_search/search_bar_spec.rb index 167fecc5ab1..2a094281133 100644 --- a/spec/features/issues/filtered_search/search_bar_spec.rb +++ b/spec/features/issues/filtered_search/search_bar_spec.rb @@ -88,7 +88,7 @@ RSpec.describe 'Search bar', :js do expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: original_size) end - it 'resets the dropdown filters', :quarantine do + it 'resets the dropdown filters', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/9985' do filtered_search.click hint_offset = get_left_style(find('#js-dropdown-hint')['style']) diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index ab319daec71..9879703c8bf 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -28,7 +28,7 @@ RSpec.describe 'Issue Detail', :js do visit project_issue_path(project, issue) end - it 'encodes the description to prevent xss issues', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/207951' do + it 'encodes the description to prevent xss issues', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/207951' do page.within('.issuable-details .detail-page-description') do image = find('img.js-lazy-loaded') diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index 9e4362bf0e5..ecda80f2483 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -195,7 +195,7 @@ RSpec.describe 'Issue Sidebar' do end end - context 'creating a project label', :js, :quarantine do + context 'creating a project label', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27992' do before do page.within('.block.labels') do click_link 'Create project' diff --git a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb index a546fb3e85b..900ef435d1d 100644 --- a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb +++ b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb @@ -31,7 +31,7 @@ RSpec.describe 'User creates branch and merge request on issue page', :js do end # In order to improve tests performance, all UI checks are placed in this test. - it 'shows elements', :quarantine do + it 'shows elements', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27993' do button_create_merge_request = find('.js-create-merge-request') button_toggle_dropdown = find('.create-mr-dropdown-wrap .dropdown-toggle') @@ -141,7 +141,7 @@ RSpec.describe 'User creates branch and merge request on issue page', :js do visit project_issue_path(project, issue) end - it 'disables the create branch button', :quarantine do + it 'disables the create branch button', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27985' do expect(page).to have_css('.create-mr-dropdown-wrap .unavailable:not(.hidden)') expect(page).to have_css('.create-mr-dropdown-wrap .available.hidden', visible: false) expect(page).to have_content /Related merge requests/ diff --git a/spec/features/issues/user_interacts_with_awards_spec.rb b/spec/features/issues/user_interacts_with_awards_spec.rb index 7b7e087a6d6..35d9db68d32 100644 --- a/spec/features/issues/user_interacts_with_awards_spec.rb +++ b/spec/features/issues/user_interacts_with_awards_spec.rb @@ -16,7 +16,7 @@ RSpec.describe 'User interacts with awards' do visit(project_issue_path(project, issue)) end - it 'toggles the thumbsup award emoji', :quarantine do + it 'toggles the thumbsup award emoji', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27959' do page.within('.awards') do thumbsup = page.first('.award-control') thumbsup.click @@ -77,7 +77,7 @@ RSpec.describe 'User interacts with awards' do end end - it 'shows the list of award emoji categories', :quarantine do + it 'shows the list of award emoji categories', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27991' do page.within('.awards') do page.find('.js-add-award').click end diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb index 3ab7fbea198..1545cb36e9b 100644 --- a/spec/features/labels_hierarchy_spec.rb +++ b/spec/features/labels_hierarchy_spec.rb @@ -23,7 +23,7 @@ RSpec.describe 'Labels Hierarchy', :js do end shared_examples 'assigning labels from sidebar' do - it 'can assign all ancestors labels', :quarantine do + it 'can assign all ancestors labels', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27952' do [grandparent_group_label, parent_group_label, project_label_1].each do |label| page.within('.block.labels') do find('.edit-link').click diff --git a/spec/features/merge_request/user_creates_image_diff_notes_spec.rb b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb index 34eaca24a01..3cd23764382 100644 --- a/spec/features/merge_request/user_creates_image_diff_notes_spec.rb +++ b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb @@ -88,7 +88,7 @@ RSpec.describe 'Merge request > User creates image diff notes', :js do create_image_diff_note end - it 'shows indicator and avatar badges, and allows collapsing/expanding the discussion notes', :quarantine do + it 'shows indicator and avatar badges, and allows collapsing/expanding the discussion notes', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27950' do indicator = find('.js-image-badge', match: :first) badge = find('.user-avatar-link .badge', match: :first) diff --git a/spec/features/merge_request/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb index dbad2f191a1..6ecffb05009 100644 --- a/spec/features/merge_request/user_posts_diff_notes_spec.rb +++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb @@ -46,7 +46,7 @@ RSpec.describe 'Merge request > User posts diff notes', :js do end context 'with an old line on the left and a new line on the right' do - it 'allows commenting on the left side', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/199050' do + it 'allows commenting on the left side', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/199050' do should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'left') end @@ -56,7 +56,7 @@ RSpec.describe 'Merge request > User posts diff notes', :js do end context 'with an unchanged line on the left and an unchanged line on the right' do - it 'allows commenting on the left side', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/196826' do + it 'allows commenting on the left side', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/196826' do should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, '..'), 'left') end diff --git a/spec/features/merge_request/user_sees_diff_spec.rb b/spec/features/merge_request/user_sees_diff_spec.rb index 2229b242d5b..d067fc0ada4 100644 --- a/spec/features/merge_request/user_sees_diff_spec.rb +++ b/spec/features/merge_request/user_sees_diff_spec.rb @@ -72,7 +72,7 @@ RSpec.describe 'Merge request > User sees diff', :js do end context 'as user who needs to fork' do - it 'shows fork/cancel confirmation', :sidekiq_might_not_need_inline, quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/196749' do + it 'shows fork/cancel confirmation', :sidekiq_might_not_need_inline, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/196749' do sign_in(user) visit diffs_project_merge_request_path(project, merge_request) diff --git a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb index e7eb4bb41cc..0506d190487 100644 --- a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb +++ b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb @@ -188,8 +188,7 @@ RSpec.describe 'User comments on a diff', :js do end context 'multiple suggestions in expanded lines' do - # https://gitlab.com/gitlab-org/gitlab/issues/38277 - it 'suggestions are appliable', :quarantine do + it 'suggestions are appliable', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/38277' do diff_file = merge_request.diffs(paths: ['files/ruby/popen.rb']).diff_files.first hash = Digest::SHA1.hexdigest(diff_file.file_path) diff --git a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb index d9421631b32..2747b5894dc 100644 --- a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb +++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb @@ -65,7 +65,7 @@ RSpec.describe 'User visits the profile preferences page' do end describe 'User changes their language', :js do - it 'creates a flash message', :quarantine do + it 'creates a flash message', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/31404' do select2('en', from: '#user_preferred_language') click_button 'Save' diff --git a/spec/features/projects/members/member_leaves_project_spec.rb b/spec/features/projects/members/member_leaves_project_spec.rb index aa7633c3b28..c4bd0b81dc0 100644 --- a/spec/features/projects/members/member_leaves_project_spec.rb +++ b/spec/features/projects/members/member_leaves_project_spec.rb @@ -20,7 +20,7 @@ RSpec.describe 'Projects > Members > Member leaves project' do expect(project.users.exists?(user.id)).to be_falsey end - it 'user leaves project by url param', :js, :quarantine do + it 'user leaves project by url param', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/35925' do visit project_path(project, leave: 1) page.accept_confirm diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb index ef65b3a2cc6..af2ecfec498 100644 --- a/spec/features/users/signup_spec.rb +++ b/spec/features/users/signup_spec.rb @@ -98,7 +98,7 @@ RSpec.shared_examples 'Signup' do expect(page).to have_content("Invalid input, please avoid emojis") end - it 'shows a pending message if the username availability is being fetched', :quarantine do + it 'shows a pending message if the username availability is being fetched', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/31484' do fill_in 'new_user_username', with: 'new-user' expect(find('.username > .validation-pending')).not_to have_css '.hide' diff --git a/spec/frontend/__mocks__/document-register-element/index.js b/spec/frontend/__mocks__/document-register-element/index.js new file mode 100644 index 00000000000..2d1ec238274 --- /dev/null +++ b/spec/frontend/__mocks__/document-register-element/index.js @@ -0,0 +1 @@ +export default () => {}; diff --git a/spec/frontend/awards_handler_spec.js b/spec/frontend/awards_handler_spec.js index 754f0702b84..ef09c59b5f6 100644 --- a/spec/frontend/awards_handler_spec.js +++ b/spec/frontend/awards_handler_spec.js @@ -1,13 +1,17 @@ import $ from 'jquery'; import Cookies from 'js-cookie'; +import MockAdapter from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; import loadAwardsHandler from '~/awards_handler'; import '~/lib/utils/common_utils'; import waitForPromises from './helpers/wait_for_promises'; +import { EMOJI_VERSION } from '~/emoji'; window.gl = window.gl || {}; window.gon = window.gon || {}; let openAndWaitForEmojiMenu; +let mock; let awardsHandler = null; const urlRoot = gon.relative_url_root; @@ -24,8 +28,13 @@ const lazyAssert = (done, assertFn) => { }; describe('AwardsHandler', () => { + const emojiData = getJSONFixture('emojis/emojis.json'); preloadFixtures('snippets/show.html'); + beforeEach(done => { + mock = new MockAdapter(axios); + mock.onGet(`/-/emojis/${EMOJI_VERSION}/emojis.json`).reply(200, emojiData); + loadFixtures('snippets/show.html'); loadAwardsHandler(true) .then(obj => { @@ -58,6 +67,8 @@ describe('AwardsHandler', () => { // restore original url root value gon.relative_url_root = urlRoot; + mock.restore(); + // Undo what we did to the shared <body> $('body').removeAttr('data-page'); diff --git a/spec/frontend/behaviors/gl_emoji_spec.js b/spec/frontend/behaviors/gl_emoji_spec.js new file mode 100644 index 00000000000..7ea0bafc328 --- /dev/null +++ b/spec/frontend/behaviors/gl_emoji_spec.js @@ -0,0 +1,110 @@ +import MockAdapter from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; +import { initEmojiMap, EMOJI_VERSION } from '~/emoji'; +import installGlEmojiElement from '~/behaviors/gl_emoji'; + +import * as EmojiUnicodeSupport from '~/emoji/support'; +import waitForPromises from 'jest/helpers/wait_for_promises'; + +jest.mock('~/emoji/support'); + +describe('gl_emoji', () => { + let mock; + const emojiData = getJSONFixture('emojis/emojis.json'); + + beforeAll(() => { + jest.spyOn(EmojiUnicodeSupport, 'default').mockReturnValue(true); + installGlEmojiElement(); + }); + + function markupToDomElement(markup) { + const div = document.createElement('div'); + div.innerHTML = markup; + document.body.appendChild(div); + + return div.firstElementChild; + } + + beforeEach(() => { + mock = new MockAdapter(axios); + mock.onGet(`/-/emojis/${EMOJI_VERSION}/emojis.json`).reply(200, emojiData); + + return initEmojiMap().catch(() => {}); + }); + + afterEach(() => { + mock.restore(); + + document.body.innerHTML = ''; + }); + + describe.each([ + [ + 'bomb emoji just with name attribute', + '<gl-emoji data-name="bomb"></gl-emoji>', + '<gl-emoji data-name="bomb" data-unicode-version="6.0" title="bomb">💣</gl-emoji>', + '<gl-emoji data-name="bomb" data-unicode-version="6.0" title="bomb"><img class="emoji" title=":bomb:" alt=":bomb:" src="/-/emojis/1/bomb.png" width="20" height="20" align="absmiddle"></gl-emoji>', + ], + [ + 'bomb emoji with name attribute and unicode version', + '<gl-emoji data-name="bomb" data-unicode-version="6.0">💣</gl-emoji>', + '<gl-emoji data-name="bomb" data-unicode-version="6.0">💣</gl-emoji>', + '<gl-emoji data-name="bomb" data-unicode-version="6.0"><img class="emoji" title=":bomb:" alt=":bomb:" src="/-/emojis/1/bomb.png" width="20" height="20" align="absmiddle"></gl-emoji>', + ], + [ + 'bomb emoji with sprite fallback', + '<gl-emoji data-fallback-sprite-class="emoji-bomb" data-name="bomb"></gl-emoji>', + '<gl-emoji data-fallback-sprite-class="emoji-bomb" data-name="bomb" data-unicode-version="6.0" title="bomb">💣</gl-emoji>', + '<gl-emoji data-fallback-sprite-class="emoji-bomb" data-name="bomb" data-unicode-version="6.0" title="bomb" class="emoji-icon emoji-bomb">💣</gl-emoji>', + ], + [ + 'bomb emoji with image fallback', + '<gl-emoji data-fallback-src="/bomb.png" data-name="bomb"></gl-emoji>', + '<gl-emoji data-fallback-src="/bomb.png" data-name="bomb" data-unicode-version="6.0" title="bomb">💣</gl-emoji>', + '<gl-emoji data-fallback-src="/bomb.png" data-name="bomb" data-unicode-version="6.0" title="bomb"><img class="emoji" title=":bomb:" alt=":bomb:" src="/bomb.png" width="20" height="20" align="absmiddle"></gl-emoji>', + ], + [ + 'invalid emoji', + '<gl-emoji data-name="invalid_emoji"></gl-emoji>', + '<gl-emoji data-name="grey_question" data-unicode-version="6.0" title="white question mark ornament">❔</gl-emoji>', + '<gl-emoji data-name="grey_question" data-unicode-version="6.0" title="white question mark ornament"><img class="emoji" title=":grey_question:" alt=":grey_question:" src="/-/emojis/1/grey_question.png" width="20" height="20" align="absmiddle"></gl-emoji>', + ], + ])('%s', (name, markup, withEmojiSupport, withoutEmojiSupport) => { + it(`renders correctly with emoji support`, async () => { + jest.spyOn(EmojiUnicodeSupport, 'default').mockReturnValue(true); + const glEmojiElement = markupToDomElement(markup); + + await waitForPromises(); + + expect(glEmojiElement.outerHTML).toBe(withEmojiSupport); + }); + + it(`renders correctly without emoji support`, async () => { + jest.spyOn(EmojiUnicodeSupport, 'default').mockReturnValue(false); + const glEmojiElement = markupToDomElement(markup); + + await waitForPromises(); + + expect(glEmojiElement.outerHTML).toBe(withoutEmojiSupport); + }); + }); + + it('Adds sprite CSS if emojis are not supported', async () => { + const testPath = '/test-path.css'; + jest.spyOn(EmojiUnicodeSupport, 'default').mockReturnValue(false); + window.gon.emoji_sprites_css_path = testPath; + + expect(document.head.querySelector(`link[href="${testPath}"]`)).toBe(null); + expect(window.gon.emoji_sprites_css_added).toBeFalsy(); + + markupToDomElement( + '<gl-emoji data-fallback-sprite-class="emoji-bomb" data-name="bomb"></gl-emoji>', + ); + await waitForPromises(); + + expect(document.head.querySelector(`link[href="${testPath}"]`).outerHTML).toBe( + '<link rel="stylesheet" href="/test-path.css">', + ); + expect(window.gon.emoji_sprites_css_added).toBe(true); + }); +}); diff --git a/spec/frontend/emoji_spec.js b/spec/frontend/emoji/emoji_spec.js index 25bc95e0dd6..c6a15d5976a 100644 --- a/spec/frontend/emoji_spec.js +++ b/spec/frontend/emoji/emoji_spec.js @@ -1,4 +1,6 @@ -import { glEmojiTag } from '~/emoji'; +import MockAdapter from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; +import { initEmojiMap, glEmojiTag, EMOJI_VERSION } from '~/emoji'; import isEmojiUnicodeSupported, { isFlagEmoji, isRainbowFlagEmoji, @@ -7,6 +9,7 @@ import isEmojiUnicodeSupported, { isHorceRacingSkinToneComboEmoji, isPersonZwjEmoji, } from '~/emoji/support/is_emoji_unicode_supported'; +import { trimText } from 'helpers/text_helper'; const emptySupportMap = { personZwj: false, @@ -50,77 +53,28 @@ const emojiFixtureMap = { }, }; -function markupToDomElement(markup) { - const div = document.createElement('div'); - div.innerHTML = markup; - return div.firstElementChild; -} - -function testGlEmojiImageFallback(element, name, src) { - expect(element.tagName.toLowerCase()).toBe('img'); - expect(element.getAttribute('src')).toBe(src); - expect(element.getAttribute('title')).toBe(`:${name}:`); - expect(element.getAttribute('alt')).toBe(`:${name}:`); -} - -const defaults = { - forceFallback: false, - sprite: false, -}; +describe('gl_emoji', () => { + let mock; + const emojiData = getJSONFixture('emojis/emojis.json'); -function testGlEmojiElement(element, name, unicodeVersion, unicodeMoji, options = {}) { - const opts = { ...defaults, ...options }; - expect(element.tagName.toLowerCase()).toBe('gl-emoji'); - expect(element.dataset.name).toBe(name); - expect(element.dataset.fallbackSrc.length).toBeGreaterThan(0); - expect(element.dataset.unicodeVersion).toBe(unicodeVersion); - - const fallbackSpriteClass = `emoji-${name}`; - if (opts.sprite) { - expect(element.dataset.fallbackSpriteClass).toBe(fallbackSpriteClass); - } - - if (opts.forceFallback && opts.sprite) { - expect(element.getAttribute('class')).toBe(`emoji-icon ${fallbackSpriteClass}`); - } - - if (opts.forceFallback && !opts.sprite) { - // Check for image fallback - testGlEmojiImageFallback(element.firstElementChild, name, element.dataset.fallbackSrc); - } else { - // Otherwise make sure things are still unicode text - expect(element.textContent.trim()).toBe(unicodeMoji); - } -} + beforeEach(() => { + mock = new MockAdapter(axios); + mock.onGet(`/-/emojis/${EMOJI_VERSION}/emojis.json`).reply(200, emojiData); + + return initEmojiMap().catch(() => {}); + }); + + afterEach(() => { + mock.restore(); + }); -describe('gl_emoji', () => { describe('glEmojiTag', () => { it('bomb emoji', () => { const emojiKey = 'bomb'; const markup = glEmojiTag(emojiFixtureMap[emojiKey].name); - const glEmojiElement = markupToDomElement(markup); - testGlEmojiElement( - glEmojiElement, - emojiFixtureMap[emojiKey].name, - emojiFixtureMap[emojiKey].unicodeVersion, - emojiFixtureMap[emojiKey].moji, - ); - }); - it('bomb emoji with image fallback', () => { - const emojiKey = 'bomb'; - const markup = glEmojiTag(emojiFixtureMap[emojiKey].name, { - forceFallback: true, - }); - const glEmojiElement = markupToDomElement(markup); - testGlEmojiElement( - glEmojiElement, - emojiFixtureMap[emojiKey].name, - emojiFixtureMap[emojiKey].unicodeVersion, - emojiFixtureMap[emojiKey].moji, - { - forceFallback: true, - }, + expect(trimText(markup)).toMatchInlineSnapshot( + `"<gl-emoji data-name=\\"bomb\\"></gl-emoji>"`, ); }); @@ -129,65 +83,8 @@ describe('gl_emoji', () => { const markup = glEmojiTag(emojiFixtureMap[emojiKey].name, { sprite: true, }); - const glEmojiElement = markupToDomElement(markup); - testGlEmojiElement( - glEmojiElement, - emojiFixtureMap[emojiKey].name, - emojiFixtureMap[emojiKey].unicodeVersion, - emojiFixtureMap[emojiKey].moji, - { - sprite: true, - }, - ); - }); - - it('bomb emoji with sprite fallback', () => { - const emojiKey = 'bomb'; - const markup = glEmojiTag(emojiFixtureMap[emojiKey].name, { - forceFallback: true, - sprite: true, - }); - const glEmojiElement = markupToDomElement(markup); - testGlEmojiElement( - glEmojiElement, - emojiFixtureMap[emojiKey].name, - emojiFixtureMap[emojiKey].unicodeVersion, - emojiFixtureMap[emojiKey].moji, - { - forceFallback: true, - sprite: true, - }, - ); - }); - - it('question mark when invalid emoji name given', () => { - const name = 'invalid_emoji'; - const emojiKey = 'grey_question'; - const markup = glEmojiTag(name); - const glEmojiElement = markupToDomElement(markup); - testGlEmojiElement( - glEmojiElement, - emojiFixtureMap[emojiKey].name, - emojiFixtureMap[emojiKey].unicodeVersion, - emojiFixtureMap[emojiKey].moji, - ); - }); - - it('question mark with image fallback when invalid emoji name given', () => { - const name = 'invalid_emoji'; - const emojiKey = 'grey_question'; - const markup = glEmojiTag(name, { - forceFallback: true, - }); - const glEmojiElement = markupToDomElement(markup); - testGlEmojiElement( - glEmojiElement, - emojiFixtureMap[emojiKey].name, - emojiFixtureMap[emojiKey].unicodeVersion, - emojiFixtureMap[emojiKey].moji, - { - forceFallback: true, - }, + expect(trimText(markup)).toMatchInlineSnapshot( + `"<gl-emoji data-fallback-sprite-class=\\"emoji-bomb\\" data-name=\\"bomb\\"></gl-emoji>"`, ); }); }); diff --git a/spec/frontend/behaviors/gl_emoji/unicode_support_map_spec.js b/spec/frontend/emoji/support/unicode_support_map_spec.js index aaee9c30cac..aaee9c30cac 100644 --- a/spec/frontend/behaviors/gl_emoji/unicode_support_map_spec.js +++ b/spec/frontend/emoji/support/unicode_support_map_spec.js diff --git a/spec/frontend/fixtures/emojis.rb b/spec/frontend/fixtures/emojis.rb new file mode 100644 index 00000000000..b95c7632917 --- /dev/null +++ b/spec/frontend/fixtures/emojis.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Emojis (JavaScript fixtures)', type: :request do + include JavaScriptFixturesHelpers + + before(:all) do + clean_frontend_fixtures('emojis/') + end + + it 'emojis/emojis.json' do |example| + get '/-/emojis/1/emojis.json' + + expect(response).to be_successful + end +end diff --git a/spec/frontend/ide/components/ide_status_list_spec.js b/spec/frontend/ide/components/ide_status_list_spec.js index 847464ed806..fed61233e55 100644 --- a/spec/frontend/ide/components/ide_status_list_spec.js +++ b/spec/frontend/ide/components/ide_status_list_spec.js @@ -1,5 +1,6 @@ import Vuex from 'vuex'; import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { GlLink } from '@gitlab/ui'; import IdeStatusList from '~/ide/components/ide_status_list.vue'; import TerminalSyncStatusSafe from '~/ide/components/terminal_sync/terminal_sync_status_safe.vue'; @@ -9,6 +10,7 @@ const TEST_FILE = { editorColumn: 23, fileLanguage: 'markdown', content: 'abc\nndef', + permalink: '/lorem.md', }; const localVue = createLocalVue(); @@ -19,6 +21,7 @@ describe('ide/components/ide_status_list', () => { let store; let wrapper; + const findLink = () => wrapper.find(GlLink); const createComponent = (options = {}) => { store = new Vuex.Store({ getters: { @@ -51,8 +54,9 @@ describe('ide/components/ide_status_list', () => { createComponent(); }); - it('shows file name', () => { - expect(wrapper.text()).toContain(TEST_FILE.name); + it('shows a link to the file that contains the file name', () => { + expect(findLink().attributes('href')).toBe(TEST_FILE.permalink); + expect(findLink().text()).toBe(TEST_FILE.name); }); it('shows file eol', () => { diff --git a/spec/frontend/monitoring/components/dashboard_panel_spec.js b/spec/frontend/monitoring/components/dashboard_panel_spec.js index 96e0c39cb27..a2499c84ff7 100644 --- a/spec/frontend/monitoring/components/dashboard_panel_spec.js +++ b/spec/frontend/monitoring/components/dashboard_panel_spec.js @@ -369,7 +369,7 @@ describe('Dashboard Panel', () => { }); }); - it('it is overriden when a datazoom event is received', () => { + it('it is overridden when a datazoom event is received', () => { state.logsPath = mockLogsPath; state.timeRange = mockTimeRange; diff --git a/spec/frontend/pipelines/test_reports/stores/actions_spec.js b/spec/frontend/pipelines/test_reports/stores/actions_spec.js index bd42db36645..c47c6e99103 100644 --- a/spec/frontend/pipelines/test_reports/stores/actions_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/actions_spec.js @@ -22,7 +22,7 @@ describe('Actions TestReports Store', () => { fullReportEndpoint, summaryEndpoint, testReports: {}, - selectedSuite: {}, + selectedSuite: null, summary: {}, }; @@ -101,28 +101,28 @@ describe('Actions TestReports Store', () => { }); }); - describe('set selected suite', () => { - const selectedSuite = testReports.test_suites[0]; + describe('set selected suite index', () => { + const selectedSuiteIndex = 0; - it('sets selectedSuite', done => { + it('sets selectedSuiteIndex', done => { testAction( - actions.setSelectedSuite, - selectedSuite, + actions.setSelectedSuiteIndex, + selectedSuiteIndex, state, - [{ type: types.SET_SELECTED_SUITE, payload: selectedSuite }], + [{ type: types.SET_SELECTED_SUITE_INDEX, payload: selectedSuiteIndex }], [], done, ); }); }); - describe('remove selected suite', () => { - it('sets selectedSuite to {}', done => { + describe('remove selected suite index', () => { + it('sets selectedSuiteIndex to null', done => { testAction( - actions.removeSelectedSuite, + actions.removeSelectedSuiteIndex, {}, state, - [{ type: types.SET_SELECTED_SUITE, payload: {} }], + [{ type: types.SET_SELECTED_SUITE_INDEX, payload: null }], [], done, ); diff --git a/spec/frontend/pipelines/test_reports/stores/getters_spec.js b/spec/frontend/pipelines/test_reports/stores/getters_spec.js index 011a7e68908..ca9ebb54138 100644 --- a/spec/frontend/pipelines/test_reports/stores/getters_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/getters_spec.js @@ -9,12 +9,12 @@ describe('Getters TestReports Store', () => { const defaultState = { testReports, - selectedSuite: testReports.test_suites[0], + selectedSuiteIndex: 0, }; const emptyState = { testReports: {}, - selectedSuite: {}, + selectedSuite: null, }; beforeEach(() => { @@ -47,6 +47,17 @@ describe('Getters TestReports Store', () => { }); }); + describe('getSelectedSuite', () => { + it('should return the selected suite', () => { + setupState(); + + const selectedSuite = getters.getSelectedSuite(state); + const expected = testReports.test_suites[state.selectedSuiteIndex]; + + expect(selectedSuite).toEqual(expected); + }); + }); + describe('getSuiteTests', () => { it('should return the test cases inside the suite', () => { setupState(); diff --git a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js index cf54cacab60..2320f84b3bb 100644 --- a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js @@ -10,7 +10,7 @@ describe('Mutations TestReports Store', () => { const defaultState = { endpoint: '', testReports: {}, - selectedSuite: {}, + selectedSuite: null, isLoading: false, }; @@ -27,12 +27,12 @@ describe('Mutations TestReports Store', () => { }); }); - describe('set selected suite', () => { - it('should set selectedSuite', () => { - const selectedSuite = testReports.test_suites[0]; - mutations[types.SET_SELECTED_SUITE](mockState, selectedSuite); + describe('set selected suite index', () => { + it('should set selectedSuiteIndex', () => { + const selectedSuiteIndex = 0; + mutations[types.SET_SELECTED_SUITE_INDEX](mockState, selectedSuiteIndex); - expect(mockState.selectedSuite).toEqual(selectedSuite); + expect(mockState.selectedSuiteIndex).toEqual(selectedSuiteIndex); }); }); diff --git a/spec/frontend/pipelines/test_reports/test_reports_spec.js b/spec/frontend/pipelines/test_reports/test_reports_spec.js index dd2b7220d7c..7bd71716cb0 100644 --- a/spec/frontend/pipelines/test_reports/test_reports_spec.js +++ b/spec/frontend/pipelines/test_reports/test_reports_spec.js @@ -3,6 +3,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; import TestReports from '~/pipelines/components/test_reports/test_reports.vue'; import * as actions from '~/pipelines/stores/test_reports/actions'; +import * as getters from '~/pipelines/stores/test_reports/getters'; const localVue = createLocalVue(); localVue.use(Vuex); @@ -29,6 +30,7 @@ describe('Test reports app', () => { ...actions, fetchSummary: () => {}, }, + getters, }); wrapper = shallowMount(TestReports, { diff --git a/spec/frontend/pipelines/test_reports/test_suite_table_spec.js b/spec/frontend/pipelines/test_reports/test_suite_table_spec.js index 5d448bcb439..65bffe7039a 100644 --- a/spec/frontend/pipelines/test_reports/test_suite_table_spec.js +++ b/spec/frontend/pipelines/test_reports/test_suite_table_spec.js @@ -28,7 +28,10 @@ describe('Test reports suite table', () => { const createComponent = (suite = testSuite) => { store = new Vuex.Store({ state: { - selectedSuite: suite, + testReports: { + test_suites: [suite], + }, + selectedSuiteIndex: 0, }, getters, }); diff --git a/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap b/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap index df4b30f1cb8..19671d425a9 100644 --- a/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap +++ b/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap @@ -18,15 +18,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` <gl-emoji - data-fallback-src="/assets/emoji/thumbsup-59ec2457ab33e8897261d01a495f6cf5c668d0004807dc541c3b1be5294b1e61.png" data-name="thumbsup" - data-unicode-version="6.0" - title="thumbs up sign" - > - - 👍 - - </gl-emoji> + /> </span> @@ -51,15 +44,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` <gl-emoji - data-fallback-src="/assets/emoji/thumbsdown-5954334e2dae5357312b3d629f10a496c728029e02216f8c8b887f9b51561c61.png" data-name="thumbsdown" - data-unicode-version="6.0" - title="thumbs down sign" - > - - 👎 - - </gl-emoji> + /> </span> @@ -84,15 +70,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` <gl-emoji - data-fallback-src="/assets/emoji/smile-14905c372d5bf7719bd727c9efae31a03291acec79801652a23710c6848c5d14.png" data-name="smile" - data-unicode-version="6.0" - title="smiling face with open mouth and smiling eyes" - > - - 😄 - - </gl-emoji> + /> </span> @@ -117,15 +96,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` <gl-emoji - data-fallback-src="/assets/emoji/ok_hand-d63002dce3cc3655b67b8765b7c28d370edba0e3758b2329b60e0e61c4d8e78d.png" data-name="ok_hand" - data-unicode-version="6.0" - title="ok hand sign" - > - - 👌 - - </gl-emoji> + /> </span> @@ -150,15 +122,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` <gl-emoji - data-fallback-src="/assets/emoji/cactus-2c5c4c35f26c7046fdc002b337e0d939729b33a26980e675950f9934c91e40fd.png" data-name="cactus" - data-unicode-version="6.0" - title="cactus" - > - - 🌵 - - </gl-emoji> + /> </span> @@ -183,15 +148,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` <gl-emoji - data-fallback-src="/assets/emoji/a-bddbb39e8a1d35d42b7c08e7d47f63988cb4d8614b79f74e70b9c67c221896cc.png" data-name="a" - data-unicode-version="6.0" - title="negative squared latin capital letter a" - > - - 🅰 - - </gl-emoji> + /> </span> @@ -216,15 +174,8 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = ` <gl-emoji - data-fallback-src="/assets/emoji/b-722f9db9442e7c0fc0d0ac0f5291fbf47c6a0ac4d8abd42e97957da705fb82bf.png" data-name="b" - data-unicode-version="6.0" - title="negative squared latin capital letter b" - > - - 🅱 - - </gl-emoji> + /> </span> diff --git a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb index 78a4ec34cf2..65d45ec694f 100644 --- a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb +++ b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb @@ -55,7 +55,7 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateBuildStage do statuses[:pending]] end - it 'recovers from unique constraint violation only twice', :quarantine do + it 'recovers from unique constraint violation only twice', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/28128' do allow(described_class::Migratable::Stage) .to receive(:find_by).and_return(nil) diff --git a/spec/lib/gitlab/lograge/custom_options_spec.rb b/spec/lib/gitlab/lograge/custom_options_spec.rb index 550f8c17f04..218007c6e2a 100644 --- a/spec/lib/gitlab/lograge/custom_options_spec.rb +++ b/spec/lib/gitlab/lograge/custom_options_spec.rb @@ -65,14 +65,14 @@ RSpec.describe Gitlab::Lograge::CustomOptions do end end - context 'when correlation_id is overriden' do + context 'when correlation_id is overridden' do let(:correlation_id_key) { Labkit::Correlation::CorrelationId::LOG_KEY } before do event_payload[correlation_id_key] = '123456' end - it 'sets the overriden value' do + it 'sets the overridden value' do expect(subject[correlation_id_key]).to eq('123456') end end diff --git a/spec/lib/gitlab/runtime_spec.rb b/spec/lib/gitlab/runtime_spec.rb index 8c1f17d070e..8ed7cc141cd 100644 --- a/spec/lib/gitlab/runtime_spec.rb +++ b/spec/lib/gitlab/runtime_spec.rb @@ -48,18 +48,47 @@ RSpec.describe Gitlab::Runtime do before do stub_const('::Puma', puma_type) allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(max_threads: 2) + stub_env('ACTION_CABLE_IN_APP', 'false') end it_behaves_like "valid runtime", :puma, 3 + + context "when ActionCable in-app mode is enabled" do + before do + stub_env('ACTION_CABLE_IN_APP', 'true') + stub_env('ACTION_CABLE_WORKER_POOL_SIZE', '3') + end + + it_behaves_like "valid runtime", :puma, 6 + end + + context "when ActionCable standalone is run" do + before do + stub_const('ACTION_CABLE_SERVER', true) + stub_env('ACTION_CABLE_WORKER_POOL_SIZE', '8') + end + + it_behaves_like "valid runtime", :puma, 11 + end end context "unicorn" do before do stub_const('::Unicorn', Module.new) stub_const('::Unicorn::HttpServer', Class.new) + stub_env('ACTION_CABLE_IN_APP', 'false') end it_behaves_like "valid runtime", :unicorn, 1 + + context "when ActionCable in-app mode is enabled" do + before do + stub_env('ACTION_CABLE_IN_APP', 'true') + stub_env('ACTION_CABLE_WORKER_POOL_SIZE', '3') + end + + it_behaves_like "valid runtime", :unicorn, 4 + end end context "sidekiq" do @@ -105,17 +134,4 @@ RSpec.describe Gitlab::Runtime do it_behaves_like "valid runtime", :rails_runner, 1 end - - context "action_cable" do - before do - stub_const('ACTION_CABLE_SERVER', true) - stub_const('::Puma', Module.new) - - allow(Gitlab::Application).to receive_message_chain(:config, :action_cable, :worker_pool_size).and_return(8) - end - - it "reports its maximum concurrency based on ActionCable's worker pool size" do - expect(subject.max_threads).to eq(9) - end - end end diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb index 425dc70e7a1..b12ad82920f 100644 --- a/spec/models/concerns/reactive_caching_spec.rb +++ b/spec/models/concerns/reactive_caching_spec.rb @@ -298,7 +298,7 @@ RSpec.describe ReactiveCaching, :use_clean_rails_memory_store_caching do expect(read_reactive_cache(instance)).not_to eq(calculation.call) end - context 'when reactive_cache_limit_enabled? is overriden to return false' do + context 'when reactive_cache_limit_enabled? is overridden to return false' do before do allow(instance).to receive(:reactive_cache_limit_enabled?).and_return(false) end diff --git a/spec/models/personal_access_token_spec.rb b/spec/models/personal_access_token_spec.rb index b9cb5477c54..7fae9cc60fc 100644 --- a/spec/models/personal_access_token_spec.rb +++ b/spec/models/personal_access_token_spec.rb @@ -204,7 +204,7 @@ RSpec.describe PersonalAccessToken do end describe '.simple_sorts' do - it 'includes overriden keys' do + it 'includes overridden keys' do expect(described_class.simple_sorts.keys).to include(*%w(expires_at_asc expires_at_desc)) end end diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 66601d26bd2..57e32b1aea9 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -792,7 +792,7 @@ RSpec.describe QuickActions::InterpretService do let(:issuable) { issue } end - it_behaves_like 'assign command', :quarantine do + it_behaves_like 'assign command', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/27989' do let(:content) { "/assign @#{developer.username} @#{developer2.username}" } let(:issuable) { merge_request } end diff --git a/spec/support/shared_examples/features/discussion_comments_shared_example.rb b/spec/support/shared_examples/features/discussion_comments_shared_example.rb index 6007798c290..9fc5d8933e5 100644 --- a/spec/support/shared_examples/features/discussion_comments_shared_example.rb +++ b/spec/support/shared_examples/features/discussion_comments_shared_example.rb @@ -266,7 +266,7 @@ RSpec.shared_examples 'thread comments' do |resource_name| end end - it 'has "Comment" selected when opening the menu', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/196825' do + it 'has "Comment" selected when opening the menu', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/196825' do find(toggle_selector).click find("#{menu_selector} li", match: :first) |