diff options
Diffstat (limited to 'spec/frontend')
23 files changed, 83 insertions, 49 deletions
diff --git a/spec/frontend/ci/ci_variable_list/components/ci_variable_modal_spec.js b/spec/frontend/ci/ci_variable_list/components/ci_variable_modal_spec.js index 8f3fccc2804..8a5f62008fd 100644 --- a/spec/frontend/ci/ci_variable_list/components/ci_variable_modal_spec.js +++ b/spec/frontend/ci/ci_variable_list/components/ci_variable_modal_spec.js @@ -152,7 +152,7 @@ describe('Ci variable modal', () => { findModal().vm.$emit('shown'); }); - it('keeps the value as false', async () => { + it('keeps the value as false', () => { expect( findProtectedVariableCheckbox().attributes('data-is-protected-checked'), ).toBeUndefined(); diff --git a/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js b/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js index 87192006efc..ab5f3711139 100644 --- a/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js +++ b/spec/frontend/ci/ci_variable_list/components/ci_variable_shared_spec.js @@ -70,7 +70,7 @@ describe('Ci Variable Shared Component', () => { const findCiSettings = () => wrapper.findComponent(ciVariableSettings); // eslint-disable-next-line consistent-return - async function createComponentWithApollo({ + function createComponentWithApollo({ customHandlers = null, isLoading = false, props = { ...createProjectProps() }, @@ -409,7 +409,7 @@ describe('Ci Variable Shared Component', () => { describe('queryData', () => { let error; - beforeEach(async () => { + beforeEach(() => { mockVariables.mockResolvedValue(mockGroupVariables); }); @@ -447,7 +447,7 @@ describe('Ci Variable Shared Component', () => { describe('mutationData', () => { let error; - beforeEach(async () => { + beforeEach(() => { mockVariables.mockResolvedValue(mockGroupVariables); }); diff --git a/spec/frontend/ci/ci_variable_list/components/ci_variable_table_spec.js b/spec/frontend/ci/ci_variable_list/components/ci_variable_table_spec.js index 2ef789e89c3..0b28cb06cec 100644 --- a/spec/frontend/ci/ci_variable_list/components/ci_variable_table_spec.js +++ b/spec/frontend/ci/ci_variable_list/components/ci_variable_table_spec.js @@ -82,11 +82,11 @@ describe('Ci variable table', () => { expect(findRevealButton().exists()).toBe(true); }); - it('displays the correct amount of variables', async () => { + it('displays the correct amount of variables', () => { expect(wrapper.findAll('.js-ci-variable-row')).toHaveLength(defaultProps.variables.length); }); - it('displays the correct variable options', async () => { + it('displays the correct variable options', () => { expect(findOptionsValues(0)).toBe('Protected, Expanded'); expect(findOptionsValues(1)).toBe('Masked'); }); diff --git a/spec/frontend/ci/pipeline_editor/components/commit/commit_form_spec.js b/spec/frontend/ci/pipeline_editor/components/commit/commit_form_spec.js index b2dfa900b1d..03f346181e4 100644 --- a/spec/frontend/ci/pipeline_editor/components/commit/commit_form_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/commit/commit_form_spec.js @@ -34,7 +34,7 @@ describe('Pipeline Editor | Commit Form', () => { const findCancelBtn = () => wrapper.find('[type="reset"]'); describe('when the form is displayed', () => { - beforeEach(async () => { + beforeEach(() => { createComponent(); }); @@ -57,7 +57,7 @@ describe('Pipeline Editor | Commit Form', () => { }); describe('when buttons are clicked', () => { - beforeEach(async () => { + beforeEach(() => { createComponent({}, mount); }); diff --git a/spec/frontend/ci/pipeline_editor/components/drawer/cards/pipeline_config_reference_card_spec.js b/spec/frontend/ci/pipeline_editor/components/drawer/cards/pipeline_config_reference_card_spec.js index 5399924b462..0296ab5a65c 100644 --- a/spec/frontend/ci/pipeline_editor/components/drawer/cards/pipeline_config_reference_card_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/drawer/cards/pipeline_config_reference_card_spec.js @@ -68,7 +68,7 @@ describe('Pipeline config reference card', () => { }); }; - it('tracks help page links', async () => { + it('tracks help page links', () => { const { CI_EXAMPLES_LINK, CI_HELP_LINK, diff --git a/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js b/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js index 560e8840d57..2861fc35342 100644 --- a/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js @@ -58,7 +58,7 @@ describe('CI Editor Header', () => { expect(findLinkBtn().props('icon')).toBe('external-link'); }); - it('tracks the click on the browse button', async () => { + it('tracks the click on the browse button', () => { const { browseTemplates } = pipelineEditorTrackingOptions.actions; testTracker(findLinkBtn(), browseTemplates); @@ -91,7 +91,7 @@ describe('CI Editor Header', () => { expect(wrapper.emitted('open-drawer')).toHaveLength(1); }); - it('tracks open help drawer action', async () => { + it('tracks open help drawer action', () => { const { actions } = pipelineEditorTrackingOptions; testTracker(findHelpBtn(), actions.openHelpDrawer); diff --git a/spec/frontend/ci/pipeline_editor/components/file-nav/branch_switcher_spec.js b/spec/frontend/ci/pipeline_editor/components/file-nav/branch_switcher_spec.js index bf14f4c4cd6..3a99949413b 100644 --- a/spec/frontend/ci/pipeline_editor/components/file-nav/branch_switcher_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/file-nav/branch_switcher_spec.js @@ -288,7 +288,7 @@ describe('Pipeline editor branch switcher', () => { }); describe('with a search term', () => { - beforeEach(async () => { + beforeEach(() => { mockAvailableBranchQuery.mockResolvedValue(mockSearchBranches); }); diff --git a/spec/frontend/ci/pipeline_editor/components/file-tree/container_spec.js b/spec/frontend/ci/pipeline_editor/components/file-tree/container_spec.js index 306dd78d395..f2effcb2966 100644 --- a/spec/frontend/ci/pipeline_editor/components/file-tree/container_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/file-tree/container_spec.js @@ -60,11 +60,11 @@ describe('Pipeline editor file nav', () => { expect(fileTreeItems().exists()).toBe(false); }); - it('renders alert tip', async () => { + it('renders alert tip', () => { expect(findTip().exists()).toBe(true); }); - it('renders learn more link', async () => { + it('renders learn more link', () => { expect(findTip().props('secondaryButtonLink')).toBe(mockIncludesHelpPagePath); }); @@ -87,7 +87,7 @@ describe('Pipeline editor file nav', () => { }); }); - it('does not render alert tip', async () => { + it('does not render alert tip', () => { expect(findTip().exists()).toBe(false); }); }); diff --git a/spec/frontend/ci/pipeline_editor/components/header/pipeline_editor_mini_graph_spec.js b/spec/frontend/ci/pipeline_editor/components/header/pipeline_editor_mini_graph_spec.js index 7bf955012c7..b8526e569ec 100644 --- a/spec/frontend/ci/pipeline_editor/components/header/pipeline_editor_mini_graph_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/header/pipeline_editor_mini_graph_spec.js @@ -96,7 +96,7 @@ describe('Pipeline Status', () => { await waitForPromises(); }); - it('should emit an error event when query fails', async () => { + it('should emit an error event when query fails', () => { expect(wrapper.emitted('showError')).toHaveLength(1); expect(wrapper.emitted('showError')[0]).toEqual([ { diff --git a/spec/frontend/ci/pipeline_editor/components/header/pipeline_status_spec.js b/spec/frontend/ci/pipeline_editor/components/header/pipeline_status_spec.js index 3faa2890254..8ca88472bf1 100644 --- a/spec/frontend/ci/pipeline_editor/components/header/pipeline_status_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/header/pipeline_status_spec.js @@ -77,7 +77,7 @@ describe('Pipeline Status', () => { await waitForPromises(); }); - it('query is called with correct variables', async () => { + it('query is called with correct variables', () => { expect(mockPipelineQuery).toHaveBeenCalledTimes(1); expect(mockPipelineQuery).toHaveBeenCalledWith({ fullPath: mockProjectFullPath, diff --git a/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js b/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js index 52a543c7686..cbdf01105c7 100644 --- a/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js @@ -314,13 +314,13 @@ describe('Pipeline editor tabs component', () => { createComponent(); }); - it('shows walkthrough popover', async () => { + it('shows walkthrough popover', () => { expect(findWalkthroughPopover().exists()).toBe(true); }); }); describe('when isNewCiConfigFile prop is false', () => { - it('does not show walkthrough popover', async () => { + it('does not show walkthrough popover', () => { createComponent({ props: { isNewCiConfigFile: false } }); expect(findWalkthroughPopover().exists()).toBe(false); }); diff --git a/spec/frontend/ci/pipeline_editor/components/popovers/file_tree_popover_spec.js b/spec/frontend/ci/pipeline_editor/components/popovers/file_tree_popover_spec.js index a9aabb103f2..3d84f06967a 100644 --- a/spec/frontend/ci/pipeline_editor/components/popovers/file_tree_popover_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/popovers/file_tree_popover_spec.js @@ -25,7 +25,7 @@ describe('FileTreePopover component', () => { }); describe('default', () => { - beforeEach(async () => { + beforeEach(() => { createComponent({ stubs: { GlSprintf } }); }); @@ -45,7 +45,7 @@ describe('FileTreePopover component', () => { }); describe('when popover has already been dismissed before', () => { - it('does not render popover', async () => { + it('does not render popover', () => { localStorage.setItem(FILE_TREE_POPOVER_DISMISSED_KEY, 'true'); createComponent(); diff --git a/spec/frontend/ci/pipeline_editor/components/popovers/validate_pipeline_popover_spec.js b/spec/frontend/ci/pipeline_editor/components/popovers/validate_pipeline_popover_spec.js index 23f9c7a87ee..18eec48ad83 100644 --- a/spec/frontend/ci/pipeline_editor/components/popovers/validate_pipeline_popover_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/popovers/validate_pipeline_popover_spec.js @@ -20,7 +20,7 @@ describe('ValidatePopover component', () => { const findFeedbackLink = () => wrapper.findByTestId('feedback-link'); describe('template', () => { - beforeEach(async () => { + beforeEach(() => { createComponent({ stubs: { GlLink, GlSprintf }, }); diff --git a/spec/frontend/ci/pipeline_editor/components/popovers/walkthrough_popover_spec.js b/spec/frontend/ci/pipeline_editor/components/popovers/walkthrough_popover_spec.js index 186fd803d47..37339b1c422 100644 --- a/spec/frontend/ci/pipeline_editor/components/popovers/walkthrough_popover_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/popovers/walkthrough_popover_spec.js @@ -18,7 +18,7 @@ describe('WalkthroughPopover component', () => { await wrapper.findByTestId('ctaBtn').trigger('click'); }); - it('emits "walkthrough-popover-cta-clicked" event', async () => { + it('emits "walkthrough-popover-cta-clicked" event', () => { expect(wrapper.emitted()['walkthrough-popover-cta-clicked']).toHaveLength(1); }); }); diff --git a/spec/frontend/ci/pipeline_editor/components/ui/editor_tab_spec.js b/spec/frontend/ci/pipeline_editor/components/ui/editor_tab_spec.js index a4e7abba7b0..f02b1f5efbc 100644 --- a/spec/frontend/ci/pipeline_editor/components/ui/editor_tab_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/ui/editor_tab_spec.js @@ -64,7 +64,7 @@ describe('~/ci/pipeline_editor/components/ui/editor_tab.vue', () => { mockChildMounted = jest.fn(); }); - it('tabs are mounted lazily', async () => { + it('tabs are mounted lazily', () => { createMockedWrapper(); expect(mockChildMounted).toHaveBeenCalledTimes(0); @@ -192,7 +192,7 @@ describe('~/ci/pipeline_editor/components/ui/editor_tab.vue', () => { createMockedWrapper(); }); - it('renders correct number of badges', async () => { + it('renders correct number of badges', () => { expect(findBadges()).toHaveLength(1); expect(findBadges().at(0).text()).toBe('NEW'); }); diff --git a/spec/frontend/ci/pipeline_editor/graphql/resolvers_spec.js b/spec/frontend/ci/pipeline_editor/graphql/resolvers_spec.js index 6a6cc3a14de..893f6775ac5 100644 --- a/spec/frontend/ci/pipeline_editor/graphql/resolvers_spec.js +++ b/spec/frontend/ci/pipeline_editor/graphql/resolvers_spec.js @@ -34,7 +34,7 @@ describe('~/ci/pipeline_editor/graphql/resolvers', () => { }); /* eslint-disable no-underscore-dangle */ - it('lint data has correct type names', async () => { + it('lint data has correct type names', () => { expect(result.__typename).toBe('CiLintContent'); expect(result.jobs[0].__typename).toBe('CiLintJob'); diff --git a/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js b/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js index d22a1832343..8bac46a3e9c 100644 --- a/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js +++ b/spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js @@ -96,7 +96,7 @@ describe('Pipeline editor app component', () => { }); }; - const createComponentWithApollo = async ({ + const createComponentWithApollo = ({ provide = {}, stubs = {}, withUndefinedBranch = false, @@ -260,7 +260,7 @@ describe('Pipeline editor app component', () => { expect(findAlert().exists()).toBe(false); }); - it('ci config query is called with correct variables', async () => { + it('ci config query is called with correct variables', () => { expect(mockCiConfigData).toHaveBeenCalledWith({ content: mockCiYml, projectPath: mockProjectFullPath, @@ -287,7 +287,7 @@ describe('Pipeline editor app component', () => { .mockImplementation(jest.fn()); }); - it('shows an empty state and does not show editor home component', async () => { + it('shows an empty state and does not show editor home component', () => { expect(findEmptyState().exists()).toBe(true); expect(findAlert().exists()).toBe(false); expect(findEditorHome().exists()).toBe(false); diff --git a/spec/frontend/ci/pipeline_new/components/pipeline_new_form_spec.js b/spec/frontend/ci/pipeline_new/components/pipeline_new_form_spec.js index 1349461d8bc..9015031b6c8 100644 --- a/spec/frontend/ci/pipeline_new/components/pipeline_new_form_spec.js +++ b/spec/frontend/ci/pipeline_new/components/pipeline_new_form_spec.js @@ -142,7 +142,7 @@ describe('Pipeline New Form', () => { await waitForPromises(); }); - it('displays the correct values for the provided query params', async () => { + it('displays the correct values for the provided query params', () => { expect(findVariableTypes().at(0).props('text')).toBe('Variable'); expect(findVariableTypes().at(1).props('text')).toBe('File'); expect(findRefsDropdown().props('value')).toEqual({ shortName: 'tag-1' }); @@ -154,7 +154,7 @@ describe('Pipeline New Form', () => { expect(findValueInputs().at(0).element.value).toBe('test_var_val'); }); - it('displays an empty variable for the user to fill out', async () => { + it('displays an empty variable for the user to fill out', () => { expect(findKeyInputs().at(2).element.value).toBe(''); expect(findValueInputs().at(2).element.value).toBe(''); expect(findVariableTypes().at(2).props('text')).toBe('Variable'); @@ -186,12 +186,12 @@ describe('Pipeline New Form', () => { }); describe('Pipeline creation', () => { - beforeEach(async () => { + beforeEach(() => { mockCiConfigVariables.mockResolvedValue(mockEmptyCiConfigVariablesResponse); mock.onPost(pipelinesPath).reply(HTTP_STATUS_OK, newPipelinePostResponse); }); - it('does not submit the native HTML form', async () => { + it('does not submit the native HTML form', () => { createComponentWithApollo(); findForm().vm.$emit('submit', dummySubmitEvent); @@ -328,7 +328,7 @@ describe('Pipeline New Form', () => { }); const testBehaviorWhenCacheIsPopulated = (queryResponse) => { - beforeEach(async () => { + beforeEach(() => { mockCiConfigVariables.mockResolvedValue(queryResponse); createComponentWithApollo({ method: mountExtended }); }); @@ -406,7 +406,7 @@ describe('Pipeline New Form', () => { await waitForPromises(); }); - it('displays all the variables', async () => { + it('displays all the variables', () => { expect(findVariableRows()).toHaveLength(6); }); @@ -445,7 +445,7 @@ describe('Pipeline New Form', () => { await waitForPromises(); }); - it('displays variables with description only', async () => { + it('displays variables with description only', () => { expect(findVariableRows()).toHaveLength(2); // extra empty variable is added at the end }); }); diff --git a/spec/frontend/ci/pipeline_new/components/refs_dropdown_spec.js b/spec/frontend/ci/pipeline_new/components/refs_dropdown_spec.js index 60ace483712..82dac1358c5 100644 --- a/spec/frontend/ci/pipeline_new/components/refs_dropdown_spec.js +++ b/spec/frontend/ci/pipeline_new/components/refs_dropdown_spec.js @@ -54,7 +54,7 @@ describe('Pipeline New Form', () => { expect(findRefsDropdownItems()).toHaveLength(0); }); - it('does not make requests immediately', async () => { + it('does not make requests immediately', () => { expect(mock.history.get).toHaveLength(0); }); @@ -117,14 +117,14 @@ describe('Pipeline New Form', () => { await waitForPromises(); }); - it('requests filtered tags and branches', async () => { + it('requests filtered tags and branches', () => { expect(mock.history.get).toHaveLength(2); expect(mock.history.get[1].params).toEqual({ search: mockSearchTerm, }); }); - it('displays dropdown with branches and tags', async () => { + it('displays dropdown with branches and tags', () => { const filteredRefLength = mockFilteredRefs.Tags.length + mockFilteredRefs.Branches.length; expect(findRefsDropdownItems()).toHaveLength(filteredRefLength); diff --git a/spec/frontend/ci/pipeline_schedules/components/delete_pipeline_schedule_modal_spec.js b/spec/frontend/ci/pipeline_schedules/components/delete_pipeline_schedule_modal_spec.js index c45267e5a47..e48f556c246 100644 --- a/spec/frontend/ci/pipeline_schedules/components/delete_pipeline_schedule_modal_spec.js +++ b/spec/frontend/ci/pipeline_schedules/components/delete_pipeline_schedule_modal_spec.js @@ -20,13 +20,13 @@ describe('Delete pipeline schedule modal', () => { createComponent(); }); - it('emits the deleteSchedule event', async () => { + it('emits the deleteSchedule event', () => { findModal().vm.$emit('primary'); expect(wrapper.emitted()).toEqual({ deleteSchedule: [[]] }); }); - it('emits the hideModal event', async () => { + it('emits the hideModal event', () => { findModal().vm.$emit('hide'); expect(wrapper.emitted()).toEqual({ hideModal: [[]] }); diff --git a/spec/frontend/ci/pipeline_schedules/components/take_ownership_modal_spec.js b/spec/frontend/ci/pipeline_schedules/components/take_ownership_modal_spec.js index e3965d13c19..7cc254b7653 100644 --- a/spec/frontend/ci/pipeline_schedules/components/take_ownership_modal_spec.js +++ b/spec/frontend/ci/pipeline_schedules/components/take_ownership_modal_spec.js @@ -26,13 +26,13 @@ describe('Take ownership modal', () => { ); }); - it('emits the takeOwnership event', async () => { + it('emits the takeOwnership event', () => { findModal().vm.$emit('primary'); expect(wrapper.emitted()).toEqual({ takeOwnership: [[]] }); }); - it('emits the hideModal event', async () => { + it('emits the hideModal event', () => { findModal().vm.$emit('hide'); expect(wrapper.emitted()).toEqual({ hideModal: [[]] }); diff --git a/spec/frontend/editor/utils_spec.js b/spec/frontend/editor/utils_spec.js index 13b8a9804b0..c9d6cbcaaa6 100644 --- a/spec/frontend/editor/utils_spec.js +++ b/spec/frontend/editor/utils_spec.js @@ -1,6 +1,8 @@ import { editor as monacoEditor } from 'monaco-editor'; import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import * as utils from '~/editor/utils'; +import languages from '~/ide/lib/languages'; +import { registerLanguages } from '~/ide/utils'; import { DEFAULT_THEME } from '~/ide/lib/themes'; describe('Source Editor utils', () => { @@ -53,13 +55,19 @@ describe('Source Editor utils', () => { }); describe('getBlobLanguage', () => { + beforeEach(() => { + registerLanguages(...languages); + }); + it.each` - path | expectedLanguage - ${'foo.js'} | ${'javascript'} - ${'foo.js.rb'} | ${'ruby'} - ${'foo.bar'} | ${'plaintext'} - ${undefined} | ${'plaintext'} - ${'foo/bar/foo.js'} | ${'javascript'} + path | expectedLanguage + ${'foo.js'} | ${'javascript'} + ${'foo.js.rb'} | ${'ruby'} + ${'foo.bar'} | ${'plaintext'} + ${undefined} | ${'plaintext'} + ${'foo/bar/foo.js'} | ${'javascript'} + ${'CODEOWNERS'} | ${'codeowners'} + ${'.gitlab/CODEOWNERS'} | ${'codeowners'} `(`returns '$expectedLanguage' for '$path' path`, ({ path, expectedLanguage }) => { const language = utils.getBlobLanguage(path); diff --git a/spec/frontend/ide/lib/languages/codeowners_spec.js b/spec/frontend/ide/lib/languages/codeowners_spec.js new file mode 100644 index 00000000000..9b204190fdf --- /dev/null +++ b/spec/frontend/ide/lib/languages/codeowners_spec.js @@ -0,0 +1,26 @@ +import { editor } from 'monaco-editor'; +import codeowners from '~/ide/lib/languages/codeowners'; +import { registerLanguages } from '~/ide/utils'; + +describe('tokenization for CODEOWNERS files', () => { + beforeEach(() => { + registerLanguages(codeowners); + }); + + it.each([ + ['## Foo bar comment', [[{ language: 'codeowners', offset: 0, type: 'comment.codeowners' }]]], + [ + '/foo/bar @gsamsa', + [ + [ + { language: 'codeowners', offset: 0, type: 'regexp.codeowners' }, + { language: 'codeowners', offset: 8, type: 'source.codeowners' }, + { language: 'codeowners', offset: 9, type: 'variable.value.codeowners' }, + ], + ], + ], + ['^[Section name]', [[{ language: 'codeowners', offset: 0, type: 'namespace.codeowners' }]]], + ])('%s', (string, tokens) => { + expect(editor.tokenize(string, 'codeowners')).toEqual(tokens); + }); +}); |