2017-09-14 07:01:07 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import lockIssueSidebar from '~/sidebar/components/lock/lock_issue_sidebar.vue';
|
|
|
|
|
|
|
|
describe('LockIssueSidebar', () => {
|
|
|
|
let vm1;
|
|
|
|
let vm2;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const Component = Vue.extend(lockIssueSidebar);
|
|
|
|
|
|
|
|
const mediator = {
|
|
|
|
service: {
|
2017-09-15 05:19:43 -04:00
|
|
|
update: Promise.resolve(true),
|
2017-09-14 07:01:07 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
|
|
|
isLockDialogOpen: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
vm1 = new Component({
|
|
|
|
propsData: {
|
|
|
|
isLocked: true,
|
|
|
|
isEditable: true,
|
|
|
|
mediator,
|
|
|
|
issuableType: 'issue',
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
vm2 = new Component({
|
|
|
|
propsData: {
|
|
|
|
isLocked: false,
|
|
|
|
isEditable: false,
|
|
|
|
mediator,
|
|
|
|
issuableType: 'merge_request',
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows if locked and/or editable', () => {
|
2018-10-17 03:13:26 -04:00
|
|
|
expect(vm1.$el.innerHTML.includes('Edit')).toBe(true);
|
2017-09-14 07:01:07 -04:00
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
expect(vm1.$el.innerHTML.includes('Locked')).toBe(true);
|
2017-09-14 07:01:07 -04:00
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
expect(vm2.$el.innerHTML.includes('Unlocked')).toBe(true);
|
2017-09-14 07:01:07 -04:00
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('displays the edit form when editable', done => {
|
2017-09-14 07:01:07 -04:00
|
|
|
expect(vm1.isLockDialogOpen).toBe(false);
|
|
|
|
|
|
|
|
vm1.$el.querySelector('.lock-edit').click();
|
|
|
|
|
|
|
|
expect(vm1.isLockDialogOpen).toBe(true);
|
|
|
|
|
|
|
|
vm1.$nextTick(() => {
|
2018-10-17 03:13:26 -04:00
|
|
|
expect(vm1.$el.innerHTML.includes('Unlock this issue?')).toBe(true);
|
2017-09-14 07:01:07 -04:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('displays the edit form when opened from collapsed state', done => {
|
2018-04-02 14:46:50 -04:00
|
|
|
expect(vm1.isLockDialogOpen).toBe(false);
|
|
|
|
|
|
|
|
vm1.$el.querySelector('.sidebar-collapsed-icon').click();
|
|
|
|
|
|
|
|
expect(vm1.isLockDialogOpen).toBe(true);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2018-10-17 03:13:26 -04:00
|
|
|
expect(vm1.$el.innerHTML.includes('Unlock this issue?')).toBe(true);
|
2018-04-02 14:46:50 -04:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-09-14 07:01:07 -04:00
|
|
|
});
|