diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 15:40:28 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 15:40:28 +0000 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/contracts/consumer/specs | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) | |
download | gitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/contracts/consumer/specs')
-rw-r--r-- | spec/contracts/consumer/specs/project/pipeline/index.spec.js | 44 | ||||
-rw-r--r-- | spec/contracts/consumer/specs/project/pipeline/show.spec.js | 53 |
2 files changed, 97 insertions, 0 deletions
diff --git a/spec/contracts/consumer/specs/project/pipeline/index.spec.js b/spec/contracts/consumer/specs/project/pipeline/index.spec.js new file mode 100644 index 00000000000..1c0358a3e28 --- /dev/null +++ b/spec/contracts/consumer/specs/project/pipeline/index.spec.js @@ -0,0 +1,44 @@ +/* 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'; + +const CONSUMER_NAME = 'Pipelines#index'; +const CONSUMER_LOG = '../logs/consumer.log'; +const CONTRACT_DIR = '../contracts/project/pipeline/index'; +const PROVIDER_NAME = 'GET List project pipelines'; + +// API endpoint: /pipelines.json +pactWith( + { + consumer: CONSUMER_NAME, + provider: PROVIDER_NAME, + log: CONSUMER_LOG, + dir: CONTRACT_DIR, + }, + + (provider) => { + describe(PROVIDER_NAME, () => { + beforeEach(() => { + const interaction = { + state: 'a few pipelines for a project exists', + ...ProjectPipelines.request, + willRespondWith: ProjectPipelines.success, + }; + provider.addInteraction(interaction); + }); + + it('returns a successful body', () => { + return getProjectPipelines({ + url: provider.mockService.baseUrl, + }).then((pipelines) => { + expect(pipelines).toEqual(ProjectPipelines.body); + }); + }); + }); + }, +); + +/* eslint-enable @gitlab/require-i18n-strings */ diff --git a/spec/contracts/consumer/specs/project/pipeline/show.spec.js b/spec/contracts/consumer/specs/project/pipeline/show.spec.js new file mode 100644 index 00000000000..0f1cc1c3108 --- /dev/null +++ b/spec/contracts/consumer/specs/project/pipeline/show.spec.js @@ -0,0 +1,53 @@ +/* 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'; + +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'; + +// GraphQL query: getPipelineHeaderData +pactWith( + { + consumer: CONSUMER_NAME, + provider: PROVIDER_NAME, + log: CONSUMER_LOG, + dir: CONTRACT_DIR, + }, + + (provider) => { + describe(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') + .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); + }); + }); + }, +); + +/* eslint-enable @gitlab/require-i18n-strings */ |