summaryrefslogtreecommitdiff
path: root/spec/frontend/pipelines/pipelines_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/pipelines/pipelines_spec.js')
-rw-r--r--spec/frontend/pipelines/pipelines_spec.js67
1 files changed, 47 insertions, 20 deletions
diff --git a/spec/frontend/pipelines/pipelines_spec.js b/spec/frontend/pipelines/pipelines_spec.js
index 351572fc83a..2523b901506 100644
--- a/spec/frontend/pipelines/pipelines_spec.js
+++ b/spec/frontend/pipelines/pipelines_spec.js
@@ -13,6 +13,7 @@ import waitForPromises from 'helpers/wait_for_promises';
import Api from '~/api';
import { createAlert, VARIANT_WARNING } from '~/flash';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status';
import NavigationControls from '~/pipelines/components/pipelines_list/nav_controls.vue';
import PipelinesComponent from '~/pipelines/components/pipelines_list/pipelines.vue';
import PipelinesCiTemplates from '~/pipelines/components/pipelines_list/empty_state/pipelines_ci_templates.vue';
@@ -141,7 +142,7 @@ describe('Pipelines', () => {
beforeEach(() => {
mock
.onGet(mockPipelinesEndpoint, { params: { scope: 'all', page: '1' } })
- .reply(200, mockPipelinesResponse);
+ .reply(HTTP_STATUS_OK, mockPipelinesResponse);
});
describe('when user has no permissions', () => {
@@ -233,7 +234,7 @@ describe('Pipelines', () => {
beforeEach(async () => {
mock
.onGet(mockPipelinesEndpoint, { params: { scope: 'finished', page: '1' } })
- .reply(200, {
+ .reply(HTTP_STATUS_OK, {
pipelines: [mockFinishedPipeline],
count: mockPipelinesResponse.count,
});
@@ -277,7 +278,7 @@ describe('Pipelines', () => {
beforeEach(async () => {
mock
.onGet(mockPipelinesEndpoint, { params: { scope: 'branches', page: '1' } })
- .reply(200, {
+ .reply(HTTP_STATUS_OK, {
pipelines: [],
count: mockPipelinesResponse.count,
});
@@ -320,7 +321,7 @@ describe('Pipelines', () => {
.onGet(mockPipelinesEndpoint, {
params: expectedParams,
})
- .replyOnce(200, {
+ .replyOnce(HTTP_STATUS_OK, {
pipelines: [mockFilteredPipeline],
count: mockPipelinesResponse.count,
});
@@ -398,7 +399,7 @@ describe('Pipelines', () => {
beforeEach(async () => {
mock.onGet(mockPipelinesEndpoint, { params: { scope: 'all', page: '1' } }).reply(
- 200,
+ HTTP_STATUS_OK,
{
pipelines: firstPage,
count: mockPipelinesResponse.count,
@@ -406,7 +407,7 @@ describe('Pipelines', () => {
mockPageHeaders({ page: 1 }),
);
mock.onGet(mockPipelinesEndpoint, { params: { scope: 'all', page: '2' } }).reply(
- 200,
+ HTTP_STATUS_OK,
{
pipelines: secondPage,
count: mockPipelinesResponse.count,
@@ -448,6 +449,26 @@ describe('Pipelines', () => {
`${window.location.pathname}?page=2&scope=all`,
);
});
+
+ it('should reset page to 1 when filtering pipelines', () => {
+ expect(window.history.pushState).toHaveBeenCalledTimes(1);
+ expect(window.history.pushState).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.anything(),
+ `${window.location.pathname}?page=2&scope=all`,
+ );
+
+ findFilteredSearch().vm.$emit('submit', [
+ { type: 'status', value: { data: 'success', operator: '=' } },
+ ]);
+
+ expect(window.history.pushState).toHaveBeenCalledTimes(2);
+ expect(window.history.pushState).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.anything(),
+ `${window.location.pathname}?page=1&scope=all&status=success`,
+ );
+ });
});
});
@@ -461,13 +482,13 @@ describe('Pipelines', () => {
// Mock no pipelines in the first attempt
mock
.onGet(mockPipelinesEndpoint, { params: { scope: 'all', page: '1' } })
- .replyOnce(200, emptyResponse, {
+ .replyOnce(HTTP_STATUS_OK, emptyResponse, {
'POLL-INTERVAL': 100,
});
// Mock pipelines in the next attempt
mock
.onGet(mockPipelinesEndpoint, { params: { scope: 'all', page: '1' } })
- .reply(200, mockPipelinesResponse, {
+ .reply(HTTP_STATUS_OK, mockPipelinesResponse, {
'POLL-INTERVAL': 100,
});
});
@@ -508,10 +529,12 @@ describe('Pipelines', () => {
describe('when no pipelines exist', () => {
beforeEach(() => {
- mock.onGet(mockPipelinesEndpoint, { params: { scope: 'all', page: '1' } }).reply(200, {
- pipelines: [],
- count: { all: '0' },
- });
+ mock
+ .onGet(mockPipelinesEndpoint, { params: { scope: 'all', page: '1' } })
+ .reply(HTTP_STATUS_OK, {
+ pipelines: [],
+ count: { all: '0' },
+ });
});
describe('when CI is enabled and user has permissions', () => {
@@ -550,10 +573,12 @@ describe('Pipelines', () => {
});
it('renders tab empty state finished scope', async () => {
- mock.onGet(mockPipelinesEndpoint, { params: { scope: 'finished', page: '1' } }).reply(200, {
- pipelines: [],
- count: { all: '0' },
- });
+ mock
+ .onGet(mockPipelinesEndpoint, { params: { scope: 'finished', page: '1' } })
+ .reply(HTTP_STATUS_OK, {
+ pipelines: [],
+ count: { all: '0' },
+ });
findNavigationTabs().vm.$emit('onChangeTab', 'finished');
@@ -643,7 +668,7 @@ describe('Pipelines', () => {
beforeEach(() => {
mock.onGet(mockPipelinesEndpoint, { scope: 'all', page: '1' }).reply(
- 200,
+ HTTP_STATUS_OK,
{
pipelines: [mockPipelineWithStages],
count: { all: '1' },
@@ -653,7 +678,9 @@ describe('Pipelines', () => {
},
);
- mock.onGet(mockPipelineWithStages.details.stages[0].dropdown_path).reply(200, stageReply);
+ mock
+ .onGet(mockPipelineWithStages.details.stages[0].dropdown_path)
+ .reply(HTTP_STATUS_OK, stageReply);
createComponent();
@@ -664,7 +691,7 @@ describe('Pipelines', () => {
describe('when a request is being made', () => {
beforeEach(async () => {
- mock.onGet(mockPipelinesEndpoint).reply(200, mockPipelinesResponse);
+ mock.onGet(mockPipelinesEndpoint).reply(HTTP_STATUS_OK, mockPipelinesResponse);
await waitForPromises();
});
@@ -702,7 +729,7 @@ describe('Pipelines', () => {
describe('when pipelines cannot be loaded', () => {
beforeEach(async () => {
- mock.onGet(mockPipelinesEndpoint).reply(500, {});
+ mock.onGet(mockPipelinesEndpoint).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, {});
});
describe('when user has no permissions', () => {