debian-mirror-gitlab/spec/javascripts/jobs/components/artifacts_block_spec.js

120 lines
3.5 KiB
JavaScript
Raw Normal View History

2018-11-20 20:47:30 +05:30
import Vue from 'vue';
import { getTimeago } from '~/lib/utils/datetime_utility';
import component from '~/jobs/components/artifacts_block.vue';
import mountComponent from '../../helpers/vue_mount_component_helper';
2019-09-04 21:01:54 +05:30
import { trimText } from '../../helpers/text_helper';
2018-11-20 20:47:30 +05:30
describe('Artifacts block', () => {
const Component = Vue.extend(component);
let vm;
const expireAt = '2018-08-14T09:38:49.157Z';
const timeago = getTimeago();
2019-02-15 15:39:39 +05:30
const formattedDate = timeago.format(expireAt);
2018-11-20 20:47:30 +05:30
2018-12-05 23:21:45 +05:30
const expiredArtifact = {
expire_at: expireAt,
expired: true,
};
const nonExpiredArtifact = {
download_path: '/gitlab-org/gitlab-ce/-/jobs/98314558/artifacts/download',
browse_path: '/gitlab-org/gitlab-ce/-/jobs/98314558/artifacts/browse',
keep_path: '/gitlab-org/gitlab-ce/-/jobs/98314558/artifacts/keep',
expire_at: expireAt,
expired: false,
};
2018-11-20 20:47:30 +05:30
afterEach(() => {
vm.$destroy();
});
describe('with expired artifacts', () => {
it('renders expired artifact date and info', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: expiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-artifacts-removed')).not.toBeNull();
expect(vm.$el.querySelector('.js-artifacts-will-be-removed')).toBeNull();
2019-02-15 15:39:39 +05:30
expect(trimText(vm.$el.querySelector('.js-artifacts-removed').textContent)).toEqual(
`The artifacts were removed ${formattedDate}`,
2018-12-05 23:21:45 +05:30
);
2018-11-20 20:47:30 +05:30
});
});
describe('with artifacts that will expire', () => {
it('renders will expire artifact date and info', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: nonExpiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-artifacts-removed')).toBeNull();
expect(vm.$el.querySelector('.js-artifacts-will-be-removed')).not.toBeNull();
2019-02-15 15:39:39 +05:30
expect(trimText(vm.$el.querySelector('.js-artifacts-will-be-removed').textContent)).toEqual(
`The artifacts will be removed ${formattedDate}`,
2018-12-05 23:21:45 +05:30
);
2018-11-20 20:47:30 +05:30
});
});
2018-12-05 23:21:45 +05:30
describe('with keep path', () => {
2018-11-20 20:47:30 +05:30
it('renders the keep button', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: nonExpiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-keep-artifacts')).not.toBeNull();
});
});
2018-12-05 23:21:45 +05:30
describe('without keep path', () => {
2018-11-20 20:47:30 +05:30
it('does not render the keep button', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: expiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-keep-artifacts')).toBeNull();
});
});
2018-12-05 23:21:45 +05:30
describe('with download path', () => {
2018-11-20 20:47:30 +05:30
it('renders the download button', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: nonExpiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-download-artifacts')).not.toBeNull();
});
});
2018-12-05 23:21:45 +05:30
describe('without download path', () => {
2018-11-20 20:47:30 +05:30
it('does not render the keep button', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: expiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-download-artifacts')).toBeNull();
});
});
2018-12-05 23:21:45 +05:30
describe('with browse path', () => {
2018-11-20 20:47:30 +05:30
it('does not render the browse button', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: nonExpiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-browse-artifacts')).not.toBeNull();
});
});
2018-12-05 23:21:45 +05:30
describe('without browse path', () => {
2018-11-20 20:47:30 +05:30
it('does not render the browse button', () => {
vm = mountComponent(Component, {
2018-12-05 23:21:45 +05:30
artifact: expiredArtifact,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-browse-artifacts')).toBeNull();
});
});
});