diff options
Diffstat (limited to 'spec/contracts/consumer/specs/project')
5 files changed, 149 insertions, 39 deletions
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); + }); + }); + }, +); |