2020-10-24 23:57:45 +05:30
|
|
|
import { GlBadge, GlLink } from '@gitlab/ui';
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2022-10-11 01:57:18 +05:30
|
|
|
import StuckBlock from '~/jobs/components/job/stuck_block.vue';
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
describe('Stuck Block Job component', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
let wrapper;
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const createWrapper = (props) => {
|
2020-10-24 23:57:45 +05:30
|
|
|
wrapper = shallowMount(StuckBlock, {
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const tags = ['docker', 'gitlab-org'];
|
|
|
|
|
|
|
|
const findStuckNoActiveRunners = () =>
|
|
|
|
wrapper.find('[data-testid="job-stuck-no-active-runners"]');
|
|
|
|
const findStuckNoRunners = () => wrapper.find('[data-testid="job-stuck-no-runners"]');
|
|
|
|
const findStuckWithTags = () => wrapper.find('[data-testid="job-stuck-with-tags"]');
|
2022-10-11 01:57:18 +05:30
|
|
|
const findRunnerPathLink = () => wrapper.findComponent(GlLink);
|
|
|
|
const findAllBadges = () => wrapper.findAllComponents(GlBadge);
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
describe('with no runners for project', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper({
|
2022-07-16 23:28:13 +05:30
|
|
|
hasOfflineRunnersForProject: true,
|
2018-11-20 20:47:30 +05:30
|
|
|
runnersPath: '/root/project/runners#js-runners-settings',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders only information about project not having runners', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findStuckNoRunners().exists()).toBe(true);
|
|
|
|
expect(findStuckWithTags().exists()).toBe(false);
|
|
|
|
expect(findStuckNoActiveRunners().exists()).toBe(false);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link to runners page', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findRunnerPathLink().attributes('href')).toBe(
|
2018-11-20 20:47:30 +05:30
|
|
|
'/root/project/runners#js-runners-settings',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with tags', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper({
|
2022-07-16 23:28:13 +05:30
|
|
|
hasOfflineRunnersForProject: false,
|
2020-10-24 23:57:45 +05:30
|
|
|
tags,
|
2018-11-20 20:47:30 +05:30
|
|
|
runnersPath: '/root/project/runners#js-runners-settings',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders information about the tags not being set', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findStuckWithTags().exists()).toBe(true);
|
|
|
|
expect(findStuckNoActiveRunners().exists()).toBe(false);
|
|
|
|
expect(findStuckNoRunners().exists()).toBe(false);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders tags', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
findAllBadges().wrappers.forEach((badgeElt, index) => {
|
|
|
|
return expect(badgeElt.text()).toBe(tags[index]);
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link to runners page', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findRunnerPathLink().attributes('href')).toBe(
|
2018-11-20 20:47:30 +05:30
|
|
|
'/root/project/runners#js-runners-settings',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without active runners', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper({
|
2022-07-16 23:28:13 +05:30
|
|
|
hasOfflineRunnersForProject: false,
|
2018-11-20 20:47:30 +05:30
|
|
|
runnersPath: '/root/project/runners#js-runners-settings',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders information about project not having runners', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findStuckNoActiveRunners().exists()).toBe(true);
|
|
|
|
expect(findStuckNoRunners().exists()).toBe(false);
|
|
|
|
expect(findStuckWithTags().exists()).toBe(false);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link to runners page', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findRunnerPathLink().attributes('href')).toBe(
|
2018-11-20 20:47:30 +05:30
|
|
|
'/root/project/runners#js-runners-settings',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|