debian-mirror-gitlab/spec/contracts/consumer/specs/project/pipelines/show.spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
3 KiB
JavaScript
Raw Normal View History

2022-08-13 15:12:31 +05:30
import { pactWith } from 'jest-pact';
import { GraphQLInteraction } from '@pact-foundation/pact';
import { extractGraphQLQuery } from '../../../helpers/graphql_query_extractor';
2023-03-04 22:38:38 +05:30
import { PipelineHeaderData } from '../../../fixtures/project/pipelines/get_pipeline_header_data.fixture';
import { DeletePipeline } from '../../../fixtures/project/pipelines/delete_pipeline.fixture';
2022-08-27 11:52:29 +05:30
import { getPipelineHeaderDataRequest, deletePipeline } from '../../../resources/graphql/pipelines';
2022-08-13 15:12:31 +05:30
const CONSUMER_NAME = 'Pipelines#show';
const CONSUMER_LOG = '../logs/consumer.log';
2023-03-04 22:38:38 +05:30
const CONTRACT_DIR = '../contracts/project/pipelines/show';
2022-08-27 11:52:29 +05:30
const GET_PIPELINE_HEADER_DATA_PROVIDER_NAME = 'GET pipeline header data';
const DELETE_PIPELINE_PROVIDER_NAME = 'DELETE pipeline';
2022-08-13 15:12:31 +05:30
// GraphQL query: getPipelineHeaderData
pactWith(
{
consumer: CONSUMER_NAME,
2022-08-27 11:52:29 +05:30
provider: GET_PIPELINE_HEADER_DATA_PROVIDER_NAME,
2022-08-13 15:12:31 +05:30
log: CONSUMER_LOG,
dir: CONTRACT_DIR,
},
(provider) => {
2022-08-27 11:52:29 +05:30
describe(GET_PIPELINE_HEADER_DATA_PROVIDER_NAME, () => {
2022-08-13 15:12:31 +05:30
beforeEach(async () => {
const query = await extractGraphQLQuery(
'app/assets/javascripts/pipelines/graphql/queries/get_pipeline_header_data.query.graphql',
);
const graphqlQuery = new GraphQLInteraction()
2022-08-27 11:52:29 +05:30
.given(PipelineHeaderData.scenario.state)
.uponReceiving(PipelineHeaderData.scenario.uponReceiving)
2022-08-13 15:12:31 +05:30
.withQuery(query)
.withRequest(PipelineHeaderData.request)
.withVariables(PipelineHeaderData.variables)
.willRespondWith(PipelineHeaderData.success);
provider.addInteraction(graphqlQuery);
});
it('returns a successful body', async () => {
const pipelineHeaderData = await getPipelineHeaderDataRequest({
url: provider.mockService.baseUrl,
});
expect(pipelineHeaderData.data).toEqual(PipelineHeaderData.body);
});
});
},
);
2022-08-27 11:52:29 +05:30
// 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);
});
});
},
);