From 4c3f961bd94656e64cee5b0ad07b3f49a84338a5 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 18 Jul 2023 12:10:09 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../components/commit/commit_section_spec.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'spec/frontend/ci/pipeline_editor') diff --git a/spec/frontend/ci/pipeline_editor/components/commit/commit_section_spec.js b/spec/frontend/ci/pipeline_editor/components/commit/commit_section_spec.js index 8834231aaef..7a9b4ffdce8 100644 --- a/spec/frontend/ci/pipeline_editor/components/commit/commit_section_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/commit/commit_section_spec.js @@ -17,7 +17,8 @@ import { import { resolvers } from '~/ci/pipeline_editor/graphql/resolvers'; import commitCreate from '~/ci/pipeline_editor/graphql/mutations/commit_ci_file.mutation.graphql'; import getCurrentBranch from '~/ci/pipeline_editor/graphql/queries/client/current_branch.query.graphql'; -import updatePipelineEtag from '~/ci/pipeline_editor/graphql/mutations/client/update_pipeline_etag.mutation.graphql'; +import getPipelineEtag from '~/ci/pipeline_editor/graphql/queries/client/pipeline_etag.query.graphql'; + import { mockCiConfigPath, mockCiYml, @@ -253,18 +254,20 @@ describe('Pipeline Editor | Commit section', () => { describe('when the commit returns a different etag path', () => { beforeEach(async () => { createComponentWithApollo(); - jest.spyOn(wrapper.vm.$apollo, 'mutate'); + jest.spyOn(mockApollo.clients.defaultClient.cache, 'writeQuery'); + mockMutateCommitData.mockResolvedValue(mockCommitCreateResponseNewEtag); await submitCommit(); }); - it('calls the client mutation to update the etag', () => { - // 1:Commit submission, 2:etag update, 3:currentBranch update, 4:lastCommit update - expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledTimes(4); - expect(wrapper.vm.$apollo.mutate).toHaveBeenNthCalledWith(2, { - mutation: updatePipelineEtag, - variables: { - pipelineEtag: mockCommitCreateResponseNewEtag.data.commitCreate.commitPipelinePath, + it('calls the client mutation to update the etag in the cache', () => { + expect(mockApollo.clients.defaultClient.cache.writeQuery).toHaveBeenCalledWith({ + query: getPipelineEtag, + data: { + etags: { + __typename: 'EtagValues', + pipeline: mockCommitCreateResponseNewEtag.data.commitCreate.commitPipelinePath, + }, }, }); }); -- cgit v1.2.3