2017-08-07 23:56:16 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import confidentialIssueSidebar from '~/sidebar/components/confidential/confidential_issue_sidebar.vue';
|
|
|
|
|
|
|
|
describe('Confidential Issue Sidebar Block', () => {
|
|
|
|
let vm1;
|
|
|
|
let vm2;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const Component = Vue.extend(confidentialIssueSidebar);
|
|
|
|
const service = {
|
2018-05-28 11:41:30 +00:00
|
|
|
update: () => Promise.resolve(true),
|
2017-08-07 23:56:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
vm1 = new Component({
|
|
|
|
propsData: {
|
|
|
|
isConfidential: true,
|
|
|
|
isEditable: true,
|
|
|
|
service,
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
vm2 = new Component({
|
|
|
|
propsData: {
|
|
|
|
isConfidential: false,
|
|
|
|
isEditable: false,
|
|
|
|
service,
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows if confidential and/or editable', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm1.$el.innerHTML.includes('Edit')).toBe(true);
|
2017-08-07 23:56:16 +00:00
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm1.$el.innerHTML.includes('This issue is confidential')).toBe(true);
|
2017-08-07 23:56:16 +00:00
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm2.$el.innerHTML.includes('Not confidential')).toBe(true);
|
2017-08-07 23:56:16 +00:00
|
|
|
});
|
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
it('displays the edit form when editable', done => {
|
2017-08-07 23:56:16 +00:00
|
|
|
expect(vm1.edit).toBe(false);
|
|
|
|
|
|
|
|
vm1.$el.querySelector('.confidential-edit').click();
|
|
|
|
|
|
|
|
expect(vm1.edit).toBe(true);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm1.$el.innerHTML.includes('You are going to turn off the confidentiality.')).toBe(
|
|
|
|
true,
|
|
|
|
);
|
2017-08-07 23:56:16 +00:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2018-04-02 18:46:50 +00:00
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
it('displays the edit form when opened from collapsed state', done => {
|
2018-04-02 18:46:50 +00:00
|
|
|
expect(vm1.edit).toBe(false);
|
|
|
|
|
|
|
|
vm1.$el.querySelector('.sidebar-collapsed-icon').click();
|
|
|
|
|
|
|
|
expect(vm1.edit).toBe(true);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm1.$el.innerHTML.includes('You are going to turn off the confidentiality.')).toBe(
|
|
|
|
true,
|
|
|
|
);
|
2018-04-02 18:46:50 +00:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-08-07 23:56:16 +00:00
|
|
|
});
|