Commit 07ab8b33 authored by Phil Hughes's avatar Phil Hughes

Merge branch '8255-transient-failure-of-dashboard_spec-js' into 'master'

Resolve "Transient failure of dashboard_spec.js"

Closes #8255

See merge request gitlab-org/gitlab-ee!8369
parents 08e5896e f4d58dcc
import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import store from 'ee/operations/store/index';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import Dashboard from 'ee/operations/components/dashboard/dashboard.vue';
import ProjectSearch from 'ee/operations/components/dashboard/project_search.vue';
import DashboardProject from 'ee/operations/components/dashboard/project.vue';
......@@ -14,29 +11,28 @@ describe('dashboard component', () => {
const ProjectSearchComponent = Vue.extend(ProjectSearch);
const DashboardProjectComponent = Vue.extend(DashboardProject);
const projectTokens = mockProjectData(1);
const mockListPath = 'mock-listPath';
const mount = () =>
mountComponentWithStore(DashboardComponent, {
new DashboardComponent({
store,
props: {
propsData: {
addPath: 'mock-addPath',
listPath: mockListPath,
listPath: 'mock-listPath',
emptyDashboardSvgPath: '/assets/illustrations/operations-dashboard_empty.svg',
emptyDashboardHelpPath: '/help/user/operations_dashboard/index.html',
},
});
methods: {
fetchProjects: () => {},
},
}).$mount();
let vm;
let mockAxios;
beforeEach(() => {
vm = mount();
mockAxios = new MockAdapter(axios);
});
afterEach(() => {
vm.$destroy();
clearState(store);
mockAxios.restore();
});
it('renders dashboard title', () => {
......@@ -57,7 +53,7 @@ describe('dashboard component', () => {
});
it('calls action to add projects on click if projectTokens have been added', () => {
const spy = spyOn(vm, 'addProjectsToDashboard');
const spy = spyOn(vm, 'addProjectsToDashboard').and.stub();
vm.$store.state.projectTokens = projectTokens;
button.click();
......@@ -65,7 +61,7 @@ describe('dashboard component', () => {
});
it('does not call action to add projects on click when projectTokens is empty', () => {
const spy = spyOn(vm, 'addProjectsToDashboard');
const spy = spyOn(vm, 'addProjectsToDashboard').and.stub();
button.click();
expect(spy).not.toHaveBeenCalled();
......@@ -102,16 +98,14 @@ describe('dashboard component', () => {
describe('empty state', () => {
beforeEach(() => {
mockAxios.onGet(mockListPath).replyOnce(200, { data: [] });
store.state.projects = [];
vm = mount();
});
it('renders empty state svg after requesting projects with no results', () => {
const svgSrc = vm.$el
.querySelector('.js-empty-state-svg')
.src.slice(-mockText.EMPTY_SVG_SOURCE.length);
const svgSrc = vm.$el.querySelector('.js-empty-state-svg').src;
expect(svgSrc).toBe(mockText.EMPTY_SVG_SOURCE);
expect(svgSrc).toMatch(mockText.EMPTY_SVG_SOURCE);
});
it('renders title', () => {
......
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