2022-07-23 23:45:48 +05:30
|
|
|
import { GlSprintf, GlIntersperse } from '@gitlab/ui';
|
2022-04-04 11:22:00 +05:30
|
|
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
|
|
|
|
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
|
|
|
|
import { useFakeDate } from 'helpers/fake_date';
|
2022-07-23 23:45:48 +05:30
|
|
|
import { findDd } from 'helpers/dl_locator_helper';
|
2022-04-04 11:22:00 +05:30
|
|
|
import { ACCESS_LEVEL_REF_PROTECTED, ACCESS_LEVEL_NOT_PROTECTED } from '~/runner/constants';
|
|
|
|
|
|
|
|
import RunnerDetails from '~/runner/components/runner_details.vue';
|
|
|
|
import RunnerDetail from '~/runner/components/runner_detail.vue';
|
|
|
|
import RunnerGroups from '~/runner/components/runner_groups.vue';
|
|
|
|
import RunnerTags from '~/runner/components/runner_tags.vue';
|
|
|
|
import RunnerTag from '~/runner/components/runner_tag.vue';
|
|
|
|
|
|
|
|
import { runnerData, runnerWithGroupData } from '../mock_data';
|
|
|
|
|
|
|
|
const mockRunner = runnerData.data.runner;
|
|
|
|
const mockGroupRunner = runnerWithGroupData.data.runner;
|
|
|
|
|
|
|
|
describe('RunnerDetails', () => {
|
|
|
|
let wrapper;
|
|
|
|
const mockNow = '2021-01-15T12:00:00Z';
|
|
|
|
const mockOneHourAgo = '2021-01-15T11:00:00Z';
|
|
|
|
|
|
|
|
useFakeDate(mockNow);
|
|
|
|
|
|
|
|
const findDetailGroups = () => wrapper.findComponent(RunnerGroups);
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
const createComponent = ({ props = {}, stubs, mountFn = shallowMountExtended } = {}) => {
|
2022-04-04 11:22:00 +05:30
|
|
|
wrapper = mountFn(RunnerDetails, {
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
RunnerDetail,
|
|
|
|
...stubs,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Details tab', () => {
|
|
|
|
describe.each`
|
|
|
|
field | runner | expectedValue
|
|
|
|
${'Description'} | ${{ description: 'My runner' }} | ${'My runner'}
|
|
|
|
${'Description'} | ${{ description: null }} | ${'None'}
|
|
|
|
${'Last contact'} | ${{ contactedAt: mockOneHourAgo }} | ${'1 hour ago'}
|
|
|
|
${'Last contact'} | ${{ contactedAt: null }} | ${'Never contacted'}
|
|
|
|
${'Version'} | ${{ version: '12.3' }} | ${'12.3'}
|
|
|
|
${'Version'} | ${{ version: null }} | ${'None'}
|
2022-07-16 23:28:13 +05:30
|
|
|
${'Executor'} | ${{ executorName: 'shell' }} | ${'shell'}
|
|
|
|
${'Architecture'} | ${{ architectureName: 'amd64' }} | ${'amd64'}
|
|
|
|
${'Platform'} | ${{ platformName: 'darwin' }} | ${'darwin'}
|
2022-04-04 11:22:00 +05:30
|
|
|
${'IP Address'} | ${{ ipAddress: '127.0.0.1' }} | ${'127.0.0.1'}
|
|
|
|
${'IP Address'} | ${{ ipAddress: null }} | ${'None'}
|
|
|
|
${'Configuration'} | ${{ accessLevel: ACCESS_LEVEL_REF_PROTECTED, runUntagged: true }} | ${'Protected, Runs untagged jobs'}
|
|
|
|
${'Configuration'} | ${{ accessLevel: ACCESS_LEVEL_REF_PROTECTED, runUntagged: false }} | ${'Protected'}
|
|
|
|
${'Configuration'} | ${{ accessLevel: ACCESS_LEVEL_NOT_PROTECTED, runUntagged: true }} | ${'Runs untagged jobs'}
|
|
|
|
${'Configuration'} | ${{ accessLevel: ACCESS_LEVEL_NOT_PROTECTED, runUntagged: false }} | ${'None'}
|
|
|
|
${'Maximum job timeout'} | ${{ maximumTimeout: null }} | ${'None'}
|
|
|
|
${'Maximum job timeout'} | ${{ maximumTimeout: 0 }} | ${'0 seconds'}
|
|
|
|
${'Maximum job timeout'} | ${{ maximumTimeout: 59 }} | ${'59 seconds'}
|
|
|
|
${'Maximum job timeout'} | ${{ maximumTimeout: 10 * 60 + 5 }} | ${'10 minutes 5 seconds'}
|
2022-10-11 01:57:18 +05:30
|
|
|
${'Token expiry'} | ${{ tokenExpiresAt: mockOneHourAgo }} | ${'1 hour ago'}
|
|
|
|
${'Token expiry'} | ${{ tokenExpiresAt: null }} | ${'Never expires'}
|
2022-04-04 11:22:00 +05:30
|
|
|
`('"$field" field', ({ field, runner, expectedValue }) => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
props: {
|
|
|
|
runner: {
|
|
|
|
...mockRunner,
|
|
|
|
...runner,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
GlIntersperse,
|
|
|
|
GlSprintf,
|
|
|
|
TimeAgo,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`displays expected value "${expectedValue}"`, () => {
|
2022-07-23 23:45:48 +05:30
|
|
|
expect(findDd(field, wrapper).text()).toBe(expectedValue);
|
2022-04-04 11:22:00 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('"Tags" field', () => {
|
|
|
|
const stubs = { RunnerTags, RunnerTag };
|
|
|
|
|
|
|
|
it('displays expected value "tag-1 tag-2"', () => {
|
|
|
|
createComponent({
|
|
|
|
props: {
|
|
|
|
runner: { ...mockRunner, tagList: ['tag-1', 'tag-2'] },
|
|
|
|
},
|
|
|
|
stubs,
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
expect(findDd('Tags', wrapper).text().replace(/\s+/g, ' ')).toBe('tag-1 tag-2');
|
2022-04-04 11:22:00 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('displays "None" when runner has no tags', () => {
|
|
|
|
createComponent({
|
|
|
|
props: {
|
|
|
|
runner: { ...mockRunner, tagList: [] },
|
|
|
|
},
|
|
|
|
stubs,
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
expect(findDd('Tags', wrapper).text().replace(/\s+/g, ' ')).toBe('None');
|
2022-04-04 11:22:00 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Group runners', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
props: {
|
|
|
|
runner: mockGroupRunner,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Shows a group runner details', () => {
|
|
|
|
expect(findDetailGroups().props('runner')).toEqual(mockGroupRunner);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|