diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-03 09:08:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-03 09:08:29 +0300 |
commit | 829c7542e8927a832df7a39ef241882c39c93399 (patch) | |
tree | aaaae42f1e43f15d6ab0641d11720644a59473e3 /spec | |
parent | 173b547fb98ab12ae41f295915453e598be3a647 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/boards/components/board_content_spec.js | 11 | ||||
-rw-r--r-- | spec/frontend/boards/components/board_form_spec.js | 39 | ||||
-rw-r--r-- | spec/frontend/notebook/index_spec.js | 6 |
3 files changed, 51 insertions, 5 deletions
diff --git a/spec/frontend/boards/components/board_content_spec.js b/spec/frontend/boards/components/board_content_spec.js index 14bf31d9f55..1bc2a41481d 100644 --- a/spec/frontend/boards/components/board_content_spec.js +++ b/spec/frontend/boards/components/board_content_spec.js @@ -4,6 +4,8 @@ import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import Draggable from 'vuedraggable'; import Vuex from 'vuex'; + +import eventHub from '~/boards/eventhub'; import waitForPromises from 'helpers/wait_for_promises'; import createMockApollo from 'helpers/mock_apollo_helper'; import EpicsSwimlanes from 'ee_component/boards/components/epics_swimlanes.vue'; @@ -204,5 +206,14 @@ describe('BoardContent', () => { it('renders BoardContentSidebar', () => { expect(wrapper.findComponent(BoardContentSidebar).exists()).toBe(true); }); + + it('refetches lists when updateBoard event is received', async () => { + jest.spyOn(eventHub, '$on').mockImplementation(() => {}); + + createComponent({ isApolloBoard: true }); + await waitForPromises(); + + expect(eventHub.$on).toHaveBeenCalledWith('updateBoard', wrapper.vm.refetchLists); + }); }); }); diff --git a/spec/frontend/boards/components/board_form_spec.js b/spec/frontend/boards/components/board_form_spec.js index 3302fb2ce43..984d15210fa 100644 --- a/spec/frontend/boards/components/board_form_spec.js +++ b/spec/frontend/boards/components/board_form_spec.js @@ -10,12 +10,14 @@ import { formType } from '~/boards/constants'; import createBoardMutation from '~/boards/graphql/board_create.mutation.graphql'; import destroyBoardMutation from '~/boards/graphql/board_destroy.mutation.graphql'; import updateBoardMutation from '~/boards/graphql/board_update.mutation.graphql'; +import eventHub from '~/boards/eventhub'; import { visitUrl } from '~/lib/utils/url_utility'; jest.mock('~/lib/utils/url_utility', () => ({ ...jest.requireActual('~/lib/utils/url_utility'), visitUrl: jest.fn().mockName('visitUrlMock'), })); +jest.mock('~/boards/eventhub'); Vue.use(Vuex); @@ -207,7 +209,7 @@ describe('BoardForm', () => { }); describe('when Apollo boards FF is on', () => { - it('calls a correct GraphQL mutation and emits addBoard event', async () => { + it('calls a correct GraphQL mutation and emits addBoard event when creating a board', async () => { createComponent( { canAdminBoard: true, currentPage: formType.new }, { isApolloBoard: true }, @@ -328,6 +330,41 @@ describe('BoardForm', () => { expect(setBoardMock).not.toHaveBeenCalled(); expect(setErrorMock).toHaveBeenCalled(); }); + + describe('when Apollo boards FF is on', () => { + it('calls a correct GraphQL mutation and emits updateBoard event when updating a board', async () => { + mutate = jest.fn().mockResolvedValue({ + data: { + updateBoard: { board: { id: 'gid://gitlab/Board/321', webPath: 'test-path' } }, + }, + }); + setWindowLocation('https://test/boards/1'); + + createComponent( + { canAdminBoard: true, currentPage: formType.edit }, + { isApolloBoard: true }, + ); + findInput().trigger('keyup.enter', { metaKey: true }); + + await waitForPromises(); + + expect(mutate).toHaveBeenCalledWith({ + mutation: updateBoardMutation, + variables: { + input: expect.objectContaining({ + id: currentBoard.id, + }), + }, + }); + + await waitForPromises(); + expect(eventHub.$emit).toHaveBeenCalledTimes(1); + expect(eventHub.$emit).toHaveBeenCalledWith('updateBoard', { + id: 'gid://gitlab/Board/321', + webPath: 'test-path', + }); + }); + }); }); describe('when deleting a board', () => { diff --git a/spec/frontend/notebook/index_spec.js b/spec/frontend/notebook/index_spec.js index b79000a3505..3c73d420703 100644 --- a/spec/frontend/notebook/index_spec.js +++ b/spec/frontend/notebook/index_spec.js @@ -1,16 +1,14 @@ import { mount } from '@vue/test-utils'; -import Vue, { nextTick } from 'vue'; +import { nextTick } from 'vue'; import json from 'test_fixtures/blob/notebook/basic.json'; import jsonWithWorksheet from 'test_fixtures/blob/notebook/worksheets.json'; import Notebook from '~/notebook/index.vue'; -const Component = Vue.extend(Notebook); - describe('Notebook component', () => { let vm; function buildComponent(notebook) { - return mount(Component, { + return mount(Notebook, { propsData: { notebook }, provide: { relativeRawPath: '' }, }).vm; |