2018-11-20 20:47:30 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import component from '~/jobs/components/trigger_block.vue';
|
|
|
|
import mountComponent from '../../helpers/vue_mount_component_helper';
|
|
|
|
|
|
|
|
describe('Trigger block', () => {
|
|
|
|
const Component = Vue.extend(component);
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with short token', () => {
|
|
|
|
it('renders short token', () => {
|
|
|
|
vm = mountComponent(Component, {
|
2018-12-05 23:21:45 +05:30
|
|
|
trigger: {
|
|
|
|
short_token: '0a666b2',
|
|
|
|
},
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-short-token').textContent).toContain('0a666b2');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without short token', () => {
|
|
|
|
it('does not render short token', () => {
|
2018-12-05 23:21:45 +05:30
|
|
|
vm = mountComponent(Component, { trigger: {} });
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-short-token')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with variables', () => {
|
2018-12-23 12:14:25 +05:30
|
|
|
describe('hide/reveal variables', () => {
|
|
|
|
it('should toggle variables on click', done => {
|
2018-11-20 20:47:30 +05:30
|
|
|
vm = mountComponent(Component, {
|
2018-12-05 23:21:45 +05:30
|
|
|
trigger: {
|
|
|
|
short_token: 'bd7e',
|
|
|
|
variables: [
|
|
|
|
{ key: 'UPLOAD_TO_GCS', value: 'false', public: false },
|
|
|
|
{ key: 'UPLOAD_TO_S3', value: 'true', public: false },
|
|
|
|
],
|
2018-11-20 20:47:30 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$el.querySelector('.js-reveal-variables').click();
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
vm.$nextTick()
|
2018-11-20 20:47:30 +05:30
|
|
|
.then(() => {
|
|
|
|
expect(vm.$el.querySelector('.js-build-variables')).not.toBeNull();
|
2018-12-23 12:14:25 +05:30
|
|
|
expect(vm.$el.querySelector('.js-reveal-variables').textContent.trim()).toEqual(
|
|
|
|
'Hide values',
|
|
|
|
);
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(vm.$el.querySelector('.js-build-variables').textContent).toContain(
|
|
|
|
'UPLOAD_TO_GCS',
|
|
|
|
);
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(vm.$el.querySelector('.js-build-variables').textContent).toContain('false');
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(vm.$el.querySelector('.js-build-variables').textContent).toContain(
|
|
|
|
'UPLOAD_TO_S3',
|
|
|
|
);
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(vm.$el.querySelector('.js-build-variables').textContent).toContain('true');
|
2018-12-23 12:14:25 +05:30
|
|
|
|
|
|
|
vm.$el.querySelector('.js-reveal-variables').click();
|
|
|
|
})
|
|
|
|
.then(vm.$nextTick)
|
|
|
|
.then(() => {
|
|
|
|
expect(vm.$el.querySelector('.js-reveal-variables').textContent.trim()).toEqual(
|
|
|
|
'Reveal values',
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-build-variables').textContent).toContain(
|
|
|
|
'UPLOAD_TO_GCS',
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-build-value').textContent).toContain('••••••');
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-build-variables').textContent).toContain(
|
|
|
|
'UPLOAD_TO_S3',
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-build-value').textContent).toContain('••••••');
|
2018-11-20 20:47:30 +05:30
|
|
|
})
|
|
|
|
.then(done)
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without variables', () => {
|
|
|
|
it('does not render variables', () => {
|
2018-12-05 23:21:45 +05:30
|
|
|
vm = mountComponent(Component, { trigger: {} });
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-reveal-variables')).toBeNull();
|
|
|
|
expect(vm.$el.querySelector('.js-build-variables')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|