mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-11-15 21:36:16 +08:00
* fix: show the VNC console's dialogs in full screen Only the console went full screen and dialogs render outside of it, so the Ctrl+Alt+Del and Soft Reboot confirmations, among others, stayed hidden behind it until full screen was left. Put the whole page in full screen instead. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: bring back deleting saved VNC console shortcut keys The Vue 3 migration dropped the close button from the list of saved shortcuts, which left no way to delete one. Restore it, and remove by position in the list: the old code parsed the displayed HTML to find the shortcut, which cannot match one with the Space key in it, such as Ctrl+Space. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: tidy the VNC console's custom shortcut keys Give the saved shortcuts in the menu the same space as the separator above them, and name the dialog's buttons Cancel and Save, which say what they do. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> --------- Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>
109 lines
3.1 KiB
JavaScript
109 lines
3.1 KiB
JavaScript
import { shallowMount } from '@vue/test-utils';
|
|
import NovncConsoleWrapper, { CONFIRM_ACTION } from '../NovncConsoleWrapper.vue';
|
|
|
|
jest.mock('../ZoomableRFB', () => ({ normalizeZoom: (value) => value }));
|
|
jest.mock('@novnc/novnc/core/input/keysym', () => ({}), { virtual: true });
|
|
jest.mock('@novnc/novnc/core/input/util', () => ({}), { virtual: true });
|
|
|
|
const consoleRef = {
|
|
ctrlAltDelete: jest.fn(),
|
|
focus: jest.fn(),
|
|
};
|
|
|
|
const mountWrapper = () => {
|
|
consoleRef.ctrlAltDelete.mockClear();
|
|
consoleRef.focus.mockClear();
|
|
|
|
const wrapper = shallowMount(NovncConsoleWrapper, {
|
|
props: {
|
|
value: {
|
|
id: 'default/vm', metadata: { name: 'vm' }, status: { phase: 'Running' }
|
|
}
|
|
},
|
|
global: {
|
|
mocks: {
|
|
$store: {
|
|
getters: {
|
|
'management/all': () => [],
|
|
'harvester-common/getFeatureEnabled': () => true,
|
|
},
|
|
},
|
|
$fetchState: { pending: false },
|
|
},
|
|
stubs: {
|
|
NovncConsole: {
|
|
template: '<div />',
|
|
methods: {
|
|
ctrlAltDelete: consoleRef.ctrlAltDelete,
|
|
focus: consoleRef.focus,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
wrapper.vm.onStatusChanged({ status: 'connected' });
|
|
|
|
return wrapper;
|
|
};
|
|
|
|
describe('component: NovncConsoleWrapper', () => {
|
|
it('should only send Ctrl+Alt+Del after it is confirmed', async() => {
|
|
const wrapper = mountWrapper();
|
|
|
|
wrapper.vm.ctrlAltDelete();
|
|
expect(wrapper.vm.confirmAction).toBe(CONFIRM_ACTION.CTRL_ALT_DEL);
|
|
expect(consoleRef.ctrlAltDelete).not.toHaveBeenCalled();
|
|
|
|
wrapper.vm.runConfirmedAction();
|
|
|
|
expect(consoleRef.ctrlAltDelete).toHaveBeenCalledTimes(1);
|
|
expect(wrapper.vm.confirmAction).toBeNull();
|
|
});
|
|
|
|
it('should not send Ctrl+Alt+Del when the confirmation is cancelled', () => {
|
|
const wrapper = mountWrapper();
|
|
|
|
wrapper.vm.ctrlAltDelete();
|
|
wrapper.vm.cancelConfirm();
|
|
|
|
expect(consoleRef.ctrlAltDelete).not.toHaveBeenCalled();
|
|
expect(wrapper.vm.confirmAction).toBeNull();
|
|
});
|
|
|
|
it('should only soft reboot after it is confirmed', () => {
|
|
const wrapper = mountWrapper();
|
|
const doSoftReboot = jest.fn();
|
|
|
|
wrapper.vm.vmResource = { doSoftReboot };
|
|
|
|
wrapper.vm.softReboot();
|
|
expect(doSoftReboot).not.toHaveBeenCalled();
|
|
|
|
wrapper.vm.runConfirmedAction();
|
|
expect(doSoftReboot).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('should not ask to send Ctrl+Alt+Del while keys cannot be sent', () => {
|
|
const wrapper = mountWrapper();
|
|
|
|
wrapper.vm.onStatusChanged({ status: 'reconnecting' });
|
|
wrapper.vm.ctrlAltDelete();
|
|
|
|
expect(wrapper.vm.confirmAction).toBeNull();
|
|
});
|
|
|
|
it('should put the whole page in full screen, so that dialogs rendered outside the console show', async() => {
|
|
const wrapper = mountWrapper();
|
|
const requestFullscreen = jest.fn().mockResolvedValue();
|
|
|
|
document.documentElement.requestFullscreen = requestFullscreen;
|
|
|
|
await wrapper.vm.toggleFullscreen();
|
|
|
|
expect(requestFullscreen).toHaveBeenCalledTimes(1);
|
|
|
|
delete document.documentElement.requestFullscreen;
|
|
});
|
|
});
|