diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-15 21:09:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-15 21:09:13 +0300 |
commit | 2eafcb0673f7d501d9e3fabde6e950a5dcc24fc2 (patch) | |
tree | e209665d6c7316e8cbc526023675429cb2beebbe /spec/frontend/diffs | |
parent | 4279dbc29c63f614e6439e104204165ff0517a59 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/diffs')
-rw-r--r-- | spec/frontend/diffs/store/actions_spec.js | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js index bf75f956d7f..87366cdbfc5 100644 --- a/spec/frontend/diffs/store/actions_spec.js +++ b/spec/frontend/diffs/store/actions_spec.js @@ -183,11 +183,11 @@ describe('DiffsStoreActions', () => { beforeEach(() => { delete noFilesData.diff_files; - - mock.onGet(endpointMetadata).reply(200, diffMetadata); }); it('should fetch diff meta information', () => { + mock.onGet(endpointMetadata).reply(200, diffMetadata); + return testAction( diffActions.fetchDiffFilesMeta, {}, @@ -206,6 +206,40 @@ describe('DiffsStoreActions', () => { [], ); }); + + it('should show a warning on 404 reponse', async () => { + mock.onGet(endpointMetadata).reply(404); + + await testAction( + diffActions.fetchDiffFilesMeta, + {}, + { endpointMetadata, diffViewType: 'inline', showWhitespace: true }, + [{ type: types.SET_LOADING, payload: true }], + [], + ); + + expect(createAlert).toHaveBeenCalledTimes(1); + expect(createAlert).toHaveBeenCalledWith({ + message: expect.stringMatching( + 'Building your merge request. Wait a few moments, then refresh this page.', + ), + variant: 'warning', + }); + }); + + it('should show no warning on any other status code', async () => { + mock.onGet(endpointMetadata).reply(500); + + await testAction( + diffActions.fetchDiffFilesMeta, + {}, + { endpointMetadata, diffViewType: 'inline', showWhitespace: true }, + [{ type: types.SET_LOADING, payload: true }], + [], + ); + + expect(createAlert).not.toHaveBeenCalled(); + }); }); describe('fetchCoverageFiles', () => { |