summaryrefslogtreecommitdiff
path: root/spec/contracts/consumer
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 08:17:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 08:17:02 +0000
commitb39512ed755239198a9c294b6a45e65c05900235 (patch)
treed234a3efade1de67c46b9e5a38ce813627726aa7 /spec/contracts/consumer
parentd31474cf3b17ece37939d20082b07f6657cc79a9 (diff)
downloadgitlab-ce-b39512ed755239198a9c294b6a45e65c05900235.tar.gz
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'spec/contracts/consumer')
-rw-r--r--spec/contracts/consumer/endpoints/project/pipelines.js16
-rw-r--r--spec/contracts/consumer/fixtures/project/merge_request/diffs_batch.fixture.js10
-rw-r--r--spec/contracts/consumer/fixtures/project/merge_request/diffs_metadata.fixture.js10
-rw-r--r--spec/contracts/consumer/fixtures/project/merge_request/discussions.fixture.js10
-rw-r--r--spec/contracts/consumer/fixtures/project/pipeline/create_a_new_pipeline.fixture.js39
-rw-r--r--spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js24
-rw-r--r--spec/contracts/consumer/fixtures/project/pipeline/get_list_project_pipelines.fixture.js10
-rw-r--r--spec/contracts/consumer/fixtures/project/pipeline/get_pipeline_header_data.fixture.js9
-rw-r--r--spec/contracts/consumer/fixtures/project/pipeline_schedule/update_pipeline_schedule.fixture.js44
-rw-r--r--spec/contracts/consumer/helpers/common_regex_patterns.js1
-rw-r--r--spec/contracts/consumer/resources/api/pipeline_schedules.js26
-rw-r--r--spec/contracts/consumer/resources/api/project/merge_requests.js (renamed from spec/contracts/consumer/endpoints/project/merge_requests.js)14
-rw-r--r--spec/contracts/consumer/resources/api/project/pipelines.js34
-rw-r--r--spec/contracts/consumer/resources/graphql/pipelines.js21
-rw-r--r--spec/contracts/consumer/specs/project/merge_request/show.spec.js36
-rw-r--r--spec/contracts/consumer/specs/project/pipeline/index.spec.js16
-rw-r--r--spec/contracts/consumer/specs/project/pipeline/new.spec.js41
-rw-r--r--spec/contracts/consumer/specs/project/pipeline/show.spec.js54
-rw-r--r--spec/contracts/consumer/specs/project/pipeline_schedule/edit.spec.js41
19 files changed, 370 insertions, 86 deletions
diff --git a/spec/contracts/consumer/endpoints/project/pipelines.js b/spec/contracts/consumer/endpoints/project/pipelines.js
deleted file mode 100644
index 33758dee75b..00000000000
--- a/spec/contracts/consumer/endpoints/project/pipelines.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { request } from 'axios';
-
-export function getProjectPipelines(endpoint) {
- const { url } = endpoint;
-
- return request({
- method: 'GET',
- baseURL: url,
- url: '/gitlab-org/gitlab-qa/-/pipelines.json',
- headers: { Accept: '*/*' },
- params: {
- scope: 'all',
- page: 1,
- },
- }).then((response) => response.data);
-}
diff --git a/spec/contracts/consumer/fixtures/project/merge_request/diffs_batch.fixture.js b/spec/contracts/consumer/fixtures/project/merge_request/diffs_batch.fixture.js
index b53e4bb335d..673aad721b3 100644
--- a/spec/contracts/consumer/fixtures/project/merge_request/diffs_batch.fixture.js
+++ b/spec/contracts/consumer/fixtures/project/merge_request/diffs_batch.fixture.js
@@ -1,5 +1,3 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { Matchers } from '@pact-foundation/pact';
const body = {
@@ -73,8 +71,12 @@ const DiffsBatch = {
body,
},
- request: {
+ scenario: {
+ state: 'a merge request with diffs exists',
uponReceiving: 'a request for diff lines',
+ },
+
+ request: {
withRequest: {
method: 'GET',
path: '/gitlab-org/gitlab-qa/-/merge_requests/1/diffs_batch.json',
@@ -87,5 +89,3 @@ const DiffsBatch = {
};
export { DiffsBatch };
-
-/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/consumer/fixtures/project/merge_request/diffs_metadata.fixture.js b/spec/contracts/consumer/fixtures/project/merge_request/diffs_metadata.fixture.js
index 39dbcf78ee7..2fee4a02023 100644
--- a/spec/contracts/consumer/fixtures/project/merge_request/diffs_metadata.fixture.js
+++ b/spec/contracts/consumer/fixtures/project/merge_request/diffs_metadata.fixture.js
@@ -1,5 +1,3 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { Matchers } from '@pact-foundation/pact';
const body = {
@@ -81,8 +79,12 @@ const DiffsMetadata = {
body,
},
+ scenario: {
+ state: 'a merge request exists',
+ uponReceiving: 'a request for diffs metadata',
+ },
+
request: {
- uponReceiving: 'a request for Diffs Metadata',
withRequest: {
method: 'GET',
path: '/gitlab-org/gitlab-qa/-/merge_requests/1/diffs_metadata.json',
@@ -94,5 +96,3 @@ const DiffsMetadata = {
};
export { DiffsMetadata };
-
-/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/consumer/fixtures/project/merge_request/discussions.fixture.js b/spec/contracts/consumer/fixtures/project/merge_request/discussions.fixture.js
index af0962a01cb..8c392395e1c 100644
--- a/spec/contracts/consumer/fixtures/project/merge_request/discussions.fixture.js
+++ b/spec/contracts/consumer/fixtures/project/merge_request/discussions.fixture.js
@@ -1,5 +1,3 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { Matchers } from '@pact-foundation/pact';
const body = Matchers.eachLike({
@@ -70,8 +68,12 @@ const Discussions = {
body,
},
- request: {
+ scenario: {
+ state: 'a merge request with discussions exists',
uponReceiving: 'a request for discussions',
+ },
+
+ request: {
withRequest: {
method: 'GET',
path: '/gitlab-org/gitlab-qa/-/merge_requests/1/discussions.json',
@@ -83,5 +85,3 @@ const Discussions = {
};
export { Discussions };
-
-/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/consumer/fixtures/project/pipeline/create_a_new_pipeline.fixture.js b/spec/contracts/consumer/fixtures/project/pipeline/create_a_new_pipeline.fixture.js
new file mode 100644
index 00000000000..68063d2fb0c
--- /dev/null
+++ b/spec/contracts/consumer/fixtures/project/pipeline/create_a_new_pipeline.fixture.js
@@ -0,0 +1,39 @@
+import { Matchers } from '@pact-foundation/pact';
+import { REDIRECT_HTML } from '../../../helpers/common_regex_patterns';
+
+const body = Matchers.term({
+ matcher: REDIRECT_HTML,
+ generate:
+ '<html><body>You are being <a href="http://example.org/gitlab-org/gitlab-qa/-/pipelines/5">redirected</a>.</body></html>',
+});
+
+const NewProjectPipeline = {
+ success: {
+ status: 302,
+ headers: {
+ 'Content-Type': 'text/html; charset=utf-8',
+ },
+ body,
+ },
+
+ scenario: {
+ state: 'a project with a valid .gitlab-ci.yml configuration exists',
+ uponReceiving: 'a request to create a new pipeline',
+ },
+
+ request: {
+ withRequest: {
+ method: 'POST',
+ path: '/gitlab-org/gitlab-qa/-/pipelines',
+ headers: {
+ Accept: '*/*',
+ 'Content-Type': 'application/json; charset=utf-8',
+ },
+ body: {
+ ref: 'master',
+ },
+ },
+ },
+};
+
+export { NewProjectPipeline };
diff --git a/spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js b/spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js
new file mode 100644
index 00000000000..2e3e7355b99
--- /dev/null
+++ b/spec/contracts/consumer/fixtures/project/pipeline/delete_pipeline.fixture.js
@@ -0,0 +1,24 @@
+const DeletePipeline = {
+ success: {
+ status: 200,
+ headers: {
+ 'Content-Type': 'application/json; charset=utf-8',
+ },
+ },
+
+ scenario: {
+ state: 'a pipeline for a project exists',
+ uponReceiving: 'a request to delete the pipeline',
+ },
+
+ request: {
+ method: 'POST',
+ path: '/api/graphql',
+ },
+
+ variables: {
+ id: 'gid://gitlab/Ci::Pipeline/316112',
+ },
+};
+
+export { DeletePipeline };
diff --git a/spec/contracts/consumer/fixtures/project/pipeline/get_list_project_pipelines.fixture.js b/spec/contracts/consumer/fixtures/project/pipeline/get_list_project_pipelines.fixture.js
index 8a7663325b9..a982e927572 100644
--- a/spec/contracts/consumer/fixtures/project/pipeline/get_list_project_pipelines.fixture.js
+++ b/spec/contracts/consumer/fixtures/project/pipeline/get_list_project_pipelines.fixture.js
@@ -1,5 +1,3 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { Matchers } from '@pact-foundation/pact';
import {
URL,
@@ -225,8 +223,12 @@ const ProjectPipelines = {
body,
},
- request: {
+ scenario: {
+ state: 'a few pipelines for a project exists',
uponReceiving: 'a request for a list of project pipelines',
+ },
+
+ request: {
withRequest: {
method: 'GET',
path: '/gitlab-org/gitlab-qa/-/pipelines.json',
@@ -239,5 +241,3 @@ const ProjectPipelines = {
};
export { ProjectPipelines };
-
-/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/consumer/fixtures/project/pipeline/get_pipeline_header_data.fixture.js b/spec/contracts/consumer/fixtures/project/pipeline/get_pipeline_header_data.fixture.js
index f51ed9c2c74..b14a230d2e0 100644
--- a/spec/contracts/consumer/fixtures/project/pipeline/get_pipeline_header_data.fixture.js
+++ b/spec/contracts/consumer/fixtures/project/pipeline/get_pipeline_header_data.fixture.js
@@ -1,5 +1,3 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { Matchers } from '@pact-foundation/pact';
import {
JOB_STATUSES,
@@ -83,6 +81,11 @@ const PipelineHeaderData = {
body,
},
+ scenario: {
+ state: 'a pipeline for a project exists',
+ uponReceiving: 'a request for the pipeline header data',
+ },
+
request: {
method: 'POST',
path: '/api/graphql',
@@ -95,5 +98,3 @@ const PipelineHeaderData = {
};
export { PipelineHeaderData };
-
-/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/consumer/fixtures/project/pipeline_schedule/update_pipeline_schedule.fixture.js b/spec/contracts/consumer/fixtures/project/pipeline_schedule/update_pipeline_schedule.fixture.js
new file mode 100644
index 00000000000..acfab14851a
--- /dev/null
+++ b/spec/contracts/consumer/fixtures/project/pipeline_schedule/update_pipeline_schedule.fixture.js
@@ -0,0 +1,44 @@
+import { Matchers } from '@pact-foundation/pact';
+import { REDIRECT_HTML } from '../../../helpers/common_regex_patterns';
+
+const body = Matchers.term({
+ matcher: REDIRECT_HTML,
+ generate:
+ '<html><body>You are being <a href="http://example.org/gitlab-org/gitlab-qa/-/pipelines/5">redirected</a>.</body></html>',
+});
+
+const UpdatePipelineSchedule = {
+ success: {
+ status: 302,
+ headers: {
+ 'Content-Type': 'text/html; charset=utf-8',
+ },
+ body,
+ },
+
+ scenario: {
+ state: 'a project with a pipeline schedule exists',
+ uponReceiving: 'a request to edit a pipeline schedule',
+ },
+
+ request: {
+ withRequest: {
+ method: 'PUT',
+ path: '/gitlab-org/gitlab-qa/-/pipeline_schedules/25',
+ headers: {
+ Accept: '*/*',
+ 'Content-Type': 'application/json; charset=utf-8',
+ },
+ body: {
+ schedule: {
+ description: 'bar',
+ cron: '0 1 * * *',
+ cron_timezone: 'UTC',
+ active: true,
+ },
+ },
+ },
+ },
+};
+
+export { UpdatePipelineSchedule };
diff --git a/spec/contracts/consumer/helpers/common_regex_patterns.js b/spec/contracts/consumer/helpers/common_regex_patterns.js
index 664a71ab8a9..78dfeb7748f 100644
--- a/spec/contracts/consumer/helpers/common_regex_patterns.js
+++ b/spec/contracts/consumer/helpers/common_regex_patterns.js
@@ -3,6 +3,7 @@
*/
export const URL = '^(http|https)://[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$';
export const URL_PATH = '^/[a-zA-Z0-9#-=?_]+$';
+export const REDIRECT_HTML = 'You are being <a href=\\"(.)+\\">redirected</a>.';
// Pipelines
export const PIPELINE_GROUPS =
diff --git a/spec/contracts/consumer/resources/api/pipeline_schedules.js b/spec/contracts/consumer/resources/api/pipeline_schedules.js
new file mode 100644
index 00000000000..ad04e59b9cd
--- /dev/null
+++ b/spec/contracts/consumer/resources/api/pipeline_schedules.js
@@ -0,0 +1,26 @@
+import axios from 'axios';
+
+export async function updatePipelineSchedule(endpoint) {
+ const { url } = endpoint;
+
+ return axios({
+ method: 'PUT',
+ baseURL: url,
+ url: '/gitlab-org/gitlab-qa/-/pipeline_schedules/25',
+ headers: {
+ Accept: '*/*',
+ 'Content-Type': 'application/json; charset=utf-8',
+ },
+ data: {
+ schedule: {
+ description: 'bar',
+ cron: '0 1 * * *',
+ cron_timezone: 'UTC',
+ active: true,
+ },
+ },
+ validateStatus: (status) => {
+ return status === 302;
+ },
+ });
+}
diff --git a/spec/contracts/consumer/endpoints/project/merge_requests.js b/spec/contracts/consumer/resources/api/project/merge_requests.js
index 38773e5fb10..e52743cede2 100644
--- a/spec/contracts/consumer/endpoints/project/merge_requests.js
+++ b/spec/contracts/consumer/resources/api/project/merge_requests.js
@@ -1,9 +1,9 @@
-import { request } from 'axios';
+import axios from 'axios';
-export function getDiffsMetadata(endpoint) {
+export async function getDiffsMetadata(endpoint) {
const { url } = endpoint;
- return request({
+ return axios({
method: 'GET',
baseURL: url,
url: '/gitlab-org/gitlab-qa/-/merge_requests/1/diffs_metadata.json',
@@ -11,10 +11,10 @@ export function getDiffsMetadata(endpoint) {
}).then((response) => response.data);
}
-export function getDiscussions(endpoint) {
+export async function getDiscussions(endpoint) {
const { url } = endpoint;
- return request({
+ return axios({
method: 'GET',
baseURL: url,
url: '/gitlab-org/gitlab-qa/-/merge_requests/1/discussions.json',
@@ -22,10 +22,10 @@ export function getDiscussions(endpoint) {
}).then((response) => response.data);
}
-export function getDiffsBatch(endpoint) {
+export async function getDiffsBatch(endpoint) {
const { url } = endpoint;
- return request({
+ return axios({
method: 'GET',
baseURL: url,
url: '/gitlab-org/gitlab-qa/-/merge_requests/1/diffs_batch.json?page=0',
diff --git a/spec/contracts/consumer/resources/api/project/pipelines.js b/spec/contracts/consumer/resources/api/project/pipelines.js
new file mode 100644
index 00000000000..8c6f5199666
--- /dev/null
+++ b/spec/contracts/consumer/resources/api/project/pipelines.js
@@ -0,0 +1,34 @@
+import axios from 'axios';
+
+export async function getProjectPipelines(endpoint) {
+ const { url } = endpoint;
+
+ return axios({
+ method: 'GET',
+ baseURL: url,
+ url: '/gitlab-org/gitlab-qa/-/pipelines.json',
+ headers: { Accept: '*/*' },
+ params: {
+ scope: 'all',
+ page: 1,
+ },
+ }).then((response) => response.data);
+}
+
+export async function postProjectPipelines(endpoint) {
+ const { url } = endpoint;
+
+ return axios({
+ method: 'POST',
+ baseURL: url,
+ url: '/gitlab-org/gitlab-qa/-/pipelines',
+ headers: {
+ Accept: '*/*',
+ 'Content-Type': 'application/json; charset=utf-8',
+ },
+ data: { ref: 'master' },
+ validateStatus: (status) => {
+ return status === 302;
+ },
+ });
+}
diff --git a/spec/contracts/consumer/resources/graphql/pipelines.js b/spec/contracts/consumer/resources/graphql/pipelines.js
index 4f7ce58891c..48724e15eb8 100644
--- a/spec/contracts/consumer/resources/graphql/pipelines.js
+++ b/spec/contracts/consumer/resources/graphql/pipelines.js
@@ -16,6 +16,27 @@ export async function getPipelineHeaderDataRequest(endpoint) {
};
return axios({
+ method: 'POST',
+ baseURL: url,
+ url: '/api/graphql',
+ headers: { Accept: '*/*' },
+ data: graphqlQuery,
+ });
+}
+
+export async function deletePipeline(endpoint) {
+ const { url } = endpoint;
+ const query = await extractGraphQLQuery(
+ 'app/assets/javascripts/pipelines/graphql/mutations/delete_pipeline.mutation.graphql',
+ );
+ const graphqlQuery = {
+ query,
+ variables: {
+ id: 'gid://gitlab/Ci::Pipeline/316112',
+ },
+ };
+
+ return axios({
baseURL: url,
url: '/api/graphql',
method: 'POST',
diff --git a/spec/contracts/consumer/specs/project/merge_request/show.spec.js b/spec/contracts/consumer/specs/project/merge_request/show.spec.js
index 8c6e029cb12..4183e19435a 100644
--- a/spec/contracts/consumer/specs/project/merge_request/show.spec.js
+++ b/spec/contracts/consumer/specs/project/merge_request/show.spec.js
@@ -1,5 +1,3 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { pactWith } from 'jest-pact';
import { DiffsBatch } from '../../../fixtures/project/merge_request/diffs_batch.fixture';
@@ -9,7 +7,7 @@ import {
getDiffsBatch,
getDiffsMetadata,
getDiscussions,
-} from '../../../endpoints/project/merge_requests';
+} from '../../../resources/api/project/merge_requests';
const CONSUMER_NAME = 'MergeRequest#show';
const CONSUMER_LOG = '../logs/consumer.log';
@@ -31,19 +29,19 @@ pactWith(
describe(DIFFS_BATCH_PROVIDER_NAME, () => {
beforeEach(() => {
const interaction = {
- state: 'a merge request with diffs exists',
+ ...DiffsBatch.scenario,
...DiffsBatch.request,
willRespondWith: DiffsBatch.success,
};
provider.addInteraction(interaction);
});
- it('returns a successful body', () => {
- return getDiffsBatch({
+ it('returns a successful body', async () => {
+ const diffsBatch = await getDiffsBatch({
url: provider.mockService.baseUrl,
- }).then((diffsBatch) => {
- expect(diffsBatch).toEqual(DiffsBatch.body);
});
+
+ expect(diffsBatch).toEqual(DiffsBatch.body);
});
});
},
@@ -61,19 +59,19 @@ pactWith(
describe(DISCUSSIONS_PROVIDER_NAME, () => {
beforeEach(() => {
const interaction = {
- state: 'a merge request with discussions exists',
+ ...Discussions.scenario,
...Discussions.request,
willRespondWith: Discussions.success,
};
provider.addInteraction(interaction);
});
- it('return a successful body', () => {
- return getDiscussions({
+ it('return a successful body', async () => {
+ const discussions = await getDiscussions({
url: provider.mockService.baseUrl,
- }).then((discussions) => {
- expect(discussions).toEqual(Discussions.body);
});
+
+ expect(discussions).toEqual(Discussions.body);
});
});
},
@@ -91,22 +89,20 @@ pactWith(
describe(DIFFS_METADATA_PROVIDER_NAME, () => {
beforeEach(() => {
const interaction = {
- state: 'a merge request exists',
+ ...DiffsMetadata.scenario,
...DiffsMetadata.request,
willRespondWith: DiffsMetadata.success,
};
provider.addInteraction(interaction);
});
- it('return a successful body', () => {
- return getDiffsMetadata({
+ it('return a successful body', async () => {
+ const diffsMetadata = await getDiffsMetadata({
url: provider.mockService.baseUrl,
- }).then((diffsMetadata) => {
- expect(diffsMetadata).toEqual(DiffsMetadata.body);
});
+
+ expect(diffsMetadata).toEqual(DiffsMetadata.body);
});
});
},
);
-
-/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/consumer/specs/project/pipeline/index.spec.js b/spec/contracts/consumer/specs/project/pipeline/index.spec.js
index 1c0358a3e28..1453435d637 100644
--- a/spec/contracts/consumer/specs/project/pipeline/index.spec.js
+++ b/spec/contracts/consumer/specs/project/pipeline/index.spec.js
@@ -1,9 +1,7 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { pactWith } from 'jest-pact';
import { ProjectPipelines } from '../../../fixtures/project/pipeline/get_list_project_pipelines.fixture';
-import { getProjectPipelines } from '../../../endpoints/project/pipelines';
+import { getProjectPipelines } from '../../../resources/api/project/pipelines';
const CONSUMER_NAME = 'Pipelines#index';
const CONSUMER_LOG = '../logs/consumer.log';
@@ -23,22 +21,20 @@ pactWith(
describe(PROVIDER_NAME, () => {
beforeEach(() => {
const interaction = {
- state: 'a few pipelines for a project exists',
+ ...ProjectPipelines.scenario,
...ProjectPipelines.request,
willRespondWith: ProjectPipelines.success,
};
provider.addInteraction(interaction);
});
- it('returns a successful body', () => {
- return getProjectPipelines({
+ it('returns a successful body', async () => {
+ const pipelines = await getProjectPipelines({
url: provider.mockService.baseUrl,
- }).then((pipelines) => {
- expect(pipelines).toEqual(ProjectPipelines.body);
});
+
+ expect(pipelines).toEqual(ProjectPipelines.body);
});
});
},
);
-
-/* eslint-enable @gitlab/require-i18n-strings */
diff --git a/spec/contracts/consumer/specs/project/pipeline/new.spec.js b/spec/contracts/consumer/specs/project/pipeline/new.spec.js
new file mode 100644
index 00000000000..c3824d5979e
--- /dev/null
+++ b/spec/contracts/consumer/specs/project/pipeline/new.spec.js
@@ -0,0 +1,41 @@
+import { pactWith } from 'jest-pact';
+
+import { NewProjectPipeline } from '../../../fixtures/project/pipeline/create_a_new_pipeline.fixture';
+import { postProjectPipelines } from '../../../resources/api/project/pipelines';
+
+const CONSUMER_NAME = 'Pipelines#new';
+const CONSUMER_LOG = '../logs/consumer.log';
+const CONTRACT_DIR = '../contracts/project/pipeline/new';
+const PROVIDER_NAME = 'POST Create a new pipeline';
+
+// API endpoint: /pipelines.json
+pactWith(
+ {
+ consumer: CONSUMER_NAME,
+ provider: PROVIDER_NAME,
+ log: CONSUMER_LOG,
+ dir: CONTRACT_DIR,
+ },
+
+ (provider) => {
+ describe(PROVIDER_NAME, () => {
+ beforeEach(async () => {
+ const interaction = {
+ ...NewProjectPipeline.scenario,
+ ...NewProjectPipeline.request,
+ willRespondWith: NewProjectPipeline.success,
+ };
+
+ provider.addInteraction(interaction);
+ });
+
+ it('returns a successful body', async () => {
+ const newPipeline = await postProjectPipelines({
+ url: provider.mockService.baseUrl,
+ });
+
+ expect(newPipeline.status).toEqual(NewProjectPipeline.success.status);
+ });
+ });
+ },
+);
diff --git a/spec/contracts/consumer/specs/project/pipeline/show.spec.js b/spec/contracts/consumer/specs/project/pipeline/show.spec.js
index 0f1cc1c3108..be6abb78eb5 100644
--- a/spec/contracts/consumer/specs/project/pipeline/show.spec.js
+++ b/spec/contracts/consumer/specs/project/pipeline/show.spec.js
@@ -1,36 +1,37 @@
-/* eslint-disable @gitlab/require-i18n-strings */
-
import { pactWith } from 'jest-pact';
import { GraphQLInteraction } from '@pact-foundation/pact';
import { extractGraphQLQuery } from '../../../helpers/graphql_query_extractor';
import { PipelineHeaderData } from '../../../fixtures/project/pipeline/get_pipeline_header_data.fixture';
-import { getPipelineHeaderDataRequest } from '../../../resources/graphql/pipelines';
+import { DeletePipeline } from '../../../fixtures/project/pipeline/delete_pipeline.fixture';
+
+import { getPipelineHeaderDataRequest, deletePipeline } from '../../../resources/graphql/pipelines';
const CONSUMER_NAME = 'Pipelines#show';
const CONSUMER_LOG = '../logs/consumer.log';
const CONTRACT_DIR = '../contracts/project/pipeline/show';
-const PROVIDER_NAME = 'GET pipeline header data';
+const GET_PIPELINE_HEADER_DATA_PROVIDER_NAME = 'GET pipeline header data';
+const DELETE_PIPELINE_PROVIDER_NAME = 'DELETE pipeline';
// GraphQL query: getPipelineHeaderData
pactWith(
{
consumer: CONSUMER_NAME,
- provider: PROVIDER_NAME,
+ provider: GET_PIPELINE_HEADER_DATA_PROVIDER_NAME,
log: CONSUMER_LOG,
dir: CONTRACT_DIR,
},
(provider) => {
- describe(PROVIDER_NAME, () => {
+ describe(GET_PIPELINE_HEADER_DATA_PROVIDER_NAME, () => {
beforeEach(async () => {
const query = await extractGraphQLQuery(
'app/assets/javascripts/pipelines/graphql/queries/get_pipeline_header_data.query.graphql',
);
const graphqlQuery = new GraphQLInteraction()
- .given('a pipeline for a project exists')
- .uponReceiving('a request for the pipeline header data')
+ .given(PipelineHeaderData.scenario.state)
+ .uponReceiving(PipelineHeaderData.scenario.uponReceiving)
.withQuery(query)
.withRequest(PipelineHeaderData.request)
.withVariables(PipelineHeaderData.variables)
@@ -50,4 +51,39 @@ pactWith(
},
);
-/* eslint-enable @gitlab/require-i18n-strings */
+// GraphQL query: deletePipeline
+pactWith(
+ {
+ consumer: CONSUMER_NAME,
+ provider: DELETE_PIPELINE_PROVIDER_NAME,
+ log: CONSUMER_LOG,
+ dir: CONTRACT_DIR,
+ },
+
+ (provider) => {
+ describe(DELETE_PIPELINE_PROVIDER_NAME, () => {
+ beforeEach(async () => {
+ const query = await extractGraphQLQuery(
+ 'app/assets/javascripts/pipelines/graphql/mutations/delete_pipeline.mutation.graphql',
+ );
+ const graphqlQuery = new GraphQLInteraction()
+ .given(DeletePipeline.scenario.state)
+ .uponReceiving(DeletePipeline.scenario.uponReceiving)
+ .withQuery(query)
+ .withRequest(DeletePipeline.request)
+ .withVariables(DeletePipeline.variables)
+ .willRespondWith(DeletePipeline.success);
+
+ provider.addInteraction(graphqlQuery);
+ });
+
+ it('returns a successful body', async () => {
+ const deletePipelineResponse = await deletePipeline({
+ url: provider.mockService.baseUrl,
+ });
+
+ expect(deletePipelineResponse.status).toEqual(DeletePipeline.success.status);
+ });
+ });
+ },
+);
diff --git a/spec/contracts/consumer/specs/project/pipeline_schedule/edit.spec.js b/spec/contracts/consumer/specs/project/pipeline_schedule/edit.spec.js
new file mode 100644
index 00000000000..117e6754255
--- /dev/null
+++ b/spec/contracts/consumer/specs/project/pipeline_schedule/edit.spec.js
@@ -0,0 +1,41 @@
+import { pactWith } from 'jest-pact';
+
+import { UpdatePipelineSchedule } from '../../../fixtures/project/pipeline_schedule/update_pipeline_schedule.fixture';
+import { updatePipelineSchedule } from '../../../resources/api/pipeline_schedules';
+
+const CONSUMER_NAME = 'PipelineSchedules#edit';
+const CONSUMER_LOG = '../logs/consumer.log';
+const CONTRACT_DIR = '../contracts/project/pipeline_schedule/edit';
+const PROVIDER_NAME = 'PUT Edit a pipeline schedule';
+
+// API endpoint: /pipelines.json
+pactWith(
+ {
+ consumer: CONSUMER_NAME,
+ provider: PROVIDER_NAME,
+ log: CONSUMER_LOG,
+ dir: CONTRACT_DIR,
+ },
+
+ (provider) => {
+ describe(PROVIDER_NAME, () => {
+ beforeEach(() => {
+ const interaction = {
+ ...UpdatePipelineSchedule.scenario,
+ ...UpdatePipelineSchedule.request,
+ willRespondWith: UpdatePipelineSchedule.success,
+ };
+
+ provider.addInteraction(interaction);
+ });
+
+ it('returns a successful body', async () => {
+ const pipelineSchedule = await updatePipelineSchedule({
+ url: provider.mockService.baseUrl,
+ });
+
+ expect(pipelineSchedule.status).toEqual(UpdatePipelineSchedule.success.status);
+ });
+ });
+ },
+);