Skip to content
Snippets Groups Projects
Unverified Commit 160157a9 authored by Mike Greiling's avatar Mike Greiling
Browse files

Prettify remaining files with differences in CE and EE

parent ed816c3d
No related branches found
No related tags found
No related merge requests found
Showing
with 512 additions and 530 deletions
<script>
import { __ } from '~/locale';
import timeagoMixin from '~/vue_shared/mixins/timeago';
import { dateInWords, timeFor } from '~/lib/utils/datetime_utility';
import collapsedCalendarIcon from './collapsed_calendar_icon.vue';
import { __ } from '~/locale';
import timeagoMixin from '~/vue_shared/mixins/timeago';
import { dateInWords, timeFor } from '~/lib/utils/datetime_utility';
import collapsedCalendarIcon from './collapsed_calendar_icon.vue';
 
export default {
name: 'SidebarCollapsedGroupedDatePicker',
components: {
collapsedCalendarIcon,
export default {
name: 'SidebarCollapsedGroupedDatePicker',
components: {
collapsedCalendarIcon,
},
mixins: [timeagoMixin],
props: {
collapsed: {
type: Boolean,
required: false,
default: true,
},
mixins: [
timeagoMixin,
],
props: {
collapsed: {
type: Boolean,
required: false,
default: true,
},
minDate: {
type: Date,
required: false,
default: null,
},
maxDate: {
type: Date,
required: false,
default: null,
},
disableClickableIcons: {
type: Boolean,
required: false,
default: false,
},
minDate: {
type: Date,
required: false,
default: null,
},
computed: {
hasMinAndMaxDates() {
return this.minDate && this.maxDate;
},
hasNoMinAndMaxDates() {
return !this.minDate && !this.maxDate;
},
showMinDateBlock() {
return this.minDate || this.hasNoMinAndMaxDates;
},
showFromText() {
return !this.maxDate && this.minDate;
},
iconClass() {
const disabledClass = this.disableClickableIcons ? 'disabled' : '';
return `sidebar-collapsed-icon calendar-icon ${disabledClass}`;
},
maxDate: {
type: Date,
required: false,
default: null,
},
methods: {
toggleSidebar() {
this.$emit('toggleCollapse');
},
dateText(dateType = 'min') {
const date = this[`${dateType}Date`];
const dateWords = dateInWords(date, true);
const parsedDateWords = dateWords ? dateWords.replace(',', '') : dateWords;
disableClickableIcons: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
hasMinAndMaxDates() {
return this.minDate && this.maxDate;
},
hasNoMinAndMaxDates() {
return !this.minDate && !this.maxDate;
},
showMinDateBlock() {
return this.minDate || this.hasNoMinAndMaxDates;
},
showFromText() {
return !this.maxDate && this.minDate;
},
iconClass() {
const disabledClass = this.disableClickableIcons ? 'disabled' : '';
return `sidebar-collapsed-icon calendar-icon ${disabledClass}`;
},
},
methods: {
toggleSidebar() {
this.$emit('toggleCollapse');
},
dateText(dateType = 'min') {
const date = this[`${dateType}Date`];
const dateWords = dateInWords(date, true);
const parsedDateWords = dateWords ? dateWords.replace(',', '') : dateWords;
 
return date ? parsedDateWords : __('None');
},
tooltipText(dateType = 'min') {
const defaultText = dateType === 'min' ? __('Start date') : __('Due date');
const date = this[`${dateType}Date`];
const timeAgo = dateType === 'min' ? this.timeFormated(date) : timeFor(date);
const dateText = date ? [
this.dateText(dateType),
`(${timeAgo})`,
].join(' ') : '';
return date ? parsedDateWords : __('None');
},
tooltipText(dateType = 'min') {
const defaultText = dateType === 'min' ? __('Start date') : __('Due date');
const date = this[`${dateType}Date`];
const timeAgo = dateType === 'min' ? this.timeFormated(date) : timeFor(date);
const dateText = date ? [this.dateText(dateType), `(${timeAgo})`].join(' ') : '';
 
if (date) {
return [defaultText, dateText].join('<br />');
}
return __('Start and due date');
},
if (date) {
return [defaultText, dateText].join('<br />');
}
return __('Start and due date');
},
};
},
};
</script>
 
<template>
Loading
Loading
Loading
Loading
@@ -14,7 +14,10 @@ export default {
},
computed: {
labelsList() {
const labelsString = this.labels.slice(0, 5).map(label => label.title).join(', ');
const labelsString = this.labels
.slice(0, 5)
.map(label => label.title)
.join(', ');
 
if (this.labels.length > 5) {
return sprintf(s__('LabelSelect|%{labelsString}, and %{remainingLabelCount} more'), {
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ describe('Board list component', () => {
let mock;
let component;
 
beforeEach((done) => {
beforeEach(done => {
const el = document.createElement('div');
 
document.body.appendChild(el);
Loading
Loading
@@ -62,122 +62,102 @@ describe('Board list component', () => {
});
 
it('renders component', () => {
expect(
component.$el.classList.contains('board-list-component'),
).toBe(true);
expect(component.$el.classList.contains('board-list-component')).toBe(true);
});
 
it('renders loading icon', (done) => {
it('renders loading icon', done => {
component.loading = true;
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-list-loading'),
).not.toBeNull();
expect(component.$el.querySelector('.board-list-loading')).not.toBeNull();
 
done();
});
});
 
it('renders issues', () => {
expect(
component.$el.querySelectorAll('.board-card').length,
).toBe(1);
expect(component.$el.querySelectorAll('.board-card').length).toBe(1);
});
 
it('sets data attribute with issue id', () => {
expect(
component.$el.querySelector('.board-card').getAttribute('data-issue-id'),
).toBe('1');
expect(component.$el.querySelector('.board-card').getAttribute('data-issue-id')).toBe('1');
});
 
it('shows new issue form', (done) => {
it('shows new issue form', done => {
component.toggleForm();
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-new-issue-form'),
).not.toBeNull();
expect(component.$el.querySelector('.board-new-issue-form')).not.toBeNull();
 
expect(
component.$el.querySelector('.is-smaller'),
).not.toBeNull();
expect(component.$el.querySelector('.is-smaller')).not.toBeNull();
 
done();
});
});
 
it('shows new issue form after eventhub event', (done) => {
it('shows new issue form after eventhub event', done => {
eventHub.$emit(`hide-issue-form-${component.list.id}`);
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-new-issue-form'),
).not.toBeNull();
expect(component.$el.querySelector('.board-new-issue-form')).not.toBeNull();
 
expect(
component.$el.querySelector('.is-smaller'),
).not.toBeNull();
expect(component.$el.querySelector('.is-smaller')).not.toBeNull();
 
done();
});
});
 
it('does not show new issue form for closed list', (done) => {
it('does not show new issue form for closed list', done => {
component.list.type = 'closed';
component.toggleForm();
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-new-issue-form'),
).toBeNull();
expect(component.$el.querySelector('.board-new-issue-form')).toBeNull();
 
done();
});
});
 
it('shows count list item', (done) => {
it('shows count list item', done => {
component.showCount = true;
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-list-count'),
).not.toBeNull();
expect(component.$el.querySelector('.board-list-count')).not.toBeNull();
 
expect(
component.$el.querySelector('.board-list-count').textContent.trim(),
).toBe('Showing all issues');
expect(component.$el.querySelector('.board-list-count').textContent.trim()).toBe(
'Showing all issues',
);
 
done();
});
});
 
it('sets data attribute with invalid id', (done) => {
it('sets data attribute with invalid id', done => {
component.showCount = true;
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-list-count').getAttribute('data-issue-id'),
).toBe('-1');
expect(component.$el.querySelector('.board-list-count').getAttribute('data-issue-id')).toBe(
'-1',
);
 
done();
});
});
 
it('shows how many more issues to load', (done) => {
it('shows how many more issues to load', done => {
component.showCount = true;
component.list.issuesSize = 20;
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-list-count').textContent.trim(),
).toBe('Showing 1 of 20 issues');
expect(component.$el.querySelector('.board-list-count').textContent.trim()).toBe(
'Showing 1 of 20 issues',
);
 
done();
});
});
 
it('loads more issues after scrolling', (done) => {
it('loads more issues after scrolling', done => {
spyOn(component.list, 'nextPage');
component.$refs.list.style.height = '100px';
component.$refs.list.style.overflow = 'scroll';
Loading
Loading
@@ -200,7 +180,9 @@ describe('Board list component', () => {
});
 
it('does not load issues if already loading', () => {
component.list.nextPage = spyOn(component.list, 'nextPage').and.returnValue(new Promise(() => {}));
component.list.nextPage = spyOn(component.list, 'nextPage').and.returnValue(
new Promise(() => {}),
);
 
component.onScroll();
component.onScroll();
Loading
Loading
@@ -208,14 +190,12 @@ describe('Board list component', () => {
expect(component.list.nextPage).toHaveBeenCalledTimes(1);
});
 
it('shows loading more spinner', (done) => {
it('shows loading more spinner', done => {
component.showCount = true;
component.list.loadingMore = true;
 
Vue.nextTick(() => {
expect(
component.$el.querySelector('.board-list-count .fa-spinner'),
).not.toBeNull();
expect(component.$el.querySelector('.board-list-count .fa-spinner')).not.toBeNull();
 
done();
});
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ describe('Board component', () => {
let vm;
let el;
 
beforeEach((done) => {
beforeEach(done => {
loadFixtures('boards/show.html.raw');
 
el = document.createElement('div');
Loading
Loading
@@ -50,56 +50,46 @@ describe('Board component', () => {
});
 
it('board is expandable when list type is backlog', () => {
expect(
vm.$el.classList.contains('is-expandable'),
).toBe(true);
expect(vm.$el.classList.contains('is-expandable')).toBe(true);
});
 
it('board is expandable when list type is closed', (done) => {
it('board is expandable when list type is closed', done => {
vm.list.type = 'closed';
 
Vue.nextTick(() => {
expect(
vm.$el.classList.contains('is-expandable'),
).toBe(true);
expect(vm.$el.classList.contains('is-expandable')).toBe(true);
 
done();
});
});
 
it('board is not expandable when list type is label', (done) => {
it('board is not expandable when list type is label', done => {
vm.list.type = 'label';
vm.list.isExpandable = false;
 
Vue.nextTick(() => {
expect(
vm.$el.classList.contains('is-expandable'),
).toBe(false);
expect(vm.$el.classList.contains('is-expandable')).toBe(false);
 
done();
});
});
 
it('collapses when clicking header', (done) => {
it('collapses when clicking header', done => {
vm.$el.querySelector('.board-header').click();
 
Vue.nextTick(() => {
expect(
vm.$el.classList.contains('is-collapsed'),
).toBe(true);
expect(vm.$el.classList.contains('is-collapsed')).toBe(true);
 
done();
});
});
 
it('created sets isExpanded to true from localStorage', (done) => {
it('created sets isExpanded to true from localStorage', done => {
vm.$el.querySelector('.board-header').click();
 
return Vue.nextTick()
.then(() => {
expect(
vm.$el.classList.contains('is-collapsed'),
).toBe(true);
expect(vm.$el.classList.contains('is-collapsed')).toBe(true);
 
// call created manually
vm.$options.created[0].call(vm);
Loading
Loading
@@ -107,11 +97,10 @@ describe('Board component', () => {
return Vue.nextTick();
})
.then(() => {
expect(
vm.$el.classList.contains('is-collapsed'),
).toBe(true);
expect(vm.$el.classList.contains('is-collapsed')).toBe(true);
 
done();
}).catch(done.fail);
})
.catch(done.fail);
});
});
import Vue from 'vue';
import emptyState from '~/environments/components/empty_state.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
Loading
Loading
@@ -25,13 +24,13 @@ describe('environments empty state', () => {
});
 
it('renders empty state and new environment button', () => {
expect(
vm.$el.querySelector('.js-blank-state-title').textContent.trim(),
).toEqual('You don\'t have any environments right now');
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
"You don't have any environments right now",
);
 
expect(
vm.$el.querySelector('.js-new-environment-button').getAttribute('href'),
).toEqual('foo');
expect(vm.$el.querySelector('.js-new-environment-button').getAttribute('href')).toEqual(
'foo',
);
});
});
 
Loading
Loading
@@ -45,13 +44,11 @@ describe('environments empty state', () => {
});
 
it('renders empty state without new button', () => {
expect(
vm.$el.querySelector('.js-blank-state-title').textContent.trim(),
).toEqual('You don\'t have any environments right now');
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
"You don't have any environments right now",
);
 
expect(
vm.$el.querySelector('.js-new-environment-button'),
).toBeNull();
expect(vm.$el.querySelector('.js-new-environment-button')).toBeNull();
});
});
});
Loading
Loading
@@ -38,7 +38,9 @@ describe('Environment item', () => {
});
 
it('Should render the number of children in a badge', () => {
expect(component.$el.querySelector('.folder-name .badge').textContent).toContain(mockItem.size);
expect(component.$el.querySelector('.folder-name .badge').textContent).toContain(
mockItem.size,
);
});
});
 
Loading
Loading
@@ -68,7 +70,8 @@ describe('Environment item', () => {
username: 'root',
id: 1,
state: 'active',
avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
avatar_url:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
web_url: 'http://localhost:3000/root',
},
commit: {
Loading
Loading
@@ -84,7 +87,8 @@ describe('Environment item', () => {
username: 'root',
id: 1,
state: 'active',
avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
avatar_url:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
web_url: 'http://localhost:3000/root',
},
commit_path: '/root/ci-folders/tree/500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
Loading
Loading
@@ -121,18 +125,18 @@ describe('Environment item', () => {
});
 
it('should render environment name', () => {
expect(component.$el.querySelector('.environment-name').textContent).toContain(environment.name);
expect(component.$el.querySelector('.environment-name').textContent).toContain(
environment.name,
);
});
 
describe('With deployment', () => {
it('should render deployment internal id', () => {
expect(
component.$el.querySelector('.deployment-column span').textContent,
).toContain(environment.last_deployment.iid);
expect(component.$el.querySelector('.deployment-column span').textContent).toContain(
environment.last_deployment.iid,
);
 
expect(
component.$el.querySelector('.deployment-column span').textContent,
).toContain('#');
expect(component.$el.querySelector('.deployment-column span').textContent).toContain('#');
});
 
it('should render last deployment date', () => {
Loading
Loading
@@ -156,56 +160,46 @@ describe('Environment item', () => {
 
describe('With build url', () => {
it('Should link to build url provided', () => {
expect(
component.$el.querySelector('.build-link').getAttribute('href'),
).toEqual(environment.last_deployment.deployable.build_path);
expect(component.$el.querySelector('.build-link').getAttribute('href')).toEqual(
environment.last_deployment.deployable.build_path,
);
});
 
it('Should render deployable name and id', () => {
expect(
component.$el.querySelector('.build-link').getAttribute('href'),
).toEqual(environment.last_deployment.deployable.build_path);
expect(component.$el.querySelector('.build-link').getAttribute('href')).toEqual(
environment.last_deployment.deployable.build_path,
);
});
});
 
describe('With commit information', () => {
it('should render commit component', () => {
expect(
component.$el.querySelector('.js-commit-component'),
).toBeDefined();
expect(component.$el.querySelector('.js-commit-component')).toBeDefined();
});
});
});
 
describe('With manual actions', () => {
it('Should render actions component', () => {
expect(
component.$el.querySelector('.js-manual-actions-container'),
).toBeDefined();
expect(component.$el.querySelector('.js-manual-actions-container')).toBeDefined();
});
});
 
describe('With external URL', () => {
it('should render external url component', () => {
expect(
component.$el.querySelector('.js-external-url-container'),
).toBeDefined();
expect(component.$el.querySelector('.js-external-url-container')).toBeDefined();
});
});
 
describe('With stop action', () => {
it('Should render stop action component', () => {
expect(
component.$el.querySelector('.js-stop-component-container'),
).toBeDefined();
expect(component.$el.querySelector('.js-stop-component-container')).toBeDefined();
});
});
 
describe('With retry action', () => {
it('Should render rollback component', () => {
expect(
component.$el.querySelector('.js-rollback-component-container'),
).toBeDefined();
expect(component.$el.querySelector('.js-rollback-component-container')).toBeDefined();
});
});
});
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ describe('Environment', () => {
 
describe('successfull request', () => {
describe('without environments', () => {
beforeEach((done) => {
beforeEach(done => {
mock.onGet(mockData.endpoint).reply(200, { environments: [] });
 
component = mountComponent(EnvironmentsComponent, mockData);
Loading
Loading
@@ -44,30 +44,34 @@ describe('Environment', () => {
});
 
it('should render the empty state', () => {
expect(
component.$el.querySelector('.js-new-environment-button').textContent,
).toContain('New environment');
expect(component.$el.querySelector('.js-new-environment-button').textContent).toContain(
'New environment',
);
 
expect(
component.$el.querySelector('.js-blank-state-title').textContent,
).toContain('You don\'t have any environments right now');
expect(component.$el.querySelector('.js-blank-state-title').textContent).toContain(
"You don't have any environments right now",
);
});
});
 
describe('with paginated environments', () => {
beforeEach((done) => {
mock.onGet(mockData.endpoint).reply(200, {
environments: [environment],
stopped_count: 1,
available_count: 0,
}, {
'X-nExt-pAge': '2',
'x-page': '1',
'X-Per-Page': '1',
'X-Prev-Page': '',
'X-TOTAL': '37',
'X-Total-Pages': '2',
});
beforeEach(done => {
mock.onGet(mockData.endpoint).reply(
200,
{
environments: [environment],
stopped_count: 1,
available_count: 0,
},
{
'X-nExt-pAge': '2',
'x-page': '1',
'X-Per-Page': '1',
'X-Prev-Page': '',
'X-TOTAL': '37',
'X-Total-Pages': '2',
},
);
 
component = mountComponent(EnvironmentsComponent, mockData);
 
Loading
Loading
@@ -78,19 +82,17 @@ describe('Environment', () => {
 
it('should render a table with environments', () => {
expect(component.$el.querySelectorAll('table')).not.toBeNull();
expect(
component.$el.querySelector('.environment-name').textContent.trim(),
).toEqual(environment.name);
expect(component.$el.querySelector('.environment-name').textContent.trim()).toEqual(
environment.name,
);
});
 
describe('pagination', () => {
it('should render pagination', () => {
expect(
component.$el.querySelectorAll('.gl-pagination li').length,
).toEqual(5);
expect(component.$el.querySelectorAll('.gl-pagination li').length).toEqual(5);
});
 
it('should make an API request when page is clicked', (done) => {
it('should make an API request when page is clicked', done => {
spyOn(component, 'updateContent');
setTimeout(() => {
component.$el.querySelector('.gl-pagination li:nth-child(5) a').click();
Loading
Loading
@@ -100,7 +102,7 @@ describe('Environment', () => {
}, 0);
});
 
it('should make an API request when using tabs', (done) => {
it('should make an API request when using tabs', done => {
setTimeout(() => {
spyOn(component, 'updateContent');
component.$el.querySelector('.js-environments-tab-stopped').click();
Loading
Loading
@@ -114,7 +116,7 @@ describe('Environment', () => {
});
 
describe('unsuccessfull request', () => {
beforeEach((done) => {
beforeEach(done => {
mock.onGet(mockData.endpoint).reply(500, {});
 
component = mountComponent(EnvironmentsComponent, mockData);
Loading
Loading
@@ -125,15 +127,16 @@ describe('Environment', () => {
});
 
it('should render empty state', () => {
expect(
component.$el.querySelector('.js-blank-state-title').textContent,
).toContain('You don\'t have any environments right now');
expect(component.$el.querySelector('.js-blank-state-title').textContent).toContain(
"You don't have any environments right now",
);
});
});
 
describe('expandable folders', () => {
beforeEach(() => {
mock.onGet(mockData.endpoint).reply(200,
mock.onGet(mockData.endpoint).reply(
200,
{
environments: [folder],
stopped_count: 0,
Loading
Loading
@@ -154,7 +157,7 @@ describe('Environment', () => {
component = mountComponent(EnvironmentsComponent, mockData);
});
 
it('should open a closed folder', (done) => {
it('should open a closed folder', done => {
setTimeout(() => {
component.$el.querySelector('.folder-name').click();
 
Loading
Loading
@@ -165,7 +168,7 @@ describe('Environment', () => {
}, 0);
});
 
it('should close an opened folder', (done) => {
it('should close an opened folder', done => {
setTimeout(() => {
// open folder
component.$el.querySelector('.folder-name').click();
Loading
Loading
@@ -182,7 +185,7 @@ describe('Environment', () => {
}, 0);
});
 
it('should show children environments and a button to show all environments', (done) => {
it('should show children environments and a button to show all environments', done => {
setTimeout(() => {
// open folder
component.$el.querySelector('.folder-name').click();
Loading
Loading
@@ -191,7 +194,9 @@ describe('Environment', () => {
// wait for next async request
setTimeout(() => {
expect(component.$el.querySelectorAll('.js-child-row').length).toEqual(1);
expect(component.$el.querySelector('.text-center > a.btn').textContent).toContain('Show all');
expect(component.$el.querySelector('.text-center > a.btn').textContent).toContain(
'Show all',
);
done();
});
});
Loading
Loading
@@ -201,7 +206,8 @@ describe('Environment', () => {
 
describe('methods', () => {
beforeEach(() => {
mock.onGet(mockData.endpoint).reply(200,
mock.onGet(mockData.endpoint).reply(
200,
{
environments: [],
stopped_count: 0,
Loading
Loading
@@ -215,8 +221,9 @@ describe('Environment', () => {
});
 
describe('updateContent', () => {
it('should set given parameters', (done) => {
component.updateContent({ scope: 'stopped', page: '3' })
it('should set given parameters', done => {
component
.updateContent({ scope: 'stopped', page: '3' })
.then(() => {
expect(component.page).toEqual('3');
expect(component.scope).toEqual('stopped');
Loading
Loading
Loading
Loading
@@ -32,37 +32,41 @@ describe('Environments Folder View', () => {
 
describe('successfull request', () => {
beforeEach(() => {
mock.onGet(mockData.endpoint).reply(200, {
environments: environmentsList,
stopped_count: 1,
available_count: 0,
}, {
'X-nExt-pAge': '2',
'x-page': '1',
'X-Per-Page': '2',
'X-Prev-Page': '',
'X-TOTAL': '20',
'X-Total-Pages': '10',
});
mock.onGet(mockData.endpoint).reply(
200,
{
environments: environmentsList,
stopped_count: 1,
available_count: 0,
},
{
'X-nExt-pAge': '2',
'x-page': '1',
'X-Per-Page': '2',
'X-Prev-Page': '',
'X-TOTAL': '20',
'X-Total-Pages': '10',
},
);
 
component = mountComponent(Component, mockData);
});
 
it('should render a table with environments', (done) => {
it('should render a table with environments', done => {
setTimeout(() => {
expect(component.$el.querySelectorAll('table')).not.toBeNull();
expect(
component.$el.querySelector('.environment-name').textContent.trim(),
).toEqual(environmentsList[0].name);
expect(component.$el.querySelector('.environment-name').textContent.trim()).toEqual(
environmentsList[0].name,
);
done();
}, 0);
});
 
it('should render available tab with count', (done) => {
it('should render available tab with count', done => {
setTimeout(() => {
expect(
component.$el.querySelector('.js-environments-tab-available').textContent,
).toContain('Available');
expect(component.$el.querySelector('.js-environments-tab-available').textContent).toContain(
'Available',
);
 
expect(
component.$el.querySelector('.js-environments-tab-available .badge').textContent,
Loading
Loading
@@ -71,11 +75,11 @@ describe('Environments Folder View', () => {
}, 0);
});
 
it('should render stopped tab with count', (done) => {
it('should render stopped tab with count', done => {
setTimeout(() => {
expect(
component.$el.querySelector('.js-environments-tab-stopped').textContent,
).toContain('Stopped');
expect(component.$el.querySelector('.js-environments-tab-stopped').textContent).toContain(
'Stopped',
);
 
expect(
component.$el.querySelector('.js-environments-tab-stopped .badge').textContent,
Loading
Loading
@@ -84,36 +88,37 @@ describe('Environments Folder View', () => {
}, 0);
});
 
it('should render parent folder name', (done) => {
it('should render parent folder name', done => {
setTimeout(() => {
expect(
component.$el.querySelector('.js-folder-name').textContent.trim(),
).toContain('Environments / review');
expect(component.$el.querySelector('.js-folder-name').textContent.trim()).toContain(
'Environments / review',
);
done();
}, 0);
});
 
describe('pagination', () => {
it('should render pagination', (done) => {
it('should render pagination', done => {
setTimeout(() => {
expect(
component.$el.querySelectorAll('.gl-pagination'),
).not.toBeNull();
expect(component.$el.querySelectorAll('.gl-pagination')).not.toBeNull();
done();
}, 0);
});
 
it('should make an API request when changing page', (done) => {
it('should make an API request when changing page', done => {
spyOn(component, 'updateContent');
setTimeout(() => {
component.$el.querySelector('.gl-pagination .js-last-button a').click();
 
expect(component.updateContent).toHaveBeenCalledWith({ scope: component.scope, page: '10' });
expect(component.updateContent).toHaveBeenCalledWith({
scope: component.scope,
page: '10',
});
done();
}, 0);
});
 
it('should make an API request when using tabs', (done) => {
it('should make an API request when using tabs', done => {
setTimeout(() => {
spyOn(component, 'updateContent');
component.$el.querySelector('.js-environments-tab-stopped').click();
Loading
Loading
@@ -134,20 +139,18 @@ describe('Environments Folder View', () => {
component = mountComponent(Component, mockData);
});
 
it('should not render a table', (done) => {
it('should not render a table', done => {
setTimeout(() => {
expect(
component.$el.querySelector('table'),
).toBe(null);
expect(component.$el.querySelector('table')).toBe(null);
done();
}, 0);
});
 
it('should render available tab with count 0', (done) => {
it('should render available tab with count 0', done => {
setTimeout(() => {
expect(
component.$el.querySelector('.js-environments-tab-available').textContent,
).toContain('Available');
expect(component.$el.querySelector('.js-environments-tab-available').textContent).toContain(
'Available',
);
 
expect(
component.$el.querySelector('.js-environments-tab-available .badge').textContent,
Loading
Loading
@@ -156,11 +159,11 @@ describe('Environments Folder View', () => {
}, 0);
});
 
it('should render stopped tab with count 0', (done) => {
it('should render stopped tab with count 0', done => {
setTimeout(() => {
expect(
component.$el.querySelector('.js-environments-tab-stopped').textContent,
).toContain('Stopped');
expect(component.$el.querySelector('.js-environments-tab-stopped').textContent).toContain(
'Stopped',
);
 
expect(
component.$el.querySelector('.js-environments-tab-stopped .badge').textContent,
Loading
Loading
@@ -181,8 +184,9 @@ describe('Environments Folder View', () => {
});
 
describe('updateContent', () => {
it('should set given parameters', (done) => {
component.updateContent({ scope: 'stopped', page: '4' })
it('should set given parameters', done => {
component
.updateContent({ scope: 'stopped', page: '4' })
.then(() => {
expect(component.page).toEqual('4');
expect(component.scope).toEqual('stopped');
Loading
Loading
Loading
Loading
@@ -25,25 +25,21 @@ describe('Title component', () => {
});
 
it('renders title HTML', () => {
expect(
vm.$el.querySelector('.title').innerHTML.trim(),
).toBe('Testing <img>');
expect(vm.$el.querySelector('.title').innerHTML.trim()).toBe('Testing <img>');
});
 
it('updates page title when changing titleHtml', (done) => {
it('updates page title when changing titleHtml', done => {
spyOn(vm, 'setPageTitle');
vm.titleHtml = 'test';
 
Vue.nextTick(() => {
expect(
vm.setPageTitle,
).toHaveBeenCalled();
expect(vm.setPageTitle).toHaveBeenCalled();
 
done();
});
});
 
it('animates title changes', (done) => {
it('animates title changes', done => {
vm.titleHtml = 'test';
 
Vue.nextTick(() => {
Loading
Loading
@@ -61,14 +57,12 @@ describe('Title component', () => {
});
});
 
it('updates page title after changing title', (done) => {
it('updates page title after changing title', done => {
vm.titleHtml = 'changed';
vm.titleText = 'changed';
 
Vue.nextTick(() => {
expect(
document.querySelector('title').textContent.trim(),
).toContain('changed');
expect(document.querySelector('title').textContent.trim()).toContain('changed');
 
done();
});
Loading
Loading
Loading
Loading
@@ -234,7 +234,7 @@ describe('Job App ', () => {
);
done();
}, 0);
})
});
});
 
it('does not renders stuck block when there are no runners', done => {
Loading
Loading
Loading
Loading
@@ -68,41 +68,20 @@ describe('Job State actions', () => {
 
describe('hideSidebar', () => {
it('should commit HIDE_SIDEBAR mutation', done => {
testAction(
hideSidebar,
null,
mockedState,
[{ type: types.HIDE_SIDEBAR }],
[],
done,
);
testAction(hideSidebar, null, mockedState, [{ type: types.HIDE_SIDEBAR }], [], done);
});
});
 
describe('showSidebar', () => {
it('should commit HIDE_SIDEBAR mutation', done => {
testAction(
showSidebar,
null,
mockedState,
[{ type: types.SHOW_SIDEBAR }],
[],
done,
);
testAction(showSidebar, null, mockedState, [{ type: types.SHOW_SIDEBAR }], [], done);
});
});
 
describe('toggleSidebar', () => {
describe('when isSidebarOpen is true', () => {
it('should dispatch hideSidebar', done => {
testAction(
toggleSidebar,
null,
mockedState,
[],
[{ type: 'hideSidebar' }],
done,
);
testAction(toggleSidebar, null, mockedState, [], [{ type: 'hideSidebar' }], done);
});
});
 
Loading
Loading
@@ -110,14 +89,7 @@ describe('Job State actions', () => {
it('should dispatch showSidebar', done => {
mockedState.isSidebarOpen = false;
 
testAction(
toggleSidebar,
null,
mockedState,
[],
[{ type: 'showSidebar' }],
done,
);
testAction(toggleSidebar, null, mockedState, [], [{ type: 'showSidebar' }], done);
});
});
});
Loading
Loading
Loading
Loading
@@ -180,7 +180,7 @@ describe('Job Store Getters', () => {
it('returns true', () => {
localState.job.runners = {
available: true,
online: false
online: false,
};
 
expect(getters.hasRunnersForProject(localState)).toEqual(true);
Loading
Loading
@@ -191,7 +191,7 @@ describe('Job Store Getters', () => {
it('returns false', () => {
localState.job.runners = {
available: false,
online: false
online: false,
};
 
expect(getters.hasRunnersForProject(localState)).toEqual(false);
Loading
Loading
@@ -202,7 +202,7 @@ describe('Job Store Getters', () => {
it('returns false', () => {
localState.job.runners = {
available: false,
online: true
online: true,
};
 
expect(getters.hasRunnersForProject(localState)).toEqual(false);
Loading
Loading
Loading
Loading
@@ -35,9 +35,7 @@ describe('common_utils', () => {
});
 
it('should decode params', () => {
expect(
commonUtils.urlParamsToArray('?label_name%5B%5D=test')[0],
).toBe('label_name[]=test');
expect(commonUtils.urlParamsToArray('?label_name%5B%5D=test')[0]).toBe('label_name[]=test');
});
 
it('should remove the question mark from the search params', () => {
Loading
Loading
@@ -49,25 +47,19 @@ describe('common_utils', () => {
 
describe('urlParamsToObject', () => {
it('parses path for label with trailing +', () => {
expect(
commonUtils.urlParamsToObject('label_name[]=label%2B', {}),
).toEqual({
expect(commonUtils.urlParamsToObject('label_name[]=label%2B', {})).toEqual({
label_name: ['label+'],
});
});
 
it('parses path for milestone with trailing +', () => {
expect(
commonUtils.urlParamsToObject('milestone_title=A%2B', {}),
).toEqual({
expect(commonUtils.urlParamsToObject('milestone_title=A%2B', {})).toEqual({
milestone_title: 'A+',
});
});
 
it('parses path for search terms with spaces', () => {
expect(
commonUtils.urlParamsToObject('search=two+words', {}),
).toEqual({
expect(commonUtils.urlParamsToObject('search=two+words', {})).toEqual({
search: 'two words',
});
});
Loading
Loading
@@ -187,7 +179,10 @@ describe('common_utils', () => {
 
describe('parseQueryStringIntoObject', () => {
it('should return object with query parameters', () => {
expect(commonUtils.parseQueryStringIntoObject('scope=all&page=2')).toEqual({ scope: 'all', page: '2' });
expect(commonUtils.parseQueryStringIntoObject('scope=all&page=2')).toEqual({
scope: 'all',
page: '2',
});
expect(commonUtils.parseQueryStringIntoObject('scope=all')).toEqual({ scope: 'all' });
expect(commonUtils.parseQueryStringIntoObject()).toEqual({});
});
Loading
Loading
@@ -211,7 +206,9 @@ describe('common_utils', () => {
describe('buildUrlWithCurrentLocation', () => {
it('should build an url with current location and given parameters', () => {
expect(commonUtils.buildUrlWithCurrentLocation()).toEqual(window.location.pathname);
expect(commonUtils.buildUrlWithCurrentLocation('?page=2')).toEqual(`${window.location.pathname}?page=2`);
expect(commonUtils.buildUrlWithCurrentLocation('?page=2')).toEqual(
`${window.location.pathname}?page=2`,
);
});
});
 
Loading
Loading
@@ -266,21 +263,24 @@ describe('common_utils', () => {
});
 
describe('normalizeCRLFHeaders', () => {
beforeEach(function () {
this.CLRFHeaders = 'a-header: a-value\nAnother-Header: ANOTHER-VALUE\nLaSt-HeAdEr: last-VALUE';
beforeEach(function() {
this.CLRFHeaders =
'a-header: a-value\nAnother-Header: ANOTHER-VALUE\nLaSt-HeAdEr: last-VALUE';
spyOn(String.prototype, 'split').and.callThrough();
this.normalizeCRLFHeaders = commonUtils.normalizeCRLFHeaders(this.CLRFHeaders);
});
 
it('should split by newline', function () {
it('should split by newline', function() {
expect(String.prototype.split).toHaveBeenCalledWith('\n');
});
 
it('should split by colon+space for each header', function () {
expect(String.prototype.split.calls.allArgs().filter(args => args[0] === ': ').length).toBe(3);
it('should split by colon+space for each header', function() {
expect(String.prototype.split.calls.allArgs().filter(args => args[0] === ': ').length).toBe(
3,
);
});
 
it('should return a normalized headers object', function () {
it('should return a normalized headers object', function() {
expect(this.normalizeCRLFHeaders).toEqual({
'A-HEADER': 'a-value',
'ANOTHER-HEADER': 'ANOTHER-VALUE',
Loading
Loading
@@ -359,67 +359,79 @@ describe('common_utils', () => {
spyOn(window, 'setTimeout').and.callFake(cb => origSetTimeout(cb, 0));
});
 
it('solves the promise from the callback', (done) => {
it('solves the promise from the callback', done => {
const expectedResponseValue = 'Success!';
commonUtils.backOff((next, stop) => (
new Promise((resolve) => {
resolve(expectedResponseValue);
}).then((resp) => {
stop(resp);
commonUtils
.backOff((next, stop) =>
new Promise(resolve => {
resolve(expectedResponseValue);
})
.then(resp => {
stop(resp);
})
.catch(done.fail),
)
.then(respBackoff => {
expect(respBackoff).toBe(expectedResponseValue);
done();
})
).catch(done.fail)).then((respBackoff) => {
expect(respBackoff).toBe(expectedResponseValue);
done();
}).catch(done.fail);
.catch(done.fail);
});
 
it('catches the rejected promise from the callback ', (done) => {
it('catches the rejected promise from the callback ', done => {
const errorMessage = 'Mistakes were made!';
commonUtils.backOff((next, stop) => {
new Promise((resolve, reject) => {
reject(new Error(errorMessage));
}).then((resp) => {
stop(resp);
}).catch(err => stop(err));
}).catch((errBackoffResp) => {
expect(errBackoffResp instanceof Error).toBe(true);
expect(errBackoffResp.message).toBe(errorMessage);
done();
});
commonUtils
.backOff((next, stop) => {
new Promise((resolve, reject) => {
reject(new Error(errorMessage));
})
.then(resp => {
stop(resp);
})
.catch(err => stop(err));
})
.catch(errBackoffResp => {
expect(errBackoffResp instanceof Error).toBe(true);
expect(errBackoffResp.message).toBe(errorMessage);
done();
});
});
 
it('solves the promise correctly after retrying a third time', (done) => {
it('solves the promise correctly after retrying a third time', done => {
let numberOfCalls = 1;
const expectedResponseValue = 'Success!';
commonUtils.backOff((next, stop) => (
Promise.resolve(expectedResponseValue)
.then((resp) => {
if (numberOfCalls < 3) {
numberOfCalls += 1;
next();
} else {
stop(resp);
}
})
).catch(done.fail)).then((respBackoff) => {
const timeouts = window.setTimeout.calls.allArgs().map(([, timeout]) => timeout);
commonUtils
.backOff((next, stop) =>
Promise.resolve(expectedResponseValue)
.then(resp => {
if (numberOfCalls < 3) {
numberOfCalls += 1;
next();
} else {
stop(resp);
}
})
.catch(done.fail),
)
.then(respBackoff => {
const timeouts = window.setTimeout.calls.allArgs().map(([, timeout]) => timeout);
 
expect(timeouts).toEqual([2000, 4000]);
expect(respBackoff).toBe(expectedResponseValue);
done();
}).catch(done.fail);
expect(timeouts).toEqual([2000, 4000]);
expect(respBackoff).toBe(expectedResponseValue);
done();
})
.catch(done.fail);
});
 
it('rejects the backOff promise after timing out', (done) => {
commonUtils.backOff(next => next(), 64000)
.catch((errBackoffResp) => {
const timeouts = window.setTimeout.calls.allArgs().map(([, timeout]) => timeout);
it('rejects the backOff promise after timing out', done => {
commonUtils.backOff(next => next(), 64000).catch(errBackoffResp => {
const timeouts = window.setTimeout.calls.allArgs().map(([, timeout]) => timeout);
 
expect(timeouts).toEqual([2000, 4000, 8000, 16000, 32000, 32000]);
expect(errBackoffResp instanceof Error).toBe(true);
expect(errBackoffResp.message).toBe('BACKOFF_TIMEOUT');
done();
});
expect(timeouts).toEqual([2000, 4000, 8000, 16000, 32000, 32000]);
expect(errBackoffResp instanceof Error).toBe(true);
expect(errBackoffResp.message).toBe('BACKOFF_TIMEOUT');
done();
});
});
});
 
Loading
Loading
@@ -466,11 +478,14 @@ describe('common_utils', () => {
});
 
describe('createOverlayIcon', () => {
it('should return the favicon with the overlay', (done) => {
commonUtils.createOverlayIcon(faviconDataUrl, overlayDataUrl).then((url) => {
expect(url).toEqual(faviconWithOverlayDataUrl);
done();
}).catch(done.fail);
it('should return the favicon with the overlay', done => {
commonUtils
.createOverlayIcon(faviconDataUrl, overlayDataUrl)
.then(url => {
expect(url).toEqual(faviconWithOverlayDataUrl);
done();
})
.catch(done.fail);
});
});
 
Loading
Loading
@@ -486,11 +501,16 @@ describe('common_utils', () => {
document.body.removeChild(document.getElementById('favicon'));
});
 
it('should set page favicon to provided favicon overlay', (done) => {
commonUtils.setFaviconOverlay(overlayDataUrl).then(() => {
expect(document.getElementById('favicon').getAttribute('href')).toEqual(faviconWithOverlayDataUrl);
done();
}).catch(done.fail);
it('should set page favicon to provided favicon overlay', done => {
commonUtils
.setFaviconOverlay(overlayDataUrl)
.then(() => {
expect(document.getElementById('favicon').getAttribute('href')).toEqual(
faviconWithOverlayDataUrl,
);
done();
})
.catch(done.fail);
});
});
 
Loading
Loading
@@ -512,24 +532,24 @@ describe('common_utils', () => {
document.body.removeChild(document.getElementById('favicon'));
});
 
it('should reset favicon in case of error', (done) => {
it('should reset favicon in case of error', done => {
mock.onGet(BUILD_URL).replyOnce(500);
 
commonUtils.setCiStatusFavicon(BUILD_URL)
.catch(() => {
const favicon = document.getElementById('favicon');
commonUtils.setCiStatusFavicon(BUILD_URL).catch(() => {
const favicon = document.getElementById('favicon');
 
expect(favicon.getAttribute('href')).toEqual(faviconDataUrl);
done();
});
expect(favicon.getAttribute('href')).toEqual(faviconDataUrl);
done();
});
});
 
it('should set page favicon to CI status favicon based on provided status', (done) => {
it('should set page favicon to CI status favicon based on provided status', done => {
mock.onGet(BUILD_URL).reply(200, {
favicon: overlayDataUrl,
});
 
commonUtils.setCiStatusFavicon(BUILD_URL)
commonUtils
.setCiStatusFavicon(BUILD_URL)
.then(() => {
const favicon = document.getElementById('favicon');
 
Loading
Loading
@@ -554,11 +574,15 @@ describe('common_utils', () => {
});
 
it('should return the svg for a linked icon', () => {
expect(commonUtils.spriteIcon('test')).toEqual('<svg ><use xlink:href="icons.svg#test" /></svg>');
expect(commonUtils.spriteIcon('test')).toEqual(
'<svg ><use xlink:href="icons.svg#test" /></svg>',
);
});
 
it('should set svg className when passed', () => {
expect(commonUtils.spriteIcon('test', 'fa fa-test')).toEqual('<svg class="fa fa-test"><use xlink:href="icons.svg#test" /></svg>');
expect(commonUtils.spriteIcon('test', 'fa fa-test')).toEqual(
'<svg class="fa fa-test"><use xlink:href="icons.svg#test" /></svg>',
);
});
});
 
Loading
Loading
@@ -578,7 +602,7 @@ describe('common_utils', () => {
 
const convertedObj = commonUtils.convertObjectPropsToCamelCase(mockObj);
 
Object.keys(convertedObj).forEach((prop) => {
Object.keys(convertedObj).forEach(prop => {
expect(snakeRegEx.test(prop)).toBeFalsy();
expect(convertedObj[prop]).toBe(mockObj[mappings[prop]]);
});
Loading
Loading
@@ -597,9 +621,7 @@ describe('common_utils', () => {
},
};
 
expect(
commonUtils.convertObjectPropsToCamelCase(obj),
).toEqual({
expect(commonUtils.convertObjectPropsToCamelCase(obj)).toEqual({
snakeKey: {
child_snake_key: 'value',
},
Loading
Loading
@@ -614,9 +636,7 @@ describe('common_utils', () => {
},
};
 
expect(
commonUtils.convertObjectPropsToCamelCase(obj, { deep: true }),
).toEqual({
expect(commonUtils.convertObjectPropsToCamelCase(obj, { deep: true })).toEqual({
snakeKey: {
childSnakeKey: 'value',
},
Loading
Loading
@@ -630,9 +650,7 @@ describe('common_utils', () => {
},
];
 
expect(
commonUtils.convertObjectPropsToCamelCase(arr, { deep: true }),
).toEqual([
expect(commonUtils.convertObjectPropsToCamelCase(arr, { deep: true })).toEqual([
{
childSnakeKey: 'value',
},
Loading
Loading
@@ -648,9 +666,7 @@ describe('common_utils', () => {
],
];
 
expect(
commonUtils.convertObjectPropsToCamelCase(arr, { deep: true }),
).toEqual([
expect(commonUtils.convertObjectPropsToCamelCase(arr, { deep: true })).toEqual([
[
{
childSnakeKey: 'value',
Loading
Loading
import { formatRelevantDigits, bytesToKiB, bytesToMiB, bytesToGiB, numberToHumanSize } from '~/lib/utils/number_utils';
import {
formatRelevantDigits,
bytesToKiB,
bytesToMiB,
bytesToGiB,
numberToHumanSize,
} from '~/lib/utils/number_utils';
 
describe('Number Utils', () => {
describe('formatRelevantDigits', () => {
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ import Vue from 'vue';
import GraphFlag from '~/monitoring/components/graph/flag.vue';
import { deploymentData } from '../mock_data';
 
const createComponent = (propsData) => {
const createComponent = propsData => {
const Component = Vue.extend(GraphFlag);
 
return new Component({
Loading
Loading
@@ -51,8 +51,7 @@ describe('GraphFlag', () => {
it('has a line at the currentXCoordinate', () => {
component = createComponent(defaultValuesComponent);
 
expect(component.$el.style.left)
.toEqual(`${70 + component.currentXCoordinate}px`);
expect(component.$el.style.left).toEqual(`${70 + component.currentXCoordinate}px`);
});
 
describe('Deployment flag', () => {
Loading
Loading
@@ -62,9 +61,7 @@ describe('GraphFlag', () => {
deploymentFlagData,
});
 
expect(
deploymentFlagComponent.$el.querySelector('.popover-title'),
).toContainText('Deployed');
expect(deploymentFlagComponent.$el.querySelector('.popover-title')).toContainText('Deployed');
});
 
it('contains the ref when a tag is available', () => {
Loading
Loading
@@ -78,13 +75,13 @@ describe('GraphFlag', () => {
},
});
 
expect(
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
).toContainText('f5bcd1d9');
expect(deploymentFlagComponent.$el.querySelector('.deploy-meta-content')).toContainText(
'f5bcd1d9',
);
 
expect(
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
).toContainText('1.0');
expect(deploymentFlagComponent.$el.querySelector('.deploy-meta-content')).toContainText(
'1.0',
);
});
 
it('does not contain the ref when a tag is unavailable', () => {
Loading
Loading
@@ -98,13 +95,13 @@ describe('GraphFlag', () => {
},
});
 
expect(
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
).toContainText('f5bcd1d9');
expect(deploymentFlagComponent.$el.querySelector('.deploy-meta-content')).toContainText(
'f5bcd1d9',
);
 
expect(
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
).not.toContainText('1.0');
expect(deploymentFlagComponent.$el.querySelector('.deploy-meta-content')).not.toContainText(
'1.0',
);
});
});
 
Loading
Loading
Loading
Loading
@@ -11,11 +11,13 @@ describe('DiscussionFilter component', () => {
beforeEach(() => {
store = createStore();
 
const discussions = [{
...discussionMock,
id: discussionMock.id,
notes: [{ ...discussionMock.notes[0], resolvable: true, resolved: true }],
}];
const discussions = [
{
...discussionMock,
id: discussionMock.id,
notes: [{ ...discussionMock.notes[0], resolvable: true, resolved: true }],
},
];
const Component = Vue.extend(DiscussionFilter);
const defaultValue = discussionFiltersMock[0].value;
 
Loading
Loading
@@ -35,11 +37,15 @@ describe('DiscussionFilter component', () => {
});
 
it('renders the all filters', () => {
expect(vm.$el.querySelectorAll('.dropdown-menu li').length).toEqual(discussionFiltersMock.length);
expect(vm.$el.querySelectorAll('.dropdown-menu li').length).toEqual(
discussionFiltersMock.length,
);
});
 
it('renders the default selected item', () => {
expect(vm.$el.querySelector('#discussion-filter-dropdown').textContent.trim()).toEqual(discussionFiltersMock[0].title);
expect(vm.$el.querySelector('#discussion-filter-dropdown').textContent.trim()).toEqual(
discussionFiltersMock[0].title,
);
});
 
it('updates to the selected item', () => {
Loading
Loading
Loading
Loading
@@ -97,7 +97,8 @@ describe('note_app', () => {
});
 
it('should render list of notes', done => {
const note = mockData.INDIVIDUAL_NOTE_RESPONSE_MAP.GET[
const note =
mockData.INDIVIDUAL_NOTE_RESPONSE_MAP.GET[
'/gitlab-org/gitlab-ce/issues/26/discussions.json'
][0].notes[0];
 
Loading
Loading
Loading
Loading
@@ -40,7 +40,9 @@ describe('graph component', () => {
).toEqual(true);
 
expect(
component.$el.querySelector('.stage-column:nth-child(2) .build:nth-child(1)').classList.contains('left-connector'),
component.$el
.querySelector('.stage-column:nth-child(2) .build:nth-child(1)')
.classList.contains('left-connector'),
).toEqual(true);
 
expect(component.$el.querySelector('loading-icon')).toBe(null);
Loading
Loading
@@ -56,7 +58,9 @@ describe('graph component', () => {
pipeline: graphJSON,
});
 
expect(component.$el.querySelector('.stage-column:nth-child(2) .stage-name').textContent.trim()).toEqual('Deploy &lt;img src=x onerror=alert(document.domain)&gt;');
expect(
component.$el.querySelector('.stage-column:nth-child(2) .stage-name').textContent.trim(),
).toEqual('Deploy &lt;img src=x onerror=alert(document.domain)&gt;');
});
});
});
Loading
Loading
@@ -78,9 +78,7 @@ describe('Assignee component', () => {
component = new AssigneeComponent({
propsData: {
rootPath: 'http://localhost:3000',
users: [
UsersMock.user,
],
users: [UsersMock.user],
editable: false,
},
}).$mount();
Loading
Loading
@@ -90,7 +88,9 @@ describe('Assignee component', () => {
 
expect(collapsed.childElementCount).toEqual(1);
expect(assignee.querySelector('.avatar').getAttribute('src')).toEqual(UsersMock.user.avatar);
expect(assignee.querySelector('.avatar').getAttribute('alt')).toEqual(`${UsersMock.user.name}'s avatar`);
expect(assignee.querySelector('.avatar').getAttribute('alt')).toEqual(
`${UsersMock.user.name}'s avatar`,
);
expect(assignee.querySelector('.author').innerText.trim()).toEqual(UsersMock.user.name);
});
 
Loading
Loading
@@ -98,34 +98,38 @@ describe('Assignee component', () => {
component = new AssigneeComponent({
propsData: {
rootPath: 'http://localhost:3000/',
users: [
UsersMock.user,
],
users: [UsersMock.user],
editable: true,
},
}).$mount();
 
expect(component.$el.querySelector('.author-link')).not.toBeNull();
// The image
expect(component.$el.querySelector('.author-link img').getAttribute('src')).toEqual(UsersMock.user.avatar);
expect(component.$el.querySelector('.author-link img').getAttribute('src')).toEqual(
UsersMock.user.avatar,
);
// Author name
expect(component.$el.querySelector('.author-link .author').innerText.trim()).toEqual(UsersMock.user.name);
expect(component.$el.querySelector('.author-link .author').innerText.trim()).toEqual(
UsersMock.user.name,
);
// Username
expect(component.$el.querySelector('.author-link .username').innerText.trim()).toEqual(`@${UsersMock.user.username}`);
expect(component.$el.querySelector('.author-link .username').innerText.trim()).toEqual(
`@${UsersMock.user.username}`,
);
});
 
it('has the root url present in the assigneeUrl method', () => {
component = new AssigneeComponent({
propsData: {
rootPath: 'http://localhost:3000/',
users: [
UsersMock.user,
],
users: [UsersMock.user],
editable: true,
},
}).$mount();
 
expect(component.assigneeUrl(UsersMock.user).indexOf('http://localhost:3000/')).not.toEqual(-1);
expect(component.assigneeUrl(UsersMock.user).indexOf('http://localhost:3000/')).not.toEqual(
-1,
);
});
});
 
Loading
Loading
@@ -147,13 +151,17 @@ describe('Assignee component', () => {
const first = collapsed.children[0];
 
expect(first.querySelector('.avatar').getAttribute('src')).toEqual(users[0].avatar);
expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[0].name}'s avatar`);
expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(
`${users[0].name}'s avatar`,
);
expect(first.querySelector('.author').innerText.trim()).toEqual(users[0].name);
 
const second = collapsed.children[1];
 
expect(second.querySelector('.avatar').getAttribute('src')).toEqual(users[1].avatar);
expect(second.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[1].name}'s avatar`);
expect(second.querySelector('.avatar').getAttribute('alt')).toEqual(
`${users[1].name}'s avatar`,
);
expect(second.querySelector('.author').innerText.trim()).toEqual(users[1].name);
});
 
Loading
Loading
@@ -174,7 +182,9 @@ describe('Assignee component', () => {
const first = collapsed.children[0];
 
expect(first.querySelector('.avatar').getAttribute('src')).toEqual(users[0].avatar);
expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[0].name}'s avatar`);
expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(
`${users[0].name}'s avatar`,
);
expect(first.querySelector('.author').innerText.trim()).toEqual(users[0].name);
 
const second = collapsed.children[1];
Loading
Loading
@@ -196,7 +206,7 @@ describe('Assignee component', () => {
expect(component.$el.querySelector('.user-list-more')).toBe(null);
});
 
it('Shows the "show-less" assignees label', (done) => {
it('Shows the "show-less" assignees label', done => {
const users = UsersMockHelper.createNumberRandomUsers(6);
component = new AssigneeComponent({
propsData: {
Loading
Loading
@@ -206,21 +216,25 @@ describe('Assignee component', () => {
},
}).$mount();
 
expect(component.$el.querySelectorAll('.user-item').length).toEqual(component.defaultRenderCount);
expect(component.$el.querySelectorAll('.user-item').length).toEqual(
component.defaultRenderCount,
);
expect(component.$el.querySelector('.user-list-more')).not.toBe(null);
const usersLabelExpectation = users.length - component.defaultRenderCount;
 
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim())
.not.toBe(`+${usersLabelExpectation} more`);
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim()).not.toBe(
`+${usersLabelExpectation} more`,
);
component.toggleShowLess();
Vue.nextTick(() => {
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim())
.toBe('- show less');
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim()).toBe(
'- show less',
);
done();
});
});
 
it('Shows the "show-less" when "n+ more " label is clicked', (done) => {
it('Shows the "show-less" when "n+ more " label is clicked', done => {
const users = UsersMockHelper.createNumberRandomUsers(6);
component = new AssigneeComponent({
propsData: {
Loading
Loading
@@ -232,8 +246,9 @@ describe('Assignee component', () => {
 
component.$el.querySelector('.user-list-more .btn-link').click();
Vue.nextTick(() => {
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim())
.toBe('- show less');
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim()).toBe(
'- show less',
);
done();
});
});
Loading
Loading
@@ -264,16 +279,18 @@ describe('Assignee component', () => {
});
 
it('shows "+1 more" label', () => {
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim())
.toBe('+ 1 more');
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim()).toBe(
'+ 1 more',
);
});
 
it('shows "show less" label', (done) => {
it('shows "show less" label', done => {
component.toggleShowLess();
 
Vue.nextTick(() => {
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim())
.toBe('- show less');
expect(component.$el.querySelector('.user-list-more .btn-link').innerText.trim()).toBe(
'- show less',
);
done();
});
});
Loading
Loading
Loading
Loading
@@ -69,12 +69,12 @@ describe('MRWidgetPipeline', () => {
pipeline: mockData.pipeline,
hasCi: true,
ciStatus: null,
troubleshootingDocsPath: 'help',
troubleshootingDocsPath: 'help',
});
 
expect(
vm.$el.querySelector('.media-body').textContent.trim(),
).toContain('Could not retrieve the pipeline status. For troubleshooting steps, read the <a href="help">documentation.</a>');
expect(vm.$el.querySelector('.media-body').textContent.trim()).toContain(
'Could not retrieve the pipeline status. For troubleshooting steps, read the <a href="help">documentation.</a>',
);
});
 
describe('with a pipeline', () => {
Loading
Loading
@@ -88,34 +88,36 @@ describe('MRWidgetPipeline', () => {
});
 
it('should render pipeline ID', () => {
expect(
vm.$el.querySelector('.pipeline-id').textContent.trim(),
).toEqual(`#${mockData.pipeline.id}`);
expect(vm.$el.querySelector('.pipeline-id').textContent.trim()).toEqual(
`#${mockData.pipeline.id}`,
);
});
 
it('should render pipeline status and commit id', () => {
expect(
vm.$el.querySelector('.media-body').textContent.trim(),
).toContain(mockData.pipeline.details.status.label);
expect(vm.$el.querySelector('.media-body').textContent.trim()).toContain(
mockData.pipeline.details.status.label,
);
 
expect(
vm.$el.querySelector('.js-commit-link').textContent.trim(),
).toEqual(mockData.pipeline.commit.short_id);
expect(vm.$el.querySelector('.js-commit-link').textContent.trim()).toEqual(
mockData.pipeline.commit.short_id,
);
 
expect(
vm.$el.querySelector('.js-commit-link').getAttribute('href'),
).toEqual(mockData.pipeline.commit.commit_path);
expect(vm.$el.querySelector('.js-commit-link').getAttribute('href')).toEqual(
mockData.pipeline.commit.commit_path,
);
});
 
it('should render pipeline graph', () => {
expect(vm.$el.querySelector('.mr-widget-pipeline-graph')).toBeDefined();
expect(vm.$el.querySelectorAll('.stage-container').length).toEqual(mockData.pipeline.details.stages.length);
expect(vm.$el.querySelectorAll('.stage-container').length).toEqual(
mockData.pipeline.details.stages.length,
);
});
 
it('should render coverage information', () => {
expect(
vm.$el.querySelector('.media-body').textContent,
).toContain(`Coverage ${mockData.pipeline.coverage}`);
expect(vm.$el.querySelector('.media-body').textContent).toContain(
`Coverage ${mockData.pipeline.coverage}`,
);
});
});
 
Loading
Loading
@@ -133,30 +135,30 @@ describe('MRWidgetPipeline', () => {
});
 
it('should render pipeline ID', () => {
expect(
vm.$el.querySelector('.pipeline-id').textContent.trim(),
).toEqual(`#${mockData.pipeline.id}`);
expect(vm.$el.querySelector('.pipeline-id').textContent.trim()).toEqual(
`#${mockData.pipeline.id}`,
);
});
 
it('should render pipeline status', () => {
expect(
vm.$el.querySelector('.media-body').textContent.trim(),
).toContain(mockData.pipeline.details.status.label);
expect(vm.$el.querySelector('.media-body').textContent.trim()).toContain(
mockData.pipeline.details.status.label,
);
 
expect(
vm.$el.querySelector('.js-commit-link'),
).toBeNull();
expect(vm.$el.querySelector('.js-commit-link')).toBeNull();
});
 
it('should render pipeline graph', () => {
expect(vm.$el.querySelector('.mr-widget-pipeline-graph')).toBeDefined();
expect(vm.$el.querySelectorAll('.stage-container').length).toEqual(mockData.pipeline.details.stages.length);
expect(vm.$el.querySelectorAll('.stage-container').length).toEqual(
mockData.pipeline.details.stages.length,
);
});
 
it('should render coverage information', () => {
expect(
vm.$el.querySelector('.media-body').textContent,
).toContain(`Coverage ${mockData.pipeline.coverage}`);
expect(vm.$el.querySelector('.media-body').textContent).toContain(
`Coverage ${mockData.pipeline.coverage}`,
);
});
});
 
Loading
Loading
@@ -172,9 +174,7 @@ describe('MRWidgetPipeline', () => {
troubleshootingDocsPath: 'help',
});
 
expect(
vm.$el.querySelector('.media-body').textContent,
).not.toContain('Coverage');
expect(vm.$el.querySelector('.media-body').textContent).not.toContain('Coverage');
});
});
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment