diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-23 15:10:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-23 15:10:26 +0300 |
commit | 5c9f6c66fabf22927e862b2b60362e4ea25b250b (patch) | |
tree | 6ff391dcb7fdd3126f71af9fa4ca5e776a9ecbe3 /spec | |
parent | 65fdda8d39a9af414dbe5aa3a385b9bcba00960b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
228 files changed, 1356 insertions, 2029 deletions
diff --git a/spec/frontend/activities_spec.js b/spec/frontend/activities_spec.js index d14be3a1f26..5033cabcf37 100644 --- a/spec/frontend/activities_spec.js +++ b/spec/frontend/activities_spec.js @@ -56,11 +56,7 @@ describe('Activities', () => { const testName = shouldHighlight ? 'should highlight' : 'should not highlight'; it(`${testName} ${getEventName(x)}`, () => { - expect( - $(getSelector(x)) - .parent() - .hasClass('active'), - ).toEqual(shouldHighlight); + expect($(getSelector(x)).parent().hasClass('active')).toEqual(shouldHighlight); }); })(x); } diff --git a/spec/frontend/alert_management/components/alert_management_table_spec.js b/spec/frontend/alert_management/components/alert_management_table_spec.js index f7a629142f9..0cc3d565e10 100644 --- a/spec/frontend/alert_management/components/alert_management_table_spec.js +++ b/spec/frontend/alert_management/components/alert_management_table_spec.js @@ -85,11 +85,7 @@ describe('AlertManagementTable', () => { }); expect(findAlertsTable().exists()).toBe(true); expect(findLoader().exists()).toBe(true); - expect( - findAlerts() - .at(0) - .classes(), - ).not.toContain('gl-hover-bg-blue-50'); + expect(findAlerts().at(0).classes()).not.toContain('gl-hover-bg-blue-50'); }); it('error state', () => { @@ -101,11 +97,7 @@ describe('AlertManagementTable', () => { expect(findAlertsTable().text()).toContain('No alerts to display'); expect(findLoader().exists()).toBe(false); expect(findAlert().props().variant).toBe('danger'); - expect( - findAlerts() - .at(0) - .classes(), - ).not.toContain('gl-hover-bg-blue-50'); + expect(findAlerts().at(0).classes()).not.toContain('gl-hover-bg-blue-50'); }); it('empty state', () => { @@ -125,11 +117,7 @@ describe('AlertManagementTable', () => { expect(findAlertsTable().text()).toContain('No alerts to display'); expect(findLoader().exists()).toBe(false); expect(findAlert().props().variant).toBe('info'); - expect( - findAlerts() - .at(0) - .classes(), - ).not.toContain('gl-hover-bg-blue-50'); + expect(findAlerts().at(0).classes()).not.toContain('gl-hover-bg-blue-50'); }); it('has data state', () => { @@ -140,11 +128,7 @@ describe('AlertManagementTable', () => { expect(findLoader().exists()).toBe(false); expect(findAlertsTable().exists()).toBe(true); expect(findAlerts()).toHaveLength(mockAlerts.length); - expect( - findAlerts() - .at(0) - .classes(), - ).toContain('gl-hover-bg-blue-50'); + expect(findAlerts().at(0).classes()).toContain('gl-hover-bg-blue-50'); }); it('displays the alert ID and title formatted correctly', () => { @@ -170,11 +154,7 @@ describe('AlertManagementTable', () => { data: { alerts: { list: mockAlerts }, alertsCount, errored: false }, loading: false, }); - expect( - findStatusDropdown() - .find('.dropdown-title') - .exists(), - ).toBe(false); + expect(findStatusDropdown().find('.dropdown-title').exists()).toBe(false); }); it('shows correct severity icons', async () => { @@ -186,11 +166,7 @@ describe('AlertManagementTable', () => { await wrapper.vm.$nextTick(); expect(wrapper.find(GlTable).exists()).toBe(true); - expect( - findAlertsTable() - .find(GlIcon) - .classes('icon-critical'), - ).toBe(true); + expect(findAlertsTable().find(GlIcon).classes('icon-critical')).toBe(true); }); it('renders severity text', () => { @@ -199,11 +175,7 @@ describe('AlertManagementTable', () => { loading: false, }); - expect( - findSeverityFields() - .at(0) - .text(), - ).toBe('Critical'); + expect(findSeverityFields().at(0).text()).toBe('Critical'); }); it('renders Unassigned when no assignee(s) present', () => { @@ -212,11 +184,7 @@ describe('AlertManagementTable', () => { loading: false, }); - expect( - findAssignees() - .at(0) - .text(), - ).toBe('Unassigned'); + expect(findAssignees().at(0).text()).toBe('Unassigned'); }); it('renders user avatar when assignee present', () => { @@ -225,9 +193,7 @@ describe('AlertManagementTable', () => { loading: false, }); - const avatar = findAssignees() - .at(1) - .find(GlAvatar); + const avatar = findAssignees().at(1).find(GlAvatar); const { src, label } = avatar.attributes(); const { name, avatarUrl } = mockAlerts[1].assignees.nodes[0]; @@ -244,9 +210,7 @@ describe('AlertManagementTable', () => { expect(visitUrl).not.toHaveBeenCalled(); - findAlerts() - .at(0) - .trigger('click'); + findAlerts().at(0).trigger('click'); expect(visitUrl).toHaveBeenCalledWith('/1527542/details', false); }); @@ -258,11 +222,9 @@ describe('AlertManagementTable', () => { expect(visitUrl).not.toHaveBeenCalled(); - findAlerts() - .at(0) - .trigger('click', { - metaKey: true, - }); + findAlerts().at(0).trigger('click', { + metaKey: true, + }); expect(visitUrl).toHaveBeenCalledWith('/1527542/details', true); }); @@ -276,24 +238,12 @@ describe('AlertManagementTable', () => { }); it('shows "None" when no link exists', () => { - expect( - findIssueFields() - .at(0) - .text(), - ).toBe('None'); + expect(findIssueFields().at(0).text()).toBe('None'); }); it('renders a link when one exists', () => { - expect( - findIssueFields() - .at(1) - .text(), - ).toBe('#1'); - expect( - findIssueFields() - .at(1) - .attributes('href'), - ).toBe('/gitlab-org/gitlab/-/issues/1'); + expect(findIssueFields().at(1).text()).toBe('#1'); + expect(findIssueFields().at(1).attributes('href')).toBe('/gitlab-org/gitlab/-/issues/1'); }); }); @@ -350,11 +300,7 @@ describe('AlertManagementTable', () => { loading: false, }); - expect( - findAlerts() - .at(0) - .classes(), - ).toContain('new-alert'); + expect(findAlerts().at(0).classes()).toContain('new-alert'); }); it('should not highlight the row when alert is not new', () => { @@ -363,11 +309,7 @@ describe('AlertManagementTable', () => { loading: false, }); - expect( - findAlerts() - .at(0) - .classes(), - ).not.toContain('new-alert'); + expect(findAlerts().at(0).classes()).not.toContain('new-alert'); }); }); }); diff --git a/spec/frontend/alert_management/components/sidebar/alert_managment_sidebar_assignees_spec.js b/spec/frontend/alert_management/components/sidebar/alert_managment_sidebar_assignees_spec.js index 6430273ec59..00c479071fe 100644 --- a/spec/frontend/alert_management/components/sidebar/alert_managment_sidebar_assignees_spec.js +++ b/spec/frontend/alert_management/components/sidebar/alert_managment_sidebar_assignees_spec.js @@ -165,21 +165,9 @@ describe('Alert Details Sidebar Assignees', () => { }, }); - expect( - findAssigned() - .find('img') - .attributes('src'), - ).toBe('/url'); - expect( - findAssigned() - .find('.dropdown-menu-user-full-name') - .text(), - ).toBe('root'); - expect( - findAssigned() - .find('.dropdown-menu-user-username') - .text(), - ).toBe('@root'); + expect(findAssigned().find('img').attributes('src')).toBe('/url'); + expect(findAssigned().find('.dropdown-menu-user-full-name').text()).toBe('root'); + expect(findAssigned().find('.dropdown-menu-user-username').text()).toBe('@root'); }); }); }); diff --git a/spec/frontend/alerts_settings/alert_mapping_builder_spec.js b/spec/frontend/alerts_settings/alert_mapping_builder_spec.js index 12536c27dfe..5acf0f050ae 100644 --- a/spec/frontend/alerts_settings/alert_mapping_builder_spec.js +++ b/spec/frontend/alerts_settings/alert_mapping_builder_spec.js @@ -28,11 +28,7 @@ describe('AlertMappingBuilder', () => { }); const findColumnInRow = (row, column) => - wrapper - .findAll('.gl-display-table-row') - .at(row) - .findAll('.gl-display-table-cell ') - .at(column); + wrapper.findAll('.gl-display-table-row').at(row).findAll('.gl-display-table-cell ').at(column); it('renders column captions', () => { expect(findColumnInRow(0, 0).text()).toContain(i18n.columns.gitlabKeyTitle); diff --git a/spec/frontend/alerts_settings/alerts_integrations_list_spec.js b/spec/frontend/alerts_settings/alerts_integrations_list_spec.js index 3a7392f64f7..5a3874d055b 100644 --- a/spec/frontend/alerts_settings/alerts_integrations_list_spec.js +++ b/spec/frontend/alerts_settings/alerts_integrations_list_spec.js @@ -72,11 +72,7 @@ describe('AlertIntegrationsList', () => { it('renders an highlighted row when a current integration is selected to edit', () => { mountComponent({ data: { currentIntegration: { id: '1' } } }); - expect( - findTableComponentRows() - .at(0) - .classes(), - ).toContain('gl-bg-blue-50'); + expect(findTableComponentRows().at(0).classes()).toContain('gl-bg-blue-50'); }); describe('integration status', () => { diff --git a/spec/frontend/alerts_settings/alerts_settings_form_spec.js b/spec/frontend/alerts_settings/alerts_settings_form_spec.js index 428c6f93444..af0999a997f 100644 --- a/spec/frontend/alerts_settings/alerts_settings_form_spec.js +++ b/spec/frontend/alerts_settings/alerts_settings_form_spec.js @@ -86,11 +86,7 @@ describe('AlertsSettingsFormNew', () => { await wrapper.vm.$nextTick(); - expect( - findFormFields() - .at(0) - .isVisible(), - ).toBe(true); + expect(findFormFields().at(0).isVisible()).toBe(true); }); it('disables the dropdown and shows help text when multi integrations are not supported', async () => { @@ -104,11 +100,7 @@ describe('AlertsSettingsFormNew', () => { const options = findSelect().findAll('option'); await options.at(2).setSelected(); - expect( - findFormFields() - .at(0) - .attributes('disabled'), - ).toBe('disabled'); + expect(findFormFields().at(0).attributes('disabled')).toBe('disabled'); }); }); @@ -119,9 +111,7 @@ describe('AlertsSettingsFormNew', () => { const options = findSelect().findAll('option'); await options.at(1).setSelected(); - await findFormFields() - .at(0) - .setValue('Test integration'); + await findFormFields().at(0).setValue('Test integration'); await findFormToggle().trigger('click'); await wrapper.vm.$nextTick(); @@ -145,12 +135,8 @@ describe('AlertsSettingsFormNew', () => { const options = findSelect().findAll('option'); await options.at(2).setSelected(); - await findFormFields() - .at(0) - .setValue('Test integration'); - await findFormFields() - .at(1) - .setValue('https://test.com'); + await findFormFields().at(0).setValue('Test integration'); + await findFormFields().at(1).setValue('https://test.com'); await findFormToggle().trigger('click'); await wrapper.vm.$nextTick(); @@ -179,9 +165,7 @@ describe('AlertsSettingsFormNew', () => { }, }); - await findFormFields() - .at(0) - .setValue('Test integration post'); + await findFormFields().at(0).setValue('Test integration post'); await findFormToggle().trigger('click'); await wrapper.vm.$nextTick(); @@ -210,12 +194,8 @@ describe('AlertsSettingsFormNew', () => { }, }); - await findFormFields() - .at(0) - .setValue('Test integration'); - await findFormFields() - .at(1) - .setValue('https://test-post.com'); + await findFormFields().at(0).setValue('Test integration'); + await findFormFields().at(1).setValue('https://test-post.com'); await findFormToggle().trigger('click'); await wrapper.vm.$nextTick(); @@ -300,11 +280,7 @@ describe('AlertsSettingsFormNew', () => { resetSamplePayloadConfirmed, }); await wrapper.vm.$nextTick(); - expect( - findTestPayloadSection() - .find(GlFormTextarea) - .attributes('disabled'), - ).toBe(disabled); + expect(findTestPayloadSection().find(GlFormTextarea).attributes('disabled')).toBe(disabled); }); }); diff --git a/spec/frontend/authentication/u2f/authenticate_spec.js b/spec/frontend/authentication/u2f/authenticate_spec.js index 7a87b420195..427e2cef00c 100644 --- a/spec/frontend/authentication/u2f/authenticate_spec.js +++ b/spec/frontend/authentication/u2f/authenticate_spec.js @@ -55,10 +55,7 @@ describe('U2FAuthenticate', () => { jest.spyOn(component, 'renderAuthenticated').mockReturnValue(true); u2fDevice = new MockU2FDevice(); - component - .start() - .then(done) - .catch(done.fail); + component.start().then(done).catch(done.fail); }); it('allows authenticating via a U2F device', () => { diff --git a/spec/frontend/authentication/u2f/register_spec.js b/spec/frontend/authentication/u2f/register_spec.js index e89ef773be6..1c2e7c45a23 100644 --- a/spec/frontend/authentication/u2f/register_spec.js +++ b/spec/frontend/authentication/u2f/register_spec.js @@ -15,10 +15,7 @@ describe('U2FRegister', () => { u2fDevice = new MockU2FDevice(); container = $('#js-register-token-2fa'); component = new U2FRegister(container, {}); - component - .start() - .then(done) - .catch(done.fail); + component.start().then(done).catch(done.fail); }); it('allows registering a U2F device', () => { diff --git a/spec/frontend/awards_handler_spec.js b/spec/frontend/awards_handler_spec.js index c6a9c911ccf..2462026be0f 100644 --- a/spec/frontend/awards_handler_spec.js +++ b/spec/frontend/awards_handler_spec.js @@ -57,9 +57,7 @@ describe('AwardsHandler', () => { preloadFixtures('snippets/show.html'); const openAndWaitForEmojiMenu = (sel = '.js-add-award') => { - $(sel) - .eq(0) - .click(); + $(sel).eq(0).click(); jest.runOnlyPendingTimers(); @@ -337,9 +335,7 @@ describe('AwardsHandler', () => { it('should remove already selected emoji', async () => { await openEmojiMenuAndAddEmoji(); - $('.js-add-award') - .eq(0) - .click(); + $('.js-add-award').eq(0).click(); const $block = $('.js-awards-block'); const $emoji = $('.emoji-menu').find( `.emoji-menu-list:not(.frequent-emojis) ${emojiSelector}`, diff --git a/spec/frontend/badges/components/badge_list_row_spec.js b/spec/frontend/badges/components/badge_list_row_spec.js index 31f0d850857..32898abb4f7 100644 --- a/spec/frontend/badges/components/badge_list_row_spec.js +++ b/spec/frontend/badges/components/badge_list_row_spec.js @@ -91,9 +91,7 @@ describe('BadgeListRow component', () => { beforeEach(done => { badge.kind = GROUP_BADGE; - Vue.nextTick() - .then(done) - .catch(done.fail); + Vue.nextTick().then(done).catch(done.fail); }); it('renders the badge kind', () => { diff --git a/spec/frontend/badges/components/badge_list_spec.js b/spec/frontend/badges/components/badge_list_spec.js index 5ffc046eb97..4b61fc6658a 100644 --- a/spec/frontend/badges/components/badge_list_spec.js +++ b/spec/frontend/badges/components/badge_list_spec.js @@ -76,9 +76,7 @@ describe('BadgeList component', () => { beforeEach(done => { store.state.kind = GROUP_BADGE; - Vue.nextTick() - .then(done) - .catch(done.fail); + Vue.nextTick().then(done).catch(done.fail); }); it('renders a message if no badges exist', done => { diff --git a/spec/frontend/badges/store/actions_spec.js b/spec/frontend/badges/store/actions_spec.js index 921c21cb55e..365520d709c 100644 --- a/spec/frontend/badges/store/actions_spec.js +++ b/spec/frontend/badges/store/actions_spec.js @@ -9,7 +9,10 @@ import { createDummyBadge, createDummyBadgeResponse } from '../dummy_badge'; describe('Badges store actions', () => { const dummyEndpointUrl = `${TEST_HOST}/badges/endpoint`; - const dummyBadges = [{ ...createDummyBadge(), id: 5 }, { ...createDummyBadge(), id: 6 }]; + const dummyBadges = [ + { ...createDummyBadge(), id: 5 }, + { ...createDummyBadge(), id: 6 }, + ]; let axiosMock; let badgeId; diff --git a/spec/frontend/batch_comments/components/diff_file_drafts_spec.js b/spec/frontend/batch_comments/components/diff_file_drafts_spec.js index 6e0b61db9fa..dcb68b1804f 100644 --- a/spec/frontend/batch_comments/components/diff_file_drafts_spec.js +++ b/spec/frontend/batch_comments/components/diff_file_drafts_spec.js @@ -44,18 +44,8 @@ describe('Batch comments diff file drafts component', () => { expect(vm.findAll('.js-diff-notes-index').length).toEqual(2); - expect( - vm - .findAll('.js-diff-notes-index') - .at(0) - .text(), - ).toEqual('1'); - - expect( - vm - .findAll('.js-diff-notes-index') - .at(1) - .text(), - ).toEqual('2'); + expect(vm.findAll('.js-diff-notes-index').at(0).text()).toEqual('1'); + + expect(vm.findAll('.js-diff-notes-index').at(1).text()).toEqual('2'); }); }); diff --git a/spec/frontend/behaviors/requires_input_spec.js b/spec/frontend/behaviors/requires_input_spec.js index 617fe49b059..0f27f89d6dc 100644 --- a/spec/frontend/behaviors/requires_input_spec.js +++ b/spec/frontend/behaviors/requires_input_spec.js @@ -32,30 +32,18 @@ describe('requiresInput', () => { it('enables submit when all required fields receive input', () => { $('.js-requires-input').requiresInput(); - $('#required1') - .val('input1') - .change(); + $('#required1').val('input1').change(); expect(submitButton).toBeDisabled(); - $('#optional1') - .val('input1') - .change(); + $('#optional1').val('input1').change(); expect(submitButton).toBeDisabled(); - $('#required2') - .val('input2') - .change(); - $('#required3') - .val('input3') - .change(); - $('#required4') - .val('input4') - .change(); - $('#required5') - .val('1') - .change(); + $('#required2').val('input2').change(); + $('#required3').val('input3').change(); + $('#required4').val('input4').change(); + $('#required5').val('1').change(); expect($('.submit')).not.toBeDisabled(); }); diff --git a/spec/frontend/blob/components/blob_header_filepath_spec.js b/spec/frontend/blob/components/blob_header_filepath_spec.js index 067a4ae61a0..7b8b5050486 100644 --- a/spec/frontend/blob/components/blob_header_filepath_spec.js +++ b/spec/frontend/blob/components/blob_header_filepath_spec.js @@ -32,12 +32,7 @@ describe('Blob Header Filepath', () => { it('renders regular name', () => { createComponent(); - expect( - wrapper - .find('.js-blob-header-filepath') - .text() - .trim(), - ).toBe(MockBlob.path); + expect(wrapper.find('.js-blob-header-filepath').text().trim()).toBe(MockBlob.path); }); it('does not fail if the name is empty', () => { @@ -71,12 +66,7 @@ describe('Blob Header Filepath', () => { ); expect(wrapper.text()).toContain(slotContent); - expect( - wrapper - .text() - .trim() - .substring(0, slotContent.length), - ).toBe(slotContent); + expect(wrapper.text().trim().substring(0, slotContent.length)).toBe(slotContent); }); }); diff --git a/spec/frontend/boards/components/board_assignee_dropdown_spec.js b/spec/frontend/boards/components/board_assignee_dropdown_spec.js index bbdcc707f09..1797437d282 100644 --- a/spec/frontend/boards/components/board_assignee_dropdown_spec.js +++ b/spec/frontend/boards/components/board_assignee_dropdown_spec.js @@ -102,7 +102,7 @@ describe('BoardCardAssigneeDropdown', () => { beforeEach(() => { store.state.activeId = '1'; store.state.issues = { - '1': { + 1: { iid, assignees: [{ username: activeIssueName, name: activeIssueName, id: activeIssueName }], }, @@ -145,12 +145,7 @@ describe('BoardCardAssigneeDropdown', () => { it('renders gl-avatar-labeled in gl-avatar-link', () => { const item = findByText('hello'); - expect( - item - .find(GlAvatarLink) - .find(GlAvatarLabeled) - .exists(), - ).toBe(true); + expect(item.find(GlAvatarLink).find(GlAvatarLabeled).exists()).toBe(true); }); }); diff --git a/spec/frontend/boards/components/board_card_spec.js b/spec/frontend/boards/components/board_card_spec.js index 8186723173c..e600bc8704d 100644 --- a/spec/frontend/boards/components/board_card_spec.js +++ b/spec/frontend/boards/components/board_card_spec.js @@ -134,9 +134,7 @@ describe('BoardCard', () => { it('does not set detail issue if link is clicked', () => { mountComponent(); - findIssueCardInner() - .find('a') - .trigger('mouseup'); + findIssueCardInner().find('a').trigger('mouseup'); expect(boardsStore.detail.issue).toEqual({}); }); diff --git a/spec/frontend/boards/components/issue_time_estimate_deprecated_spec.js b/spec/frontend/boards/components/issue_time_estimate_deprecated_spec.js index 8e5c0af6f9d..21b3fac15ef 100644 --- a/spec/frontend/boards/components/issue_time_estimate_deprecated_spec.js +++ b/spec/frontend/boards/components/issue_time_estimate_deprecated_spec.js @@ -24,12 +24,7 @@ describe('Issue Time Estimate component', () => { }); it('renders the correct time estimate', () => { - expect( - wrapper - .find('time') - .text() - .trim(), - ).toEqual('2w 3d 1m'); + expect(wrapper.find('time').text().trim()).toEqual('2w 3d 1m'); }); it('renders expanded time estimate in tooltip', () => { @@ -41,12 +36,7 @@ describe('Issue Time Estimate component', () => { wrapper.setProps({ estimate: 'Foo <script>alert("XSS")</script>' }); wrapper.vm.$nextTick(() => { expect(alertSpy).not.toHaveBeenCalled(); - expect( - wrapper - .find('time') - .text() - .trim(), - ).toEqual('0m'); + expect(wrapper.find('time').text().trim()).toEqual('0m'); expect(wrapper.find('.js-issue-time-estimate').text()).toContain('0m'); done(); }); @@ -64,12 +54,7 @@ describe('Issue Time Estimate component', () => { }); it('renders the correct time estimate', () => { - expect( - wrapper - .find('time') - .text() - .trim(), - ).toEqual('104h 1m'); + expect(wrapper.find('time').text().trim()).toEqual('104h 1m'); }); it('renders expanded time estimate in tooltip', () => { diff --git a/spec/frontend/boards/components/issue_time_estimate_spec.js b/spec/frontend/boards/components/issue_time_estimate_spec.js index 2ef439ebc04..b09f879ea85 100644 --- a/spec/frontend/boards/components/issue_time_estimate_spec.js +++ b/spec/frontend/boards/components/issue_time_estimate_spec.js @@ -21,12 +21,7 @@ describe('Issue Time Estimate component', () => { }); it('renders the correct time estimate', () => { - expect( - wrapper - .find('time') - .text() - .trim(), - ).toEqual('2w 3d 1m'); + expect(wrapper.find('time').text().trim()).toEqual('2w 3d 1m'); }); it('renders expanded time estimate in tooltip', () => { @@ -38,12 +33,7 @@ describe('Issue Time Estimate component', () => { wrapper.setProps({ estimate: 'Foo <script>alert("XSS")</script>' }); wrapper.vm.$nextTick(() => { expect(alertSpy).not.toHaveBeenCalled(); - expect( - wrapper - .find('time') - .text() - .trim(), - ).toEqual('0m'); + expect(wrapper.find('time').text().trim()).toEqual('0m'); expect(wrapper.find('.js-issue-time-estimate').text()).toContain('0m'); done(); }); @@ -63,12 +53,7 @@ describe('Issue Time Estimate component', () => { }); it('renders the correct time estimate', () => { - expect( - wrapper - .find('time') - .text() - .trim(), - ).toEqual('104h 1m'); + expect(wrapper.find('time').text().trim()).toEqual('104h 1m'); }); it('renders expanded time estimate in tooltip', () => { diff --git a/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js b/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js index da000d21f6a..cc877ca818b 100644 --- a/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js +++ b/spec/frontend/boards/components/sidebar/board_sidebar_labels_select_spec.js @@ -84,7 +84,10 @@ describe('~/boards/components/sidebar/board_sidebar_labels_select.vue', () => { }); describe('when labels are updated over existing labels', () => { - const testLabelsPayload = [{ id: 5, set: true }, { id: 7, set: true }]; + const testLabelsPayload = [ + { id: 5, set: true }, + { id: 7, set: true }, + ]; const expectedLabels = [{ id: 5 }, { id: 7 }]; beforeEach(async () => { diff --git a/spec/frontend/boards/issue_card_deprecated_spec.js b/spec/frontend/boards/issue_card_deprecated_spec.js index 6debe8c0409..0b34be65029 100644 --- a/spec/frontend/boards/issue_card_deprecated_spec.js +++ b/spec/frontend/boards/issue_card_deprecated_spec.js @@ -245,12 +245,7 @@ describe('Issue card component', () => { }); it('renders more avatar counter', () => { - expect( - wrapper - .find('.board-card-assignee .avatar-counter') - .text() - .trim(), - ).toEqual('+2'); + expect(wrapper.find('.board-card-assignee .avatar-counter').text().trim()).toEqual('+2'); }); it('renders two assignees', () => { @@ -278,12 +273,7 @@ describe('Issue card component', () => { }); wrapper.vm.$nextTick(() => { - expect( - wrapper - .find('.board-card-assignee .avatar-counter') - .text() - .trim(), - ).toEqual('99+'); + expect(wrapper.find('.board-card-assignee .avatar-counter').text().trim()).toEqual('99+'); done(); }); }); diff --git a/spec/frontend/boards/issue_card_inner_spec.js b/spec/frontend/boards/issue_card_inner_spec.js index 3070f826c0d..d6029c4b66f 100644 --- a/spec/frontend/boards/issue_card_inner_spec.js +++ b/spec/frontend/boards/issue_card_inner_spec.js @@ -250,12 +250,7 @@ describe('Issue card component', () => { }); it('renders more avatar counter', () => { - expect( - wrapper - .find('.board-card-assignee .avatar-counter') - .text() - .trim(), - ).toEqual('+2'); + expect(wrapper.find('.board-card-assignee .avatar-counter').text().trim()).toEqual('+2'); }); it('renders two assignees', () => { @@ -281,12 +276,7 @@ describe('Issue card component', () => { await wrapper.vm.$nextTick(); - expect( - wrapper - .find('.board-card-assignee .avatar-counter') - .text() - .trim(), - ).toEqual('99+'); + expect(wrapper.find('.board-card-assignee .avatar-counter').text().trim()).toEqual('99+'); }); }); }); diff --git a/spec/frontend/boards/project_select_spec.js b/spec/frontend/boards/project_select_spec.js index e187828702e..fd4f84e996a 100644 --- a/spec/frontend/boards/project_select_spec.js +++ b/spec/frontend/boards/project_select_spec.js @@ -39,9 +39,7 @@ describe('ProjectSelect component', () => { const findLabel = () => wrapper.find("[data-testid='header-label']"); const findGlDropdown = () => wrapper.find(GlDropdown); const findGlDropdownLoadingIcon = () => - findGlDropdown() - .find('button:first-child') - .find(GlLoadingIcon); + findGlDropdown().find('button:first-child').find(GlLoadingIcon); const findGlSearchBoxByType = () => wrapper.find(GlSearchBoxByType); const findGlDropdownItems = () => wrapper.findAll(GlDropdownItem); const findFirstGlDropdownItem = () => findGlDropdownItems().at(0); @@ -159,9 +157,7 @@ describe('ProjectSelect component', () => { await createWrapper(); - await findFirstGlDropdownItem() - .find('button') - .trigger('click'); + await findFirstGlDropdownItem().find('button').trigger('click'); }); it('emits setSelectedProject with correct project metadata', () => { @@ -174,11 +170,9 @@ describe('ProjectSelect component', () => { }); it('renders the name of the selected project', () => { - expect( - findGlDropdown() - .find('.gl-new-dropdown-button-text') - .text(), - ).toBe(mockProjectsList1[0].name); + expect(findGlDropdown().find('.gl-new-dropdown-button-text').text()).toBe( + mockProjectsList1[0].name, + ); }); }); diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js index 19018447f3f..efe9afde530 100644 --- a/spec/frontend/boards/stores/actions_spec.js +++ b/spec/frontend/boards/stores/actions_spec.js @@ -526,8 +526,8 @@ describe('moveIssue', () => { }; const issues = { - '436': mockIssue, - '437': mockIssue2, + 436: mockIssue, + 437: mockIssue2, }; const state = { diff --git a/spec/frontend/boards/stores/getters_spec.js b/spec/frontend/boards/stores/getters_spec.js index 6ceb8867d1f..8a9ff8232e7 100644 --- a/spec/frontend/boards/stores/getters_spec.js +++ b/spec/frontend/boards/stores/getters_spec.js @@ -39,7 +39,7 @@ describe('Boards - Getters', () => { }); describe('getIssueById', () => { - const state = { issues: { '1': 'issue' } }; + const state = { issues: { 1: 'issue' } }; it.each` id | expected @@ -56,7 +56,7 @@ describe('Boards - Getters', () => { ${'1'} | ${'issue'} ${''} | ${{}} `('returns $expected when $id is passed to state', ({ id, expected }) => { - const state = { issues: { '1': 'issue' }, activeId: id }; + const state = { issues: { 1: 'issue' }, activeId: id }; expect(getters.activeIssue(state)).toEqual(expected); }); diff --git a/spec/frontend/boards/stores/mutations_spec.js b/spec/frontend/boards/stores/mutations_spec.js index 50c621cdd52..1fa948b3848 100644 --- a/spec/frontend/boards/stores/mutations_spec.js +++ b/spec/frontend/boards/stores/mutations_spec.js @@ -236,7 +236,7 @@ describe('Board Store Mutations', () => { 'gid://gitlab/List/1': [mockIssue.id], }; const issues = { - '1': mockIssue, + 1: mockIssue, }; state = { @@ -345,8 +345,8 @@ describe('Board Store Mutations', () => { }; const issues = { - '1': mockIssue, - '2': mockIssue2, + 1: mockIssue, + 2: mockIssue2, }; state = { @@ -374,7 +374,7 @@ describe('Board Store Mutations', () => { describe('MOVE_ISSUE_SUCCESS', () => { it('updates issue in issues state', () => { const issues = { - '436': { id: rawIssue.id }, + 436: { id: rawIssue.id }, }; state = { @@ -386,7 +386,7 @@ describe('Board Store Mutations', () => { issue: rawIssue, }); - expect(state.issues).toEqual({ '436': { ...mockIssue, id: 436 } }); + expect(state.issues).toEqual({ 436: { ...mockIssue, id: 436 } }); }); }); @@ -446,7 +446,7 @@ describe('Board Store Mutations', () => { 'gid://gitlab/List/1': [mockIssue.id], }; const issues = { - '1': mockIssue, + 1: mockIssue, }; state = { @@ -472,8 +472,8 @@ describe('Board Store Mutations', () => { 'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id], }; const issues = { - '1': mockIssue, - '2': mockIssue2, + 1: mockIssue, + 2: mockIssue2, }; state = { @@ -496,8 +496,8 @@ describe('Board Store Mutations', () => { 'gid://gitlab/List/1': [mockIssue.id, mockIssue2.id], }; const issues = { - '1': mockIssue, - '2': mockIssue2, + 1: mockIssue, + 2: mockIssue2, }; state = { diff --git a/spec/frontend/ci_settings_pipeline_triggers/components/triggers_list_spec.js b/spec/frontend/ci_settings_pipeline_triggers/components/triggers_list_spec.js index e07afb5d736..b10f4984aff 100644 --- a/spec/frontend/ci_settings_pipeline_triggers/components/triggers_list_spec.js +++ b/spec/frontend/ci_settings_pipeline_triggers/components/triggers_list_spec.js @@ -19,10 +19,7 @@ describe('TriggersList', () => { const findHeaderAt = i => wrapper.findAll('thead th').at(i); const findRows = () => wrapper.findAll('tbody tr'); const findRowAt = i => findRows().at(i); - const findCell = (i, col) => - findRowAt(i) - .findAll('td') - .at(col); + const findCell = (i, col) => findRowAt(i).findAll('td').at(col); const findClipboardBtn = i => findCell(i, 0).find(ClipboardButton); const findInvalidBadge = i => findCell(i, 0).find(GlBadge); const findEditBtn = i => findRowAt(i).find('[data-testid="edit-btn"]'); @@ -67,11 +64,7 @@ describe('TriggersList', () => { it('displays a time ago label when last used', () => { expect(findCell(0, 3).text()).toBe('Never'); - expect( - findCell(1, 3) - .find(TimeAgoTooltip) - .props('time'), - ).toBe(triggers[1].lastUsed); + expect(findCell(1, 3).find(TimeAgoTooltip).props('time')).toBe(triggers[1].lastUsed); }); it('displays actions in a rows', () => { diff --git a/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js b/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js index 4a2e56c570d..ad1bdec1735 100644 --- a/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js +++ b/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js @@ -31,10 +31,7 @@ describe('VariableList', () => { it('should add another row when editing the last rows key input', () => { const $row = $wrapper.find('.js-row'); - $row - .find('.js-ci-variable-input-key') - .val('foo') - .trigger('input'); + $row.find('.js-ci-variable-input-key').val('foo').trigger('input'); expect($wrapper.find('.js-row').length).toBe(2); @@ -46,10 +43,7 @@ describe('VariableList', () => { it('should add another row when editing the last rows value textarea', () => { const $row = $wrapper.find('.js-row'); - $row - .find('.js-ci-variable-input-value') - .val('foo') - .trigger('input'); + $row.find('.js-ci-variable-input-value').val('foo').trigger('input'); expect($wrapper.find('.js-row').length).toBe(2); @@ -61,18 +55,11 @@ describe('VariableList', () => { it('should remove empty row after blurring', () => { const $row = $wrapper.find('.js-row'); - $row - .find('.js-ci-variable-input-key') - .val('foo') - .trigger('input'); + $row.find('.js-ci-variable-input-key').val('foo').trigger('input'); expect($wrapper.find('.js-row').length).toBe(2); - $row - .find('.js-ci-variable-input-key') - .val('') - .trigger('input') - .trigger('blur'); + $row.find('.js-ci-variable-input-key').val('').trigger('input').trigger('blur'); expect($wrapper.find('.js-row').length).toBe(1); }); diff --git a/spec/frontend/confirm_modal_spec.js b/spec/frontend/confirm_modal_spec.js index 70076532a94..1b7edfb8ee6 100644 --- a/spec/frontend/confirm_modal_spec.js +++ b/spec/frontend/confirm_modal_spec.js @@ -78,9 +78,7 @@ describe('ConfirmModal', () => { describe('when button clicked', () => { beforeEach(() => { initConfirmModal(); - findJsHooks() - .item(0) - .click(); + findJsHooks().item(0).click(); }); it('does not replace JsHook with GlModal', () => { @@ -116,9 +114,7 @@ describe('ConfirmModal', () => { `(`when multiple buttons exist`, ({ index }) => { beforeEach(() => { initConfirmModal(); - findJsHooks() - .item(index) - .click(); + findJsHooks().item(index).click(); }); it('correct props are passed to gl-modal', () => { diff --git a/spec/frontend/create_cluster/components/cluster_form_dropdown_spec.js b/spec/frontend/create_cluster/components/cluster_form_dropdown_spec.js index 17abf409717..de6725a2b74 100644 --- a/spec/frontend/create_cluster/components/cluster_form_dropdown_spec.js +++ b/spec/frontend/create_cluster/components/cluster_form_dropdown_spec.js @@ -44,10 +44,7 @@ describe('ClusterFormDropdown', () => { wrapper.setProps({ items }); return wrapper.vm.$nextTick().then(() => { - wrapper - .findAll('.js-dropdown-item') - .at(1) - .trigger('click'); + wrapper.findAll('.js-dropdown-item').at(1).trigger('click'); return wrapper.vm.$nextTick(); }); }); @@ -65,17 +62,11 @@ describe('ClusterFormDropdown', () => { return wrapper.vm .$nextTick() .then(() => { - wrapper - .findAll('.js-dropdown-item') - .at(0) - .trigger('click'); + wrapper.findAll('.js-dropdown-item').at(0).trigger('click'); return wrapper.vm.$nextTick(); }) .then(() => { - wrapper - .findAll('.js-dropdown-item') - .at(1) - .trigger('click'); + wrapper.findAll('.js-dropdown-item').at(1).trigger('click'); return wrapper.vm.$nextTick(); }); }); @@ -102,10 +93,7 @@ describe('ClusterFormDropdown', () => { wrapper.setProps({ items, multiple: true, value: null }); return wrapper.vm.$nextTick().then(() => { - wrapper - .findAll('.js-dropdown-item') - .at(0) - .trigger('click'); + wrapper.findAll('.js-dropdown-item').at(0).trigger('click'); expect(wrapper.emitted('input')[0]).toEqual([[firstItem.value]]); }); diff --git a/spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js b/spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js index 03c22c570a8..2853d18e2cb 100644 --- a/spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js +++ b/spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js @@ -101,7 +101,10 @@ describe('awsServicesFacade', () => { let vpcsOutput; beforeEach(() => { - vpcs = [{ VpcId: 'vpc-1', Tags: [] }, { VpcId: 'vpc-2', Tags: [] }]; + vpcs = [ + { VpcId: 'vpc-1', Tags: [] }, + { VpcId: 'vpc-2', Tags: [] }, + ]; vpcsOutput = vpcs.map(({ VpcId: vpcId }) => ({ name: vpcId, value: vpcId })); mockDescribeVpcsPromise.mockResolvedValueOnce({ Vpcs: vpcs }); diff --git a/spec/frontend/create_item_dropdown_spec.js b/spec/frontend/create_item_dropdown_spec.js index a814952faab..148b3468ff2 100644 --- a/spec/frontend/create_item_dropdown_spec.js +++ b/spec/frontend/create_item_dropdown_spec.js @@ -27,20 +27,14 @@ describe('CreateItemDropdown', () => { function createItemAndClearInput(text) { // Filter for the new item - $wrapperEl - .find('.dropdown-input-field') - .val(text) - .trigger('input'); + $wrapperEl.find('.dropdown-input-field').val(text).trigger('input'); // Create the new item const $createButton = $wrapperEl.find('.js-dropdown-create-new-item'); $createButton.click(); // Clear out the filter - $wrapperEl - .find('.dropdown-input-field') - .val('') - .trigger('input'); + $wrapperEl.find('.dropdown-input-field').val('').trigger('input'); } beforeEach(() => { @@ -91,10 +85,7 @@ describe('CreateItemDropdown', () => { $('.js-dropdown-menu-toggle').click(); // Filter for the new item - $wrapperEl - .find('.dropdown-input-field') - .val(NEW_ITEM_TEXT) - .trigger('input'); + $wrapperEl.find('.dropdown-input-field').val(NEW_ITEM_TEXT).trigger('input'); }); it('create new item button should include the filter text', () => { diff --git a/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js b/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js index 9f28ddfd230..039e85d604b 100644 --- a/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js +++ b/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js @@ -29,10 +29,7 @@ describe('Deploy freeze modal', () => { }); const findModal = () => wrapper.find(GlModal); - const addDeployFreezeButton = () => - findModal() - .findAll(GlButton) - .at(1); + const addDeployFreezeButton = () => findModal().findAll(GlButton).at(1); const setInput = (freezeStartCron, freezeEndCron, selectedTimezone) => { store.state.freezeStartCron = freezeStartCron; diff --git a/spec/frontend/deploy_keys/components/app_spec.js b/spec/frontend/deploy_keys/components/app_spec.js index 291502c9ed7..8d37b5ce38f 100644 --- a/spec/frontend/deploy_keys/components/app_spec.js +++ b/spec/frontend/deploy_keys/components/app_spec.js @@ -64,12 +64,7 @@ describe('Deploy keys app component', () => { expect(element.exists()).toBe(true); expect(element.text().trim()).toContain(label); - expect( - element - .find('.badge') - .text() - .trim(), - ).toBe(count.toString()); + expect(element.find('.badge').text().trim()).toBe(count.toString()); }); }); diff --git a/spec/frontend/deploy_keys/components/key_spec.js b/spec/frontend/deploy_keys/components/key_spec.js index d990c64c241..f1305a45adc 100644 --- a/spec/frontend/deploy_keys/components/key_spec.js +++ b/spec/frontend/deploy_keys/components/key_spec.js @@ -9,11 +9,7 @@ describe('Deploy keys key', () => { const data = getJSONFixture('deploy_keys/keys.json'); - const findTextAndTrim = selector => - wrapper - .find(selector) - .text() - .trim(); + const findTextAndTrim = selector => wrapper.find(selector).text().trim(); const createComponent = propsData => { wrapper = mount(key, { @@ -103,10 +99,7 @@ describe('Deploy keys key', () => { it('expands all project labels after click', () => { createComponent({ deployKey }); const { length } = deployKey.deploy_keys_projects; - wrapper - .findAll('.deploy-project-label') - .at(1) - .trigger('click'); + wrapper.findAll('.deploy-project-label').at(1).trigger('click'); return wrapper.vm.$nextTick().then(() => { const labels = wrapper.findAll('.deploy-project-label'); diff --git a/spec/frontend/deploy_keys/components/keys_panel_spec.js b/spec/frontend/deploy_keys/components/keys_panel_spec.js index 53c8ba073bc..ecfbcaec894 100644 --- a/spec/frontend/deploy_keys/components/keys_panel_spec.js +++ b/spec/frontend/deploy_keys/components/keys_panel_spec.js @@ -48,12 +48,9 @@ describe('Deploy keys panel', () => { expect(wrapper.find('.settings-message').exists()).toBe(true); - expect( - wrapper - .find('.settings-message') - .text() - .trim(), - ).toBe('No deploy keys found. Create one with the form above.'); + expect(wrapper.find('.settings-message').text().trim()).toBe( + 'No deploy keys found. Create one with the form above.', + ); }); it('renders no table header if keys are empty', () => { diff --git a/spec/frontend/deprecated_jquery_dropdown_spec.js b/spec/frontend/deprecated_jquery_dropdown_spec.js index e6323859899..32e3a1532a4 100644 --- a/spec/frontend/deprecated_jquery_dropdown_spec.js +++ b/spec/frontend/deprecated_jquery_dropdown_spec.js @@ -230,10 +230,7 @@ describe('deprecatedJQueryDropdown', () => { it('should still have input value on close and restore', () => { const $searchInput = $(SEARCH_INPUT_SELECTOR); initDropDown.call(this, false, true); - $searchInput - .trigger('focus') - .val('g') - .trigger('input'); + $searchInput.trigger('focus').val('g').trigger('input'); expect($searchInput.val()).toEqual('g'); test.dropdownButtonElement.trigger('hidden.bs.dropdown'); diff --git a/spec/frontend/design_management/components/design_notes/design_discussion_spec.js b/spec/frontend/design_management/components/design_notes/design_discussion_spec.js index 9fbd9b2c2a3..0687db177b4 100644 --- a/spec/frontend/design_management/components/design_notes/design_discussion_spec.js +++ b/spec/frontend/design_management/components/design_notes/design_discussion_spec.js @@ -150,16 +150,8 @@ describe('Design discussions component', () => { }); it('shows only the first note', () => { - expect( - findDesignNotes() - .at(0) - .isVisible(), - ).toBe(true); - expect( - findDesignNotes() - .at(1) - .isVisible(), - ).toBe(false); + expect(findDesignNotes().at(0).isVisible()).toBe(true); + expect(findDesignNotes().at(1).isVisible()).toBe(false); }); it('renders resolved message', () => { @@ -193,11 +185,7 @@ describe('Design discussions component', () => { }); it('renders the second note', () => { - expect( - findDesignNotes() - .at(1) - .isVisible(), - ).toBe(true); + expect(findDesignNotes().at(1).isVisible()).toBe(true); }); it('renders a reply placeholder', () => { diff --git a/spec/frontend/design_management/pages/index_spec.js b/spec/frontend/design_management/pages/index_spec.js index 147169dd9aa..31810fc34f0 100644 --- a/spec/frontend/design_management/pages/index_spec.js +++ b/spec/frontend/design_management/pages/index_spec.js @@ -545,16 +545,12 @@ describe('Design management index page', () => { }); it('adds two designs to selected designs when their checkboxes are checked', () => { - findDesignCheckboxes() - .at(0) - .trigger('click'); + findDesignCheckboxes().at(0).trigger('click'); return wrapper.vm .$nextTick() .then(() => { - findDesignCheckboxes() - .at(1) - .trigger('click'); + findDesignCheckboxes().at(1).trigger('click'); return wrapper.vm.$nextTick(); }) @@ -581,9 +577,7 @@ describe('Design management index page', () => { }); it('removes all designs from selected designs when at least one design was selected', () => { - findDesignCheckboxes() - .at(0) - .trigger('click'); + findDesignCheckboxes().at(0).trigger('click'); return wrapper.vm .$nextTick() @@ -716,11 +710,7 @@ describe('Design management index page', () => { await wrapper.vm.$nextTick(); expect(findDesigns()).toHaveLength(3); - expect( - findDesigns() - .at(0) - .props('id'), - ).toBe('1'); + expect(findDesigns().at(0).props('id')).toBe('1'); }); it('calls a mutation with correct parameters and reorders designs', async () => { @@ -732,11 +722,7 @@ describe('Design management index page', () => { await wrapper.vm.$nextTick(); - expect( - findDesigns() - .at(0) - .props('id'), - ).toBe('2'); + expect(findDesigns().at(0).props('id')).toBe('2'); }); it('prevents reordering when reorderDesigns mutation is in progress', async () => { diff --git a/spec/frontend/diffs/components/diff_discussions_spec.js b/spec/frontend/diffs/components/diff_discussions_spec.js index 96b76183cee..4f2fa4b84e3 100644 --- a/spec/frontend/diffs/components/diff_discussions_spec.js +++ b/spec/frontend/diffs/components/diff_discussions_spec.js @@ -91,12 +91,7 @@ describe('DiffDiscussions', () => { const noteableDiscussion = wrapper.find(NoteableDiscussion); expect(noteableDiscussion.find('.badge-pill').exists()).toBe(true); - expect( - noteableDiscussion - .find('.badge-pill') - .text() - .trim(), - ).toBe('1'); + expect(noteableDiscussion.find('.badge-pill').text().trim()).toBe('1'); }); }); }); diff --git a/spec/frontend/diffs/components/diff_gutter_avatars_spec.js b/spec/frontend/diffs/components/diff_gutter_avatars_spec.js index 61e110b345a..5884a9ebd3a 100644 --- a/spec/frontend/diffs/components/diff_gutter_avatars_spec.js +++ b/spec/frontend/diffs/components/diff_gutter_avatars_spec.js @@ -66,9 +66,7 @@ describe('DiffGutterAvatars', () => { }); it('should emit toggleDiscussions event on avatars click', () => { - findUserAvatars() - .at(0) - .trigger('click'); + findUserAvatars().at(0).trigger('click'); return wrapper.vm.$nextTick().then(() => { expect(wrapper.emitted().toggleLineDiscussions).toBeTruthy(); diff --git a/spec/frontend/diffs/components/diff_view_spec.js b/spec/frontend/diffs/components/diff_view_spec.js index 4d90112d8f6..2190aa1794f 100644 --- a/spec/frontend/diffs/components/diff_view_spec.js +++ b/spec/frontend/diffs/components/diff_view_spec.js @@ -64,12 +64,7 @@ describe('DiffView', () => { inline: type === 'inline', }); expect(wrapper.findAll(DiffCommentCell).length).toBe(total); - expect( - wrapper - .find(container) - .find(DiffCommentCell) - .exists(), - ).toBe(true); + expect(wrapper.find(container).find(DiffCommentCell).exists()).toBe(true); }, ); diff --git a/spec/frontend/diffs/components/image_diff_overlay_spec.js b/spec/frontend/diffs/components/image_diff_overlay_spec.js index 087715111b4..209c101d09f 100644 --- a/spec/frontend/diffs/components/image_diff_overlay_spec.js +++ b/spec/frontend/diffs/components/image_diff_overlay_spec.js @@ -49,18 +49,8 @@ describe('Diffs image diff overlay component', () => { createComponent(); const imageBadges = getAllImageBadges(); - expect( - imageBadges - .at(0) - .text() - .trim(), - ).toBe('1'); - expect( - imageBadges - .at(1) - .text() - .trim(), - ).toBe('2'); + expect(imageBadges.at(0).text().trim()).toBe('1'); + expect(imageBadges.at(1).text().trim()).toBe('2'); }); it('renders icon when showCommentIcon is true', () => { diff --git a/spec/frontend/diffs/components/tree_list_spec.js b/spec/frontend/diffs/components/tree_list_spec.js index c89403e4869..4666321e0c2 100644 --- a/spec/frontend/diffs/components/tree_list_spec.js +++ b/spec/frontend/diffs/components/tree_list_spec.js @@ -88,16 +88,8 @@ describe('Diffs tree list component', () => { it('renders tree', () => { expect(getFileRows()).toHaveLength(2); - expect( - getFileRows() - .at(0) - .html(), - ).toContain('index.js'); - expect( - getFileRows() - .at(1) - .html(), - ).toContain('app'); + expect(getFileRows().at(0).html()).toContain('index.js'); + expect(getFileRows().at(1).html()).toContain('app'); }); it('hides file stats', () => { @@ -111,9 +103,7 @@ describe('Diffs tree list component', () => { it('calls toggleTreeOpen when clicking folder', () => { jest.spyOn(wrapper.vm.$store, 'dispatch').mockReturnValue(undefined); - getFileRows() - .at(1) - .trigger('click'); + getFileRows().at(1).trigger('click'); expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith('diffs/toggleTreeOpen', 'app'); }); diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js index 55e744e573b..b351f4e4eca 100644 --- a/spec/frontend/diffs/store/actions_spec.js +++ b/spec/frontend/diffs/store/actions_spec.js @@ -272,7 +272,7 @@ describe('DiffsStoreActions', () => { afterEach(() => mock.restore()); it('should commit SET_COVERAGE_DATA with received response', done => { - const data = { files: { 'app.js': { '1': 0, '2': 1 } } }; + const data = { files: { 'app.js': { 1: 0, 2: 1 } } }; mock.onGet(endpointCoverage).reply(200, { data }); @@ -1410,7 +1410,7 @@ describe('DiffsStoreActions', () => { const state = { diffFiles: [{ file_hash: '123' }] }; const rootGetters = { getDiscussion: () => ({ diff_file: { file_hash: '123' } }), - notesById: { '1': { discussion_id: '2' } }, + notesById: { 1: { discussion_id: '2' } }, }; setCurrentDiffFileIdFromNote({ commit, state, rootGetters }, '1'); @@ -1423,7 +1423,7 @@ describe('DiffsStoreActions', () => { const state = { diffFiles: [{ file_hash: '123' }] }; const rootGetters = { getDiscussion: () => ({ id: '1' }), - notesById: { '1': { discussion_id: '2' } }, + notesById: { 1: { discussion_id: '2' } }, }; setCurrentDiffFileIdFromNote({ commit, state, rootGetters }, '1'); @@ -1436,7 +1436,7 @@ describe('DiffsStoreActions', () => { const state = { diffFiles: [{ file_hash: '123' }] }; const rootGetters = { getDiscussion: () => ({ diff_file: { file_hash: '124' } }), - notesById: { '1': { discussion_id: '2' } }, + notesById: { 1: { discussion_id: '2' } }, }; setCurrentDiffFileIdFromNote({ commit, state, rootGetters }, '1'); diff --git a/spec/frontend/diffs/store/getters_spec.js b/spec/frontend/diffs/store/getters_spec.js index 8cbcefa28d1..4d7f861ac22 100644 --- a/spec/frontend/diffs/store/getters_spec.js +++ b/spec/frontend/diffs/store/getters_spec.js @@ -251,9 +251,12 @@ describe('Diffs Module Getters', () => { discussionMock.diff_file.file_hash = diffFileMock.file_hash; expect( - getters.getDiffFileDiscussions(localState, {}, {}, { discussions: [discussionMock] })( - diffFileMock, - ).length, + getters.getDiffFileDiscussions( + localState, + {}, + {}, + { discussions: [discussionMock] }, + )(diffFileMock).length, ).toEqual(1); }); @@ -345,7 +348,7 @@ describe('Diffs Module Getters', () => { describe('fileLineCoverage', () => { beforeEach(() => { - Object.assign(localState.coverageFiles, { files: { 'app.js': { '1': 0, '2': 5 } } }); + Object.assign(localState.coverageFiles, { files: { 'app.js': { 1: 0, 2: 5 } } }); }); it('returns empty object when no coverage data is available', () => { diff --git a/spec/frontend/diffs/store/mutations_spec.js b/spec/frontend/diffs/store/mutations_spec.js index be187c49a20..2c342d8e2a5 100644 --- a/spec/frontend/diffs/store/mutations_spec.js +++ b/spec/frontend/diffs/store/mutations_spec.js @@ -105,7 +105,7 @@ describe('DiffsStoreMutations', () => { describe('SET_COVERAGE_DATA', () => { it('should set coverage data properly', () => { const state = { coverageFiles: {} }; - const coverage = { 'app.js': { '1': 0, '2': 1 } }; + const coverage = { 'app.js': { 1: 0, 2: 1 } }; mutations[types.SET_COVERAGE_DATA](state, coverage); diff --git a/spec/frontend/error_tracking/components/error_tracking_actions_spec.js b/spec/frontend/error_tracking/components/error_tracking_actions_spec.js index b22805f5227..05b3d2f1dec 100644 --- a/spec/frontend/error_tracking/components/error_tracking_actions_spec.js +++ b/spec/frontend/error_tracking/components/error_tracking_actions_spec.js @@ -41,16 +41,8 @@ describe('Error Tracking Actions', () => { expect(findButtons().exists()).toBe(true); return wrapper.vm.$nextTick().then(() => { - expect( - findButtons() - .at(0) - .attributes('title'), - ).toBe('Ignore'); - expect( - findButtons() - .at(1) - .attributes('title'), - ).toBe('Resolve'); + expect(findButtons().at(0).attributes('title')).toBe('Ignore'); + expect(findButtons().at(1).attributes('title')).toBe('Resolve'); }); }); }); @@ -64,11 +56,7 @@ describe('Error Tracking Actions', () => { expect(findButtons().exists()).toBe(true); return wrapper.vm.$nextTick().then(() => { - expect( - findButtons() - .at(0) - .attributes('title'), - ).toBe('Undo Ignore'); + expect(findButtons().at(0).attributes('title')).toBe('Undo Ignore'); }); }); }); @@ -82,11 +70,7 @@ describe('Error Tracking Actions', () => { expect(findButtons().exists()).toBe(true); return wrapper.vm.$nextTick().then(() => { - expect( - findButtons() - .at(1) - .attributes('title'), - ).toBe('Unresolve'); + expect(findButtons().at(1).attributes('title')).toBe('Unresolve'); }); }); }); diff --git a/spec/frontend/error_tracking/components/error_tracking_list_spec.js b/spec/frontend/error_tracking/components/error_tracking_list_spec.js index 9a2d086e161..fa8992a8d9f 100644 --- a/spec/frontend/error_tracking/components/error_tracking_list_spec.js +++ b/spec/frontend/error_tracking/components/error_tracking_list_spec.js @@ -19,18 +19,9 @@ describe('ErrorTrackingList', () => { const findErrorListTable = () => wrapper.find('table'); const findErrorListRows = () => wrapper.findAll('tbody tr'); const dropdownsArray = () => wrapper.findAll(GlDropdown); - const findRecentSearchesDropdown = () => - dropdownsArray() - .at(0) - .find(GlDropdown); - const findStatusFilterDropdown = () => - dropdownsArray() - .at(1) - .find(GlDropdown); - const findSortDropdown = () => - dropdownsArray() - .at(2) - .find(GlDropdown); + const findRecentSearchesDropdown = () => dropdownsArray().at(0).find(GlDropdown); + const findStatusFilterDropdown = () => dropdownsArray().at(1).find(GlDropdown); + const findSortDropdown = () => dropdownsArray().at(2).find(GlDropdown); const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const findPagination = () => wrapper.find(GlPagination); const findErrorActions = () => wrapper.find(ErrorTrackingActions); diff --git a/spec/frontend/error_tracking/store/list/actions_spec.js b/spec/frontend/error_tracking/store/list/actions_spec.js index 7326472e1dd..e829912580a 100644 --- a/spec/frontend/error_tracking/store/list/actions_spec.js +++ b/spec/frontend/error_tracking/store/list/actions_spec.js @@ -48,7 +48,10 @@ describe('error tracking actions', () => { actions.startPolling, {}, {}, - [{ type: types.SET_LOADING, payload: true }, { type: types.SET_LOADING, payload: false }], + [ + { type: types.SET_LOADING, payload: true }, + { type: types.SET_LOADING, payload: false }, + ], [], () => { expect(createFlash).toHaveBeenCalledTimes(1); @@ -64,7 +67,10 @@ describe('error tracking actions', () => { actions.restartPolling, {}, {}, - [{ type: types.SET_ERRORS, payload: [] }, { type: types.SET_LOADING, payload: true }], + [ + { type: types.SET_ERRORS, payload: [] }, + { type: types.SET_LOADING, payload: true }, + ], [], ); }); @@ -110,7 +116,10 @@ describe('error tracking actions', () => { actions.sortByField, field, {}, - [{ type: types.SET_CURSOR, payload: null }, { type: types.SET_SORT_FIELD, payload: field }], + [ + { type: types.SET_CURSOR, payload: null }, + { type: types.SET_SORT_FIELD, payload: field }, + ], [{ type: 'stopPolling' }, { type: 'startPolling' }], ); }); diff --git a/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js b/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js index f4a765a3d73..e2a8b57f555 100644 --- a/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js +++ b/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js @@ -35,12 +35,7 @@ describe('error tracking settings form', () => { it('is rendered', () => { expect(wrapper.findAll(GlFormInput).length).toBe(2); expect(wrapper.find(GlFormInput).attributes('id')).toBe('error-tracking-api-host'); - expect( - wrapper - .findAll(GlFormInput) - .at(1) - .attributes('id'), - ).toBe('error-tracking-token'); + expect(wrapper.findAll(GlFormInput).at(1).attributes('id')).toBe('error-tracking-token'); expect(wrapper.findAll(GlButton).exists()).toBe(true); }); @@ -56,12 +51,9 @@ describe('error tracking settings form', () => { ); expect(pageText).not.toContain('Connection has failed. Re-check Auth Token and try again'); - expect( - wrapper - .findAll(GlFormInput) - .at(0) - .attributes('placeholder'), - ).toContain('https://mysentryserver.com'); + expect(wrapper.findAll(GlFormInput).at(0).attributes('placeholder')).toContain( + 'https://mysentryserver.com', + ); }); }); diff --git a/spec/frontend/feature_flags/components/environments_dropdown_spec.js b/spec/frontend/feature_flags/components/environments_dropdown_spec.js index 7bc71ef51c7..39ec05ebd4f 100644 --- a/spec/frontend/feature_flags/components/environments_dropdown_spec.js +++ b/spec/frontend/feature_flags/components/environments_dropdown_spec.js @@ -136,10 +136,7 @@ describe('Feature flags > Environments dropdown ', () => { }); it('emits create event', async () => { - wrapper - .findAll(GlButton) - .at(0) - .vm.$emit('click'); + wrapper.findAll(GlButton).at(0).vm.$emit('click'); await wrapper.vm.$nextTick(); expect(wrapper.emitted('createClicked')).toEqual([['production']]); }); diff --git a/spec/frontend/feature_flags/components/feature_flags_spec.js b/spec/frontend/feature_flags/components/feature_flags_spec.js index 3c1234fea94..83a2293be89 100644 --- a/spec/frontend/feature_flags/components/feature_flags_spec.js +++ b/spec/frontend/feature_flags/components/feature_flags_spec.js @@ -101,11 +101,9 @@ describe('Feature flags', () => { it('shows a feature flags limit reached alert', () => { expect(limitAlert().exists()).toBe(true); - expect( - limitAlert() - .find(GlSprintf) - .attributes('message'), - ).toContain('Feature flags limit reached'); + expect(limitAlert().find(GlSprintf).attributes('message')).toContain( + 'Feature flags limit reached', + ); }); describe('when the alert is dismissed', () => { diff --git a/spec/frontend/feature_flags/components/form_spec.js b/spec/frontend/feature_flags/components/form_spec.js index 2c2a726d26f..2473c59e450 100644 --- a/spec/frontend/feature_flags/components/form_spec.js +++ b/spec/frontend/feature_flags/components/form_spec.js @@ -347,10 +347,7 @@ describe('feature flag form', () => { return wrapper.vm.$nextTick(); }) .then(() => { - wrapper - .find('.js-add-new-scope') - .find(ToggleButton) - .vm.$emit('change', true); + wrapper.find('.js-add-new-scope').find(ToggleButton).vm.$emit('change', true); }) .then(() => { wrapper.find(ToggleButton).vm.$emit('change', true); diff --git a/spec/frontend/filtered_search/components/recent_searches_dropdown_content_spec.js b/spec/frontend/filtered_search/components/recent_searches_dropdown_content_spec.js index 158f70f7d47..36782403d6d 100644 --- a/spec/frontend/filtered_search/components/recent_searches_dropdown_content_spec.js +++ b/spec/frontend/filtered_search/components/recent_searches_dropdown_content_spec.js @@ -84,18 +84,11 @@ describe('Recent Searches Dropdown Content', () => { }); it('expect second dropdown to have 2 tokens', () => { - expect( - findDropdownItems() - .at(1) - .findAll('.js-dropdown-token'), - ).toHaveLength(2); + expect(findDropdownItems().at(1).findAll('.js-dropdown-token')).toHaveLength(2); }); it('emits recentSearchesItemSelected on dropdown item click', () => { - findDropdownItems() - .at(0) - .find('.js-dropdown-button') - .trigger('click'); + findDropdownItems().at(0).find('.js-dropdown-button').trigger('click'); expect(onRecentSearchesItemSelectedSpy).toHaveBeenCalledWith('foo'); }); diff --git a/spec/frontend/gfm_auto_complete_spec.js b/spec/frontend/gfm_auto_complete_spec.js index eb9343847f1..048491683b9 100644 --- a/spec/frontend/gfm_auto_complete_spec.js +++ b/spec/frontend/gfm_auto_complete_spec.js @@ -656,10 +656,7 @@ describe('GfmAutoComplete', () => { }); const triggerDropdown = text => { - $textarea - .trigger('focus') - .val(text) - .caret('pos', -1); + $textarea.trigger('focus').val(text).caret('pos', -1); $textarea.trigger('keyup'); return new Promise(window.requestAnimationFrame); diff --git a/spec/frontend/gl_field_errors_spec.js b/spec/frontend/gl_field_errors_spec.js index 078659bf429..f5b50c238df 100644 --- a/spec/frontend/gl_field_errors_spec.js +++ b/spec/frontend/gl_field_errors_spec.js @@ -41,18 +41,9 @@ describe('GL Style Field Errors', () => { }); it('should not show any errors before submit attempt', () => { - testContext.$form - .find('.email') - .val('not-a-valid-email') - .keyup(); - testContext.$form - .find('.text-required') - .val('') - .keyup(); - testContext.$form - .find('.alphanumberic') - .val('?---*') - .keyup(); + testContext.$form.find('.email').val('not-a-valid-email').keyup(); + testContext.$form.find('.text-required').val('').keyup(); + testContext.$form.find('.alphanumberic').val('?---*').keyup(); const errorsShown = testContext.$form.find('.gl-field-error-outline'); @@ -60,18 +51,9 @@ describe('GL Style Field Errors', () => { }); it('should show errors when input valid is submitted', () => { - testContext.$form - .find('.email') - .val('not-a-valid-email') - .keyup(); - testContext.$form - .find('.text-required') - .val('') - .keyup(); - testContext.$form - .find('.alphanumberic') - .val('?---*') - .keyup(); + testContext.$form.find('.email').val('not-a-valid-email').keyup(); + testContext.$form.find('.text-required').val('').keyup(); + testContext.$form.find('.alphanumberic').val('?---*').keyup(); testContext.$form.submit(); diff --git a/spec/frontend/groups/components/visibility_level_dropdown_spec.js b/spec/frontend/groups/components/visibility_level_dropdown_spec.js index bf9508dc768..8f65a0e9c13 100644 --- a/spec/frontend/groups/components/visibility_level_dropdown_spec.js +++ b/spec/frontend/groups/components/visibility_level_dropdown_spec.js @@ -56,10 +56,7 @@ describe('Visibility Level Dropdown', () => { describe('Selecting an option', () => { beforeEach(() => { - wrapper - .findAll(GlDropdownItem) - .at(1) - .vm.$emit('click'); + wrapper.findAll(GlDropdownItem).at(1).vm.$emit('click'); }); it('sets the value of the hidden input to the selected value', () => { diff --git a/spec/frontend/helpers/monitor_helper_spec.js b/spec/frontend/helpers/monitor_helper_spec.js index 219b05e312b..ef2a9fb0665 100644 --- a/spec/frontend/helpers/monitor_helper_spec.js +++ b/spec/frontend/helpers/monitor_helper_spec.js @@ -3,7 +3,11 @@ import { getSeriesLabel, makeDataSeries } from '~/helpers/monitor_helper'; describe('monitor helper', () => { const defaultConfig = { default: true, name: 'default name' }; const name = 'data name'; - const series = [[1, 1], [2, 2], [3, 3]]; + const series = [ + [1, 1], + [2, 2], + [3, 3], + ]; describe('getSeriesLabel', () => { const metricAttributes = { __name__: 'up', app: 'prometheus' }; diff --git a/spec/frontend/helpers/user_mock_data_helper.js b/spec/frontend/helpers/user_mock_data_helper.js index a6adc9dc3a0..db747283d9e 100644 --- a/spec/frontend/helpers/user_mock_data_helper.js +++ b/spec/frontend/helpers/user_mock_data_helper.js @@ -2,12 +2,7 @@ let id = 1; // Code taken from: https://gist.github.com/6174/6062387 const getRandomString = () => - Math.random() - .toString(36) - .substring(2, 15) + - Math.random() - .toString(36) - .substring(2, 15); + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); const getRandomUrl = () => `https://${getRandomString()}.com/${getRandomString()}`; diff --git a/spec/frontend/ide/components/file_row_extra_spec.js b/spec/frontend/ide/components/file_row_extra_spec.js index 2a106ad37c0..b6ad801d589 100644 --- a/spec/frontend/ide/components/file_row_extra_spec.js +++ b/spec/frontend/ide/components/file_row_extra_spec.js @@ -45,15 +45,16 @@ describe('IDE extra file row component', () => { expect(vm.folderChangesTooltip).toBe(undefined); }); - [{ input: 1, output: '1 changed file' }, { input: 2, output: '2 changed files' }].forEach( - ({ input, output }) => { - it('returns changed files count if changes count is not 0', () => { - changesCount = input; - - expect(vm.folderChangesTooltip).toBe(output); - }); - }, - ); + [ + { input: 1, output: '1 changed file' }, + { input: 2, output: '2 changed files' }, + ].forEach(({ input, output }) => { + it('returns changed files count if changes count is not 0', () => { + changesCount = input; + + expect(vm.folderChangesTooltip).toBe(output); + }); + }); }); describe('show tree changes count', () => { diff --git a/spec/frontend/ide/components/file_templates/bar_spec.js b/spec/frontend/ide/components/file_templates/bar_spec.js index 5a33837fb14..75bc9ca73ea 100644 --- a/spec/frontend/ide/components/file_templates/bar_spec.js +++ b/spec/frontend/ide/components/file_templates/bar_spec.js @@ -67,10 +67,7 @@ describe('IDE file templates bar component', () => { it('calls fetchTemplate on click', () => { jest.spyOn(vm, 'fetchTemplate').mockImplementation(); - vm.$el - .querySelectorAll('.dropdown-content')[1] - .querySelector('button') - .click(); + vm.$el.querySelectorAll('.dropdown-content')[1].querySelector('button').click(); expect(vm.fetchTemplate).toHaveBeenCalledWith({ name: 'test', diff --git a/spec/frontend/ide/components/ide_sidebar_nav_spec.js b/spec/frontend/ide/components/ide_sidebar_nav_spec.js index 49d476b56e4..502d64fb86b 100644 --- a/spec/frontend/ide/components/ide_sidebar_nav_spec.js +++ b/spec/frontend/ide/components/ide_sidebar_nav_spec.js @@ -58,10 +58,7 @@ describe('ide/components/ide_sidebar_nav', () => { tooltip: getBinding(button.element, 'tooltip').value, }; }); - const clickTab = () => - findButtons() - .at(TEST_CURRENT_INDEX) - .trigger('click'); + const clickTab = () => findButtons().at(TEST_CURRENT_INDEX).trigger('click'); describe.each` isOpen | side | otherSide | classes | classesObj | emitEvent | emitArg diff --git a/spec/frontend/ide/components/jobs/stage_spec.js b/spec/frontend/ide/components/jobs/stage_spec.js index 3a47571ee13..97d601e0a11 100644 --- a/spec/frontend/ide/components/jobs/stage_spec.js +++ b/spec/frontend/ide/components/jobs/stage_spec.js @@ -60,10 +60,7 @@ describe('IDE pipeline stage', () => { it('emits clickViewLog entity with job', () => { const [job] = defaultProps.stage.jobs; createComponent(); - wrapper - .findAll(Item) - .at(0) - .vm.$emit('clickViewLog', job); + wrapper.findAll(Item).at(0).vm.$emit('clickViewLog', job); return wrapper.vm.$nextTick().then(() => { expect(wrapper.emitted().clickViewLog[0][0]).toBe(job); }); diff --git a/spec/frontend/ide/components/merge_requests/list_spec.js b/spec/frontend/ide/components/merge_requests/list_spec.js index 80dcd861451..d1b980156b3 100644 --- a/spec/frontend/ide/components/merge_requests/list_spec.js +++ b/spec/frontend/ide/components/merge_requests/list_spec.js @@ -82,9 +82,7 @@ describe('IDE merge requests list', () => { return wrapper.vm .$nextTick() .then(() => { - findSearchTypeButtons() - .at(0) - .trigger('click'); + findSearchTypeButtons().at(0).trigger('click'); return wrapper.vm.$nextTick(); }) .then(() => { @@ -168,9 +166,7 @@ describe('IDE merge requests list', () => { describe('with search type', () => { beforeEach(() => { - findSearchTypeButtons() - .at(0) - .trigger('click'); + findSearchTypeButtons().at(0).trigger('click'); return wrapper.vm .$nextTick() diff --git a/spec/frontend/ide/components/pipelines/list_spec.js b/spec/frontend/ide/components/pipelines/list_spec.js index c1744fefe20..0238fff6aa9 100644 --- a/spec/frontend/ide/components/pipelines/list_spec.js +++ b/spec/frontend/ide/components/pipelines/list_spec.js @@ -165,11 +165,7 @@ describe('IDE pipelines list', () => { const isLoadingJobs = true; createComponent({}, { ...withLatestPipelineState, stages, isLoadingJobs }); - const jobProps = wrapper - .findAll(GlTab) - .at(0) - .find(JobsList) - .props(); + const jobProps = wrapper.findAll(GlTab).at(0).find(JobsList).props(); expect(jobProps.stages).toBe(stages); expect(jobProps.loading).toBe(isLoadingJobs); }); @@ -180,11 +176,7 @@ describe('IDE pipelines list', () => { const isLoadingJobs = true; createComponent({}, { ...withLatestPipelineState, isLoadingJobs }); - const jobProps = wrapper - .findAll(GlTab) - .at(1) - .find(JobsList) - .props(); + const jobProps = wrapper.findAll(GlTab).at(1).find(JobsList).props(); expect(jobProps.stages).toBe(failedStages); expect(jobProps.loading).toBe(isLoadingJobs); }); diff --git a/spec/frontend/ide/components/repo_commit_section_spec.js b/spec/frontend/ide/components/repo_commit_section_spec.js index 096079308cd..47e99677a70 100644 --- a/spec/frontend/ide/components/repo_commit_section_spec.js +++ b/spec/frontend/ide/components/repo_commit_section_spec.js @@ -77,18 +77,8 @@ describe('RepoCommitSection', () => { }); it('renders no changes text', () => { - expect( - wrapper - .find(EmptyState) - .text() - .trim(), - ).toContain('No changes'); - expect( - wrapper - .find(EmptyState) - .find('img') - .attributes('src'), - ).toBe(TEST_NO_CHANGES_SVG); + expect(wrapper.find(EmptyState).text().trim()).toContain('No changes'); + expect(wrapper.find(EmptyState).find('img').attributes('src')).toBe(TEST_NO_CHANGES_SVG); }); }); diff --git a/spec/frontend/ide/lib/create_file_diff_spec.js b/spec/frontend/ide/lib/create_file_diff_spec.js index 4b428468a6d..0e1f8a8c541 100644 --- a/spec/frontend/ide/lib/create_file_diff_spec.js +++ b/spec/frontend/ide/lib/create_file_diff_spec.js @@ -21,11 +21,7 @@ const spliceLines = (content, lineNumber, deleteCount = 0, newLines = []) => { return lines.join('\n'); }; -const mapLines = (content, mapFn) => - content - .split('\n') - .map(mapFn) - .join('\n'); +const mapLines = (content, mapFn) => content.split('\n').map(mapFn).join('\n'); describe('IDE lib/create_file_diff', () => { it('returns empty string with "garbage" action', () => { diff --git a/spec/frontend/ide/stores/actions/merge_request_spec.js b/spec/frontend/ide/stores/actions/merge_request_spec.js index b1cceda9d85..f7dd6fd47eb 100644 --- a/spec/frontend/ide/stores/actions/merge_request_spec.js +++ b/spec/frontend/ide/stores/actions/merge_request_spec.js @@ -71,7 +71,7 @@ describe('IDE store merge request actions', () => { .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) .then(() => { expect(store.state.projects.abcproject.mergeRequests).toEqual({ - '2': expect.objectContaining(mrData), + 2: expect.objectContaining(mrData), }); done(); }) diff --git a/spec/frontend/ide/stores/modules/commit/actions_spec.js b/spec/frontend/ide/stores/modules/commit/actions_spec.js index cfe2bddf76c..899b8f2c7e8 100644 --- a/spec/frontend/ide/stores/modules/commit/actions_spec.js +++ b/spec/frontend/ide/stores/modules/commit/actions_spec.js @@ -456,9 +456,7 @@ describe('IDE commit module actions', () => { .dispatch('commit/commitChanges') .then(() => { expect(visitUrl).toHaveBeenCalledWith( - `webUrl/-/merge_requests/new?merge_request[source_branch]=${ - store.getters['commit/placeholderBranchName'] - }&merge_request[target_branch]=master&nav_source=webide`, + `webUrl/-/merge_requests/new?merge_request[source_branch]=${store.getters['commit/placeholderBranchName']}&merge_request[target_branch]=master&nav_source=webide`, ); done(); diff --git a/spec/frontend/incidents/components/incidents_list_spec.js b/spec/frontend/incidents/components/incidents_list_spec.js index 6329a84ff6e..8212776742c 100644 --- a/spec/frontend/incidents/components/incidents_list_spec.js +++ b/spec/frontend/incidents/components/incidents_list_spec.js @@ -158,17 +158,11 @@ describe('Incidents List', () => { describe('Assignees', () => { it('shows Unassigned when there are no assignees', () => { - expect( - findAssignees() - .at(0) - .text(), - ).toBe(I18N.unassigned); + expect(findAssignees().at(0).text()).toBe(I18N.unassigned); }); it('renders an avatar component when there is an assignee', () => { - const avatar = findAssignees() - .at(1) - .find(GlAvatar); + const avatar = findAssignees().at(1).find(GlAvatar); const { src, label } = avatar.attributes(); const { name, avatarUrl } = mockIncidents[1].assignees.nodes[0]; @@ -189,9 +183,7 @@ describe('Incidents List', () => { }); it('contains a link to the incident details page', async () => { - findTableRows() - .at(0) - .trigger('click'); + findTableRows().at(0).trigger('click'); expect(visitUrl).toHaveBeenCalledWith( joinPaths(`/project/issues/incident`, mockIncidents[0].iid), ); diff --git a/spec/frontend/incidents_settings/components/incidents_settings_tabs_spec.js b/spec/frontend/incidents_settings/components/incidents_settings_tabs_spec.js index 11b9eda2585..e94645c4e1d 100644 --- a/spec/frontend/incidents_settings/components/incidents_settings_tabs_spec.js +++ b/spec/frontend/incidents_settings/components/incidents_settings_tabs_spec.js @@ -42,16 +42,9 @@ describe('IncidentsSettingTabs', () => { const activeTabs = wrapper.vm.$options.tabs.filter(tab => tab.active); expect(findIntegrationTabs().length).toBe(activeTabs.length); activeTabs.forEach((tab, index) => { + expect(findIntegrationTabs().at(index).attributes('title')).toBe(tab.title); expect( - findIntegrationTabs() - .at(index) - .attributes('title'), - ).toBe(tab.title); - expect( - findIntegrationTabs() - .at(index) - .find(`[data-testid="${tab.component}-tab"]`) - .exists(), + findIntegrationTabs().at(index).find(`[data-testid="${tab.component}-tab"]`).exists(), ).toBe(true); }); }); diff --git a/spec/frontend/integrations/edit/components/dynamic_field_spec.js b/spec/frontend/integrations/edit/components/dynamic_field_spec.js index 53234419f5f..ecd03103992 100644 --- a/spec/frontend/integrations/edit/components/dynamic_field_spec.js +++ b/spec/frontend/integrations/edit/components/dynamic_field_spec.js @@ -37,153 +37,142 @@ describe('DynamicField', () => { const findGlFormTextarea = () => wrapper.find(GlFormTextarea); describe('template', () => { - describe.each([[true, 'disabled', 'readonly'], [false, undefined, undefined]])( - 'dynamic field, when isInheriting = `%p`', - (isInheriting, disabled, readonly) => { - describe('type is checkbox', () => { - beforeEach(() => { - createComponent( - { - type: 'checkbox', - }, - isInheriting, - ); - }); - - it(`renders GlFormCheckbox, which ${isInheriting ? 'is' : 'is not'} disabled`, () => { - expect(findGlFormCheckbox().exists()).toBe(true); - expect( - findGlFormCheckbox() - .find('[type=checkbox]') - .attributes('disabled'), - ).toBe(disabled); - }); + describe.each([ + [true, 'disabled', 'readonly'], + [false, undefined, undefined], + ])('dynamic field, when isInheriting = `%p`', (isInheriting, disabled, readonly) => { + describe('type is checkbox', () => { + beforeEach(() => { + createComponent( + { + type: 'checkbox', + }, + isInheriting, + ); + }); - it('does not render other types of input', () => { - expect(findGlFormSelect().exists()).toBe(false); - expect(findGlFormTextarea().exists()).toBe(false); - expect(findGlFormInput().exists()).toBe(false); - }); + it(`renders GlFormCheckbox, which ${isInheriting ? 'is' : 'is not'} disabled`, () => { + expect(findGlFormCheckbox().exists()).toBe(true); + expect(findGlFormCheckbox().find('[type=checkbox]').attributes('disabled')).toBe( + disabled, + ); }); - describe('type is select', () => { - beforeEach(() => { - createComponent( - { - type: 'select', - choices: [['all', 'All details'], ['standard', 'Standard']], - }, - isInheriting, - ); - }); + it('does not render other types of input', () => { + expect(findGlFormSelect().exists()).toBe(false); + expect(findGlFormTextarea().exists()).toBe(false); + expect(findGlFormInput().exists()).toBe(false); + }); + }); - it(`renders GlFormSelect, which ${isInheriting ? 'is' : 'is not'} disabled`, () => { - expect(findGlFormSelect().exists()).toBe(true); - expect(findGlFormSelect().findAll('option')).toHaveLength(2); - expect( - findGlFormSelect() - .find('select') - .attributes('disabled'), - ).toBe(disabled); - }); + describe('type is select', () => { + beforeEach(() => { + createComponent( + { + type: 'select', + choices: [ + ['all', 'All details'], + ['standard', 'Standard'], + ], + }, + isInheriting, + ); + }); - it('does not render other types of input', () => { - expect(findGlFormCheckbox().exists()).toBe(false); - expect(findGlFormTextarea().exists()).toBe(false); - expect(findGlFormInput().exists()).toBe(false); - }); + it(`renders GlFormSelect, which ${isInheriting ? 'is' : 'is not'} disabled`, () => { + expect(findGlFormSelect().exists()).toBe(true); + expect(findGlFormSelect().findAll('option')).toHaveLength(2); + expect(findGlFormSelect().find('select').attributes('disabled')).toBe(disabled); }); - describe('type is textarea', () => { - beforeEach(() => { - createComponent( - { - type: 'textarea', - }, - isInheriting, - ); - }); + it('does not render other types of input', () => { + expect(findGlFormCheckbox().exists()).toBe(false); + expect(findGlFormTextarea().exists()).toBe(false); + expect(findGlFormInput().exists()).toBe(false); + }); + }); - it(`renders GlFormTextarea, which ${isInheriting ? 'is' : 'is not'} readonly`, () => { - expect(findGlFormTextarea().exists()).toBe(true); - expect( - findGlFormTextarea() - .find('textarea') - .attributes('readonly'), - ).toBe(readonly); - }); + describe('type is textarea', () => { + beforeEach(() => { + createComponent( + { + type: 'textarea', + }, + isInheriting, + ); + }); - it('does not render other types of input', () => { - expect(findGlFormCheckbox().exists()).toBe(false); - expect(findGlFormSelect().exists()).toBe(false); - expect(findGlFormInput().exists()).toBe(false); - }); + it(`renders GlFormTextarea, which ${isInheriting ? 'is' : 'is not'} readonly`, () => { + expect(findGlFormTextarea().exists()).toBe(true); + expect(findGlFormTextarea().find('textarea').attributes('readonly')).toBe(readonly); }); - describe('type is password', () => { - beforeEach(() => { - createComponent( - { - type: 'password', - }, - isInheriting, - ); - }); + it('does not render other types of input', () => { + expect(findGlFormCheckbox().exists()).toBe(false); + expect(findGlFormSelect().exists()).toBe(false); + expect(findGlFormInput().exists()).toBe(false); + }); + }); - it(`renders GlFormInput, which ${isInheriting ? 'is' : 'is not'} readonly`, () => { - expect(findGlFormInput().exists()).toBe(true); - expect(findGlFormInput().attributes('type')).toBe('password'); - expect(findGlFormInput().attributes('readonly')).toBe(readonly); - }); + describe('type is password', () => { + beforeEach(() => { + createComponent( + { + type: 'password', + }, + isInheriting, + ); + }); - it('does not render other types of input', () => { - expect(findGlFormCheckbox().exists()).toBe(false); - expect(findGlFormSelect().exists()).toBe(false); - expect(findGlFormTextarea().exists()).toBe(false); - }); + it(`renders GlFormInput, which ${isInheriting ? 'is' : 'is not'} readonly`, () => { + expect(findGlFormInput().exists()).toBe(true); + expect(findGlFormInput().attributes('type')).toBe('password'); + expect(findGlFormInput().attributes('readonly')).toBe(readonly); }); - describe('type is text', () => { - beforeEach(() => { - createComponent( - { - type: 'text', - required: true, - }, - isInheriting, - ); - }); + it('does not render other types of input', () => { + expect(findGlFormCheckbox().exists()).toBe(false); + expect(findGlFormSelect().exists()).toBe(false); + expect(findGlFormTextarea().exists()).toBe(false); + }); + }); - it(`renders GlFormInput, which ${isInheriting ? 'is' : 'is not'} readonly`, () => { - expect(findGlFormInput().exists()).toBe(true); - expect(findGlFormInput().attributes()).toMatchObject({ + describe('type is text', () => { + beforeEach(() => { + createComponent( + { type: 'text', - id: 'service_project_url', - name: 'service[project_url]', - placeholder: defaultProps.placeholder, - required: 'required', - }); - expect(findGlFormInput().attributes('readonly')).toBe(readonly); - }); + required: true, + }, + isInheriting, + ); + }); - it('does not render other types of input', () => { - expect(findGlFormCheckbox().exists()).toBe(false); - expect(findGlFormSelect().exists()).toBe(false); - expect(findGlFormTextarea().exists()).toBe(false); + it(`renders GlFormInput, which ${isInheriting ? 'is' : 'is not'} readonly`, () => { + expect(findGlFormInput().exists()).toBe(true); + expect(findGlFormInput().attributes()).toMatchObject({ + type: 'text', + id: 'service_project_url', + name: 'service[project_url]', + placeholder: defaultProps.placeholder, + required: 'required', }); + expect(findGlFormInput().attributes('readonly')).toBe(readonly); }); - }, - ); + + it('does not render other types of input', () => { + expect(findGlFormCheckbox().exists()).toBe(false); + expect(findGlFormSelect().exists()).toBe(false); + expect(findGlFormTextarea().exists()).toBe(false); + }); + }); + }); describe('help text', () => { it('renders description with help text', () => { createComponent(); - expect( - findGlFormGroup() - .find('small') - .text(), - ).toBe(defaultProps.help); + expect(findGlFormGroup().find('small').text()).toBe(defaultProps.help); }); it('renders description with help text as HTML', () => { @@ -193,11 +182,7 @@ describe('DynamicField', () => { help: helpHTML, }); - expect( - findGlFormGroup() - .find('small') - .html(), - ).toContain(helpHTML); + expect(findGlFormGroup().find('small').html()).toContain(helpHTML); }); }); @@ -205,11 +190,7 @@ describe('DynamicField', () => { it('renders label with title', () => { createComponent(); - expect( - findGlFormGroup() - .find('label') - .text(), - ).toBe(defaultProps.title); + expect(findGlFormGroup().find('label').text()).toBe(defaultProps.title); }); describe('for password field with some value (hidden by backend)', () => { @@ -219,11 +200,7 @@ describe('DynamicField', () => { value: 'true', }); - expect( - findGlFormGroup() - .find('label') - .text(), - ).toBe(`Enter new ${defaultProps.title}`); + expect(findGlFormGroup().find('label').text()).toBe(`Enter new ${defaultProps.title}`); }); }); }); diff --git a/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js b/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js index 782930eb6a2..f3827d6f55a 100644 --- a/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js +++ b/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js @@ -57,9 +57,7 @@ describe('JiraTriggerFields', () => { // browsers don't include unchecked boxes in form submissions. it('includes comment settings as false even if unchecked', () => { expect( - findCommentSettings() - .find('input[name="service[comment_on_event_enabled]"]') - .exists(), + findCommentSettings().find('input[name="service[comment_on_event_enabled]"]').exists(), ).toBe(true); }); diff --git a/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js index dd05f49b458..1864888ef49 100644 --- a/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js +++ b/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js @@ -130,10 +130,7 @@ describe('RelatedIssuesBlock', () => { describe('showCategorizedIssues prop', () => { const issueList = () => wrapper.findAll('.js-related-issues-token-list-item'); const categorizedHeadings = () => wrapper.findAll('h4'); - const headingTextAt = index => - categorizedHeadings() - .at(index) - .text(); + const headingTextAt = index => categorizedHeadings().at(index).text(); const mountComponent = showCategorizedIssues => { wrapper = mount(RelatedIssuesBlock, { propsData: { diff --git a/spec/frontend/issuable/related_issues/components/related_issues_list_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_list_spec.js index 39bc244297b..ffd9683cd6b 100644 --- a/spec/frontend/issuable/related_issues/components/related_issues_list_spec.js +++ b/spec/frontend/issuable/related_issues/components/related_issues_list_spec.js @@ -182,12 +182,7 @@ describe('RelatedIssuesList', () => { }); it('shows due date', () => { - expect( - wrapper - .find(IssueDueDate) - .find('.board-card-info-text') - .text(), - ).toBe('Nov 22, 2010'); + expect(wrapper.find(IssueDueDate).find('.board-card-info-text').text()).toBe('Nov 22, 2010'); }); }); }); diff --git a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js index 2c02e1e1de4..93fe321957c 100644 --- a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js +++ b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js @@ -315,9 +315,7 @@ describe('RelatedIssuesRoot', () => { const input = 23; wrapper.vm.onInput({ - untouchedRawReferences: String(input) - .trim() - .split(/\s/), + untouchedRawReferences: String(input).trim().split(/\s/), touchedReference: input, }); diff --git a/spec/frontend/issuable_list/components/issuable_item_spec.js b/spec/frontend/issuable_list/components/issuable_item_spec.js index 3a9a0d3fd59..3c01bf2d319 100644 --- a/spec/frontend/issuable_list/components/issuable_item_spec.js +++ b/spec/frontend/issuable_list/components/issuable_item_spec.js @@ -252,12 +252,9 @@ describe('IssuableItem', () => { await wrapper.vm.$nextTick(); - expect( - wrapper - .find('[data-testid="issuable-title"]') - .find(GlLink) - .attributes('target'), - ).toBe('_blank'); + expect(wrapper.find('[data-testid="issuable-title"]').find(GlLink).attributes('target')).toBe( + '_blank', + ); }); it('renders issuable reference', () => { diff --git a/spec/frontend/issuable_show/components/issuable_body_spec.js b/spec/frontend/issuable_show/components/issuable_body_spec.js index 5708eaf4a31..65bace1ce3f 100644 --- a/spec/frontend/issuable_show/components/issuable_body_spec.js +++ b/spec/frontend/issuable_show/components/issuable_body_spec.js @@ -98,10 +98,7 @@ describe('IssuableBody', () => { it('renders issuable edit info', () => { const editedEl = wrapper.find('small'); - const sanitizedText = editedEl - .text() - .replace(/\n/g, ' ') - .replace(/\s+/g, ' '); + const sanitizedText = editedEl.text().replace(/\n/g, ' ').replace(/\s+/g, ' '); expect(sanitizedText).toContain('Edited'); expect(sanitizedText).toContain('ago'); diff --git a/spec/frontend/issuable_suggestions/components/app_spec.js b/spec/frontend/issuable_suggestions/components/app_spec.js index 0cb5b9c90ba..fb8ef00567c 100644 --- a/spec/frontend/issuable_suggestions/components/app_spec.js +++ b/spec/frontend/issuable_suggestions/components/app_spec.js @@ -85,12 +85,7 @@ describe('Issuable suggestions app component', () => { wrapper.setData(data); return wrapper.vm.$nextTick(() => { - expect( - wrapper - .findAll('li') - .at(0) - .classes(), - ).toContain('gl-mb-3'); + expect(wrapper.findAll('li').at(0).classes()).toContain('gl-mb-3'); }); }); @@ -98,12 +93,7 @@ describe('Issuable suggestions app component', () => { wrapper.setData(data); return wrapper.vm.$nextTick(() => { - expect( - wrapper - .findAll('li') - .at(1) - .classes(), - ).not.toContain('gl-mb-3'); + expect(wrapper.findAll('li').at(1).classes()).not.toContain('gl-mb-3'); }); }); }); diff --git a/spec/frontend/issue_show/components/header_actions_spec.js b/spec/frontend/issue_show/components/header_actions_spec.js index b9836ae7240..8af99cd5a31 100644 --- a/spec/frontend/issue_show/components/header_actions_spec.js +++ b/spec/frontend/issue_show/components/header_actions_spec.js @@ -70,10 +70,7 @@ describe('HeaderActions component', () => { const findModal = () => wrapper.find(GlModal); - const findModalLinkAt = index => - findModal() - .findAll(GlLink) - .at(index); + const findModalLinkAt = index => findModal().findAll(GlLink).at(index); const mountComponent = ({ props = {}, diff --git a/spec/frontend/issue_show/components/pinned_links_spec.js b/spec/frontend/issue_show/components/pinned_links_spec.js index bb67feee601..74a0b39a852 100644 --- a/spec/frontend/issue_show/components/pinned_links_spec.js +++ b/spec/frontend/issue_show/components/pinned_links_spec.js @@ -26,11 +26,7 @@ describe('PinnedLinks', () => { zoomMeetingUrl: `<a href="${plainZoomUrl}">Zoom</a>`, }); - expect( - findButtons() - .at(0) - .text(), - ).toBe(JOIN_ZOOM_MEETING); + expect(findButtons().at(0).text()).toBe(JOIN_ZOOM_MEETING); }); it('displays Status link', () => { @@ -38,11 +34,7 @@ describe('PinnedLinks', () => { publishedIncidentUrl: `<a href="${plainStatusUrl}">Status</a>`, }); - expect( - findButtons() - .at(0) - .text(), - ).toBe(STATUS_PAGE_PUBLISHED); + expect(findButtons().at(0).text()).toBe(STATUS_PAGE_PUBLISHED); }); it('does not render if there are no links', () => { diff --git a/spec/frontend/issues_list/components/issuables_list_app_spec.js b/spec/frontend/issues_list/components/issuables_list_app_spec.js index 1f80b4fc54a..c14d78322e8 100644 --- a/spec/frontend/issues_list/components/issuables_list_app_spec.js +++ b/spec/frontend/issues_list/components/issuables_list_app_spec.js @@ -238,15 +238,15 @@ describe('Issuables list component', () => { wrapper.vm.onSelectIssuable({ issuable: i0, selected: false }); expect(wrapper.vm.selection).toEqual({}); wrapper.vm.onSelectIssuable({ issuable: i1, selected: true }); - expect(wrapper.vm.selection).toEqual({ '1': true }); + expect(wrapper.vm.selection).toEqual({ 1: true }); wrapper.vm.onSelectIssuable({ issuable: i0, selected: true }); - expect(wrapper.vm.selection).toEqual({ '1': true, '0': true }); + expect(wrapper.vm.selection).toEqual({ 1: true, 0: true }); wrapper.vm.onSelectIssuable({ issuable: i2, selected: true }); - expect(wrapper.vm.selection).toEqual({ '1': true, '0': true, '2': true }); + expect(wrapper.vm.selection).toEqual({ 1: true, 0: true, 2: true }); wrapper.vm.onSelectIssuable({ issuable: i2, selected: true }); - expect(wrapper.vm.selection).toEqual({ '1': true, '0': true, '2': true }); + expect(wrapper.vm.selection).toEqual({ 1: true, 0: true, 2: true }); wrapper.vm.onSelectIssuable({ issuable: i0, selected: false }); - expect(wrapper.vm.selection).toEqual({ '1': true, '2': true }); + expect(wrapper.vm.selection).toEqual({ 1: true, 2: true }); }); it('broadcasts a message to the bulk edit sidebar when a value is added to selection', () => { diff --git a/spec/frontend/jobs/components/empty_state_spec.js b/spec/frontend/jobs/components/empty_state_spec.js index 29d0c4e07aa..f9a6afe0770 100644 --- a/spec/frontend/jobs/components/empty_state_spec.js +++ b/spec/frontend/jobs/components/empty_state_spec.js @@ -46,11 +46,7 @@ describe('Empty State', () => { }); it('renders provided title', () => { - expect( - findTitle() - .text() - .trim(), - ).toBe(defaultProps.title); + expect(findTitle().text().trim()).toBe(defaultProps.title); }); }); @@ -60,11 +56,7 @@ describe('Empty State', () => { }); it('renders content', () => { - expect( - findContent() - .text() - .trim(), - ).toBe(content); + expect(findContent().text().trim()).toBe(content); }); }); diff --git a/spec/frontend/jobs/components/job_app_spec.js b/spec/frontend/jobs/components/job_app_spec.js index 94653d4d4c7..d5fa158806f 100644 --- a/spec/frontend/jobs/components/job_app_spec.js +++ b/spec/frontend/jobs/components/job_app_spec.js @@ -133,13 +133,9 @@ describe('Job App', () => { }); it('should render provided job information', () => { - expect( - wrapper - .find('.header-main-content') - .text() - .replace(/\s+/g, ' ') - .trim(), - ).toContain('passed Job #4757 triggered 1 year ago by Root'); + expect(wrapper.find('.header-main-content').text().replace(/\s+/g, ' ').trim()).toContain( + 'passed Job #4757 triggered 1 year ago by Root', + ); }); it('should render new issue link', () => { @@ -151,11 +147,7 @@ describe('Job App', () => { it('should render created key', () => setupAndMount().then(() => { expect( - wrapper - .find('.header-main-content') - .text() - .replace(/\s+/g, ' ') - .trim(), + wrapper.find('.header-main-content').text().replace(/\s+/g, ' ').trim(), ).toContain('passed Job #4757 created 3 weeks ago by Root'); })); }); diff --git a/spec/frontend/jobs/components/log/line_spec.js b/spec/frontend/jobs/components/log/line_spec.js index 914ae2424c8..a127ee98c2a 100644 --- a/spec/frontend/jobs/components/log/line_spec.js +++ b/spec/frontend/jobs/components/log/line_spec.js @@ -34,10 +34,7 @@ describe('Job Log Line', () => { const findLine = () => wrapper.find('span'); const findLink = () => findLine().find('a'); const findLinks = () => findLine().findAll('a'); - const findLinkAttributeByIndex = i => - findLinks() - .at(i) - .attributes(); + const findLinkAttributeByIndex = i => findLinks().at(i).attributes(); beforeEach(() => { data = mockProps(); diff --git a/spec/frontend/jobs/components/log/log_spec.js b/spec/frontend/jobs/components/log/log_spec.js index 015d5e01a46..f662ffa1780 100644 --- a/spec/frontend/jobs/components/log/log_spec.js +++ b/spec/frontend/jobs/components/log/log_spec.js @@ -62,11 +62,7 @@ describe('Job Log', () => { }); it('renders an icon with the open state', () => { - expect( - findCollapsibleLine() - .find('[data-testid="angle-down-icon"]') - .exists(), - ).toBe(true); + expect(findCollapsibleLine().find('[data-testid="angle-down-icon"]').exists()).toBe(true); }); describe('on click header section', () => { diff --git a/spec/frontend/lib/utils/chart_utils_spec.js b/spec/frontend/lib/utils/chart_utils_spec.js index e811b8405fb..65bb68c5017 100644 --- a/spec/frontend/lib/utils/chart_utils_spec.js +++ b/spec/frontend/lib/utils/chart_utils_spec.js @@ -3,7 +3,11 @@ import { firstAndLastY } from '~/lib/utils/chart_utils'; describe('Chart utils', () => { describe('firstAndLastY', () => { it('returns the first and last y-values of a given data set as an array', () => { - const data = [['', 1], ['', 2], ['', 3]]; + const data = [ + ['', 1], + ['', 2], + ['', 3], + ]; expect(firstAndLastY(data)).toEqual([1, 3]); }); diff --git a/spec/frontend/line_highlighter_spec.js b/spec/frontend/line_highlighter_spec.js index 0da1ea1df2d..dd4f85deccd 100644 --- a/spec/frontend/line_highlighter_spec.js +++ b/spec/frontend/line_highlighter_spec.js @@ -88,9 +88,7 @@ describe('LineHighlighter', () => { describe('clickHandler', () => { it('handles clicking on a child icon element', () => { const spy = jest.spyOn(testContext.class, 'setHash'); - $('#L13 i') - .mousedown() - .click(); + $('#L13 i').mousedown().click(); expect(spy).toHaveBeenCalledWith(13); expect($('#LC13')).toHaveClass(testContext.css); diff --git a/spec/frontend/logs/components/environment_logs_spec.js b/spec/frontend/logs/components/environment_logs_spec.js index e32deaea993..74e924a8f6e 100644 --- a/spec/frontend/logs/components/environment_logs_spec.js +++ b/spec/frontend/logs/components/environment_logs_spec.js @@ -181,11 +181,7 @@ describe('EnvironmentLogs', () => { it('shows a logs trace', () => { expect(findLogTrace().text()).toBe(''); - expect( - findLogTrace() - .find('.js-build-loader-animation') - .isVisible(), - ).toBe(true); + expect(findLogTrace().find('.js-build-loader-animation').isVisible()).toBe(true); }); }); diff --git a/spec/frontend/matchers.js b/spec/frontend/matchers.js index 50feba86a61..3db5aba2758 100644 --- a/spec/frontend/matchers.js +++ b/spec/frontend/matchers.js @@ -40,10 +40,7 @@ export default { let clearMatch; try { - clearReceived = received - .replace(/\s\s+/gm, ' ') - .replace(/\s\./gm, '.') - .trim(); + clearReceived = received.replace(/\s\s+/gm, ' ').replace(/\s\./gm, '.').trim(); } catch (e) { return { actual: received, message: 'The received value is not a string', pass: false }; } diff --git a/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js b/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js index a48942dd277..05ea0dc2886 100644 --- a/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js +++ b/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js @@ -57,10 +57,8 @@ describe('ResendInviteButton', () => { it('displays form with correct action and inputs', () => { expect(findForm().attributes('action')).toBe('/groups/foo-bar/-/group_members/1/resend_invite'); - expect( - findForm() - .find('input[name="authenticity_token"]') - .attributes('value'), - ).toBe('mock-csrf-token'); + expect(findForm().find('input[name="authenticity_token"]').attributes('value')).toBe( + 'mock-csrf-token', + ); }); }); diff --git a/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js b/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js index ca885000c2f..37f5333343a 100644 --- a/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js +++ b/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js @@ -86,7 +86,10 @@ describe('MembersFilteredSearchBar', () => { token: GlFilteredSearchToken, unique: true, operators: [{ value: '=', description: 'is' }], - options: [{ value: 'exclude', title: 'Direct' }, { value: 'only', title: 'Inherited' }], + options: [ + { value: 'exclude', title: 'Direct' }, + { value: 'only', title: 'Inherited' }, + ], }, ]); }); diff --git a/spec/frontend/members/components/table/expiration_datepicker_spec.js b/spec/frontend/members/components/table/expiration_datepicker_spec.js index ba1b2256e76..7319989e1d9 100644 --- a/spec/frontend/members/components/table/expiration_datepicker_spec.js +++ b/spec/frontend/members/components/table/expiration_datepicker_spec.js @@ -72,11 +72,9 @@ describe('ExpirationDatepicker', () => { }); it('sets `minDate` prop as tomorrow', () => { - expect( - findDatepicker() - .props('minDate') - .toISOString(), - ).toBe(new Date('2020-3-16').toISOString()); + expect(findDatepicker().props('minDate').toISOString()).toBe( + new Date('2020-3-16').toISOString(), + ); }); it('sets `target` prop as `null` so datepicker opens on focus', () => { diff --git a/spec/frontend/members/components/table/members_table_spec.js b/spec/frontend/members/components/table/members_table_spec.js index 9945cc7ee57..728853b585b 100644 --- a/spec/frontend/members/components/table/members_table_spec.js +++ b/spec/frontend/members/components/table/members_table_spec.js @@ -100,10 +100,7 @@ describe('MembersTable', () => { if (expectedComponent) { expect( - wrapper - .find(`[data-label="${label}"][role="cell"]`) - .find(expectedComponent) - .exists(), + wrapper.find(`[data-label="${label}"][role="cell"]`).find(expectedComponent).exists(), ).toBe(true); } }); @@ -117,10 +114,7 @@ describe('MembersTable', () => { expect(actionField.exists()).toBe(true); expect(actionField.classes('gl-sr-only')).toBe(true); expect( - wrapper - .find(`[data-label="Actions"][role="cell"]`) - .find(MemberActionButtons) - .exists(), + wrapper.find(`[data-label="Actions"][role="cell"]`).find(MemberActionButtons).exists(), ).toBe(true); }); @@ -177,12 +171,9 @@ describe('MembersTable', () => { it('renders badge in "Max role" field', () => { createComponent({ members: [memberMock], tableFields: ['maxRole'] }); - expect( - wrapper - .find(`[data-label="Max role"][role="cell"]`) - .find(GlBadge) - .text(), - ).toBe(memberMock.accessLevel.stringValue); + expect(wrapper.find(`[data-label="Max role"][role="cell"]`).find(GlBadge).text()).toBe( + memberMock.accessLevel.stringValue, + ); }); }); @@ -203,10 +194,6 @@ describe('MembersTable', () => { it('adds QA selector to table row', () => { createComponent(); - expect( - findTable() - .find('tbody tr') - .attributes('data-qa-selector'), - ).toBe('member_row'); + expect(findTable().find('tbody tr').attributes('data-qa-selector')).toBe('member_row'); }); }); diff --git a/spec/frontend/merge_request_spec.js b/spec/frontend/merge_request_spec.js index 1cb7206b97f..4f9e063a0e1 100644 --- a/spec/frontend/merge_request_spec.js +++ b/spec/frontend/merge_request_spec.js @@ -32,10 +32,7 @@ describe('MergeRequest', () => { jest.spyOn($, 'ajax').mockImplementation(); const changeEvent = document.createEvent('HTMLEvents'); changeEvent.initEvent('change', true, true); - $('input[type=checkbox]') - .first() - .attr('checked', true)[0] - .dispatchEvent(changeEvent); + $('input[type=checkbox]').first().attr('checked', true)[0].dispatchEvent(changeEvent); setImmediate(() => { expect($('.js-task-list-field').val()).toBe( '- [x] Task List Item\n- [ ]\n- [ ] Task List Item 2\n', @@ -49,10 +46,7 @@ describe('MergeRequest', () => { jest.spyOn($, 'ajax').mockImplementation(); const changeEvent = document.createEvent('HTMLEvents'); changeEvent.initEvent('change', true, true); - $('input[type=checkbox]') - .last() - .attr('checked', true)[0] - .dispatchEvent(changeEvent); + $('input[type=checkbox]').last().attr('checked', true)[0].dispatchEvent(changeEvent); setImmediate(() => { expect($('.js-task-list-field').val()).toBe( '- [ ] Task List Item\n- [ ]\n- [x] Task List Item 2\n', diff --git a/spec/frontend/milestones/milestone_combobox_spec.js b/spec/frontend/milestones/milestone_combobox_spec.js index 047484f117f..c7a123f7d99 100644 --- a/spec/frontend/milestones/milestone_combobox_spec.js +++ b/spec/frontend/milestones/milestone_combobox_spec.js @@ -336,9 +336,7 @@ describe('Milestone combobox component', () => { await localVue.nextTick(); expect( - findFirstProjectMilestonesDropdownItem() - .find('span') - .classes('selected-item'), + findFirstProjectMilestonesDropdownItem().find('span').classes('selected-item'), ).toBe(false); selectFirstProjectMilestone(); @@ -346,9 +344,7 @@ describe('Milestone combobox component', () => { await localVue.nextTick(); expect( - findFirstProjectMilestonesDropdownItem() - .find('span') - .classes('selected-item'), + findFirstProjectMilestonesDropdownItem().find('span').classes('selected-item'), ).toBe(true); }); @@ -465,21 +461,17 @@ describe('Milestone combobox component', () => { await localVue.nextTick(); - expect( - findFirstGroupMilestonesDropdownItem() - .find('span') - .classes('selected-item'), - ).toBe(false); + expect(findFirstGroupMilestonesDropdownItem().find('span').classes('selected-item')).toBe( + false, + ); selectFirstGroupMilestone(); await localVue.nextTick(); - expect( - findFirstGroupMilestonesDropdownItem() - .find('span') - .classes('selected-item'), - ).toBe(true); + expect(findFirstGroupMilestonesDropdownItem().find('span').classes('selected-item')).toBe( + true, + ); }); describe('when a group milestones is selected', () => { diff --git a/spec/frontend/monitoring/alert_widget_spec.js b/spec/frontend/monitoring/alert_widget_spec.js index d004b1da0b6..e66c389a4ab 100644 --- a/spec/frontend/monitoring/alert_widget_spec.js +++ b/spec/frontend/monitoring/alert_widget_spec.js @@ -28,12 +28,20 @@ describe('AlertWidget', () => { const nonFiringAlertResult = [ { - values: [[0, 1], [1, 42], [2, 41]], + values: [ + [0, 1], + [1, 42], + [2, 41], + ], }, ]; const firingAlertResult = [ { - values: [[0, 42], [1, 43], [2, 44]], + values: [ + [0, 42], + [1, 43], + [2, 44], + ], }, ]; const metricId = '5'; @@ -88,10 +96,7 @@ describe('AlertWidget', () => { const findWidgetForm = () => wrapper.find({ ref: 'widgetForm' }); const findAlertErrorMessage = () => wrapper.find({ ref: 'alertErrorMessage' }); const findCurrentSettingsText = () => - wrapper - .find({ ref: 'alertCurrentSetting' }) - .text() - .replace(/\s\s+/g, ' '); + wrapper.find({ ref: 'alertCurrentSetting' }).text().replace(/\s\s+/g, ' '); const findBadge = () => wrapper.find(GlBadge); const findTooltip = () => wrapper.find(GlTooltip); @@ -300,11 +305,7 @@ describe('AlertWidget', () => { createComponent(propsWithManyAlerts); return waitForPromises().then(() => { - expect( - findTooltip() - .text() - .replace(/\s\s+/g, ' '), - ).toEqual('Firing: alert-label > 42'); + expect(findTooltip().text().replace(/\s\s+/g, ' ')).toEqual('Firing: alert-label > 42'); }); }); }); diff --git a/spec/frontend/monitoring/components/dashboard_panel_spec.js b/spec/frontend/monitoring/components/dashboard_panel_spec.js index 1808faf8f0e..0936e390770 100644 --- a/spec/frontend/monitoring/components/dashboard_panel_spec.js +++ b/spec/frontend/monitoring/components/dashboard_panel_spec.js @@ -777,11 +777,7 @@ describe('Dashboard Panel', () => { await wrapper.vm.$nextTick(); expect(findRunbookLinks().length).toBe(1); - expect( - findRunbookLinks() - .at(0) - .attributes('href'), - ).toBe(invalidUrl); + expect(findRunbookLinks().at(0).attributes('href')).toBe(invalidUrl); }); }); }); diff --git a/spec/frontend/monitoring/components/dashboard_spec.js b/spec/frontend/monitoring/components/dashboard_spec.js index 27e479ba498..0552d1621bf 100644 --- a/spec/frontend/monitoring/components/dashboard_spec.js +++ b/spec/frontend/monitoring/components/dashboard_spec.js @@ -587,12 +587,9 @@ describe('Dashboard', () => { }); it('group empty area displays a NO_DATA state', () => { - expect( - wrapper - .findAll({ ref: 'empty-group' }) - .at(0) - .props('selectedState'), - ).toEqual(metricStates.NO_DATA); + expect(wrapper.findAll({ ref: 'empty-group' }).at(0).props('selectedState')).toEqual( + metricStates.NO_DATA, + ); }); }); @@ -634,9 +631,7 @@ describe('Dashboard', () => { describe('when rearrange button is clicked', () => { const findFirstDraggableRemoveButton = () => - findDraggablePanels() - .at(0) - .find('.js-draggable-remove'); + findDraggablePanels().at(0).find('.js-draggable-remove'); beforeEach(() => { findRearrangeButton().vm.$emit('click'); @@ -668,11 +663,7 @@ describe('Dashboard', () => { }); it('shows a remove button, which removes a panel', () => { - expect( - findFirstDraggableRemoveButton() - .find('a') - .exists(), - ).toBe(true); + expect(findFirstDraggableRemoveButton().find('a').exists()).toBe(true); expect(findDraggablePanels().length).toEqual(metricsDashboardPanelCount); findFirstDraggableRemoveButton().trigger('click'); @@ -772,10 +763,7 @@ describe('Dashboard', () => { const panelIndex = 1; // skip expanded panel const getClipboardTextFirstPanel = () => - wrapper - .findAll(DashboardPanel) - .at(panelIndex) - .props('clipboardText'); + wrapper.findAll(DashboardPanel).at(panelIndex).props('clipboardText'); beforeEach(() => { setupStoreWithData(store); diff --git a/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js b/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js index d8ffb4443ac..442269d93fa 100644 --- a/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js +++ b/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js @@ -101,9 +101,7 @@ describe('duplicate dashboard modal', () => { commitMessage: 'A commit message', }; - findModal() - .find(DuplicateDashboardForm) - .vm.$emit('change', formVals); + findModal().find(DuplicateDashboardForm).vm.$emit('change', formVals); // Binding's second argument contains the modal id expect(wrapper.vm.form).toEqual(formVals); diff --git a/spec/frontend/monitoring/components/variables/dropdown_field_spec.js b/spec/frontend/monitoring/components/variables/dropdown_field_spec.js index cc384aef231..690df5045ae 100644 --- a/spec/frontend/monitoring/components/variables/dropdown_field_spec.js +++ b/spec/frontend/monitoring/components/variables/dropdown_field_spec.js @@ -10,7 +10,10 @@ describe('Custom variable component', () => { label: 'Select environment', value: 'Production', options: { - values: [{ text: 'Production', value: 'prod' }, { text: 'Canary', value: 'canary' }], + values: [ + { text: 'Production', value: 'prod' }, + { text: 'Canary', value: 'canary' }, + ], }, }; @@ -54,9 +57,7 @@ describe('Custom variable component', () => { createShallowWrapper(); jest.spyOn(wrapper.vm, '$emit'); - findDropdownItems() - .at(1) - .vm.$emit('click'); + findDropdownItems().at(1).vm.$emit('click'); return wrapper.vm.$nextTick(() => { expect(wrapper.vm.$emit).toHaveBeenCalledWith('input', 'canary'); diff --git a/spec/frontend/monitoring/router_spec.js b/spec/frontend/monitoring/router_spec.js index 8b97c8ed125..c30c4c56a6c 100644 --- a/spec/frontend/monitoring/router_spec.js +++ b/spec/frontend/monitoring/router_spec.js @@ -63,12 +63,7 @@ describe('Monitoring router', () => { }); expect(wrapper.find(DashboardPage).exists()).toBe(true); - expect( - wrapper - .find(DashboardPage) - .find(Dashboard) - .exists(), - ).toBe(true); + expect(wrapper.find(DashboardPage).find(Dashboard).exists()).toBe(true); }); }); @@ -91,12 +86,7 @@ describe('Monitoring router', () => { }); expect(wrapper.find(DashboardPage).exists()).toBe(true); - expect( - wrapper - .find(DashboardPage) - .find(Dashboard) - .exists(), - ).toBe(true); + expect(wrapper.find(DashboardPage).find(Dashboard).exists()).toBe(true); }); }); diff --git a/spec/frontend/monitoring/store/mutations_spec.js b/spec/frontend/monitoring/store/mutations_spec.js index 8d1351fc909..984e52e7bef 100644 --- a/spec/frontend/monitoring/store/mutations_spec.js +++ b/spec/frontend/monitoring/store/mutations_spec.js @@ -465,7 +465,10 @@ describe('Monitoring mutations', () => { }); expect(variable.options).toEqual({ - values: [{ text: 'prometheus', value: 'prometheus' }, { text: 'node', value: 'node' }], + values: [ + { text: 'prometheus', value: 'prometheus' }, + { text: 'node', value: 'node' }, + ], }); }); }); diff --git a/spec/frontend/monitoring/store/utils_spec.js b/spec/frontend/monitoring/store/utils_spec.js index b97948fa1bf..80b15e76879 100644 --- a/spec/frontend/monitoring/store/utils_spec.js +++ b/spec/frontend/monitoring/store/utils_spec.js @@ -775,7 +775,11 @@ describe('normalizeQueryResponseData', () => { job: 'prometheus', instance: 'localhost:9090', }, - values: [[1435781430.781, '1'], [1435781445.781, '2'], [1435781460.781, '3']], + values: [ + [1435781430.781, '1'], + [1435781445.781, '2'], + [1435781460.781, '3'], + ], }, { metric: { @@ -783,7 +787,11 @@ describe('normalizeQueryResponseData', () => { job: 'node', instance: 'localhost:9091', }, - values: [[1435781430.781, '4'], [1435781445.781, '5'], [1435781460.781, '6']], + values: [ + [1435781430.781, '4'], + [1435781445.781, '5'], + [1435781460.781, '6'], + ], }, ], }; @@ -840,7 +848,10 @@ describe('normalizeQueryResponseData', () => { job: 'prometheus', instance: 'localhost:9090', }, - values: [[1435781430.781, '1'], [1435781460.781, 'NaN']], + values: [ + [1435781430.781, '1'], + [1435781460.781, 'NaN'], + ], }, ], }; @@ -849,7 +860,10 @@ describe('normalizeQueryResponseData', () => { { metric: { __name__: 'up', instance: 'localhost:9090', job: 'prometheus' }, value: ['2015-07-01T20:11:00.781Z', NaN], - values: [['2015-07-01T20:10:30.781Z', 1], ['2015-07-01T20:11:00.781Z', NaN]], + values: [ + ['2015-07-01T20:10:30.781Z', 1], + ['2015-07-01T20:11:00.781Z', NaN], + ], }, ]); }); diff --git a/spec/frontend/new_branch_spec.js b/spec/frontend/new_branch_spec.js index cff7ec1a9ee..a28daa653b0 100644 --- a/spec/frontend/new_branch_spec.js +++ b/spec/frontend/new_branch_spec.js @@ -12,9 +12,7 @@ describe('Branch', () => { preloadFixtures('branches/new_branch.html'); function fillNameWith(value) { - $('.js-branch-name') - .val(value) - .trigger('blur'); + $('.js-branch-name').val(value).trigger('blur'); } function expectToHaveError(error) { diff --git a/spec/frontend/notes/components/discussion_actions_spec.js b/spec/frontend/notes/components/discussion_actions_spec.js index b26eb00bfdc..32ebcd13b8a 100644 --- a/spec/frontend/notes/components/discussion_actions_spec.js +++ b/spec/frontend/notes/components/discussion_actions_spec.js @@ -117,19 +117,13 @@ describe('DiscussionActions', () => { it('emits showReplyForm event when clicking on reply placeholder', () => { jest.spyOn(wrapper.vm, '$emit'); - wrapper - .find(ReplyPlaceholder) - .find('button') - .trigger('click'); + wrapper.find(ReplyPlaceholder).find('button').trigger('click'); expect(wrapper.vm.$emit).toHaveBeenCalledWith('showReplyForm'); }); it('emits resolve event when clicking on resolve button', () => { jest.spyOn(wrapper.vm, '$emit'); - wrapper - .find(ResolveDiscussionButton) - .find('button') - .trigger('click'); + wrapper.find(ResolveDiscussionButton).find('button').trigger('click'); expect(wrapper.vm.$emit).toHaveBeenCalledWith('resolve'); }); }); diff --git a/spec/frontend/notes/components/discussion_filter_note_spec.js b/spec/frontend/notes/components/discussion_filter_note_spec.js index d35f8f7c28d..9ae3f08df77 100644 --- a/spec/frontend/notes/components/discussion_filter_note_spec.js +++ b/spec/frontend/notes/components/discussion_filter_note_spec.js @@ -31,20 +31,14 @@ describe('DiscussionFilterNote component', () => { it('emits `dropdownSelect` event with 0 parameter on clicking Show all activity button', () => { jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); - wrapper - .findAll(GlButton) - .at(0) - .vm.$emit('click'); + wrapper.findAll(GlButton).at(0).vm.$emit('click'); expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 0); }); it('emits `dropdownSelect` event with 1 parameter on clicking Show comments only button', () => { jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); - wrapper - .findAll(GlButton) - .at(1) - .vm.$emit('click'); + wrapper.findAll(GlButton).at(1).vm.$emit('click'); expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 1); }); diff --git a/spec/frontend/notes/components/discussion_filter_spec.js b/spec/frontend/notes/components/discussion_filter_spec.js index 9f3655c53b9..0ac60efa45b 100644 --- a/spec/frontend/notes/components/discussion_filter_spec.js +++ b/spec/frontend/notes/components/discussion_filter_spec.js @@ -82,12 +82,9 @@ describe('DiscussionFilter component', () => { }); it('renders the default selected item', () => { - expect( - wrapper - .find('#discussion-filter-dropdown .dropdown-item') - .text() - .trim(), - ).toBe(discussionFiltersMock[0].title); + expect(wrapper.find('#discussion-filter-dropdown .dropdown-item').text().trim()).toBe( + discussionFiltersMock[0].title, + ); }); it('updates to the selected item', () => { diff --git a/spec/frontend/notes/components/note_actions_spec.js b/spec/frontend/notes/components/note_actions_spec.js index f01c6c6b84e..2965d3d3adc 100644 --- a/spec/frontend/notes/components/note_actions_spec.js +++ b/spec/frontend/notes/components/note_actions_spec.js @@ -65,23 +65,11 @@ describe('noteActions', () => { }); it('should render noteable author badge', () => { - expect( - wrapper - .findAll('.note-role') - .at(0) - .text() - .trim(), - ).toEqual('Author'); + expect(wrapper.findAll('.note-role').at(0).text().trim()).toEqual('Author'); }); it('should render access level badge', () => { - expect( - wrapper - .findAll('.note-role') - .at(1) - .text() - .trim(), - ).toEqual(props.accessLevel); + expect(wrapper.findAll('.note-role').at(1).text().trim()).toEqual(props.accessLevel); }); it('should render contributor badge', () => { @@ -91,13 +79,7 @@ describe('noteActions', () => { }); return wrapper.vm.$nextTick().then(() => { - expect( - wrapper - .findAll('.note-role') - .at(1) - .text() - .trim(), - ).toBe('Contributor'); + expect(wrapper.findAll('.note-role').at(1).text().trim()).toBe('Contributor'); }); }); diff --git a/spec/frontend/notes/components/note_form_spec.js b/spec/frontend/notes/components/note_form_spec.js index cc434d6c952..c48c72c63de 100644 --- a/spec/frontend/notes/components/note_form_spec.js +++ b/spec/frontend/notes/components/note_form_spec.js @@ -91,12 +91,7 @@ describe('issue_note_form component', () => { const conflictWarning = wrapper.find('.js-conflict-edit-warning'); expect(conflictWarning.exists()).toBe(true); - expect( - conflictWarning - .text() - .replace(/\s+/g, ' ') - .trim(), - ).toBe(message); + expect(conflictWarning.text().replace(/\s+/g, ' ').trim()).toBe(message); }); }); }); diff --git a/spec/frontend/notes/components/notes_app_spec.js b/spec/frontend/notes/components/notes_app_spec.js index e905a12919e..2e01fa887ae 100644 --- a/spec/frontend/notes/components/notes_app_spec.js +++ b/spec/frontend/notes/components/notes_app_spec.js @@ -129,12 +129,9 @@ describe('note_app', () => { '/gitlab-org/gitlab-foss/issues/26/discussions.json' ][0].notes[0]; - expect( - wrapper - .find('.main-notes-list .note-header-author-name') - .text() - .trim(), - ).toEqual(note.author.name); + expect(wrapper.find('.main-notes-list .note-header-author-name').text().trim()).toEqual( + note.author.name, + ); expect(wrapper.find('.main-notes-list .note-text').html()).toContain(note.note_html); }); @@ -272,23 +269,15 @@ describe('note_app', () => { it('should render markdown docs url', () => { const { markdownDocsPath } = mockData.notesDataMock; - expect( - wrapper - .find(`a[href="${markdownDocsPath}"]`) - .text() - .trim(), - ).toEqual('Markdown'); + expect(wrapper.find(`a[href="${markdownDocsPath}"]`).text().trim()).toEqual('Markdown'); }); it('should render quick action docs url', () => { const { quickActionsDocsPath } = mockData.notesDataMock; - expect( - wrapper - .find(`a[href="${quickActionsDocsPath}"]`) - .text() - .trim(), - ).toEqual('quick actions'); + expect(wrapper.find(`a[href="${quickActionsDocsPath}"]`).text().trim()).toEqual( + 'quick actions', + ); }); }); @@ -304,12 +293,9 @@ describe('note_app', () => { const { markdownDocsPath } = mockData.notesDataMock; return Vue.nextTick().then(() => { - expect( - wrapper - .find(`.edit-note a[href="${markdownDocsPath}"]`) - .text() - .trim(), - ).toEqual('Markdown is supported'); + expect(wrapper.find(`.edit-note a[href="${markdownDocsPath}"]`).text().trim()).toEqual( + 'Markdown is supported', + ); }); }); diff --git a/spec/frontend/notes/old_notes_spec.js b/spec/frontend/notes/old_notes_spec.js index dee4f93f0ce..39c80e111ed 100644 --- a/spec/frontend/notes/old_notes_spec.js +++ b/spec/frontend/notes/old_notes_spec.js @@ -82,9 +82,7 @@ describe.skip('Old Notes (~/notes.js)', () => { it('modifies the Markdown field', () => { const changeEvent = document.createEvent('HTMLEvents'); changeEvent.initEvent('change', true, true); - $('input[type=checkbox]') - .attr('checked', true)[0] - .dispatchEvent(changeEvent); + $('input[type=checkbox]').attr('checked', true)[0].dispatchEvent(changeEvent); expect($('.js-task-list-field.original-task-list').val()).toBe('- [x] Task List Item'); }); @@ -746,12 +744,7 @@ describe.skip('Old Notes (~/notes.js)', () => { .find(`#note_${note.id}`) .find('.js-task-list-container'); - expect( - $updatedNoteEl - .find('.note-text') - .text() - .trim(), - ).toEqual(''); + expect($updatedNoteEl.find('.note-text').text().trim()).toEqual(''); done(); }); @@ -912,26 +905,15 @@ describe.skip('Old Notes (~/notes.js)', () => { expect($tempNote.find('.timeline-icon .avatar').attr('src')).toEqual(currentUserAvatar); expect($tempNote.find('.timeline-content').hasClass('discussion')).toBeFalsy(); - expect( - $tempNoteHeader - .find('.d-none.d-sm-inline-block') - .text() - .trim(), - ).toEqual(currentUserFullname); - - expect( - $tempNoteHeader - .find('.note-headline-light') - .text() - .trim(), - ).toEqual(`@${currentUsername}`); - - expect( - $tempNote - .find('.note-body .note-text p') - .text() - .trim(), - ).toEqual(sampleComment); + expect($tempNoteHeader.find('.d-none.d-sm-inline-block').text().trim()).toEqual( + currentUserFullname, + ); + + expect($tempNoteHeader.find('.note-headline-light').text().trim()).toEqual( + `@${currentUsername}`, + ); + + expect($tempNote.find('.note-body .note-text p').text().trim()).toEqual(sampleComment); }); it('should return constructed placeholder element for discussion note based on form contents', () => { @@ -959,12 +941,9 @@ describe.skip('Old Notes (~/notes.js)', () => { }); const $tempNoteHeader = $tempNote.find('.note-header'); - expect( - $tempNoteHeader - .find('.d-none.d-sm-inline-block') - .text() - .trim(), - ).toEqual('Foo <script>alert("XSS")</script>'); + expect($tempNoteHeader.find('.d-none.d-sm-inline-block').text().trim()).toEqual( + 'Foo <script>alert("XSS")</script>', + ); }); }); @@ -987,12 +966,7 @@ describe.skip('Old Notes (~/notes.js)', () => { expect($tempNote.attr('id')).toEqual(uniqueId); expect($tempNote.hasClass('being-posted')).toBeTruthy(); expect($tempNote.hasClass('fade-in-half')).toBeTruthy(); - expect( - $tempNote - .find('.timeline-content i') - .text() - .trim(), - ).toEqual(sampleCommandDescription); + expect($tempNote.find('.timeline-content i').text().trim()).toEqual(sampleCommandDescription); }); }); diff --git a/spec/frontend/notes/stores/actions_spec.js b/spec/frontend/notes/stores/actions_spec.js index c9912621785..35608e7f7b4 100644 --- a/spec/frontend/notes/stores/actions_spec.js +++ b/spec/frontend/notes/stores/actions_spec.js @@ -302,10 +302,7 @@ describe('Actions Notes Store', () => { .onGet(notesDataMock.notesPath) .reply(200, { notes: [], last_fetched_at: '123456' }, { 'poll-interval': '1000' }); - store - .dispatch('setNotesData', notesDataMock) - .then(done) - .catch(done.fail); + store.dispatch('setNotesData', notesDataMock).then(done).catch(done.fail); }); it('calls service with last fetched state', done => { diff --git a/spec/frontend/notes/stores/getters_spec.js b/spec/frontend/notes/stores/getters_spec.js index 1a369caee49..deef3572763 100644 --- a/spec/frontend/notes/stores/getters_spec.js +++ b/spec/frontend/notes/stores/getters_spec.js @@ -298,17 +298,18 @@ describe('Getters Notes Store', () => { }; }); - [{ step: 1, id: '123', expected: '123' }, { step: -1, id: '123', expected: '123' }].forEach( - ({ step, id, expected }) => { - it(`with step ${step} and match, returns only value`, () => { - const params = createDiscussionNeighborParams(id, true, step); - - expect(getters.findUnresolvedDiscussionIdNeighbor(state, localGetters)(params)).toBe( - expected, - ); - }); - }, - ); + [ + { step: 1, id: '123', expected: '123' }, + { step: -1, id: '123', expected: '123' }, + ].forEach(({ step, id, expected }) => { + it(`with step ${step} and match, returns only value`, () => { + const params = createDiscussionNeighborParams(id, true, step); + + expect(getters.findUnresolvedDiscussionIdNeighbor(state, localGetters)(params)).toBe( + expected, + ); + }); + }); it('with no match, returns only value', () => { const params = createDiscussionNeighborParams('bogus', true, 1); diff --git a/spec/frontend/oauth_remember_me_spec.js b/spec/frontend/oauth_remember_me_spec.js index e12db05ac43..250886e3781 100644 --- a/spec/frontend/oauth_remember_me_spec.js +++ b/spec/frontend/oauth_remember_me_spec.js @@ -3,9 +3,7 @@ import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me'; describe('OAuthRememberMe', () => { const findFormAction = selector => { - return $(`#oauth-container .oauth-login${selector}`) - .parent('form') - .attr('action'); + return $(`#oauth-container .oauth-login${selector}`).parent('form').attr('action'); }; preloadFixtures('static/oauth_remember_me.html'); diff --git a/spec/frontend/packages/details/components/conan_installation_spec.js b/spec/frontend/packages/details/components/conan_installation_spec.js index c79d1bb50dd..92c1f8e7f4a 100644 --- a/spec/frontend/packages/details/components/conan_installation_spec.js +++ b/spec/frontend/packages/details/components/conan_installation_spec.js @@ -48,21 +48,13 @@ describe('ConanInstallation', () => { describe('installation commands', () => { it('renders the correct command', () => { - expect( - findCodeInstructions() - .at(0) - .props('instruction'), - ).toBe(conanInstallationCommandStr); + expect(findCodeInstructions().at(0).props('instruction')).toBe(conanInstallationCommandStr); }); }); describe('setup commands', () => { it('renders the correct command', () => { - expect( - findCodeInstructions() - .at(1) - .props('instruction'), - ).toBe(conanSetupCommandStr); + expect(findCodeInstructions().at(1).props('instruction')).toBe(conanSetupCommandStr); }); }); }); diff --git a/spec/frontend/packages/details/components/maven_installation_spec.js b/spec/frontend/packages/details/components/maven_installation_spec.js index f301a03a7f3..ff62969e709 100644 --- a/spec/frontend/packages/details/components/maven_installation_spec.js +++ b/spec/frontend/packages/details/components/maven_installation_spec.js @@ -51,11 +51,7 @@ describe('MavenInstallation', () => { describe('installation commands', () => { it('renders the correct xml block', () => { - expect( - findCodeInstructions() - .at(0) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(0).props()).toMatchObject({ instruction: xmlCodeBlock, multiline: true, trackingAction: TrackingActions.COPY_MAVEN_XML, @@ -63,11 +59,7 @@ describe('MavenInstallation', () => { }); it('renders the correct maven command', () => { - expect( - findCodeInstructions() - .at(1) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(1).props()).toMatchObject({ instruction: mavenCommandStr, multiline: false, trackingAction: TrackingActions.COPY_MAVEN_COMMAND, @@ -77,11 +69,7 @@ describe('MavenInstallation', () => { describe('setup commands', () => { it('renders the correct xml block', () => { - expect( - findCodeInstructions() - .at(2) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(2).props()).toMatchObject({ instruction: mavenSetupXml, multiline: true, trackingAction: TrackingActions.COPY_MAVEN_SETUP, diff --git a/spec/frontend/packages/details/components/npm_installation_spec.js b/spec/frontend/packages/details/components/npm_installation_spec.js index 4223a05453c..dd6e62185a9 100644 --- a/spec/frontend/packages/details/components/npm_installation_spec.js +++ b/spec/frontend/packages/details/components/npm_installation_spec.js @@ -47,11 +47,7 @@ describe('NpmInstallation', () => { describe('installation commands', () => { it('renders the correct npm command', () => { - expect( - findCodeInstructions() - .at(0) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(0).props()).toMatchObject({ instruction: 'npm i @Test/package', multiline: false, trackingAction: TrackingActions.COPY_NPM_INSTALL_COMMAND, @@ -59,11 +55,7 @@ describe('NpmInstallation', () => { }); it('renders the correct yarn command', () => { - expect( - findCodeInstructions() - .at(1) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(1).props()).toMatchObject({ instruction: 'yarn add @Test/package', multiline: false, trackingAction: TrackingActions.COPY_YARN_INSTALL_COMMAND, @@ -73,11 +65,7 @@ describe('NpmInstallation', () => { describe('setup commands', () => { it('renders the correct npm command', () => { - expect( - findCodeInstructions() - .at(2) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(2).props()).toMatchObject({ instruction: 'echo @Test:registry=undefined/ >> .npmrc', multiline: false, trackingAction: TrackingActions.COPY_NPM_SETUP_COMMAND, @@ -85,11 +73,7 @@ describe('NpmInstallation', () => { }); it('renders the correct yarn command', () => { - expect( - findCodeInstructions() - .at(3) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(3).props()).toMatchObject({ instruction: 'echo \\"@Test:registry\\" \\"undefined/\\" >> .yarnrc', multiline: false, trackingAction: TrackingActions.COPY_YARN_SETUP_COMMAND, diff --git a/spec/frontend/packages/details/components/nuget_installation_spec.js b/spec/frontend/packages/details/components/nuget_installation_spec.js index b381d131e94..685d0808dd9 100644 --- a/spec/frontend/packages/details/components/nuget_installation_spec.js +++ b/spec/frontend/packages/details/components/nuget_installation_spec.js @@ -49,11 +49,7 @@ describe('NugetInstallation', () => { describe('installation commands', () => { it('renders the correct command', () => { - expect( - findCodeInstructions() - .at(0) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(0).props()).toMatchObject({ instruction: nugetInstallationCommandStr, trackingAction: TrackingActions.COPY_NUGET_INSTALL_COMMAND, }); @@ -62,11 +58,7 @@ describe('NugetInstallation', () => { describe('setup commands', () => { it('renders the correct command', () => { - expect( - findCodeInstructions() - .at(1) - .props(), - ).toMatchObject({ + expect(findCodeInstructions().at(1).props()).toMatchObject({ instruction: nugetSetupCommandStr, trackingAction: TrackingActions.COPY_NUGET_SETUP_COMMAND, }); diff --git a/spec/frontend/packages/details/store/actions_spec.js b/spec/frontend/packages/details/store/actions_spec.js index 70f87d18bcb..96fcf90b0fb 100644 --- a/spec/frontend/packages/details/store/actions_spec.js +++ b/spec/frontend/packages/details/store/actions_spec.js @@ -42,7 +42,10 @@ describe('Actions Package details store', () => { fetchPackageVersions, undefined, { packageEntity }, - [{ type: types.SET_LOADING, payload: true }, { type: types.SET_LOADING, payload: false }], + [ + { type: types.SET_LOADING, payload: true }, + { type: types.SET_LOADING, payload: false }, + ], [], () => { expect(Api.projectPackage).toHaveBeenCalledWith( @@ -61,7 +64,10 @@ describe('Actions Package details store', () => { fetchPackageVersions, undefined, { packageEntity }, - [{ type: types.SET_LOADING, payload: true }, { type: types.SET_LOADING, payload: false }], + [ + { type: types.SET_LOADING, payload: true }, + { type: types.SET_LOADING, payload: false }, + ], [], () => { expect(Api.projectPackage).toHaveBeenCalledWith( diff --git a/spec/frontend/packages/list/stores/actions_spec.js b/spec/frontend/packages/list/stores/actions_spec.js index cf205ecbac4..71b4d07a8af 100644 --- a/spec/frontend/packages/list/stores/actions_spec.js +++ b/spec/frontend/packages/list/stores/actions_spec.js @@ -109,7 +109,10 @@ describe('Actions Package list store', () => { undefined, { config: { isGroupPage: false, resourceId: 2 }, sorting }, [], - [{ type: 'setLoading', payload: true }, { type: 'setLoading', payload: false }], + [ + { type: 'setLoading', payload: true }, + { type: 'setLoading', payload: false }, + ], () => { expect(createFlash).toHaveBeenCalled(); done(); @@ -192,7 +195,10 @@ describe('Actions Package list store', () => { payload, null, [], - [{ type: 'setLoading', payload: true }, { type: 'setLoading', payload: false }], + [ + { type: 'setLoading', payload: true }, + { type: 'setLoading', payload: false }, + ], () => { expect(createFlash).toHaveBeenCalled(); done(); diff --git a/spec/frontend/packages/shared/components/package_tags_spec.js b/spec/frontend/packages/shared/components/package_tags_spec.js index cc49a9a9244..d26e4e76b87 100644 --- a/spec/frontend/packages/shared/components/package_tags_spec.js +++ b/spec/frontend/packages/shared/components/package_tags_spec.js @@ -75,11 +75,7 @@ describe('PackageTags', () => { const expectedStyle = [...defaultStyle, 'gl-display-flex', 'gl-ml-3']; - expect( - tagBadges() - .at(0) - .classes(), - ).toEqual(expect.arrayContaining(expectedStyle)); + expect(tagBadges().at(0).classes()).toEqual(expect.arrayContaining(expectedStyle)); }); it('shows tag badge for medium or heigher resolutions', () => { @@ -87,11 +83,7 @@ describe('PackageTags', () => { const expectedStyle = [...defaultStyle, 'd-md-flex']; - expect( - tagBadges() - .at(1) - .classes(), - ).toEqual(expect.arrayContaining(expectedStyle)); + expect(tagBadges().at(1).classes()).toEqual(expect.arrayContaining(expectedStyle)); }); it('correctly prepends left and appends right when there is more than one tag', () => { diff --git a/spec/frontend/pages/projects/forks/new/components/fork_groups_list_spec.js b/spec/frontend/pages/projects/forks/new/components/fork_groups_list_spec.js index 9993e4da980..c9b88c2ba34 100644 --- a/spec/frontend/pages/projects/forks/new/components/fork_groups_list_spec.js +++ b/spec/frontend/pages/projects/forks/new/components/fork_groups_list_spec.js @@ -104,12 +104,10 @@ describe('Fork groups list component', () => { expect(wrapper.findAll(ForkGroupsListItem)).toHaveLength(namespaces.length); namespaces.forEach((namespace, idx) => { - expect( - wrapper - .findAll(ForkGroupsListItem) - .at(idx) - .props(), - ).toStrictEqual({ group: namespace, hasReachedProjectLimit }); + expect(wrapper.findAll(ForkGroupsListItem).at(idx).props()).toStrictEqual({ + group: namespace, + hasReachedProjectLimit, + }); }); }); @@ -123,11 +121,6 @@ describe('Fork groups list component', () => { await nextTick(); expect(wrapper.findAll(ForkGroupsListItem)).toHaveLength(1); - expect( - wrapper - .findAll(ForkGroupsListItem) - .at(0) - .props().group.name, - ).toBe('otherdummy'); + expect(wrapper.findAll(ForkGroupsListItem).at(0).props().group.name).toBe('otherdummy'); }); }); diff --git a/spec/frontend/pages/projects/pipeline_schedules/shared/components/timezone_dropdown_spec.js b/spec/frontend/pages/projects/pipeline_schedules/shared/components/timezone_dropdown_spec.js index 5efcedf678b..fb45cf9e5d3 100644 --- a/spec/frontend/pages/projects/pipeline_schedules/shared/components/timezone_dropdown_spec.js +++ b/spec/frontend/pages/projects/pipeline_schedules/shared/components/timezone_dropdown_spec.js @@ -88,10 +88,7 @@ describe('Timezone Dropdown', () => { onSelectTimezone, }); - $wrapper - .find(tzListSel) - .first() - .trigger('click'); + $wrapper.find(tzListSel).first().trigger('click'); expect(onSelectTimezone).toHaveBeenCalled(); }); @@ -118,10 +115,7 @@ describe('Timezone Dropdown', () => { displayFormat, }); - $wrapper - .find(tzListSel) - .first() - .trigger('click'); + $wrapper.find(tzListSel).first().trigger('click'); expect(displayFormat).toHaveBeenCalled(); }); diff --git a/spec/frontend/pages/projects/shared/permissions/components/project_feature_settings_spec.js b/spec/frontend/pages/projects/shared/permissions/components/project_feature_settings_spec.js index a9fad921ea1..6e57823b761 100644 --- a/spec/frontend/pages/projects/shared/permissions/components/project_feature_settings_spec.js +++ b/spec/frontend/pages/projects/shared/permissions/components/project_feature_settings_spec.js @@ -6,7 +6,13 @@ import projectFeatureToggle from '~/vue_shared/components/toggle_button.vue'; describe('Project Feature Settings', () => { const defaultProps = { name: 'Test', - options: [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], + options: [ + [1, 1], + [2, 2], + [3, 3], + [4, 4], + [5, 5], + ], value: 1, disabledInput: false, showToggle: true, @@ -82,10 +88,7 @@ describe('Project Feature Settings', () => { wrapper = mount(projectFeatureSetting, { propsData: defaultProps }); expect(wrapper.emitted().change).toBeUndefined(); - wrapper - .find(projectFeatureToggle) - .find('button') - .trigger('click'); + wrapper.find(projectFeatureToggle).find('button').trigger('click'); return wrapper.vm.$nextTick().then(() => { expect(wrapper.emitted().change.length).toBe(1); @@ -119,10 +122,7 @@ describe('Project Feature Settings', () => { it('should emit the change when a new option is selected', () => { expect(wrapper.emitted().change).toBeUndefined(); - wrapper - .findAll('option') - .at(1) - .trigger('change'); + wrapper.findAll('option').at(1).trigger('change'); return wrapper.vm.$nextTick().then(() => { expect(wrapper.emitted().change.length).toBe(1); diff --git a/spec/frontend/pages/search/show/refresh_counts_spec.js b/spec/frontend/pages/search/show/refresh_counts_spec.js index ead268b3971..9a21647f5d0 100644 --- a/spec/frontend/pages/search/show/refresh_counts_spec.js +++ b/spec/frontend/pages/search/show/refresh_counts_spec.js @@ -5,7 +5,10 @@ import refreshCounts from '~/pages/search/show/refresh_counts'; const URL = `${TEST_HOST}/search/count?search=lorem+ipsum&project_id=3`; const urlWithScope = scope => `${URL}&scope=${scope}`; -const counts = [{ scope: 'issues', count: 4 }, { scope: 'merge_requests', count: 5 }]; +const counts = [ + { scope: 'issues', count: 4 }, + { scope: 'merge_requests', count: 5 }, +]; const fixture = `<div class="badge">22</div> <div class="badge js-search-count hidden" data-url="${urlWithScope('issues')}"></div> <div class="badge js-search-count hidden" data-url="${urlWithScope('merge_requests')}"></div>`; diff --git a/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js b/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js index 4b50342bf84..9be471aade2 100644 --- a/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js +++ b/spec/frontend/pages/sessions/new/preserve_url_fragment_spec.js @@ -3,9 +3,7 @@ import preserveUrlFragment from '~/pages/sessions/new/preserve_url_fragment'; describe('preserve_url_fragment', () => { const findFormAction = selector => { - return $(`.omniauth-container ${selector}`) - .parent('form') - .attr('action'); + return $(`.omniauth-container ${selector}`).parent('form').attr('action'); }; preloadFixtures('sessions/new.html'); diff --git a/spec/frontend/pipeline_editor/components/lint/ci_lint_spec.js b/spec/frontend/pipeline_editor/components/lint/ci_lint_spec.js index e69f0b953d2..40e1d7fdb24 100644 --- a/spec/frontend/pipeline_editor/components/lint/ci_lint_spec.js +++ b/spec/frontend/pipeline_editor/components/lint/ci_lint_spec.js @@ -49,11 +49,7 @@ describe('~/pipeline_editor/components/lint/ci_lint.vue', () => { }); it('displays link to the right help page', () => { - expect( - findAlert() - .find(GlLink) - .attributes('href'), - ).toBe(mockLintHelpPagePath); + expect(findAlert().find(GlLink).attributes('href')).toBe(mockLintHelpPagePath); }); it('displays jobs', () => { diff --git a/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js b/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js index 1e09c311439..b692ed636ab 100644 --- a/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js +++ b/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js @@ -177,11 +177,7 @@ describe('~/pipeline_editor/pipeline_editor_app.vue', () => { }); it('displays the tab and its content', async () => { - expect( - findTabAt(0) - .find(TextEditor) - .exists(), - ).toBe(true); + expect(findTabAt(0).find(TextEditor).exists()).toBe(true); }); it('displays tab lazily, until editor is ready', async () => { diff --git a/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js b/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js index b42339f626e..015a97169fa 100644 --- a/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js +++ b/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js @@ -44,10 +44,7 @@ describe('Pipeline New Form', () => { const findWarnings = () => wrapper.findAll('[data-testid="run-pipeline-warning"]'); const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const getExpectedPostParams = () => JSON.parse(mock.history.post[0].data); - const changeRef = i => - findDropdownItems() - .at(i) - .vm.$emit('click'); + const changeRef = i => findDropdownItems().at(i).vm.$emit('click'); const createComponent = (term = '', props = {}, method = shallowMount) => { wrapper = method(PipelineNewForm, { @@ -99,11 +96,7 @@ describe('Pipeline New Form', () => { createComponent('master'); expect(findDropdownItems()).toHaveLength(1); - expect( - findDropdownItems() - .at(0) - .text(), - ).toBe('master'); + expect(findDropdownItems().at(0).text()).toBe('master'); }); }); @@ -136,9 +129,7 @@ describe('Pipeline New Form', () => { }); it('removes ci variable row on remove icon button click', async () => { - findRemoveIcons() - .at(1) - .trigger('click'); + findRemoveIcons().at(1).trigger('click'); await wrapper.vm.$nextTick(); @@ -298,26 +289,16 @@ describe('Pipeline New Form', () => { }); it('adds a description to the first variable from yml', () => { - expect( - findVariableRows() - .at(0) - .text(), - ).toContain(mockYmlDesc); + expect(findVariableRows().at(0).text()).toContain(mockYmlDesc); }); it('removes the description when a variable key changes', async () => { findKeyInputs().at(0).element.value = 'yml_var_modified'; - findKeyInputs() - .at(0) - .trigger('change'); + findKeyInputs().at(0).trigger('change'); await wrapper.vm.$nextTick(); - expect( - findVariableRows() - .at(0) - .text(), - ).not.toContain(mockYmlDesc); + expect(findVariableRows().at(0).text()).not.toContain(mockYmlDesc); }); }); diff --git a/spec/frontend/pipelines/components/dag/dag_annotations_spec.js b/spec/frontend/pipelines/components/dag/dag_annotations_spec.js index 5747c91bee8..80807c0b330 100644 --- a/spec/frontend/pipelines/components/dag/dag_annotations_spec.js +++ b/spec/frontend/pipelines/components/dag/dag_annotations_spec.js @@ -66,11 +66,7 @@ describe('The DAG annotations', () => { expect(getAllTextBlocks().length).toBe(Object.keys(multiNote).length); Object.values(multiNote).forEach((item, idx) => { - expect( - getAllTextBlocks() - .at(idx) - .text(), - ).toBe(`${item.source.name} → ${item.target.name}`); + expect(getAllTextBlocks().at(idx).text()).toBe(`${item.source.name} → ${item.target.name}`); }); }); diff --git a/spec/frontend/pipelines/components/dag/dag_graph_spec.js b/spec/frontend/pipelines/components/dag/dag_graph_spec.js index 7786212cb69..02692cc3994 100644 --- a/spec/frontend/pipelines/components/dag/dag_graph_spec.js +++ b/spec/frontend/pipelines/components/dag/dag_graph_spec.js @@ -88,11 +88,7 @@ describe('The DAG graph', () => { }); it('renders the title as text', () => { - expect( - getAllLabels() - .at(0) - .text(), - ).toBe(parsedData.nodes[0].name); + expect(getAllLabels().at(0).text()).toBe(parsedData.nodes[0].name); }); }); }); diff --git a/spec/frontend/pipelines/components/dag/parsing_utils_spec.js b/spec/frontend/pipelines/components/dag/parsing_utils_spec.js index ceb6b64d4ad..5d3f680a57c 100644 --- a/spec/frontend/pipelines/components/dag/parsing_utils_spec.js +++ b/spec/frontend/pipelines/components/dag/parsing_utils_spec.js @@ -30,7 +30,10 @@ describe('DAG visualization parsing utilities', () => { { source: 'job2', target: 'job4' }, ]; - const dedupedLinks = [{ source: 'job1', target: 'job2' }, { source: 'job2', target: 'job4' }]; + const dedupedLinks = [ + { source: 'job1', target: 'job2' }, + { source: 'job2', target: 'job4' }, + ]; const nodeLookup = { job1: { diff --git a/spec/frontend/pipelines/graph/graph_component_legacy_spec.js b/spec/frontend/pipelines/graph/graph_component_legacy_spec.js index 3b1909b6564..7662520650f 100644 --- a/spec/frontend/pipelines/graph/graph_component_legacy_spec.js +++ b/spec/frontend/pipelines/graph/graph_component_legacy_spec.js @@ -104,11 +104,9 @@ describe('graph component', () => { }); it('should include the left-connector class in the build of the second child', () => { - expect( - findStageColumnAt(1) - .find('.build:nth-child(1)') - .classes('left-connector'), - ).toBe(true); + expect(findStageColumnAt(1).find('.build:nth-child(1)').classes('left-connector')).toBe( + true, + ); }); it('should include the js-has-linked-pipelines flag', () => { @@ -119,12 +117,7 @@ describe('graph component', () => { describe('computeds and methods', () => { describe('capitalizeStageName', () => { it('it capitalizes the stage name', () => { - expect( - wrapper - .findAll('.stage-column .stage-name') - .at(1) - .text(), - ).toBe('Prebuild'); + expect(wrapper.findAll('.stage-column .stage-name').at(1).text()).toBe('Prebuild'); }); }); diff --git a/spec/frontend/pipelines/graph/graph_component_spec.js b/spec/frontend/pipelines/graph/graph_component_spec.js index 7572dd83798..7b12070e08f 100644 --- a/spec/frontend/pipelines/graph/graph_component_spec.js +++ b/spec/frontend/pipelines/graph/graph_component_spec.js @@ -47,9 +47,7 @@ describe('graph component', () => { describe('when column requests a refresh', () => { beforeEach(() => { - findStageColumns() - .at(0) - .vm.$emit('refreshPipelineGraph'); + findStageColumns().at(0).vm.$emit('refreshPipelineGraph'); }); it('refreshPipelineGraph is emitted', () => { diff --git a/spec/frontend/pipelines/graph/stage_column_component_legacy_spec.js b/spec/frontend/pipelines/graph/stage_column_component_legacy_spec.js index 463e4c12c7d..2965325ea7c 100644 --- a/spec/frontend/pipelines/graph/stage_column_component_legacy_spec.js +++ b/spec/frontend/pipelines/graph/stage_column_component_legacy_spec.js @@ -40,12 +40,7 @@ describe('stage column component', () => { }); it('should render provided title', () => { - expect( - wrapper - .find('.stage-name') - .text() - .trim(), - ).toBe('foo'); + expect(wrapper.find('.stage-name').text().trim()).toBe('foo'); }); it('should render the provided groups', () => { diff --git a/spec/frontend/pipelines/pipelines_actions_spec.js b/spec/frontend/pipelines/pipelines_actions_spec.js index 071a2b24889..69c1b7ce43d 100644 --- a/spec/frontend/pipelines/pipelines_actions_spec.js +++ b/spec/frontend/pipelines/pipelines_actions_spec.js @@ -55,11 +55,7 @@ describe('Pipelines Actions dropdown', () => { }); it("renders a disabled action when it's not playable", () => { - expect( - findAllDropdownItems() - .at(1) - .attributes('disabled'), - ).toBe('true'); + expect(findAllDropdownItems().at(1).attributes('disabled')).toBe('true'); }); describe('on click', () => { @@ -100,9 +96,7 @@ describe('Pipelines Actions dropdown', () => { mock.onPost(scheduledJobAction.path).reply(200); jest.spyOn(window, 'confirm').mockReturnValue(true); - findAllDropdownItems() - .at(0) - .vm.$emit('click'); + findAllDropdownItems().at(0).vm.$emit('click'); expect(window.confirm).toHaveBeenCalled(); @@ -115,28 +109,20 @@ describe('Pipelines Actions dropdown', () => { mock.onPost(scheduledJobAction.path).reply(200); jest.spyOn(window, 'confirm').mockReturnValue(false); - findAllDropdownItems() - .at(0) - .vm.$emit('click'); + findAllDropdownItems().at(0).vm.$emit('click'); expect(window.confirm).toHaveBeenCalled(); expect(mock.history.post.length).toBe(0); }); it('displays the remaining time in the dropdown', () => { - expect( - findAllCountdowns() - .at(0) - .props('endDateString'), - ).toBe(scheduledJobAction.scheduled_at); + expect(findAllCountdowns().at(0).props('endDateString')).toBe( + scheduledJobAction.scheduled_at, + ); }); it('displays 00:00:00 for expired jobs in the dropdown', () => { - expect( - findAllCountdowns() - .at(1) - .props('endDateString'), - ).toBe(expiredJobAction.scheduled_at); + expect(findAllCountdowns().at(1).props('endDateString')).toBe(expiredJobAction.scheduled_at); }); }); }); diff --git a/spec/frontend/pipelines/pipelines_spec.js b/spec/frontend/pipelines/pipelines_spec.js index ce0e76ba22d..14caf785027 100644 --- a/spec/frontend/pipelines/pipelines_spec.js +++ b/spec/frontend/pipelines/pipelines_spec.js @@ -194,16 +194,8 @@ describe('Pipelines', () => { }); it('renders empty state', () => { - expect( - findEmptyState() - .find('h4') - .text(), - ).toBe('Build with confidence'); - expect( - findEmptyState() - .find(GlButton) - .attributes('href'), - ).toBe(paths.helpPagePath); + expect(findEmptyState().find('h4').text()).toBe('Build with confidence'); + expect(findEmptyState().find(GlButton).attributes('href')).toBe(paths.helpPagePath); }); it('does not render tabs nor buttons', () => { @@ -320,11 +312,7 @@ describe('Pipelines', () => { 'This project is not currently set up to run pipelines.', ); - expect( - findEmptyState() - .find(GlButton) - .exists(), - ).toBeFalsy(); + expect(findEmptyState().find(GlButton).exists()).toBeFalsy(); }); it('does not render tabs or buttons', () => { diff --git a/spec/frontend/pipelines/pipelines_store_spec.js b/spec/frontend/pipelines/pipelines_store_spec.js index ce21f788ed5..f374ecd0c0a 100644 --- a/spec/frontend/pipelines/pipelines_store_spec.js +++ b/spec/frontend/pipelines/pipelines_store_spec.js @@ -21,7 +21,10 @@ describe('Pipelines Store', () => { }); it('should store the provided array', () => { - const array = [{ id: 1, status: 'running' }, { id: 2, status: 'success' }]; + const array = [ + { id: 1, status: 'running' }, + { id: 2, status: 'success' }, + ]; store.storePipelines(array); expect(store.state.pipelines).toEqual(array); diff --git a/spec/frontend/pipelines/pipelines_table_row_spec.js b/spec/frontend/pipelines/pipelines_table_row_spec.js index 32d53c0f1f8..d682c45f816 100644 --- a/spec/frontend/pipelines/pipelines_table_row_spec.js +++ b/spec/frontend/pipelines/pipelines_table_row_spec.js @@ -82,10 +82,7 @@ describe('Pipelines Table Row', () => { ).toEqual(pipeline.user.path); expect( - wrapper - .find('.table-section:nth-child(3) .js-user-avatar-image-toolip') - .text() - .trim(), + wrapper.find('.table-section:nth-child(3) .js-user-avatar-image-toolip').text().trim(), ).toEqual(pipeline.user.name); }); }); diff --git a/spec/frontend/profile/account/components/delete_account_modal_spec.js b/spec/frontend/profile/account/components/delete_account_modal_spec.js index 7834456f7c4..6ee919a8cc5 100644 --- a/spec/frontend/profile/account/components/delete_account_modal_spec.js +++ b/spec/frontend/profile/account/components/delete_account_modal_spec.js @@ -65,9 +65,7 @@ describe('DeleteAccountModal component', () => { vm.isOpen = true; - Vue.nextTick() - .then(done) - .catch(done.fail); + Vue.nextTick().then(done).catch(done.fail); }); it('does not accept empty password', done => { @@ -117,9 +115,7 @@ describe('DeleteAccountModal component', () => { vm.isOpen = true; - Vue.nextTick() - .then(done) - .catch(done.fail); + Vue.nextTick().then(done).catch(done.fail); }); it('does not accept wrong username', done => { diff --git a/spec/frontend/project_find_file_spec.js b/spec/frontend/project_find_file_spec.js index 6a50f68a4e9..104233eb6d5 100644 --- a/spec/frontend/project_find_file_spec.js +++ b/spec/frontend/project_find_file_spec.js @@ -58,7 +58,10 @@ describe('ProjectFindFile', () => { mock = new MockAdapter(axios); element = $(TEMPLATE); - mock.onGet(FILE_FIND_URL).replyOnce(200, files.map(x => x.path)); + mock.onGet(FILE_FIND_URL).replyOnce( + 200, + files.map(x => x.path), + ); getProjectFindFileInstance(); // This triggers a load / axios call + subsequent render in the constructor setImmediate(done); diff --git a/spec/frontend/projects/commits/components/author_select_spec.js b/spec/frontend/projects/commits/components/author_select_spec.js index 68c285a4097..63920ddfd72 100644 --- a/spec/frontend/projects/commits/components/author_select_spec.js +++ b/spec/frontend/projects/commits/components/author_select_spec.js @@ -139,11 +139,7 @@ describe('Author Select', () => { }); it('has a "Any Author" as the first list item', () => { - expect( - findDropdownItems() - .at(0) - .text(), - ).toBe('Any Author'); + expect(findDropdownItems().at(0).text()).toBe('Any Author'); }); it('displays the project authors', () => { @@ -163,21 +159,13 @@ describe('Author Select', () => { wrapper.setData({ currentAuthor }); return wrapper.vm.$nextTick().then(() => { - expect( - findDropdownItems() - .at(1) - .props(), - ).toEqual(expect.objectContaining(result)); + expect(findDropdownItems().at(1).props()).toEqual(expect.objectContaining(result)); }); }); it("display the author's name", () => { return wrapper.vm.$nextTick().then(() => { - expect( - findDropdownItems() - .at(1) - .text(), - ).toBe(currentAuthor); + expect(findDropdownItems().at(1).text()).toBe(currentAuthor); }); }); @@ -186,9 +174,7 @@ describe('Author Select', () => { const spy = jest.spyOn(urlUtility, 'redirectTo'); spy.mockImplementation(() => 'mock'); - findDropdownItems() - .at(1) - .vm.$emit('click'); + findDropdownItems().at(1).vm.$emit('click'); expect(spy).toHaveBeenCalledWith(redirectToUrl); }); @@ -198,9 +184,7 @@ describe('Author Select', () => { const spy = jest.spyOn(urlUtility, 'redirectTo'); spy.mockImplementation(); - findDropdownItems() - .at(0) - .vm.$emit('click'); + findDropdownItems().at(0).vm.$emit('click'); expect(spy).toHaveBeenCalledWith(redirectToUrl); }); }); diff --git a/spec/frontend/projects/pipelines/charts/mock_data.js b/spec/frontend/projects/pipelines/charts/mock_data.js index da055536fcc..3bc09f0b0a0 100644 --- a/spec/frontend/projects/pipelines/charts/mock_data.js +++ b/spec/frontend/projects/pipelines/charts/mock_data.js @@ -25,11 +25,23 @@ export const lastYearChartData = { export const transformedAreaChartData = [ { name: 'all', - data: [['01 Jan', 4], ['02 Jan', 6], ['03 Jan', 3], ['04 Jan', 6], ['05 Jan', 7]], + data: [ + ['01 Jan', 4], + ['02 Jan', 6], + ['03 Jan', 3], + ['04 Jan', 6], + ['05 Jan', 7], + ], }, { name: 'success', - data: [['01 Jan', 3], ['02 Jan', 3], ['03 Jan', 3], ['04 Jan', 3], ['05 Jan', 5]], + data: [ + ['01 Jan', 3], + ['02 Jan', 3], + ['03 Jan', 3], + ['04 Jan', 3], + ['05 Jan', 5], + ], }, ]; diff --git a/spec/frontend/projects/project_new_spec.js b/spec/frontend/projects/project_new_spec.js index c32979dcd74..ed6bd818bd9 100644 --- a/spec/frontend/projects/project_new_spec.js +++ b/spec/frontend/projects/project_new_spec.js @@ -38,10 +38,7 @@ describe('New Project', () => { beforeEach(() => { projectNew.bindEvents(); - $projectPath - .val('') - .keyup() - .val(dummyImportUrl); + $projectPath.val('').keyup().val(dummyImportUrl); }); it('does not change project path for disabled $projectImportUrl', () => { diff --git a/spec/frontend/prometheus_metrics/prometheus_metrics_spec.js b/spec/frontend/prometheus_metrics/prometheus_metrics_spec.js index 2460851a6a4..429707eab58 100644 --- a/spec/frontend/prometheus_metrics/prometheus_metrics_spec.js +++ b/spec/frontend/prometheus_metrics/prometheus_metrics_spec.js @@ -91,12 +91,7 @@ describe('PrometheusMetrics', () => { ); expect($metricsListLi.length).toEqual(metrics.length); - expect( - $metricsListLi - .first() - .find('.badge') - .text(), - ).toEqual(`${metrics[0].active_metrics}`); + expect($metricsListLi.first().find('.badge').text()).toEqual(`${metrics[0].active_metrics}`); }); it('should show missing environment variables list', () => { diff --git a/spec/frontend/ref/components/ref_selector_spec.js b/spec/frontend/ref/components/ref_selector_spec.js index 7f0a4c7d3f4..ca5a5a62235 100644 --- a/spec/frontend/ref/components/ref_selector_spec.js +++ b/spec/frontend/ref/components/ref_selector_spec.js @@ -313,9 +313,7 @@ describe('Ref selector component', () => { it('renders the "Branches" heading with a total number indicator', () => { expect( - findBranchesSection() - .find('[data-testid="section-header"]') - .text(), + findBranchesSection().find('[data-testid="section-header"]').text(), ).toMatchInterpolatedText('Branches 123'); }); @@ -392,9 +390,7 @@ describe('Ref selector component', () => { it('renders the "Tags" heading with a total number indicator', () => { expect( - findTagsSection() - .find('[data-testid="section-header"]') - .text(), + findTagsSection().find('[data-testid="section-header"]').text(), ).toMatchInterpolatedText('Tags 456'); }); @@ -460,9 +456,7 @@ describe('Ref selector component', () => { it('renders the "Commits" heading with a total number indicator', () => { expect( - findCommitsSection() - .find('[data-testid="section-header"]') - .text(), + findCommitsSection().find('[data-testid="section-header"]').text(), ).toMatchInterpolatedText('Commits 1'); }); diff --git a/spec/frontend/registry/explorer/components/details_page/tags_list_row_spec.js b/spec/frontend/registry/explorer/components/details_page/tags_list_row_spec.js index e1b75636735..1cde19510a2 100644 --- a/spec/frontend/registry/explorer/components/details_page/tags_list_row_spec.js +++ b/spec/frontend/registry/explorer/components/details_page/tags_list_row_spec.js @@ -306,11 +306,7 @@ describe('tags list row', () => { }); it(`is ${clipboard} that clipboard button exist`, () => { - expect( - finderFunction() - .find(ClipboardButton) - .exists(), - ).toBe(clipboard); + expect(finderFunction().find(ClipboardButton).exists()).toBe(clipboard); }); }); }); diff --git a/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js b/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js index 035b59731c9..b843e9a2ad3 100644 --- a/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js +++ b/spec/frontend/registry/explorer/components/details_page/tags_list_spec.js @@ -78,18 +78,14 @@ describe('Tags List', () => { it('is enabled when at least one item is selected', async () => { mountComponent(); - findTagsListRow() - .at(0) - .vm.$emit('select'); + findTagsListRow().at(0).vm.$emit('select'); await wrapper.vm.$nextTick(); expect(findDeleteButton().attributes('disabled')).toBe(undefined); }); it('click event emits a deleted event with selected items', () => { mountComponent(); - findTagsListRow() - .at(0) - .vm.$emit('select'); + findTagsListRow().at(0).vm.$emit('select'); findDeleteButton().vm.$emit('click'); expect(wrapper.emitted('delete')).toEqual([[{ 'beta-24753': true }]]); @@ -116,22 +112,14 @@ describe('Tags List', () => { describe('events', () => { it('select event update the selected items', async () => { mountComponent(); - findTagsListRow() - .at(0) - .vm.$emit('select'); + findTagsListRow().at(0).vm.$emit('select'); await wrapper.vm.$nextTick(); - expect( - findTagsListRow() - .at(0) - .attributes('selected'), - ).toBe('true'); + expect(findTagsListRow().at(0).attributes('selected')).toBe('true'); }); it('delete event emit a delete event', () => { mountComponent(); - findTagsListRow() - .at(0) - .vm.$emit('delete'); + findTagsListRow().at(0).vm.$emit('delete'); expect(wrapper.emitted('delete')).toEqual([[{ 'beta-24753': true }]]); }); }); diff --git a/spec/frontend/registry/explorer/components/details_page/tags_loader_spec.js b/spec/frontend/registry/explorer/components/details_page/tags_loader_spec.js index b27d3e2c042..40d84d9d4a5 100644 --- a/spec/frontend/registry/explorer/components/details_page/tags_loader_spec.js +++ b/spec/frontend/registry/explorer/components/details_page/tags_loader_spec.js @@ -32,11 +32,7 @@ describe('TagsLoader component', () => { it('has the correct props', () => { mountComponent(); - expect( - findGlSkeletonLoaders() - .at(0) - .props(), - ).toMatchObject({ + expect(findGlSkeletonLoaders().at(0).props()).toMatchObject({ width: component.loader.width, height: component.loader.height, }); diff --git a/spec/frontend/registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap b/spec/frontend/registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap index bab6b25cc15..46b07b4c2d6 100644 --- a/spec/frontend/registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap +++ b/spec/frontend/registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap @@ -56,7 +56,7 @@ exports[`Registry Project Empty state to match the default snapshot 1`] = ` </p> <gl-form-input-group-stub - class="gl-mb-4 " + class="gl-mb-4" predefinedoptions="[object Object]" value="" > diff --git a/spec/frontend/registry/explorer/components/list_page/image_list_spec.js b/spec/frontend/registry/explorer/components/list_page/image_list_spec.js index 54befc9973a..9c293cb5c31 100644 --- a/spec/frontend/registry/explorer/components/list_page/image_list_spec.js +++ b/spec/frontend/registry/explorer/components/list_page/image_list_spec.js @@ -35,9 +35,7 @@ describe('Image List', () => { it('when delete event is emitted on the row it emits up a delete event', () => { mountComponent(); - findRow() - .at(0) - .vm.$emit('delete', 'foo'); + findRow().at(0).vm.$emit('delete', 'foo'); expect(wrapper.emitted('delete')).toEqual([['foo']]); }); }); diff --git a/spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js b/spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js index fb0b98ba004..692972185c8 100644 --- a/spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js +++ b/spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js @@ -119,11 +119,7 @@ describe('Registry Breadcrumb', () => { }); it('has the same classes as the last children of the crumbs', () => { - expect( - findLastCrumb() - .classes() - .join(' '), - ).toEqual(lastChildren.className); + expect(findLastCrumb().classes().join(' ')).toEqual(lastChildren.className); }); it('has a link to the current route', () => { diff --git a/spec/frontend/registry/settings/components/expiration_dropdown_spec.js b/spec/frontend/registry/settings/components/expiration_dropdown_spec.js index e0cac317ad6..329aa55e739 100644 --- a/spec/frontend/registry/settings/components/expiration_dropdown_spec.js +++ b/spec/frontend/registry/settings/components/expiration_dropdown_spec.js @@ -8,7 +8,10 @@ describe('ExpirationDropdown', () => { const defaultProps = { name: 'foo', label: 'label-bar', - formOptions: [{ key: 'foo', label: 'bar' }, { key: 'baz', label: 'zab' }], + formOptions: [ + { key: 'foo', label: 'bar' }, + { key: 'baz', label: 'zab' }, + ], }; const findFormSelect = () => wrapper.find(GlFormSelect); diff --git a/spec/frontend/registry/settings/utils_spec.js b/spec/frontend/registry/settings/utils_spec.js index f92d51db307..7bc627908af 100644 --- a/spec/frontend/registry/settings/utils_spec.js +++ b/spec/frontend/registry/settings/utils_spec.js @@ -11,7 +11,10 @@ describe('Utils', () => { [{ variable: 1 }, { variable: 2 }], olderThanTranslationGenerator, ); - expect(result).toEqual([{ variable: 1, label: '1 day' }, { variable: 2, label: '2 days' }]); + expect(result).toEqual([ + { variable: 1, label: '1 day' }, + { variable: 2, label: '2 days' }, + ]); }); }); diff --git a/spec/frontend/related_merge_requests/components/related_merge_requests_spec.js b/spec/frontend/related_merge_requests/components/related_merge_requests_spec.js index db33a9cdce1..e0395d93036 100644 --- a/spec/frontend/related_merge_requests/components/related_merge_requests_spec.js +++ b/spec/frontend/related_merge_requests/components/related_merge_requests_spec.js @@ -73,10 +73,7 @@ describe('RelatedMergeRequests', () => { expect(wrapper.find('.js-items-count').text()).toEqual('2'); expect(wrapper.findAll(RelatedIssuableItem).length).toEqual(2); - const props = wrapper - .findAll(RelatedIssuableItem) - .at(1) - .props(); + const props = wrapper.findAll(RelatedIssuableItem).at(1).props(); const data = mockData[1]; expect(props.idKey).toEqual(data.id); diff --git a/spec/frontend/releases/components/release_block_milestone_info_spec.js b/spec/frontend/releases/components/release_block_milestone_info_spec.js index bb34693c757..5cde8d630e6 100644 --- a/spec/frontend/releases/components/release_block_milestone_info_spec.js +++ b/spec/frontend/releases/components/release_block_milestone_info_spec.js @@ -67,9 +67,7 @@ describe('Release block milestone info', () => { ).toBe(true); milestones.forEach((m, i) => { - const milestoneLink = milestoneListContainer() - .findAll(GlLink) - .at(i); + const milestoneLink = milestoneListContainer().findAll(GlLink).at(i); expect(milestoneLink.text()).toBe(m.title); expect(milestoneLink.attributes('href')).toBe(m.webUrl); @@ -118,9 +116,7 @@ describe('Release block milestone info', () => { }); const clickShowMoreFewerButton = () => { - milestoneListContainer() - .find(GlButton) - .trigger('click'); + milestoneListContainer().find(GlButton).trigger('click'); return wrapper.vm.$nextTick(); }; diff --git a/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js b/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js index 77d7c6f8678..ecb657af6f1 100644 --- a/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js +++ b/spec/frontend/reports/codequality_report/grouped_codequality_reports_app_spec.js @@ -139,11 +139,7 @@ describe('Grouped code quality reports app', () => { }); it('renders a help icon with more information', () => { - expect( - findWidget() - .find('[data-testid="question-icon"]') - .exists(), - ).toBe(true); + expect(findWidget().find('[data-testid="question-icon"]').exists()).toBe(true); }); }); @@ -157,11 +153,7 @@ describe('Grouped code quality reports app', () => { }); it('does not render a help icon', () => { - expect( - findWidget() - .find('[data-testid="question-icon"]') - .exists(), - ).toBe(false); + expect(findWidget().find('[data-testid="question-icon"]').exists()).toBe(false); }); }); }); diff --git a/spec/frontend/reports/components/grouped_test_reports_app_spec.js b/spec/frontend/reports/components/grouped_test_reports_app_spec.js index 66d429017b2..345936d86e2 100644 --- a/spec/frontend/reports/components/grouped_test_reports_app_spec.js +++ b/spec/frontend/reports/components/grouped_test_reports_app_spec.js @@ -232,11 +232,9 @@ describe('Grouped test reports app', () => { }); it('renders resolved errors', () => { - expect( - findAllIssueDescriptions() - .at(2) - .text(), - ).toContain(resolvedFailures.suites[0].resolved_errors[0].name); + expect(findAllIssueDescriptions().at(2).text()).toContain( + resolvedFailures.suites[0].resolved_errors[0].name, + ); }); }); diff --git a/spec/frontend/repository/components/breadcrumbs_spec.js b/spec/frontend/repository/components/breadcrumbs_spec.js index 38e5c9aaca5..a0dc608ddc9 100644 --- a/spec/frontend/repository/components/breadcrumbs_spec.js +++ b/spec/frontend/repository/components/breadcrumbs_spec.js @@ -36,23 +36,15 @@ describe('Repository breadcrumbs component', () => { it('escapes hash in directory path', () => { factory('app/assets/javascripts#'); - expect( - vm - .findAll(RouterLinkStub) - .at(3) - .props('to'), - ).toEqual('/-/tree/app/assets/javascripts%23'); + expect(vm.findAll(RouterLinkStub).at(3).props('to')).toEqual( + '/-/tree/app/assets/javascripts%23', + ); }); it('renders last link as active', () => { factory('app/assets'); - expect( - vm - .findAll(RouterLinkStub) - .at(2) - .attributes('aria-current'), - ).toEqual('page'); + expect(vm.findAll(RouterLinkStub).at(2).attributes('aria-current')).toEqual('page'); }); it('does not render add to tree dropdown when permissions are false', () => { diff --git a/spec/frontend/repository/components/directory_download_links_spec.js b/spec/frontend/repository/components/directory_download_links_spec.js index 4d70b44de08..72c4165c2e9 100644 --- a/spec/frontend/repository/components/directory_download_links_spec.js +++ b/spec/frontend/repository/components/directory_download_links_spec.js @@ -7,7 +7,10 @@ function factory(currentPath) { vm = shallowMount(DirectoryDownloadLinks, { propsData: { currentPath, - links: [{ text: 'zip', path: 'http://test.com/' }, { text: 'tar', path: 'http://test.com/' }], + links: [ + { text: 'zip', path: 'http://test.com/' }, + { text: 'tar', path: 'http://test.com/' }, + ], }, }); } diff --git a/spec/frontend/self_monitor/components/self_monitor_form_spec.js b/spec/frontend/self_monitor/components/self_monitor_form_spec.js index 618cc16cdf4..dfa961c5115 100644 --- a/spec/frontend/self_monitor/components/self_monitor_form_spec.js +++ b/spec/frontend/self_monitor/components/self_monitor_form_spec.js @@ -79,10 +79,7 @@ describe('self monitor component', () => { wrapper = shallowMount(SelfMonitor, { store }); expect( - wrapper - .find({ ref: 'selfMonitoringFormText' }) - .find('a') - .attributes('href'), + wrapper.find({ ref: 'selfMonitoringFormText' }).find('a').attributes('href'), ).toEqual(`${TEST_HOST}/instance-administrators-random/gitlab-self-monitoring`); }); }); diff --git a/spec/frontend/serverless/mock_data.js b/spec/frontend/serverless/mock_data.js index ef616ceb37f..1816ad62a04 100644 --- a/spec/frontend/serverless/mock_data.js +++ b/spec/frontend/serverless/mock_data.js @@ -102,7 +102,10 @@ export const mockMetrics = { result: [ { metric: {}, - values: [[1551352298.756, '0'], [1551352358.756, '0']], + values: [ + [1551352298.756, '0'], + [1551352358.756, '0'], + ], }, ], }, diff --git a/spec/frontend/sidebar/components/assignees/collapsed_assignee_spec.js b/spec/frontend/sidebar/components/assignees/collapsed_assignee_spec.js index 49a6d9e8ae6..ee1f8ed8d2b 100644 --- a/spec/frontend/sidebar/components/assignees/collapsed_assignee_spec.js +++ b/spec/frontend/sidebar/components/assignees/collapsed_assignee_spec.js @@ -28,12 +28,7 @@ describe('CollapsedAssignee assignee component', () => { it('has author name', () => { createComponent(); - expect( - wrapper - .find('.author') - .text() - .trim(), - ).toEqual(TEST_USER.name); + expect(wrapper.find('.author').text().trim()).toEqual(TEST_USER.name); }); it('has assignee avatar', () => { diff --git a/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js b/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js index 638d3706d12..3366d70f0fe 100644 --- a/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js +++ b/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js @@ -119,21 +119,11 @@ describe('SidebarSeverity', () => { }); it('should display only icon with a tooltip', () => { - expect( - findSeverityToken() - .at(0) - .attributes('icononly'), - ).toBe('true'); - expect( - findSeverityToken() - .at(0) - .attributes('iconsize'), - ).toBe('14'); - expect( - findTooltip() - .text() - .replace(/\s+/g, ' '), - ).toContain(`Severity: ${INCIDENT_SEVERITY[severity].label}`); + expect(findSeverityToken().at(0).attributes('icononly')).toBe('true'); + expect(findSeverityToken().at(0).attributes('iconsize')).toBe('14'); + expect(findTooltip().text().replace(/\s+/g, ' ')).toContain( + `Severity: ${INCIDENT_SEVERITY[severity].label}`, + ); }); it('should expand the dropdown on collapsed icon click', async () => { diff --git a/spec/frontend/sidebar/sidebar_move_issue_spec.js b/spec/frontend/sidebar/sidebar_move_issue_spec.js index ad919f69546..ba14c61400f 100644 --- a/spec/frontend/sidebar/sidebar_move_issue_spec.js +++ b/spec/frontend/sidebar/sidebar_move_issue_spec.js @@ -133,10 +133,7 @@ describe('SidebarMoveIssue', () => { // Wait for the autocomplete request to finish setImmediate(() => { - test.$content - .find('.js-move-issue-dropdown-item') - .eq(0) - .trigger('click'); + test.$content.find('.js-move-issue-dropdown-item').eq(0).trigger('click'); expect(test.mediator.setMoveToProjectId).toHaveBeenCalledWith(0); expect(test.$confirmButton.prop('disabled')).toBeTruthy(); @@ -152,10 +149,7 @@ describe('SidebarMoveIssue', () => { // Wait for the autocomplete request to finish setImmediate(() => { - test.$content - .find('.js-move-issue-dropdown-item') - .eq(1) - .trigger('click'); + test.$content.find('.js-move-issue-dropdown-item').eq(1).trigger('click'); expect(test.mediator.setMoveToProjectId).toHaveBeenCalledWith(20); expect(test.$confirmButton.attr('disabled')).toBe(undefined); diff --git a/spec/frontend/sidebar/todo_spec.js b/spec/frontend/sidebar/todo_spec.js index b0e94f16dd7..4adfaf7ad7b 100644 --- a/spec/frontend/sidebar/todo_spec.js +++ b/spec/frontend/sidebar/todo_spec.js @@ -42,12 +42,7 @@ describe('SidebarTodo', () => { ({ isTodo, iconClass, label, icon }) => { createComponent({ isTodo }); - expect( - wrapper - .find(GlIcon) - .classes() - .join(' '), - ).toStrictEqual(iconClass); + expect(wrapper.find(GlIcon).classes().join(' ')).toStrictEqual(iconClass); expect(wrapper.find(GlIcon).props('name')).toStrictEqual(icon); expect(wrapper.find('button').text()).toBe(label); }, diff --git a/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js b/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js index 055168a1711..ddfbeb9a58f 100644 --- a/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js +++ b/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js @@ -50,14 +50,8 @@ describe('snippets/components/snippet_blob_actions_edit', () => { }, classes: index > 0 ? ['gl-mt-3'] : [], })); - const triggerBlobDelete = idx => - findBlobEdits() - .at(idx) - .vm.$emit('delete'); - const triggerBlobUpdate = (idx, props) => - findBlobEdits() - .at(idx) - .vm.$emit('blob-updated', props); + const triggerBlobDelete = idx => findBlobEdits().at(idx).vm.$emit('delete'); + const triggerBlobUpdate = (idx, props) => findBlobEdits().at(idx).vm.$emit('blob-updated', props); afterEach(() => { wrapper.destroy(); @@ -213,11 +207,7 @@ describe('snippets/components/snippet_blob_actions_edit', () => { it('disables delete button', () => { expect(findBlobEdits()).toHaveLength(1); - expect( - findBlobEdits() - .at(0) - .props(), - ).toMatchObject({ + expect(findBlobEdits().at(0).props()).toMatchObject({ showDelete: true, canDelete: false, }); diff --git a/spec/frontend/transfer_edit_spec.js b/spec/frontend/transfer_edit_spec.js index dc9455a569d..ad8c9c68f37 100644 --- a/spec/frontend/transfer_edit_spec.js +++ b/spec/frontend/transfer_edit_spec.js @@ -13,41 +13,19 @@ describe('setupTransferEdit', () => { }); it('disables submit button on load', () => { - expect( - $(formSelector) - .find(':submit') - .prop('disabled'), - ).toBe(true); + expect($(formSelector).find(':submit').prop('disabled')).toBe(true); }); it('enables submit button when selection changes to non-empty value', () => { - const nonEmptyValue = $(formSelector) - .find(targetSelector) - .find('option') - .not(':empty') - .val(); - $(formSelector) - .find(targetSelector) - .val(nonEmptyValue) - .trigger('change'); - - expect( - $(formSelector) - .find(':submit') - .prop('disabled'), - ).toBeFalsy(); + const nonEmptyValue = $(formSelector).find(targetSelector).find('option').not(':empty').val(); + $(formSelector).find(targetSelector).val(nonEmptyValue).trigger('change'); + + expect($(formSelector).find(':submit').prop('disabled')).toBeFalsy(); }); it('disables submit button when selection changes to empty value', () => { - $(formSelector) - .find(targetSelector) - .val('') - .trigger('change'); - - expect( - $(formSelector) - .find(':submit') - .prop('disabled'), - ).toBe(true); + $(formSelector).find(targetSelector).val('').trigger('change'); + + expect($(formSelector).find(':submit').prop('disabled')).toBe(true); }); }); diff --git a/spec/frontend/version_check_image_spec.js b/spec/frontend/version_check_image_spec.js index 2ab157105a1..5bb28687be3 100644 --- a/spec/frontend/version_check_image_spec.js +++ b/spec/frontend/version_check_image_spec.js @@ -19,7 +19,7 @@ describe('VersionCheckImage', () => { it('registers an error event', () => { jest.spyOn($.prototype, 'on').mockImplementation(() => {}); // eslint-disable-next-line func-names - jest.spyOn($.prototype, 'off').mockImplementation(function() { + jest.spyOn($.prototype, 'off').mockImplementation(function () { return this; }); diff --git a/spec/frontend/vue_mr_widget/components/approvals/approvals_spec.js b/spec/frontend/vue_mr_widget/components/approvals/approvals_spec.js index 65ca3639dcc..62086de9465 100644 --- a/spec/frontend/vue_mr_widget/components/approvals/approvals_spec.js +++ b/spec/frontend/vue_mr_widget/components/approvals/approvals_spec.js @@ -31,10 +31,7 @@ const testApprovalRulesResponse = () => ({ rules: [{ id: 2 }] }); // For some reason, the `Promise.resolve()` needs to be deferred // or the timing doesn't work. const tick = () => Promise.resolve(); -const waitForTick = done => - tick() - .then(done) - .catch(done.fail); +const waitForTick = done => tick().then(done).catch(done.fail); describe('MRWidget approvals', () => { let wrapper; diff --git a/spec/frontend/vue_mr_widget/components/artifacts_list_spec.js b/spec/frontend/vue_mr_widget/components/artifacts_list_spec.js index 1b1624e3e8f..1097f1f8b8d 100644 --- a/spec/frontend/vue_mr_widget/components/artifacts_list_spec.js +++ b/spec/frontend/vue_mr_widget/components/artifacts_list_spec.js @@ -39,20 +39,10 @@ describe('Artifacts List', () => { }); it('renders job url', () => { - expect( - wrapper - .findAll(GlLink) - .at(1) - .attributes('href'), - ).toEqual(data.artifacts[0].job_path); + expect(wrapper.findAll(GlLink).at(1).attributes('href')).toEqual(data.artifacts[0].job_path); }); it('renders job name', () => { - expect( - wrapper - .findAll(GlLink) - .at(1) - .text(), - ).toEqual(data.artifacts[0].job_name); + expect(wrapper.findAll(GlLink).at(1).text()).toEqual(data.artifacts[0].job_name); }); }); diff --git a/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js b/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js index 8a604355625..d872ba9ffac 100644 --- a/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js @@ -65,18 +65,8 @@ describe('Merge Request Collapsible Extension', () => { }); it('renders the buttons disabled', () => { - expect( - wrapper - .findAll('button') - .at(0) - .attributes('disabled'), - ).toEqual('disabled'); - expect( - wrapper - .findAll('button') - .at(1) - .attributes('disabled'), - ).toEqual('disabled'); + expect(wrapper.findAll('button').at(0).attributes('disabled')).toEqual('disabled'); + expect(wrapper.findAll('button').at(1).attributes('disabled')).toEqual('disabled'); }); it('renders loading spinner', () => { diff --git a/spec/frontend/vue_mr_widget/components/mr_widget_pipeline_spec.js b/spec/frontend/vue_mr_widget/components/mr_widget_pipeline_spec.js index 7ecd8629607..7364e0ef15e 100644 --- a/spec/frontend/vue_mr_widget/components/mr_widget_pipeline_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_widget_pipeline_spec.js @@ -72,21 +72,13 @@ describe('MRWidgetPipeline', () => { }); it('should render pipeline ID', () => { - expect( - findPipelineID() - .text() - .trim(), - ).toBe(`#${mockData.pipeline.id}`); + expect(findPipelineID().text().trim()).toBe(`#${mockData.pipeline.id}`); }); it('should render pipeline status and commit id', () => { expect(findPipelineInfoContainer().text()).toMatch(mockData.pipeline.details.status.label); - expect( - findCommitLink() - .text() - .trim(), - ).toBe(mockData.pipeline.commit.short_id); + expect(findCommitLink().text().trim()).toBe(mockData.pipeline.commit.short_id); expect(findCommitLink().attributes('href')).toBe(mockData.pipeline.commit.commit_path); }); @@ -148,11 +140,7 @@ describe('MRWidgetPipeline', () => { }); it('should render pipeline ID', () => { - expect( - findPipelineID() - .text() - .trim(), - ).toBe(`#${mockData.pipeline.id}`); + expect(findPipelineID().text().trim()).toBe(`#${mockData.pipeline.id}`); }); it('should render pipeline status', () => { diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_closed_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_closed_spec.js index 322f440763c..55d7e2391b2 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_closed_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_closed_spec.js @@ -39,10 +39,7 @@ describe('MRWidgetClosed', () => { it('renders closed by information with author and time', () => { expect( - vm.$el - .querySelector('.js-mr-widget-author') - .textContent.trim() - .replace(/\s\s+/g, ' '), + vm.$el.querySelector('.js-mr-widget-author').textContent.trim().replace(/\s\s+/g, ' '), ).toContain('Closed by Administrator less than a minute ago'); }); @@ -54,10 +51,7 @@ describe('MRWidgetClosed', () => { it('renders information about the changes not being merged', () => { expect( - vm.$el - .querySelector('.mr-info-list') - .textContent.trim() - .replace(/\s\s+/g, ' '), + vm.$el.querySelector('.mr-info-list').textContent.trim().replace(/\s\s+/g, ' '), ).toContain('The changes were not merged into so_long_jquery'); }); diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js index ad21e6e6f4f..ee67b6aae55 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_conflicts_spec.js @@ -167,12 +167,9 @@ describe('MRWidgetConflicts', () => { }, }); - expect( - vm - .text() - .trim() - .replace(/\s\s+/g, ' '), - ).toContain('ask someone with write access'); + expect(vm.text().trim().replace(/\s\s+/g, ' ')).toContain( + 'ask someone with write access', + ); }); it('should not have action buttons', async () => { diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js index 9057ffaea45..003415961af 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js @@ -480,7 +480,10 @@ describe('ReadyToMerge', () => { jest.spyOn(vm.service, 'poll').mockReturnValue(returnPromise('merged')); jest.spyOn(vm, 'initiateRemoveSourceBranchPolling').mockImplementation(() => {}); - vm.handleMergePolling(() => {}, () => {}); + vm.handleMergePolling( + () => {}, + () => {}, + ); setImmediate(() => { const statusBox = document.querySelector('.status-box'); @@ -496,7 +499,10 @@ describe('ReadyToMerge', () => { jest.spyOn(vm.service, 'poll').mockReturnValue(returnPromise('merged')); jest.spyOn(vm, 'initiateRemoveSourceBranchPolling').mockImplementation(() => {}); - vm.handleMergePolling(() => {}, () => {}); + vm.handleMergePolling( + () => {}, + () => {}, + ); setImmediate(() => { expect(document.querySelector('.js-merge-counter').textContent).toBe('0'); @@ -657,10 +663,7 @@ describe('ReadyToMerge', () => { const findCommitsHeaderElement = () => wrapper.find(CommitsHeader); const findCommitEditElements = () => wrapper.findAll(CommitEdit); const findCommitDropdownElement = () => wrapper.find(CommitMessageDropdown); - const findFirstCommitEditLabel = () => - findCommitEditElements() - .at(0) - .props('label'); + const findFirstCommitEditLabel = () => findCommitEditElements().at(0).props('label'); describe('squash checkbox', () => { it('should be rendered when squash before merge is enabled and there is more than 1 commit', () => { diff --git a/spec/frontend/vue_mr_widget/mock_data.js b/spec/frontend/vue_mr_widget/mock_data.js index 8ee920f06a1..7f82f3ee233 100644 --- a/spec/frontend/vue_mr_widget/mock_data.js +++ b/spec/frontend/vue_mr_widget/mock_data.js @@ -194,7 +194,10 @@ export default { updated_at: '2017-04-07T15:28:44.800Z', }, pipelineCoverageDelta: '15.25', - buildsWithCoverage: [{ name: 'karma', coverage: '40.2' }, { name: 'rspec', coverage: '80.4' }], + buildsWithCoverage: [ + { name: 'karma', coverage: '40.2' }, + { name: 'rspec', coverage: '80.4' }, + ], work_in_progress: false, source_branch_exists: false, mergeable_discussions_state: true, diff --git a/spec/frontend/vue_mr_widget/mr_widget_how_to_merge_modal_spec.js b/spec/frontend/vue_mr_widget/mr_widget_how_to_merge_modal_spec.js index aaaee3327a8..bd22183cbea 100644 --- a/spec/frontend/vue_mr_widget/mr_widget_how_to_merge_modal_spec.js +++ b/spec/frontend/vue_mr_widget/mr_widget_how_to_merge_modal_spec.js @@ -50,19 +50,11 @@ describe('MRWidgetHowToMerge', () => { it('should render different instructions based on if the user can merge', () => { mountComponent({ props: { canMerge: true } }); - expect( - findInstructionsFields() - .at(2) - .text(), - ).toContain('git push origin'); + expect(findInstructionsFields().at(2).text()).toContain('git push origin'); }); it('should render different instructions based on if the merge is based off a fork', () => { mountComponent({ props: { isFork: true } }); - expect( - findInstructionsFields() - .at(0) - .text(), - ).toContain('FETCH_HEAD'); + expect(findInstructionsFields().at(0).text()).toContain('FETCH_HEAD'); }); }); diff --git a/spec/frontend/vue_shared/components/awards_list_spec.js b/spec/frontend/vue_shared/components/awards_list_spec.js index d20de81c446..0fcb7a41f17 100644 --- a/spec/frontend/vue_shared/components/awards_list_spec.js +++ b/spec/frontend/vue_shared/components/awards_list_spec.js @@ -135,9 +135,7 @@ describe('vue_shared/components/awards_list', () => { it('with award clicked, it emits award', () => { expect(wrapper.emitted().award).toBeUndefined(); - findAwardButtons() - .at(2) - .vm.$emit('click'); + findAwardButtons().at(2).vm.$emit('click'); expect(wrapper.emitted().award).toEqual([[EMOJI_SMILE]]); }); @@ -162,9 +160,7 @@ describe('vue_shared/components/awards_list', () => { it('when clicked, it emits award as number', () => { expect(wrapper.emitted().award).toBeUndefined(); - findAwardButtons() - .at(0) - .vm.$emit('click'); + findAwardButtons().at(0).vm.$emit('click'); expect(wrapper.emitted().award).toEqual([[Number(EMOJI_100)]]); }); diff --git a/spec/frontend/vue_shared/components/color_picker/color_picker_spec.js b/spec/frontend/vue_shared/components/color_picker/color_picker_spec.js index a50a4b742b3..c8fe6c3131c 100644 --- a/spec/frontend/vue_shared/components/color_picker/color_picker_spec.js +++ b/spec/frontend/vue_shared/components/color_picker/color_picker_spec.js @@ -130,9 +130,7 @@ describe('ColorPicker', () => { it('has preset color selected', async () => { createComponent(); - await presetColors() - .at(0) - .trigger('click'); + await presetColors().at(0).trigger('click'); expect(wrapper.vm.$data.selectedColor).toBe(setColor); }); diff --git a/spec/frontend/vue_shared/components/commit_spec.js b/spec/frontend/vue_shared/components/commit_spec.js index 9b5c0941a0d..b420e220081 100644 --- a/spec/frontend/vue_shared/components/commit_spec.js +++ b/spec/frontend/vue_shared/components/commit_spec.js @@ -43,12 +43,7 @@ describe('Commit component', () => { }, }); - expect( - wrapper - .find('.icon-container') - .find(GlIcon) - .exists(), - ).toBe(true); + expect(wrapper.find('.icon-container').find(GlIcon).exists()).toBe(true); }); describe('Given all the props', () => { diff --git a/spec/frontend/vue_shared/components/expand_button_spec.js b/spec/frontend/vue_shared/components/expand_button_spec.js index aea90e5b31f..09566c6d959 100644 --- a/spec/frontend/vue_shared/components/expand_button_spec.js +++ b/spec/frontend/vue_shared/components/expand_button_spec.js @@ -41,12 +41,7 @@ describe('Expand button', () => { }); it('does not render expanded text', () => { - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).not.toBe(text.short); + expect(wrapper.find(ExpandButton).text().trim()).not.toBe(text.short); }); describe('when short text is provided', () => { @@ -60,12 +55,7 @@ describe('Expand button', () => { }); it('renders short text', () => { - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).toBe(text.short); + expect(wrapper.find(ExpandButton).text().trim()).toBe(text.short); }); it('renders button before text', () => { @@ -108,12 +98,7 @@ describe('Expand button', () => { }); it('only renders expanded text', () => { - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).toBe(text.expanded); + expect(wrapper.find(ExpandButton).text().trim()).toBe(text.expanded); }); it('renders button after text', () => { @@ -140,21 +125,11 @@ describe('Expand button', () => { }); it('clicking hides expanded text', () => { - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).toBe(text.expanded); + expect(wrapper.find(ExpandButton).text().trim()).toBe(text.expanded); expanderAppendEl().trigger('click'); return wrapper.vm.$nextTick().then(() => { - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).not.toBe(text.expanded); + expect(wrapper.find(ExpandButton).text().trim()).not.toBe(text.expanded); }); }); @@ -172,21 +147,11 @@ describe('Expand button', () => { }); it('clicking reveals short text', () => { - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).toBe(text.expanded); + expect(wrapper.find(ExpandButton).text().trim()).toBe(text.expanded); expanderAppendEl().trigger('click'); return wrapper.vm.$nextTick().then(() => { - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).toBe(text.short); + expect(wrapper.find(ExpandButton).text().trim()).toBe(text.short); }); }); }); diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js index 4869e75a2f3..9e96c154546 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js @@ -82,7 +82,10 @@ describe('prepareTokens', () => { ], [ 'assignees', - [{ value: 'krillin', operator: '=' }, { value: 'piccolo', operator: '!=' }], + [ + { value: 'krillin', operator: '=' }, + { value: 'piccolo', operator: '!=' }, + ], [ { type: 'assignees', value: { data: 'krillin', operator: '=' } }, { type: 'assignees', value: { data: 'piccolo', operator: '!=' } }, @@ -90,7 +93,10 @@ describe('prepareTokens', () => { ], [ 'foo', - [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '!=' }], + [ + { value: 'bar', operator: '!=' }, + { value: 'baz', operator: '!=' }, + ], [ { type: 'foo', value: { data: 'bar', operator: '!=' } }, { type: 'foo', value: { data: 'baz', operator: '!=' } }, @@ -112,7 +118,10 @@ describe('processFilters', () => { expect(result).toStrictEqual({ foo: [{ value: 'foo', operator: '=' }], - bar: [{ value: 'bar1', operator: '=' }, { value: 'bar2', operator: '!=' }], + bar: [ + { value: 'bar1', operator: '=' }, + { value: 'bar2', operator: '!=' }, + ], }); }); @@ -164,17 +173,26 @@ describe('filterToQueryObject', () => { ], [ 'foo', - [{ value: 'bar', operator: '=' }, { value: 'baz', operator: '=' }], + [ + { value: 'bar', operator: '=' }, + { value: 'baz', operator: '=' }, + ], { foo: ['bar', 'baz'], 'not[foo]': null }, ], [ 'foo', - [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '!=' }], + [ + { value: 'bar', operator: '!=' }, + { value: 'baz', operator: '!=' }, + ], { foo: null, 'not[foo]': ['bar', 'baz'] }, ], [ 'foo', - [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '=' }], + [ + { value: 'bar', operator: '!=' }, + { value: 'baz', operator: '=' }, + ], { foo: ['baz'], 'not[foo]': ['bar'] }, ], ])('gathers filter values %s=%j into query object=%j', (token, value, result) => { @@ -200,15 +218,30 @@ describe('urlQueryToFilter', () => { ['not[foo]=bar&foo=baz', { foo: { value: 'baz', operator: '=' } }], [ 'foo[]=bar&foo[]=baz¬[foo]=', - { foo: [{ value: 'bar', operator: '=' }, { value: 'baz', operator: '=' }] }, + { + foo: [ + { value: 'bar', operator: '=' }, + { value: 'baz', operator: '=' }, + ], + }, ], [ 'foo[]=¬[foo][]=bar¬[foo][]=baz', - { foo: [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '!=' }] }, + { + foo: [ + { value: 'bar', operator: '!=' }, + { value: 'baz', operator: '!=' }, + ], + }, ], [ 'foo[]=baz¬[foo][]=bar', - { foo: [{ value: 'baz', operator: '=' }, { value: 'bar', operator: '!=' }] }, + { + foo: [ + { value: 'baz', operator: '=' }, + { value: 'bar', operator: '!=' }, + ], + }, ], ['not[foo][]=bar', { foo: [{ value: 'bar', operator: '!=' }] }], ])('gathers filter values %s into query object=%j', (query, result) => { 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 64fbe70696d..2c7b6de9ce3 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 @@ -110,7 +110,10 @@ export const mockMembershipToken = { token: GlFilteredSearchToken, unique: true, operators: [{ value: '=', description: 'is' }], - options: [{ value: 'exclude', title: 'Direct' }, { value: 'only', title: 'Inherited' }], + options: [ + { value: 'exclude', title: 'Direct' }, + { value: 'only', title: 'Inherited' }, + ], }; export const mockMembershipTokenOptionsWithoutTitles = { diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js index 74172db81c2..e3ca2a710d0 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js @@ -181,12 +181,9 @@ describe('LabelToken', () => { expect(tokenSegments).toHaveLength(3); // Label, =, "Foo Label" expect(tokenSegments.at(2).text()).toBe(`~${mockRegularLabel.title}`); // "Foo Label" - expect( - tokenSegments - .at(2) - .find('.gl-token') - .attributes('style'), - ).toBe('background-color: rgb(186, 218, 85); color: rgb(255, 255, 255);'); + expect(tokenSegments.at(2).find('.gl-token').attributes('style')).toBe( + 'background-color: rgb(186, 218, 85); color: rgb(255, 255, 255);', + ); }); it('renders provided defaultLabels as suggestions', async () => { diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js index 67f9a9c70cc..0247833cf22 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js @@ -140,7 +140,10 @@ describe('MilestoneToken', () => { }); describe('template', () => { - const defaultMilestones = [{ text: 'foo', value: 'foo' }, { text: 'bar', value: 'baz' }]; + const defaultMilestones = [ + { text: 'foo', value: 'foo' }, + { text: 'bar', value: 'baz' }, + ]; beforeEach(async () => { wrapper = createComponent({ value: { data: `"${mockRegularMilestone.title}"` } }); diff --git a/spec/frontend/vue_shared/components/gl_countdown_spec.js b/spec/frontend/vue_shared/components/gl_countdown_spec.js index 365c9fad478..1c56b451776 100644 --- a/spec/frontend/vue_shared/components/gl_countdown_spec.js +++ b/spec/frontend/vue_shared/components/gl_countdown_spec.js @@ -22,9 +22,7 @@ describe('GlCountdown', () => { endDateString: '2000-01-01T01:02:03Z', }); - Vue.nextTick() - .then(done) - .catch(done.fail); + Vue.nextTick().then(done).catch(done.fail); }); it('displays remaining time', () => { @@ -50,9 +48,7 @@ describe('GlCountdown', () => { endDateString: '1900-01-01T00:00:00Z', }); - Vue.nextTick() - .then(done) - .catch(done.fail); + Vue.nextTick().then(done).catch(done.fail); }); it('displays 00:00:00', () => { diff --git a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js index 2319bf61482..441d73caf5b 100644 --- a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js +++ b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js @@ -115,9 +115,7 @@ describe('RelatedIssuableItem', () => { const tokenMetadata = () => wrapper.find('.item-meta'); it('renders item path and ID', () => { - const pathAndID = tokenMetadata() - .find('.item-path-id') - .text(); + const pathAndID = tokenMetadata().find('.item-path-id').text(); expect(pathAndID).toContain('gitlab-org/gitlab-test'); expect(pathAndID).toContain('#1'); diff --git a/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js b/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js index b67f4cf12bf..f9a8b64f89b 100644 --- a/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js +++ b/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js @@ -61,11 +61,7 @@ describe('SuggestionDiffRow', () => { }); expect(wrapper.classes()).toContain('line_holder'); - expect( - findSuggestionContent() - .find('span') - .classes(), - ).toContain('line'); + expect(findSuggestionContent().find('span').classes()).toContain('line'); }); it('renders the rich text when it is available', () => { diff --git a/spec/frontend/vue_shared/components/paginated_table_with_search_and_tabs/paginated_table_with_search_and_tabs_spec.js b/spec/frontend/vue_shared/components/paginated_table_with_search_and_tabs/paginated_table_with_search_and_tabs_spec.js index 0f7c8e97635..491f783622a 100644 --- a/spec/frontend/vue_shared/components/paginated_table_with_search_and_tabs/paginated_table_with_search_and_tabs_spec.js +++ b/spec/frontend/vue_shared/components/paginated_table_with_search_and_tabs/paginated_table_with_search_and_tabs_spec.js @@ -124,7 +124,10 @@ describe('AlertManagementEmptyState', () => { it('renders the tabs selection with valid tabs', () => { mountComponent({ props: { - statusTabs: [{ status: 'opened', title: 'Open' }, { status: 'closed', title: 'Closed' }], + statusTabs: [ + { status: 'opened', title: 'Open' }, + { status: 'closed', title: 'Closed' }, + ], }, }); @@ -216,12 +219,7 @@ describe('AlertManagementEmptyState', () => { findPagination().vm.$emit('input', 3); await wrapper.vm.$nextTick(); - expect( - findPagination() - .findAll('.page-item') - .at(0) - .text(), - ).toBe('Prev'); + expect(findPagination().findAll('.page-item').at(0).text()).toBe('Prev'); }); it('returns prevPage number', async () => { @@ -244,12 +242,7 @@ describe('AlertManagementEmptyState', () => { findPagination().vm.$emit('input', 3); await wrapper.vm.$nextTick(); - expect( - findPagination() - .findAll('.page-item') - .at(1) - .text(), - ).toBe('Next'); + expect(findPagination().findAll('.page-item').at(1).text()).toBe('Next'); }); it('returns nextPage number', async () => { diff --git a/spec/frontend/vue_shared/components/registry/title_area_spec.js b/spec/frontend/vue_shared/components/registry/title_area_spec.js index b743a663f06..24a2cb7ae06 100644 --- a/spec/frontend/vue_shared/components/registry/title_area_spec.js +++ b/spec/frontend/vue_shared/components/registry/title_area_spec.js @@ -142,16 +142,8 @@ describe('title area', () => { await wrapper.vm.$nextTick(); - expect( - findSlotOrderElements() - .at(0) - .attributes('data-testid'), - ).toBe(DYNAMIC_SLOT); - expect( - findSlotOrderElements() - .at(1) - .attributes('data-testid'), - ).toBe('metadata-foo'); + expect(findSlotOrderElements().at(0).attributes('data-testid')).toBe(DYNAMIC_SLOT); + expect(findSlotOrderElements().at(1).attributes('data-testid')).toBe('metadata-foo'); }); }); diff --git a/spec/frontend/vue_shared/components/sidebar/date_picker_spec.js b/spec/frontend/vue_shared/components/sidebar/date_picker_spec.js index 47edfbe3115..fc1fa3fc1c1 100644 --- a/spec/frontend/vue_shared/components/sidebar/date_picker_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/date_picker_spec.js @@ -46,12 +46,7 @@ describe('SidebarDatePicker', () => { it('should render None if there is no selectedDate', () => { mountComponent(); - expect( - wrapper - .find('.value-content span') - .text() - .trim(), - ).toEqual('None'); + expect(wrapper.find('.value-content span').text().trim()).toEqual('None'); }); it('should render date-picker when editing', () => { @@ -63,12 +58,7 @@ describe('SidebarDatePicker', () => { it('should render label', () => { const label = 'label'; mountComponent({ label }); - expect( - wrapper - .find('.title') - .text() - .trim(), - ).toEqual(label); + expect(wrapper.find('.title').text().trim()).toEqual(label); }); it('should render loading-icon when isLoading', () => { @@ -82,12 +72,7 @@ describe('SidebarDatePicker', () => { }); it('should render edit button', () => { - expect( - wrapper - .find('.title .btn-blank') - .text() - .trim(), - ).toEqual('Edit'); + expect(wrapper.find('.title .btn-blank').text().trim()).toEqual('Edit'); }); it('should enable editing when edit button is clicked', async () => { @@ -102,12 +87,7 @@ describe('SidebarDatePicker', () => { it('should render date if selectedDate', () => { mountComponent({ selectedDate: new Date('07/07/2017') }); - expect( - wrapper - .find('.value-content strong') - .text() - .trim(), - ).toEqual('Jul 7, 2017'); + expect(wrapper.find('.value-content strong').text().trim()).toEqual('Jul 7, 2017'); }); describe('selectedDate and editable', () => { @@ -116,12 +96,7 @@ describe('SidebarDatePicker', () => { }); it('should render remove button if selectedDate and editable', () => { - expect( - wrapper - .find('.value-content .btn-blank') - .text() - .trim(), - ).toEqual('remove'); + expect(wrapper.find('.value-content .btn-blank').text().trim()).toEqual('remove'); }); it('should emit saveDate with null when remove button is clicked', () => { diff --git a/spec/frontend/vue_shared/components/sidebar/issuable_move_dropdown_spec.js b/spec/frontend/vue_shared/components/sidebar/issuable_move_dropdown_spec.js index a97e26caf53..256b3cff525 100644 --- a/spec/frontend/vue_shared/components/sidebar/issuable_move_dropdown_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/issuable_move_dropdown_spec.js @@ -184,11 +184,7 @@ describe('IssuableMoveDropdown', () => { }); it('renders gl-dropdown-form component', () => { - expect( - findDropdownEl() - .find(GlDropdownForm) - .exists(), - ).toBe(true); + expect(findDropdownEl().find(GlDropdownForm).exists()).toBe(true); }); it('renders header element', () => { @@ -216,11 +212,7 @@ describe('IssuableMoveDropdown', () => { await wrapper.vm.$nextTick(); - expect( - findDropdownEl() - .find(GlLoadingIcon) - .exists(), - ).toBe(true); + expect(findDropdownEl().find(GlLoadingIcon).exists()).toBe(true); }); it('renders gl-dropdown-item components for available projects', async () => { @@ -288,10 +280,7 @@ describe('IssuableMoveDropdown', () => { await wrapper.vm.$nextTick(); expect( - wrapper - .find('[data-testid="footer"]') - .find(GlButton) - .attributes('disabled'), + wrapper.find('[data-testid="footer"]').find(GlButton).attributes('disabled'), ).not.toBeDefined(); }); }); @@ -331,10 +320,7 @@ describe('IssuableMoveDropdown', () => { }); it('close icon in dropdown header closes the dropdown when clicked', () => { - wrapper - .find('[data-testid="header"]') - .find(GlButton) - .vm.$emit('click', mockEvent); + wrapper.find('[data-testid="header"]').find(GlButton).vm.$emit('click', mockEvent); expect(wrapper.vm.$refs.dropdown.hide).toHaveBeenCalled(); }); @@ -346,10 +332,7 @@ describe('IssuableMoveDropdown', () => { await wrapper.vm.$nextTick(); - wrapper - .findAll(GlDropdownItem) - .at(0) - .vm.$emit('click', mockEvent); + wrapper.findAll(GlDropdownItem).at(0).vm.$emit('click', mockEvent); expect(wrapper.vm.selectedProject).toBe(mockProjects[0]); }); @@ -361,10 +344,7 @@ describe('IssuableMoveDropdown', () => { await wrapper.vm.$nextTick(); - wrapper - .find('[data-testid="footer"]') - .find(GlButton) - .vm.$emit('click'); + wrapper.find('[data-testid="footer"]').find(GlButton).vm.$emit('click'); expect(wrapper.vm.$refs.dropdown.hide).toHaveBeenCalled(); expect(wrapper.emitted('move-issuable')).toBeTruthy(); diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select/dropdown_value_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select/dropdown_value_spec.js index 53e8a0e1278..ecb3c3a42c8 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select/dropdown_value_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select/dropdown_value_spec.js @@ -71,12 +71,7 @@ describe('DropdownValueComponent', () => { it('render slot content inside component when `labels` prop is empty', () => { const vmEmptyLabels = createComponent([]); - expect( - vmEmptyLabels - .find('.text-secondary') - .text() - .trim(), - ).toBe(mockConfig.emptyValueText); + expect(vmEmptyLabels.find('.text-secondary').text().trim()).toBe(mockConfig.emptyValueText); vmEmptyLabels.destroy(); }); diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view_spec.js index 04320a72be6..14273afc979 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view_spec.js @@ -125,10 +125,7 @@ describe('DropdownContentsCreateView', () => { }); it('renders dropdown back button element', () => { - const backBtnEl = wrapper - .find('.dropdown-title') - .findAll(GlButton) - .at(0); + const backBtnEl = wrapper.find('.dropdown-title').findAll(GlButton).at(0); expect(backBtnEl.exists()).toBe(true); expect(backBtnEl.attributes('aria-label')).toBe('Go back'); @@ -143,10 +140,7 @@ describe('DropdownContentsCreateView', () => { }); it('renders dropdown close button element', () => { - const closeBtnEl = wrapper - .find('.dropdown-title') - .findAll(GlButton) - .at(1); + const closeBtnEl = wrapper.find('.dropdown-title').findAll(GlButton).at(1); expect(closeBtnEl.exists()).toBe(true); expect(closeBtnEl.attributes('aria-label')).toBe('Close'); @@ -190,10 +184,7 @@ describe('DropdownContentsCreateView', () => { }); it('renders create button element', () => { - const createBtnEl = wrapper - .find('.dropdown-actions') - .findAll(GlButton) - .at(0); + const createBtnEl = wrapper.find('.dropdown-actions').findAll(GlButton).at(0); expect(createBtnEl.exists()).toBe(true); expect(createBtnEl.text()).toContain('Create'); @@ -211,10 +202,7 @@ describe('DropdownContentsCreateView', () => { }); it('renders cancel button element', () => { - const cancelBtnEl = wrapper - .find('.dropdown-actions') - .findAll(GlButton) - .at(1); + const cancelBtnEl = wrapper.find('.dropdown-actions').findAll(GlButton).at(1); expect(cancelBtnEl.exists()).toBe(true); expect(cancelBtnEl.text()).toContain('Cancel'); diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view_spec.js index 78367b3a5b4..989cd256e26 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view_spec.js @@ -371,9 +371,7 @@ describe('DropdownContentsLabelsView', () => { wrapper.vm.$store.state.allowLabelCreate = false; return wrapper.vm.$nextTick(() => { - const createLabelLink = findDropdownFooter() - .findAll(GlLink) - .at(0); + const createLabelLink = findDropdownFooter().findAll(GlLink).at(0); expect(createLabelLink.text()).not.toBe('Create label'); }); diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/getters_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/getters_spec.js index 52116f757c5..1f899e84897 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/getters_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_vue/store/getters_spec.js @@ -26,7 +26,10 @@ describe('LabelsSelect Getters', () => { }); it('returns first label title and remaining labels count when state.labels has more than 1 label', () => { - const labels = [{ id: 1, title: 'Foo', set: true }, { id: 2, title: 'Bar', set: true }]; + const labels = [ + { id: 1, title: 'Foo', set: true }, + { id: 2, title: 'Bar', set: true }, + ]; expect(getters.dropdownButtonText({ labels }, { isDropdownVariantSidebar: true })).toBe( 'Foo +1 more', diff --git a/spec/frontend/vue_shared/components/split_button_spec.js b/spec/frontend/vue_shared/components/split_button_spec.js index e09bc073042..f1a427e1351 100644 --- a/spec/frontend/vue_shared/components/split_button_spec.js +++ b/spec/frontend/vue_shared/components/split_button_spec.js @@ -26,10 +26,7 @@ describe('SplitButton', () => { }; const findDropdown = () => wrapper.find(GlDropdown); - const findDropdownItem = (index = 0) => - findDropdown() - .findAll(GlDropdownItem) - .at(index); + const findDropdownItem = (index = 0) => findDropdown().findAll(GlDropdownItem).at(index); const selectItem = index => { findDropdownItem(index).vm.$emit('click'); diff --git a/spec/frontend/vue_shared/directives/tooltip_spec.js b/spec/frontend/vue_shared/directives/tooltip_spec.js index 4217b8d3c02..31ea48b941d 100644 --- a/spec/frontend/vue_shared/directives/tooltip_spec.js +++ b/spec/frontend/vue_shared/directives/tooltip_spec.js @@ -151,11 +151,7 @@ describe('Tooltip directive', () => { }); it('should have tooltip plugin applied to all instances', () => { - expect( - $(wrapper.vm.$el) - .find('.js-look-for-tooltip') - .data('bs.tooltip'), - ).toBeDefined(); + expect($(wrapper.vm.$el).find('.js-look-for-tooltip').data('bs.tooltip')).toBeDefined(); }); }); }); diff --git a/spec/frontend_integration/ide/helpers/ide_helper.js b/spec/frontend_integration/ide/helpers/ide_helper.js index 7ae7c4cb0b6..212ec06b766 100644 --- a/spec/frontend_integration/ide/helpers/ide_helper.js +++ b/spec/frontend_integration/ide/helpers/ide_helper.js @@ -122,10 +122,7 @@ export const waitForTabToOpen = fileName => findByText(document.querySelector('.multi-file-edit-pane'), fileName); export const createFile = async (path, content) => { - const parentPath = path - .split('/') - .slice(0, -1) - .join('/'); + const parentPath = path.split('/').slice(0, -1).join('/'); const parentRow = await findAndTraverseToPath(parentPath); diff --git a/spec/frontend_integration/test_helpers/factories/commit_id.js b/spec/frontend_integration/test_helpers/factories/commit_id.js index 9fa278c9dde..815da19a2d9 100644 --- a/spec/frontend_integration/test_helpers/factories/commit_id.js +++ b/spec/frontend_integration/test_helpers/factories/commit_id.js @@ -1,7 +1,5 @@ const COMMIT_ID_LENGTH = 40; -const DEFAULT_COMMIT_ID = Array(COMMIT_ID_LENGTH) - .fill('0') - .join(''); +const DEFAULT_COMMIT_ID = Array(COMMIT_ID_LENGTH).fill('0').join(''); export const createCommitId = (index = 0) => `${index}${DEFAULT_COMMIT_ID}`.substr(0, COMMIT_ID_LENGTH); diff --git a/spec/frontend_integration/test_helpers/utils/obj_spec.js b/spec/frontend_integration/test_helpers/utils/obj_spec.js index 0ad7b4a1a4c..614250ccddc 100644 --- a/spec/frontend_integration/test_helpers/utils/obj_spec.js +++ b/spec/frontend_integration/test_helpers/utils/obj_spec.js @@ -3,9 +3,9 @@ import { withKeys, withValues } from './obj'; describe('frontend_integration/test_helpers/utils/obj', () => { describe('withKeys', () => { it('picks and maps keys', () => { - expect(withKeys({ a: '123', b: 456, c: 'd' }, { b: 'lorem', c: 'ipsum', z: 'zed ' })).toEqual( - { lorem: 456, ipsum: 'd' }, - ); + expect( + withKeys({ a: '123', b: 456, c: 'd' }, { b: 'lorem', c: 'ipsum', z: 'zed ' }), + ).toEqual({ lorem: 456, ipsum: 'd' }); }); }); diff --git a/spec/javascripts/fly_out_nav_browser_spec.js b/spec/javascripts/fly_out_nav_browser_spec.js index f84cee72042..c7949640ce9 100644 --- a/spec/javascripts/fly_out_nav_browser_spec.js +++ b/spec/javascripts/fly_out_nav_browser_spec.js @@ -255,8 +255,9 @@ describe('Fly out sidebar navigation', () => { showSubLevelItems(el); expect(subItems.style.transform).toBe( - `translate3d(200px, ${Math.floor(el.getBoundingClientRect().top) - - getHeaderHeight()}px, 0px)`, + `translate3d(200px, ${ + Math.floor(el.getBoundingClientRect().top) - getHeaderHeight() + }px, 0px)`, ); }); diff --git a/spec/javascripts/lib/utils/browser_spec.js b/spec/javascripts/lib/utils/browser_spec.js index 6b1074a3b4f..a537719f238 100644 --- a/spec/javascripts/lib/utils/browser_spec.js +++ b/spec/javascripts/lib/utils/browser_spec.js @@ -24,7 +24,7 @@ const PIXEL_TOLERANCE = 0.2; const urlToImage = url => new Promise(resolve => { const img = new Image(); - img.onload = function() { + img.onload = function () { resolve(img); }; img.src = url; diff --git a/spec/javascripts/matchers.js b/spec/javascripts/matchers.js index 5b7b7dc78b1..b698f283eb4 100644 --- a/spec/javascripts/matchers.js +++ b/spec/javascripts/matchers.js @@ -32,8 +32,9 @@ export default { return { pass: differentPixels < 20, - message: `${differentPixels} pixels differ more than ${threshold * - 100} percent between input and output.`, + message: `${differentPixels} pixels differ more than ${ + threshold * 100 + } percent between input and output.`, }; }, }; diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index b37a53515a6..012b5059090 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -40,7 +40,7 @@ Vue.config.warnHandler = (msg, vm, trace) => { }; let hasVueErrors = false; -Vue.config.errorHandler = function(err) { +Vue.config.errorHandler = function (err) { hasVueErrors = true; fail(err); }; @@ -118,8 +118,8 @@ testContexts.forEach(context => { } catch (err) { console.log(err); console.error('[GL SPEC RUNNER ERROR] Unable to load spec: ', path); - describe('Test bundle', function() { - it(`includes '${path}'`, function() { + describe('Test bundle', function () { + it(`includes '${path}'`, function () { expect(err).toBeNull(); }); }); diff --git a/spec/lib/gitlab/database/postgres_hll/batch_distinct_counter_spec.rb b/spec/lib/gitlab/database/postgres_hll/batch_distinct_counter_spec.rb index 934e2274358..2c550f14a08 100644 --- a/spec/lib/gitlab/database/postgres_hll/batch_distinct_counter_spec.rb +++ b/spec/lib/gitlab/database/postgres_hll/batch_distinct_counter_spec.rb @@ -24,107 +24,48 @@ RSpec.describe Gitlab::Database::PostgresHll::BatchDistinctCounter do allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(in_transaction) end - context 'different distribution of relation records' do - [10, 100, 100_000].each do |spread| - context "records are spread within #{spread}" do - before do - ids = (1..spread).to_a.sample(10) - create_list(:issue, 10).each_with_index do |issue, i| - issue.id = ids[i] - end - end - - it 'counts table' do - expect(described_class.new(model).estimate_distinct_count).to be_within(error_rate).percent_of(10) - end - end - end - end - context 'unit test for different counting parameters' do before_all do create_list(:issue, 3, author: user) create_list(:issue, 2, author: another_user) end - describe '#estimate_distinct_count' do - it 'counts table' do - expect(described_class.new(model).estimate_distinct_count).to be_within(error_rate).percent_of(5) - end - - it 'counts with column field' do - expect(described_class.new(model, column).estimate_distinct_count).to be_within(error_rate).percent_of(2) - end - - it 'counts with :id field' do - expect(described_class.new(model, :id).estimate_distinct_count).to be_within(error_rate).percent_of(5) - end - - it 'counts with "id" field' do - expect(described_class.new(model, "id").estimate_distinct_count).to be_within(error_rate).percent_of(5) - end - - it 'counts with table.column field' do - expect(described_class.new(model, "#{model.table_name}.#{column}").estimate_distinct_count).to be_within(error_rate).percent_of(2) - end - - it 'counts with Arel column' do - expect(described_class.new(model, model.arel_table[column]).estimate_distinct_count).to be_within(error_rate).percent_of(2) - end - - it 'counts over joined relations' do - expect(described_class.new(model.joins(:author), "users.email").estimate_distinct_count).to be_within(error_rate).percent_of(2) - end - - it 'counts with :column field with batch_size of 50K' do - expect(described_class.new(model, column).estimate_distinct_count(batch_size: 50_000)).to be_within(error_rate).percent_of(2) - end - - it 'will not count table with a batch size less than allowed' do - expect(described_class.new(model, column).estimate_distinct_count(batch_size: small_batch_size)).to eq(fallback) - end - - it 'counts with different number of batches and aggregates total result' do - stub_const('Gitlab::Database::PostgresHll::BatchDistinctCounter::MIN_REQUIRED_BATCH_SIZE', 0) - - [1, 2, 4, 5, 6].each { |i| expect(described_class.new(model).estimate_distinct_count(batch_size: i)).to be_within(error_rate).percent_of(5) } - end - - it 'counts with a start and finish' do - expect(described_class.new(model, column).estimate_distinct_count(start: model.minimum(:id), finish: model.maximum(:id))).to be_within(error_rate).percent_of(2) + describe '#execute' do + it 'builds hll buckets' do + expect(described_class.new(model).execute).to be_an_instance_of(Gitlab::Database::PostgresHll::Buckets) end - it "defaults the batch size to #{Gitlab::Database::PostgresHll::BatchDistinctCounter::DEFAULT_BATCH_SIZE}" do + it "defaults batch size to #{Gitlab::Database::PostgresHll::BatchDistinctCounter::DEFAULT_BATCH_SIZE}" do min_id = model.minimum(:id) batch_end_id = min_id + calculate_batch_size(Gitlab::Database::PostgresHll::BatchDistinctCounter::DEFAULT_BATCH_SIZE) expect(model).to receive(:where).with("id" => min_id..batch_end_id).and_call_original - described_class.new(model).estimate_distinct_count + described_class.new(model).execute end context 'when a transaction is open' do let(:in_transaction) { true } it 'raises an error' do - expect { described_class.new(model, column).estimate_distinct_count }.to raise_error('BatchCount can not be run inside a transaction') + expect { described_class.new(model, column).execute }.to raise_error('BatchCount can not be run inside a transaction') end end context 'disallowed configurations' do let(:default_batch_size) { Gitlab::Database::PostgresHll::BatchDistinctCounter::DEFAULT_BATCH_SIZE } - it 'returns fallback if start is bigger than finish' do - expect(described_class.new(model, column).estimate_distinct_count(start: 1, finish: 0)).to eq(fallback) + it 'raises WRONG_CONFIGURATION_ERROR if start is bigger than finish' do + expect { described_class.new(model, column).execute(start: 1, finish: 0) }.to raise_error(described_class::WRONG_CONFIGURATION_ERROR) end - it 'returns fallback if data volume exceeds upper limit' do + it 'raises WRONG_CONFIGURATION_ERROR if data volume exceeds upper limit' do large_finish = Gitlab::Database::PostgresHll::BatchDistinctCounter::MAX_DATA_VOLUME + 1 - expect(described_class.new(model, column).estimate_distinct_count(start: 1, finish: large_finish)).to eq(fallback) + expect { described_class.new(model, column).execute(start: 1, finish: large_finish) }.to raise_error(described_class::WRONG_CONFIGURATION_ERROR) end - it 'returns fallback if batch size is less than min required' do - expect(described_class.new(model, column).estimate_distinct_count(batch_size: small_batch_size)).to eq(fallback) + it 'raises WRONG_CONFIGURATION_ERROR if batch size is less than min required' do + expect { described_class.new(model, column).execute(batch_size: small_batch_size) }.to raise_error(described_class::WRONG_CONFIGURATION_ERROR) end end end diff --git a/spec/lib/gitlab/database/postgres_hll/buckets_spec.rb b/spec/lib/gitlab/database/postgres_hll/buckets_spec.rb new file mode 100644 index 00000000000..b4d8fd4a449 --- /dev/null +++ b/spec/lib/gitlab/database/postgres_hll/buckets_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Database::PostgresHll::Buckets do + let(:error_rate) { Gitlab::Database::PostgresHll::BatchDistinctCounter::ERROR_RATE } # HyperLogLog is a probabilistic algorithm, which provides estimated data, with given error margin + let(:buckets_hash_5) { { 121 => 2, 126 => 1, 141 => 1, 383 => 1, 56 => 1 } } + let(:buckets_hash_2) { { 141 => 1, 56 => 1 } } + + describe '#estimated_distinct_count' do + it 'provides estimated cardinality', :aggregate_failures do + expect(described_class.new(buckets_hash_5).estimated_distinct_count).to be_within(error_rate).percent_of(5) + expect(described_class.new(buckets_hash_2).estimated_distinct_count).to be_within(error_rate).percent_of(2) + expect(described_class.new({}).estimated_distinct_count).to eq 0 + expect(described_class.new.estimated_distinct_count).to eq 0 + end + end + + describe '#merge_hash!' do + let(:hash_a) { { 1 => 1, 2 => 3 } } + let(:hash_b) { { 1 => 2, 2 => 1 } } + + it 'merges two hashes together into union of two sets' do + expect(described_class.new(hash_a).merge_hash!(hash_b).to_json).to eq described_class.new(1 => 2, 2 => 3).to_json + end + end + + describe '#to_json' do + it 'serialize HyperLogLog buckets as hash' do + expect(described_class.new(1 => 5).to_json).to eq '{"1":5}' + end + end +end diff --git a/spec/lib/gitlab/utils/usage_data_spec.rb b/spec/lib/gitlab/utils/usage_data_spec.rb index 521d6584a20..099faf170a8 100644 --- a/spec/lib/gitlab/utils/usage_data_spec.rb +++ b/spec/lib/gitlab/utils/usage_data_spec.rb @@ -38,32 +38,123 @@ RSpec.describe Gitlab::Utils::UsageData do end describe '#estimate_batch_distinct_count' do + let(:error_rate) { Gitlab::Database::PostgresHll::BatchDistinctCounter::ERROR_RATE } # HyperLogLog is a probabilistic algorithm, which provides estimated data, with given error margin let(:relation) { double(:relation) } + before do + allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) + end + it 'delegates counting to counter class instance' do + buckets = instance_double(Gitlab::Database::PostgresHll::Buckets) + expect_next_instance_of(Gitlab::Database::PostgresHll::BatchDistinctCounter, relation, 'column') do |instance| - expect(instance).to receive(:estimate_distinct_count) + expect(instance).to receive(:execute) .with(batch_size: nil, start: nil, finish: nil) - .and_return(5) + .and_return(buckets) end + expect(buckets).to receive(:estimated_distinct_count).and_return(5) expect(described_class.estimate_batch_distinct_count(relation, 'column')).to eq(5) end - it 'returns default fallback value when counting fails due to database error' do - stub_const("Gitlab::Utils::UsageData::FALLBACK", 15) - allow(Gitlab::Database::PostgresHll::BatchDistinctCounter).to receive(:new).and_raise(ActiveRecord::StatementInvalid.new('')) + context 'quasi integration test for different counting parameters' do + let_it_be(:user) { create(:user, email: 'email1@domain.com') } + let_it_be(:another_user) { create(:user, email: 'email2@domain.com') } + + let(:model) { Issue } + let(:column) { :author_id } + + context 'different distribution of relation records' do + [10, 100, 100_000].each do |spread| + context "records are spread within #{spread}" do + before do + ids = (1..spread).to_a.sample(10) + create_list(:issue, 10).each_with_index do |issue, i| + issue.id = ids[i] + end + end + + it 'counts table' do + expect(described_class.estimate_batch_distinct_count(model)).to be_within(error_rate).percent_of(10) + end + end + end + end + + context 'different counting parameters' do + before_all do + create_list(:issue, 3, author: user) + create_list(:issue, 2, author: another_user) + end + + it 'counts table' do + expect(described_class.estimate_batch_distinct_count(model)).to be_within(error_rate).percent_of(5) + end + + it 'counts with column field' do + expect(described_class.estimate_batch_distinct_count(model, column)).to be_within(error_rate).percent_of(2) + end + + it 'counts with :id field' do + expect(described_class.estimate_batch_distinct_count(model, :id)).to be_within(error_rate).percent_of(5) + end + + it 'counts with "id" field' do + expect(described_class.estimate_batch_distinct_count(model, "id")).to be_within(error_rate).percent_of(5) + end + + it 'counts with table.column field' do + expect(described_class.estimate_batch_distinct_count(model, "#{model.table_name}.#{column}")).to be_within(error_rate).percent_of(2) + end + + it 'counts with Arel column' do + expect(described_class.estimate_batch_distinct_count(model, model.arel_table[column])).to be_within(error_rate).percent_of(2) + end + + it 'counts over joined relations' do + expect(described_class.estimate_batch_distinct_count(model.joins(:author), "users.email")).to be_within(error_rate).percent_of(2) + end + + it 'counts with :column field with batch_size of 50K' do + expect(described_class.estimate_batch_distinct_count(model, column, batch_size: 50_000)).to be_within(error_rate).percent_of(2) + end + + it 'counts with different number of batches and aggregates total result' do + stub_const('Gitlab::Database::PostgresHll::BatchDistinctCounter::MIN_REQUIRED_BATCH_SIZE', 0) + + [1, 2, 4, 5, 6].each { |i| expect(described_class.estimate_batch_distinct_count(model, batch_size: i)).to be_within(error_rate).percent_of(5) } + end - expect(described_class.estimate_batch_distinct_count(relation)).to eq(15) + it 'counts with a start and finish' do + expect(described_class.estimate_batch_distinct_count(model, column, start: model.minimum(:id), finish: model.maximum(:id))).to be_within(error_rate).percent_of(2) + end + end end - it 'logs error and returns DISTRIBUTED_HLL_FALLBACK value when counting raises any error', :aggregate_failures do - error = StandardError.new('') - stub_const("Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK", 15) - allow(Gitlab::Database::PostgresHll::BatchDistinctCounter).to receive(:new).and_raise(error) + describe 'error handling' do + before do + stub_const("Gitlab::Utils::UsageData::FALLBACK", 3) + stub_const("Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK", 4) + end + + it 'returns fallback if counter raises WRONG_CONFIGURATION_ERROR' do + expect(described_class.estimate_batch_distinct_count(relation, 'id', start: 1, finish: 0)).to eq 3 + end - expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).with(error) - expect(described_class.estimate_batch_distinct_count(relation)).to eq(15) + it 'returns default fallback value when counting fails due to database error' do + allow(Gitlab::Database::PostgresHll::BatchDistinctCounter).to receive(:new).and_raise(ActiveRecord::StatementInvalid.new('')) + + expect(described_class.estimate_batch_distinct_count(relation)).to eq(3) + end + + it 'logs error and returns DISTRIBUTED_HLL_FALLBACK value when counting raises any error', :aggregate_failures do + error = StandardError.new('') + allow(Gitlab::Database::PostgresHll::BatchDistinctCounter).to receive(:new).and_raise(error) + + expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).with(error) + expect(described_class.estimate_batch_distinct_count(relation)).to eq(4) + end end end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index ea03cbc3706..4e10ca58cf4 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -850,12 +850,13 @@ RSpec.describe ApplicationSetting do end end - describe '#instance_review_permitted?', :request_store do + describe '#instance_review_permitted?', :request_store, :use_clean_rails_memory_store_caching do subject { setting.instance_review_permitted? } before do - RequestStore.store[:current_license] = nil - expect(Rails.cache).to receive(:fetch).and_return( + allow(License).to receive(:current).and_return(nil) if Gitlab.ee? + allow(Rails.cache).to receive(:fetch).and_call_original + expect(Rails.cache).to receive(:fetch).with('limited_users_count', anything).and_return( ::ApplicationSetting::INSTANCE_REVIEW_MIN_USERS + users_over_minimum ) end diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index b045533a3cd..f0c84898d67 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -4824,4 +4824,107 @@ RSpec.describe Ci::Build do it { is_expected.to eq false } end end + + describe '#drop_with_exit_code!' do + let(:exit_code) { 1 } + let(:options) { {} } + + before do + build.options.merge!(options) + build.save! + end + + subject(:drop_with_exit_code) do + build.drop_with_exit_code!(:unknown_failure, exit_code) + end + + shared_examples 'drops the build without changing allow_failure' do + it 'does not change allow_failure' do + expect { drop_with_exit_code } + .not_to change { build.reload.allow_failure } + end + + it 'drops the build' do + expect { drop_with_exit_code } + .to change { build.reload.failed? } + end + end + + context 'when exit_codes are not defined' do + it_behaves_like 'drops the build without changing allow_failure' + end + + context 'when allow_failure_criteria is nil' do + let(:options) { { allow_failure_criteria: nil } } + + it_behaves_like 'drops the build without changing allow_failure' + end + + context 'when exit_codes is nil' do + let(:options) do + { + allow_failure_criteria: { + exit_codes: nil + } + } + end + + it_behaves_like 'drops the build without changing allow_failure' + end + + context 'when exit_codes do not match' do + let(:options) do + { + allow_failure_criteria: { + exit_codes: [2, 3, 4] + } + } + end + + it_behaves_like 'drops the build without changing allow_failure' + end + + context 'with matching exit codes' do + let(:options) do + { allow_failure_criteria: { exit_codes: [1, 2, 3] } } + end + + it 'changes allow_failure' do + expect { drop_with_exit_code } + .to change { build.reload.allow_failure } + end + + it 'drops the build' do + expect { drop_with_exit_code } + .to change { build.reload.failed? } + end + + it 'is executed inside a transaction' do + expect(build).to receive(:drop!) + .with(:unknown_failure) + .and_raise(ActiveRecord::Rollback) + + expect(build).to receive(:conditionally_allow_failure!) + .with(1) + .and_call_original + + expect { drop_with_exit_code } + .not_to change { build.reload.allow_failure } + end + + context 'when exit_code is nil' do + let(:exit_code) {} + + it_behaves_like 'drops the build without changing allow_failure' + end + + context 'when ci_allow_failure_with_exit_codes is disabled' do + before do + stub_feature_flags(ci_allow_failure_with_exit_codes: false) + end + + it_behaves_like 'drops the build without changing allow_failure' + end + end + end end diff --git a/spec/models/namespace_onboarding_action_spec.rb b/spec/models/namespace_onboarding_action_spec.rb index 70dcb989b32..aba6b2061c3 100644 --- a/spec/models/namespace_onboarding_action_spec.rb +++ b/spec/models/namespace_onboarding_action_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe NamespaceOnboardingAction do - let(:namespace) { build(:namespace) } + let(:namespace) { create(:namespace) } describe 'associations' do it { is_expected.to belong_to(:namespace).required } @@ -46,6 +46,32 @@ RSpec.describe NamespaceOnboardingAction do expect { create_action }.to change { count_namespace_actions }.by(0) end + context 'when the namespace is created outside the monitoring window' do + let(:namespace) { create(:namespace, created_at: (NamespaceOnboardingAction::MONITORING_WINDOW + 1.day).ago) } + + it 'does not create an action for the namespace' do + expect { create_action }.not_to change { count_namespace_actions } + end + + context 'when an action has already been recorded for the namespace' do + before do + described_class.create!(namespace: namespace, action: :git_write) + end + + it 'creates an action for the namespace' do + expect { create_action }.to change { count_namespace_actions }.by(1) + end + end + end + + context 'when the namespace is not a root' do + let(:namespace) { create(:namespace, parent: build(:namespace)) } + + it 'does not create an action for the namespace' do + expect { create_action }.not_to change { count_namespace_actions } + end + end + def count_namespace_actions described_class.where(namespace: namespace, action: action).count end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 0130618d004..f86669d60b7 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -1500,4 +1500,24 @@ RSpec.describe Namespace do end end end + + describe '#root?' do + subject { namespace.root? } + + context 'when is subgroup' do + before do + namespace.parent = build(:group) + end + + it 'returns false' do + is_expected.to eq(false) + end + end + + context 'when is root' do + it 'returns true' do + is_expected.to eq(true) + end + end + end end diff --git a/spec/requests/api/ci/runner/jobs_put_spec.rb b/spec/requests/api/ci/runner/jobs_put_spec.rb index e9d793d5a22..f4c99307b1a 100644 --- a/spec/requests/api/ci/runner/jobs_put_spec.rb +++ b/spec/requests/api/ci/runner/jobs_put_spec.rb @@ -78,6 +78,33 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do end end + context 'when an exit_code is provided' do + context 'when the exit_codes are acceptable' do + before do + job.options[:allow_failure_criteria] = { exit_codes: [1] } + job.save! + end + + it 'accepts an exit code' do + update_job(state: 'failed', exit_code: 1) + + expect(job.reload).to be_failed + expect(job.allow_failure).to be_truthy + expect(job).to be_unknown_failure + end + end + + context 'when the exit_codes are not defined' do + it 'ignore the exit code' do + update_job(state: 'failed', exit_code: 1) + + expect(job.reload).to be_failed + expect(job.allow_failure).to be_falsy + expect(job).to be_unknown_failure + end + end + end + context 'when failure_reason is script_failure' do before do update_job(state: 'failed', failure_reason: 'script_failure') diff --git a/spec/requests/api/graphql/project/alert_management/alert/assignees_spec.rb b/spec/requests/api/graphql/project/alert_management/alert/assignees_spec.rb index dd001a73349..9ab94f1d749 100644 --- a/spec/requests/api/graphql/project/alert_management/alert/assignees_spec.rb +++ b/spec/requests/api/graphql/project/alert_management/alert/assignees_spec.rb @@ -60,19 +60,35 @@ RSpec.describe 'getting Alert Management Alert Assignees' do expect(second_assignees).to be_empty end - it 'avoids N+1 queries' do - base_count = ActiveRecord::QueryRecorder.new do - post_graphql(query, current_user: current_user) + describe 'performance' do + let(:first_n) { var('Int') } + let(:params) { { first: first_n } } + let(:limited_query) { with_signature([first_n], query) } + + before do + create(:alert_management_alert, project: project, assignees: [current_user]) + end + + it 'can limit results' do + post_graphql(limited_query, current_user: current_user, variables: first_n.with(1)) + + expect(alerts.size).to eq 1 + expect(alerts).not_to include(a_hash_including('iid' => first_alert.iid.to_s)) end - # An N+1 would mean a new alert would increase the query count - third_alert = create(:alert_management_alert, project: project, assignees: [current_user]) + it 'can include all results' do + post_graphql(limited_query, current_user: current_user) - expect { post_graphql(query, current_user: current_user) }.not_to exceed_query_limit(base_count) + expect(alerts.size).to be > 1 + expect(alerts).to include(a_hash_including('iid' => first_alert.iid.to_s)) + end - third_assignees = assignees[third_alert.iid.to_s] + it 'avoids N+1 queries' do + base_count = ActiveRecord::QueryRecorder.new do + post_graphql(limited_query, current_user: current_user, variables: first_n.with(1)) + end - expect(third_assignees.length).to eq(1) - expect(third_assignees.first).to include('username' => current_user.username) + expect { post_graphql(limited_query, current_user: current_user) }.not_to exceed_query_limit(base_count) + end end end diff --git a/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb b/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb index 1350cba119b..5d46f370756 100644 --- a/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb +++ b/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb @@ -65,16 +65,28 @@ RSpec.describe 'getting Alert Management Alert Notes' do expect(second_notes_result).to be_empty end - it 'avoids N+1 queries' do - base_count = ActiveRecord::QueryRecorder.new do - post_graphql(query, current_user: current_user) + describe 'performance' do + let(:first_n) { var('Int') } + let(:params) { { first: first_n } } + + before do + # An N+1 would mean a new alert would increase the query count + create(:alert_management_alert, project: project) end - # An N+1 would mean a new alert would increase the query count - create(:alert_management_alert, project: project) + it 'avoids N+1 queries' do + q = with_signature([first_n], query) - expect { post_graphql(query, current_user: current_user) }.not_to exceed_query_limit(base_count) - expect(alerts_result.length).to eq(3) + base_count = ActiveRecord::QueryRecorder.new do + post_graphql(q, current_user: current_user, variables: first_n.with(1)) + expect(alerts_result.length).to eq(1) + end + + expect do + post_graphql(q, current_user: current_user, variables: first_n.with(3)) + expect(alerts_result.length).to eq(3) + end.not_to exceed_query_limit(base_count) + end end context 'for non-system notes' do diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 971ab176cfa..4b8abb5f47a 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -490,6 +490,7 @@ RSpec.describe Ci::CreatePipelineService do expect(execute_service).not_to be_persisted expect(Ci::Pipeline.count).to eq(0) + expect(Namespaces::OnboardingPipelineCreatedWorker).not_to receive(:perform_async) end shared_examples 'a failed pipeline' do @@ -1427,6 +1428,13 @@ RSpec.describe Ci::CreatePipelineService do pipeline end + it 'schedules a namespace onboarding create action worker' do + expect(Namespaces::OnboardingPipelineCreatedWorker) + .to receive(:perform_async).with(project.namespace_id) + + pipeline + end + context 'when target sha is specified' do let(:target_sha) { merge_request.target_branch_sha } diff --git a/spec/services/ci/update_build_state_service_spec.rb b/spec/services/ci/update_build_state_service_spec.rb index 3112e5dda1b..63190cc5d49 100644 --- a/spec/services/ci/update_build_state_service_spec.rb +++ b/spec/services/ci/update_build_state_service_spec.rb @@ -82,8 +82,9 @@ RSpec.describe Ci::UpdateBuildStateService do let(:params) do { output: { checksum: 'crc32:12345678', bytesize: 123 }, + state: 'failed', failure_reason: 'script_failure', - state: 'failed' + exit_code: 42 } end @@ -95,6 +96,15 @@ RSpec.describe Ci::UpdateBuildStateService do expect(result.status).to eq 200 end + it 'updates the allow_failure flag' do + expect(build) + .to receive(:drop_with_exit_code!) + .with('script_failure', 42) + .and_call_original + + subject.execute + end + it 'does not increment invalid trace metric' do execute_with_stubbed_metrics! @@ -115,6 +125,15 @@ RSpec.describe Ci::UpdateBuildStateService do expect(build).to be_failed end + it 'updates the allow_failure flag' do + expect(build) + .to receive(:drop_with_exit_code!) + .with('script_failure', 42) + .and_call_original + + subject.execute + end + it 'responds with 200 OK status' do result = subject.execute diff --git a/spec/services/onboarding_progress_service_spec.rb b/spec/services/onboarding_progress_service_spec.rb index 59b6083d38a..de4c0d2a3ba 100644 --- a/spec/services/onboarding_progress_service_spec.rb +++ b/spec/services/onboarding_progress_service_spec.rb @@ -5,29 +5,39 @@ require 'spec_helper' RSpec.describe OnboardingProgressService do describe '#execute' do let(:namespace) { create(:namespace, parent: root_namespace) } + let(:root_namespace) { nil } + let(:action) { :namespace_action } subject(:execute_service) { described_class.new(namespace).execute(action: :subscription_created) } context 'when the namespace is a root' do - let(:root_namespace) { nil } - - it 'records a namespace onboarding progress action for the given namespace' do + it 'records a namespace onboarding progress action fot the given namespace' do expect(NamespaceOnboardingAction).to receive(:create_action) - .with(namespace, :subscription_created).and_call_original + .with(namespace, :subscription_created).and_call_original expect { execute_service }.to change(NamespaceOnboardingAction, :count).by(1) end end context 'when the namespace is not the root' do - let_it_be(:root_namespace) { build(:namespace) } + let(:root_namespace) { build(:namespace) } it 'records a namespace onboarding progress action for the root namespace' do expect(NamespaceOnboardingAction).to receive(:create_action) - .with(root_namespace, :subscription_created).and_call_original + .with(root_namespace, :subscription_created).and_call_original expect { execute_service }.to change(NamespaceOnboardingAction, :count).by(1) end end + + context 'when no namespace is passed' do + let(:namespace) { nil } + + it 'does not record a namespace onboarding progress action' do + expect(NamespaceOnboardingAction).not_to receive(:create_action) + + execute_service + end + end end end diff --git a/spec/services/projects/schedule_bulk_repository_shard_moves_service_spec.rb b/spec/services/projects/schedule_bulk_repository_shard_moves_service_spec.rb index 5b76386bfab..15c9d1e5925 100644 --- a/spec/services/projects/schedule_bulk_repository_shard_moves_service_spec.rb +++ b/spec/services/projects/schedule_bulk_repository_shard_moves_service_spec.rb @@ -3,45 +3,10 @@ require 'spec_helper' RSpec.describe Projects::ScheduleBulkRepositoryShardMovesService do - before do - stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/extra_storage' }) - end - - let!(:project) { create(:project, :repository).tap { |project| project.track_project_repository } } - let(:source_storage_name) { 'default' } - let(:destination_storage_name) { 'test_second_storage' } - - describe '#execute' do - it 'schedules project repository storage moves' do - expect { subject.execute(source_storage_name, destination_storage_name) } - .to change(ProjectRepositoryStorageMove, :count).by(1) - - storage_move = project.repository_storage_moves.last! - - expect(storage_move).to have_attributes( - source_storage_name: source_storage_name, - destination_storage_name: destination_storage_name, - state_name: :scheduled - ) - end - - context 'read-only repository' do - let!(:project) { create(:project, :repository, :read_only).tap { |project| project.track_project_repository } } - - it 'does not get scheduled' do - expect(subject).to receive(:log_info) - .with("Project #{project.full_path} (#{project.id}) was skipped: Project is read only") - expect { subject.execute(source_storage_name, destination_storage_name) } - .to change(ProjectRepositoryStorageMove, :count).by(0) - end - end - end - - describe '.enqueue' do - it 'defers to the worker' do - expect(::ProjectScheduleBulkRepositoryShardMovesWorker).to receive(:perform_async).with(source_storage_name, destination_storage_name) + it_behaves_like 'moves repository shard in bulk' do + let_it_be_with_reload(:container) { create(:project, :repository).tap { |project| project.track_project_repository } } - described_class.enqueue(source_storage_name, destination_storage_name) - end + let(:move_service_klass) { ProjectRepositoryStorageMove } + let(:bulk_worker_klass) { ::ProjectScheduleBulkRepositoryShardMovesWorker } end end diff --git a/spec/services/snippets/schedule_bulk_repository_shard_moves_service_spec.rb b/spec/services/snippets/schedule_bulk_repository_shard_moves_service_spec.rb new file mode 100644 index 00000000000..764c7f94a46 --- /dev/null +++ b/spec/services/snippets/schedule_bulk_repository_shard_moves_service_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Snippets::ScheduleBulkRepositoryShardMovesService do + it_behaves_like 'moves repository shard in bulk' do + let_it_be_with_reload(:container) { create(:snippet, :repository) } + + let(:move_service_klass) { SnippetRepositoryStorageMove } + let(:bulk_worker_klass) { ::SnippetScheduleBulkRepositoryShardMovesWorker } + end +end diff --git a/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb b/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb new file mode 100644 index 00000000000..e67fc4ab04a --- /dev/null +++ b/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'moves repository shard in bulk' do + let(:source_storage_name) { 'default' } + let(:destination_storage_name) { 'test_second_storage' } + + before do + stub_storage_settings(destination_storage_name => { 'path' => 'tmp/tests/extra_storage' }) + end + + describe '#execute' do + it 'schedules container repository storage moves' do + expect { subject.execute(source_storage_name, destination_storage_name) } + .to change(move_service_klass, :count).by(1) + + storage_move = container.repository_storage_moves.last! + + expect(storage_move).to have_attributes( + source_storage_name: source_storage_name, + destination_storage_name: destination_storage_name, + state_name: :scheduled + ) + end + + context 'read-only repository' do + it 'does not get scheduled' do + container.set_repository_read_only! + + expect(subject).to receive(:log_info) + .with(/Container #{container.full_path} \(#{container.id}\) was skipped: #{container.class} is read only/) + expect { subject.execute(source_storage_name, destination_storage_name) } + .to change(move_service_klass, :count).by(0) + end + end + end + + describe '.enqueue' do + it 'defers to the worker' do + expect(bulk_worker_klass).to receive(:perform_async).with(source_storage_name, destination_storage_name) + + described_class.enqueue(source_storage_name, destination_storage_name) + end + end +end diff --git a/spec/support/shared_examples/workers/schedule_bulk_repository_shard_moves_shared_examples.rb b/spec/support/shared_examples/workers/schedule_bulk_repository_shard_moves_shared_examples.rb new file mode 100644 index 00000000000..465aca63148 --- /dev/null +++ b/spec/support/shared_examples/workers/schedule_bulk_repository_shard_moves_shared_examples.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'schedules bulk repository shard moves' do + let(:source_storage_name) { 'default' } + let(:destination_storage_name) { 'test_second_storage' } + + describe "#perform" do + before do + stub_storage_settings(destination_storage_name => { 'path' => 'tmp/tests/extra_storage' }) + + allow(worker_klass).to receive(:perform_async) + end + + include_examples 'an idempotent worker' do + let(:job_args) { [source_storage_name, destination_storage_name] } + + it 'schedules container repository storage moves' do + expect { subject }.to change(move_service_klass, :count).by(1) + + storage_move = container.repository_storage_moves.last! + + expect(storage_move).to have_attributes( + source_storage_name: source_storage_name, + destination_storage_name: destination_storage_name, + state_name: :scheduled + ) + end + end + end +end diff --git a/spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb b/spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb new file mode 100644 index 00000000000..240a0b69834 --- /dev/null +++ b/spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Namespaces::OnboardingPipelineCreatedWorker, '#perform' do + include AfterNextHelpers + + let_it_be(:ci_pipeline) { create(:ci_pipeline) } + + it 'records the event' do + expect_next(OnboardingProgressService, ci_pipeline.project.namespace) + .to receive(:execute).with(action: :pipeline_created).and_call_original + + expect do + subject.perform(ci_pipeline.project.namespace_id) + end.to change(NamespaceOnboardingAction, :count).by(1) + end + + context "when a namespace doesn't exist" do + it "does nothing" do + expect_next(OnboardingProgressService, ci_pipeline.project.namespace).not_to receive(:execute) + + expect { subject.perform(nil) }.not_to change(NamespaceOnboardingAction, :count) + end + end +end diff --git a/spec/workers/project_schedule_bulk_repository_shard_moves_worker_spec.rb b/spec/workers/project_schedule_bulk_repository_shard_moves_worker_spec.rb index aadfae51906..fb762593d75 100644 --- a/spec/workers/project_schedule_bulk_repository_shard_moves_worker_spec.rb +++ b/spec/workers/project_schedule_bulk_repository_shard_moves_worker_spec.rb @@ -3,31 +3,10 @@ require 'spec_helper' RSpec.describe ProjectScheduleBulkRepositoryShardMovesWorker do - describe "#perform" do - before do - stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/extra_storage' }) + it_behaves_like 'schedules bulk repository shard moves' do + let_it_be_with_reload(:container) { create(:project, :repository).tap { |project| project.track_project_repository } } - allow(ProjectUpdateRepositoryStorageWorker).to receive(:perform_async) - end - - let!(:project) { create(:project, :repository).tap { |project| project.track_project_repository } } - let(:source_storage_name) { 'default' } - let(:destination_storage_name) { 'test_second_storage' } - - include_examples 'an idempotent worker' do - let(:job_args) { [source_storage_name, destination_storage_name] } - - it 'schedules project repository storage moves' do - expect { subject }.to change(ProjectRepositoryStorageMove, :count).by(1) - - storage_move = project.repository_storage_moves.last! - - expect(storage_move).to have_attributes( - source_storage_name: source_storage_name, - destination_storage_name: destination_storage_name, - state_name: :scheduled - ) - end - end + let(:move_service_klass) { ProjectRepositoryStorageMove } + let(:worker_klass) { ProjectUpdateRepositoryStorageWorker } end end diff --git a/spec/workers/snippet_schedule_bulk_repository_shard_moves_worker_spec.rb b/spec/workers/snippet_schedule_bulk_repository_shard_moves_worker_spec.rb new file mode 100644 index 00000000000..3a09b6ce449 --- /dev/null +++ b/spec/workers/snippet_schedule_bulk_repository_shard_moves_worker_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe SnippetScheduleBulkRepositoryShardMovesWorker do + it_behaves_like 'schedules bulk repository shard moves' do + let_it_be_with_reload(:container) { create(:snippet, :repository).tap { |snippet| snippet.create_repository } } + + let(:move_service_klass) { SnippetRepositoryStorageMove } + let(:worker_klass) { SnippetUpdateRepositoryStorageWorker } + end +end |