diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-26 06:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-26 06:09:01 +0300 |
commit | baaa5c45c022d394bf1478d462a3b1aea413b7ed (patch) | |
tree | c18f52b77c9b4a92f504dfd1060e7495e293a937 /spec/frontend | |
parent | b3618e799d30ae6df5c55e47b8ec8ebedb1af5a0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
3 files changed, 58 insertions, 2 deletions
diff --git a/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js b/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js index 20c4a0fbf6a..2f934898ef1 100644 --- a/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js +++ b/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js @@ -177,6 +177,10 @@ describe('Pipeline Editor | Commit section', () => { expect(wrapper.emitted('commit')[0]).toEqual([{ type: COMMIT_SUCCESS }]); }); + it('emits an event to refetch the commit sha', () => { + expect(wrapper.emitted('updateCommitSha')).toHaveLength(1); + }); + it('shows no saving state', () => { expect(findCommitBtnLoadingIcon().exists()).toBe(false); }); @@ -216,6 +220,10 @@ describe('Pipeline Editor | Commit section', () => { }, }); }); + + it('does not emit an event to refetch the commit sha', () => { + expect(wrapper.emitted('updateCommitSha')).toBeUndefined(); + }); }); describe('when the user commits changes to open a new merge request', () => { diff --git a/spec/frontend/pipeline_editor/mock_data.js b/spec/frontend/pipeline_editor/mock_data.js index 19ad4f051ba..310727212a9 100644 --- a/spec/frontend/pipeline_editor/mock_data.js +++ b/spec/frontend/pipeline_editor/mock_data.js @@ -173,6 +173,29 @@ export const mockCommitShaResults = { }, }; +export const mockNewCommitShaResults = { + data: { + project: { + pipelines: { + nodes: [ + { + id: 'gid://gitlab/Ci::Pipeline/2', + sha: 'eeff1122', + path: `/${mockProjectFullPath}/-/pipelines/489`, + commitPath: `/${mockProjectFullPath}/-/commit/bb1abcfe3d8a3f67a8ab9fc00207d468f3022bee`, + }, + { + id: 'gid://gitlab/Ci::Pipeline/1', + sha: mockCommitSha, + path: `/${mockProjectFullPath}/-/pipelines/488`, + commitPath: `/${mockProjectFullPath}/-/commit/d0d56d363d8a3f67a8ab9fc00207d468f30032ca`, + }, + ], + }, + }, + }, +}; + export const mockEmptyCommitShaResults = { data: { project: { diff --git a/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js b/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js index affe45f1b1d..2c9bedc6e76 100644 --- a/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js +++ b/spec/frontend/pipeline_editor/pipeline_editor_app_spec.js @@ -29,6 +29,7 @@ import { mockCommitShaResults, mockDefaultBranch, mockEmptyCommitShaResults, + mockNewCommitShaResults, mockProjectFullPath, } from './mock_data'; @@ -282,7 +283,7 @@ describe('Pipeline editor app component', () => { expect(window.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'smooth' }); }); - it('polls for commit sha while pipeline data is not yet available', async () => { + it('polls for commit sha while pipeline data is not yet available for newly committed branch', async () => { jest .spyOn(wrapper.vm.$apollo.queries.commitSha, 'startPolling') .mockImplementation(jest.fn()); @@ -295,7 +296,19 @@ describe('Pipeline editor app component', () => { expect(wrapper.vm.$apollo.queries.commitSha.startPolling).toHaveBeenCalledTimes(1); }); - it('stops polling for commit sha when pipeline data is available', async () => { + it('polls for commit sha while pipeline data is not yet available for current branch', async () => { + jest + .spyOn(wrapper.vm.$apollo.queries.commitSha, 'startPolling') + .mockImplementation(jest.fn()); + + // simulate a commit to the current branch + findEditorHome().vm.$emit('updateCommitSha'); + await waitForPromises(); + + expect(wrapper.vm.$apollo.queries.commitSha.startPolling).toHaveBeenCalledTimes(1); + }); + + it('stops polling for commit sha when pipeline data is available for newly committed branch', async () => { jest .spyOn(wrapper.vm.$apollo.queries.commitSha, 'stopPolling') .mockImplementation(jest.fn()); @@ -305,6 +318,18 @@ describe('Pipeline editor app component', () => { expect(wrapper.vm.$apollo.queries.commitSha.stopPolling).toHaveBeenCalledTimes(1); }); + + it('stops polling for commit sha when pipeline data is available for current branch', async () => { + jest + .spyOn(wrapper.vm.$apollo.queries.commitSha, 'stopPolling') + .mockImplementation(jest.fn()); + + mockLatestCommitShaQuery.mockResolvedValue(mockNewCommitShaResults); + findEditorHome().vm.$emit('updateCommitSha'); + await waitForPromises(); + + expect(wrapper.vm.$apollo.queries.commitSha.stopPolling).toHaveBeenCalledTimes(1); + }); }); describe('and the commit mutation fails', () => { |