Commit bfc2b8a3 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Added realtime prop and corrected specs

parent 60424546
import Vue from 'vue';
import ShortcutsNavigation from '~/shortcuts_navigation'; import ShortcutsNavigation from '~/shortcuts_navigation';
import NotificationsForm from '~/notifications_form'; import NotificationsForm from '~/notifications_form';
import UserCallout from '~/user_callout'; import UserCallout from '~/user_callout';
...@@ -5,6 +6,7 @@ import TreeView from '~/tree'; ...@@ -5,6 +6,7 @@ import TreeView from '~/tree';
import BlobViewer from '~/blob/viewer/index'; import BlobViewer from '~/blob/viewer/index';
import Activities from '~/activities'; import Activities from '~/activities';
import { ajaxGet } from '~/lib/utils/common_utils'; import { ajaxGet } from '~/lib/utils/common_utils';
import commitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
import Star from '../../../star'; import Star from '../../../star';
import notificationsDropdown from '../../../notifications_dropdown'; import notificationsDropdown from '../../../notifications_dropdown';
...@@ -24,4 +26,21 @@ export default () => { ...@@ -24,4 +26,21 @@ export default () => {
$('#tree-slider').waitForImages(() => { $('#tree-slider').waitForImages(() => {
ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath); ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath);
}); });
const commitPipelineStatusEl = document.getElementById('commit-pipeline-status');
// eslint-disable-next-line no-new
new Vue({
el: '#commit-pipeline-status',
components: {
commitPipelineStatus,
},
render(createElement) {
return createElement('commit-pipeline-status', {
props: {
endpoint: commitPipelineStatusEl.dataset.endpoint,
realtime: false,
},
});
},
});
}; };
import Vue from 'vue'; import Vue from 'vue';
import commitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
import TreeView from '../../../../tree'; import TreeView from '../../../../tree';
import ShortcutsNavigation from '../../../../shortcuts_navigation'; import ShortcutsNavigation from '../../../../shortcuts_navigation';
import BlobViewer from '../../../../blob/viewer'; import BlobViewer from '../../../../blob/viewer';
import NewCommitForm from '../../../../new_commit_form'; import NewCommitForm from '../../../../new_commit_form';
import { ajaxGet } from '../../../../lib/utils/common_utils'; import { ajaxGet } from '../../../../lib/utils/common_utils';
import commitPipelineStatus from '../components/commit_pipeline_status_component.vue';
export default () => { export default () => {
new ShortcutsNavigation(); // eslint-disable-line no-new new ShortcutsNavigation(); // eslint-disable-line no-new
......
...@@ -18,22 +18,33 @@ ...@@ -18,22 +18,33 @@
type: String, type: String,
required: true, required: true,
}, },
realtime: {
type: Boolean,
required: false,
default: true,
},
}, },
data() { data() {
return { return {
ciStatus: {}, ciStatus: {},
isLoading: true, isLoading: true,
service: {}, service: {},
stageTitle: '',
}; };
}, },
mounted() { mounted() {
this.service = new CommitPipelineService(this.endpoint); this.service = new CommitPipelineService(this.endpoint);
this.initPolling(); if (this.realtime) {
this.initPolling();
} else {
this.fetchPipelineCommitData();
}
}, },
methods: { methods: {
successCallback(res) { successCallback(res) {
if (res.data.pipelines.length > 0) { if (res.data.pipelines.length > 0) {
this.ciStatus = res.data.pipelines[0].details.status; this.ciStatus = res.data.pipelines[0].details.stages[0].status;
this.stageTitle = res.data.pipelines[0].details.stages[0].title;
this.isLoading = false; this.isLoading = false;
} else { } else {
this.isLoading = true; this.isLoading = true;
...@@ -86,8 +97,8 @@ ...@@ -86,8 +97,8 @@
> >
<ci-icon <ci-icon
v-tooltip v-tooltip
:title="ciStatus.text" :title="stageTitle"
:aria-label="ciStatus.text" :aria-label="stageTitle"
data-container="body" data-container="body"
:status="ciStatus" :status="ciStatus"
/> />
......
...@@ -23,6 +23,7 @@ Feature: Project ...@@ -23,6 +23,7 @@ Feature: Project
And I visit project "Shop" page And I visit project "Shop" page
Then I should see project "Shop" README Then I should see project "Shop" README
@javascript
Scenario: I should see last commit with CI Scenario: I should see last commit with CI
Given project "Shop" has CI enabled Given project "Shop" has CI enabled
Given project "Shop" has CI build Given project "Shop" has CI build
......
...@@ -218,6 +218,7 @@ module SharedProject ...@@ -218,6 +218,7 @@ module SharedProject
end end
step 'I should see last commit with CI status' do step 'I should see last commit with CI status' do
sleep 2
page.within ".blob-commit-info" do page.within ".blob-commit-info" do
expect(page).to have_content(project.commit.sha[0..6]) expect(page).to have_content(project.commit.sha[0..6])
expect(page).to have_link("Commit: skipped") expect(page).to have_link("Commit: skipped")
......
import Vue from 'vue'; import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import commitPipelineStatus from '~/pages/projects/tree/components/commit_pipeline_status_component.vue'; import commitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
import mountComponent from '../helpers/vue_mount_component_helper'; import mountComponent from '../helpers/vue_mount_component_helper';
describe('Commit pipeline status component', () => { describe('Commit pipeline status component', () => {
...@@ -25,7 +25,12 @@ describe('Commit pipeline status component', () => { ...@@ -25,7 +25,12 @@ describe('Commit pipeline status component', () => {
pipelines: [ pipelines: [
{ {
details: { details: {
status: mockCiStatus, stages: [
{
status: mockCiStatus,
title: 'Commit: canceled',
},
],
}, },
}, },
], ],
......
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