Commit 38d50bae authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '300550-fixture-pipelines-pipelines-json-does-not-contain-any-stage' into 'master'

Add stages to mock pipeline in fixture

See merge request gitlab-org/gitlab!54467
parents b4ad8f3d 42748aba
......@@ -5,16 +5,22 @@ require 'spec_helper'
RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'pipelines-project') }
let(:commit) { create(:commit, project: project) }
let(:commit_without_author) { RepoHelpers.another_sample_commit }
let!(:user) { create(:user, developer_projects: [project], email: commit.author_email) }
let!(:pipeline) { create(:ci_pipeline, project: project, sha: commit.id, user: user) }
let_it_be(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'pipelines-project') }
let_it_be(:commit_without_author) { RepoHelpers.another_sample_commit }
let!(:pipeline_without_author) { create(:ci_pipeline, project: project, sha: commit_without_author.id) }
let!(:pipeline_without_commit) { create(:ci_pipeline, status: :success, project: project, sha: '0000') }
let!(:build_pipeline_without_author) { create(:ci_build, pipeline: pipeline_without_author, stage: 'test') }
render_views
let_it_be(:pipeline_without_commit) { create(:ci_pipeline, status: :success, project: project, sha: '0000') }
let!(:build_pipeline_without_commit) { create(:ci_build, pipeline: pipeline_without_commit, stage: 'test') }
let(:commit) { create(:commit, project: project) }
let(:user) { create(:user, developer_projects: [project], email: commit.author_email) }
let!(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project, sha: commit.id, user: user) }
let!(:build_success) { create(:ci_build, pipeline: pipeline, stage: 'build') }
let!(:build_test) { create(:ci_build, pipeline: pipeline, stage: 'test') }
let!(:build_deploy_failed) { create(:ci_build, status: :failed, pipeline: pipeline, stage: 'deploy') }
before(:all) do
clean_frontend_fixtures('pipelines/')
......@@ -32,4 +38,14 @@ RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :co
expect(response).to be_successful
end
it "pipelines/test_report.json" do
get :test_report, params: {
namespace_id: namespace,
project_id: project,
id: pipeline.id
}, format: :json
expect(response).to be_successful
end
end
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Projects::PipelinesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:namespace) { create(:namespace, name: "frontend-fixtures") }
let(:project) { create(:project, :repository, namespace: namespace, path: "pipelines-project") }
let(:commit) { create(:commit, project: project) }
let(:user) { create(:user, developer_projects: [project], email: commit.author_email) }
let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project, user: user) }
render_views
before do
sign_in(user)
end
it "pipelines/test_report.json" do
get :test_report, params: {
namespace_id: project.namespace,
project_id: project,
id: pipeline.id
}, format: :json
expect(response).to be_successful
end
end
......@@ -2,328 +2,6 @@ const PIPELINE_RUNNING = 'RUNNING';
const PIPELINE_CANCELED = 'CANCELED';
const PIPELINE_FAILED = 'FAILED';
export const pipelineWithStages = {
id: 20333396,
user: {
id: 128633,
name: 'Rémy Coutable',
username: 'rymai',
state: 'active',
avatar_url:
'https://secure.gravatar.com/avatar/263da227929cc0035cb0eba512bcf81a?s=80\u0026d=identicon',
web_url: 'https://gitlab.com/rymai',
path: '/rymai',
},
active: true,
coverage: '58.24',
source: 'push',
created_at: '2018-04-11T14:04:53.881Z',
updated_at: '2018-04-11T14:05:00.792Z',
path: '/gitlab-org/gitlab/pipelines/20333396',
flags: {
latest: true,
stuck: false,
auto_devops: false,
yaml_errors: false,
retryable: false,
cancelable: true,
failure_reason: false,
},
details: {
status: {
icon: 'status_running',
text: 'running',
label: 'running',
group: 'running',
has_details: true,
details_path: '/gitlab-org/gitlab/pipelines/20333396',
favicon:
'https://assets.gitlab-static.net/assets/ci_favicons/favicon_status_running-2eb56be2871937954b2ba6d6f4ee9fdf7e5e1c146ac45f7be98119ccaca1aca9.ico',
},
duration: null,
finished_at: null,
stages: [
{
name: 'build',
title: 'build: skipped',
status: {
icon: 'status_skipped',
text: 'skipped',
label: 'skipped',
group: 'skipped',
has_details: true,
details_path: '/gitlab-org/gitlab/pipelines/20333396#build',
favicon:
'https://assets.gitlab-static.net/assets/ci_favicons/favicon_status_skipped-a2eee568a5bffdb494050c7b62dde241de9189280836288ac8923d369f16222d.ico',
},
path: '/gitlab-org/gitlab/pipelines/20333396#build',
dropdown_path: '/gitlab-org/gitlab/pipelines/20333396/stage.json?stage=build',
},
{
name: 'prepare',
title: 'prepare: passed',
status: {
icon: 'status_success',
text: 'passed',
label: 'passed',
group: 'success',
has_details: true,
details_path: '/gitlab-org/gitlab/pipelines/20333396#prepare',
favicon:
'https://assets.gitlab-static.net/assets/ci_favicons/favicon_status_success-26f59841becbef8c6fe414e9e74471d8bfd6a91b5855c19fe7f5923a40a7da47.ico',
},
path: '/gitlab-org/gitlab/pipelines/20333396#prepare',
dropdown_path: '/gitlab-org/gitlab/pipelines/20333396/stage.json?stage=prepare',
},
{
name: 'test',
title: 'test: running',
status: {
icon: 'status_running',
text: 'running',
label: 'running',
group: 'running',
has_details: true,
details_path: '/gitlab-org/gitlab/pipelines/20333396#test',
favicon:
'https://assets.gitlab-static.net/assets/ci_favicons/favicon_status_running-2eb56be2871937954b2ba6d6f4ee9fdf7e5e1c146ac45f7be98119ccaca1aca9.ico',
},
path: '/gitlab-org/gitlab/pipelines/20333396#test',
dropdown_path: '/gitlab-org/gitlab/pipelines/20333396/stage.json?stage=test',
},
{
name: 'post-test',
title: 'post-test: created',
status: {
icon: 'status_created',
text: 'created',
label: 'created',
group: 'created',
has_details: true,
details_path: '/gitlab-org/gitlab/pipelines/20333396#post-test',
favicon:
'https://assets.gitlab-static.net/assets/ci_favicons/favicon_status_created-e997aa0b7db73165df8a9d6803932b18d7b7cc37d604d2d96e378fea2dba9c5f.ico',
},
path: '/gitlab-org/gitlab/pipelines/20333396#post-test',
dropdown_path: '/gitlab-org/gitlab/pipelines/20333396/stage.json?stage=post-test',
},
{
name: 'pages',
title: 'pages: created',
status: {
icon: 'status_created',
text: 'created',
label: 'created',
group: 'created',
has_details: true,
details_path: '/gitlab-org/gitlab/pipelines/20333396#pages',
favicon:
'https://assets.gitlab-static.net/assets/ci_favicons/favicon_status_created-e997aa0b7db73165df8a9d6803932b18d7b7cc37d604d2d96e378fea2dba9c5f.ico',
},
path: '/gitlab-org/gitlab/pipelines/20333396#pages',
dropdown_path: '/gitlab-org/gitlab/pipelines/20333396/stage.json?stage=pages',
},
{
name: 'post-cleanup',
title: 'post-cleanup: created',
status: {
icon: 'status_created',
text: 'created',
label: 'created',
group: 'created',
has_details: true,
details_path: '/gitlab-org/gitlab/pipelines/20333396#post-cleanup',
favicon:
'https://assets.gitlab-static.net/assets/ci_favicons/favicon_status_created-e997aa0b7db73165df8a9d6803932b18d7b7cc37d604d2d96e378fea2dba9c5f.ico',
},
path: '/gitlab-org/gitlab/pipelines/20333396#post-cleanup',
dropdown_path: '/gitlab-org/gitlab/pipelines/20333396/stage.json?stage=post-cleanup',
},
],
artifacts: [
{
name: 'gitlab:assets:compile',
expired: false,
expire_at: '2018-05-12T14:22:54.730Z',
path: '/gitlab-org/gitlab/-/jobs/62411438/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411438/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411438/artifacts/browse',
},
{
name: 'rspec-mysql 12 28',
expired: false,
expire_at: '2018-05-12T14:22:45.136Z',
path: '/gitlab-org/gitlab/-/jobs/62411397/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411397/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411397/artifacts/browse',
},
{
name: 'rspec-mysql 6 28',
expired: false,
expire_at: '2018-05-12T14:22:41.523Z',
path: '/gitlab-org/gitlab/-/jobs/62411391/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411391/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411391/artifacts/browse',
},
{
name: 'rspec-pg geo 0 1',
expired: false,
expire_at: '2018-05-12T14:22:13.287Z',
path: '/gitlab-org/gitlab/-/jobs/62411353/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411353/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411353/artifacts/browse',
},
{
name: 'rspec-mysql 0 28',
expired: false,
expire_at: '2018-05-12T14:22:06.834Z',
path: '/gitlab-org/gitlab/-/jobs/62411385/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411385/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411385/artifacts/browse',
},
{
name: 'spinach-mysql 0 2',
expired: false,
expire_at: '2018-05-12T14:21:51.409Z',
path: '/gitlab-org/gitlab/-/jobs/62411423/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411423/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411423/artifacts/browse',
},
{
name: 'karma',
expired: false,
expire_at: '2018-05-12T14:21:20.934Z',
path: '/gitlab-org/gitlab/-/jobs/62411440/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411440/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411440/artifacts/browse',
},
{
name: 'spinach-pg 0 2',
expired: false,
expire_at: '2018-05-12T14:20:01.028Z',
path: '/gitlab-org/gitlab/-/jobs/62411419/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411419/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411419/artifacts/browse',
},
{
name: 'spinach-pg 1 2',
expired: false,
expire_at: '2018-05-12T14:19:04.336Z',
path: '/gitlab-org/gitlab/-/jobs/62411421/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411421/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411421/artifacts/browse',
},
{
name: 'sast',
expired: null,
expire_at: null,
path: '/gitlab-org/gitlab/-/jobs/62411442/artifacts/download',
browse_path: '/gitlab-org/gitlab/-/jobs/62411442/artifacts/browse',
},
{
name: 'code_quality',
expired: false,
expire_at: '2018-04-18T14:16:24.484Z',
path: '/gitlab-org/gitlab/-/jobs/62411441/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411441/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411441/artifacts/browse',
},
{
name: 'cache gems',
expired: null,
expire_at: null,
path: '/gitlab-org/gitlab/-/jobs/62411447/artifacts/download',
browse_path: '/gitlab-org/gitlab/-/jobs/62411447/artifacts/browse',
},
{
name: 'dependency_scanning',
expired: null,
expire_at: null,
path: '/gitlab-org/gitlab/-/jobs/62411443/artifacts/download',
browse_path: '/gitlab-org/gitlab/-/jobs/62411443/artifacts/browse',
},
{
name: 'compile-assets',
expired: false,
expire_at: '2018-04-18T14:12:07.638Z',
path: '/gitlab-org/gitlab/-/jobs/62411334/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411334/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411334/artifacts/browse',
},
{
name: 'setup-test-env',
expired: false,
expire_at: '2018-04-18T14:10:27.024Z',
path: '/gitlab-org/gitlab/-/jobs/62411336/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411336/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411336/artifacts/browse',
},
{
name: 'retrieve-tests-metadata',
expired: false,
expire_at: '2018-05-12T14:06:35.926Z',
path: '/gitlab-org/gitlab/-/jobs/62411333/artifacts/download',
keep_path: '/gitlab-org/gitlab/-/jobs/62411333/artifacts/keep',
browse_path: '/gitlab-org/gitlab/-/jobs/62411333/artifacts/browse',
},
],
manual_actions: [
{
name: 'package-and-qa',
path: '/gitlab-org/gitlab/-/jobs/62411330/play',
playable: true,
},
{
name: 'review-docs-deploy',
path: '/gitlab-org/gitlab/-/jobs/62411332/play',
playable: true,
},
],
},
ref: {
name: 'master',
path: '/gitlab-org/gitlab/commits/master',
tag: false,
branch: true,
},
commit: {
id: 'e6a2885c503825792cb8a84a8731295e361bd059',
short_id: 'e6a2885c',
title: "Merge branch 'ce-to-ee-2018-04-11' into 'master'",
created_at: '2018-04-11T14:04:39.000Z',
parent_ids: [
'5d9b5118f6055f72cff1a82b88133609912f2c1d',
'6fdc6ee76a8062fe41b1a33f7c503334a6ebdc02',
],
message:
"Merge branch 'ce-to-ee-2018-04-11' into 'master'\n\nCE upstream - 2018-04-11 12:26 UTC\n\nSee merge request gitlab-org/gitlab-ee!5326",
author_name: 'Rémy Coutable',
author_email: 'remy@rymai.me',
authored_date: '2018-04-11T14:04:39.000Z',
committer_name: 'Rémy Coutable',
committer_email: 'remy@rymai.me',
committed_date: '2018-04-11T14:04:39.000Z',
author: {
id: 128633,
name: 'Rémy Coutable',
username: 'rymai',
state: 'active',
avatar_url:
'https://secure.gravatar.com/avatar/263da227929cc0035cb0eba512bcf81a?s=80\u0026d=identicon',
web_url: 'https://gitlab.com/rymai',
path: '/rymai',
},
author_gravatar_url:
'https://secure.gravatar.com/avatar/263da227929cc0035cb0eba512bcf81a?s=80\u0026d=identicon',
commit_url:
'https://gitlab.com/gitlab-org/gitlab/commit/e6a2885c503825792cb8a84a8731295e361bd059',
commit_path: '/gitlab-org/gitlab/commit/e6a2885c503825792cb8a84a8731295e361bd059',
},
cancel_path: '/gitlab-org/gitlab/pipelines/20333396/cancel',
triggered_by: null,
triggered: [],
};
const threeWeeksAgo = new Date();
threeWeeksAgo.setDate(threeWeeksAgo.getDate() - 21);
......
......@@ -18,7 +18,7 @@ import Store from '~/pipelines/stores/pipelines_store';
import NavigationTabs from '~/vue_shared/components/navigation_tabs.vue';
import TablePagination from '~/vue_shared/components/pagination/table_pagination.vue';
import { pipelineWithStages, stageReply, users, mockSearch, branches } from './mock_data';
import { stageReply, users, mockSearch, branches } from './mock_data';
jest.mock('~/flash');
......@@ -27,6 +27,9 @@ const mockProjectId = '21';
const mockPipelinesEndpoint = `/${mockProjectPath}/pipelines.json`;
const mockPipelinesResponse = getJSONFixture('pipelines/pipelines.json');
const mockPipelinesIds = mockPipelinesResponse.pipelines.map(({ id }) => id);
const mockPipelineWithStages = mockPipelinesResponse.pipelines.find(
(p) => p.details.stages && p.details.stages.length,
);
describe('Pipelines', () => {
let wrapper;
......@@ -611,14 +614,15 @@ describe('Pipelines', () => {
mock.onGet(mockPipelinesEndpoint, { scope: 'all', page: '1' }).reply(
200,
{
pipelines: [pipelineWithStages],
pipelines: [mockPipelineWithStages],
count: { all: '1' },
},
{
'POLL-INTERVAL': 100,
},
);
mock.onGet(pipelineWithStages.details.stages[0].dropdown_path).reply(200, stageReply);
mock.onGet(mockPipelineWithStages.details.stages[0].dropdown_path).reply(200, stageReply);
createComponent();
......
......@@ -155,7 +155,7 @@ describe('Pipelines Table Row', () => {
it('should render an icon for each stage', () => {
expect(
wrapper.findAll(
'.table-section:nth-child(4) [data-testid="mini-pipeline-graph-dropdown-toggle"]',
'.table-section:nth-child(5) [data-testid="mini-pipeline-graph-dropdown-toggle"]',
).length,
).toEqual(pipeline.details.stages.length);
});
......@@ -182,9 +182,10 @@ describe('Pipelines Table Row', () => {
expect(wrapper.find('.js-pipelines-retry-button').attributes('title')).toMatch('Retry');
expect(wrapper.find('.js-pipelines-cancel-button').exists()).toBe(true);
expect(wrapper.find('.js-pipelines-cancel-button').attributes('title')).toMatch('Cancel');
const dropdownMenu = wrapper.find('.dropdown-menu');
expect(dropdownMenu.text()).toContain(scheduledJobAction.name);
const actionsMenu = wrapper.find('[data-testid="pipelines-manual-actions-dropdown"]');
expect(actionsMenu.text()).toContain(scheduledJobAction.name);
});
it('emits `retryPipeline` event when retry button is clicked and toggles loading', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment