From 327eb738acf7334641c95d0962a85640ffcbca58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:13:45 -0600 Subject: [PATCH 1/4] test(add): add tests for changing and restoring keybinds --- tests/helpers/commands.ts | 28 ++++++-- .../settings/SettingsKeybindsScreen.ts | 16 +++++ tests/specs/18-settings-keybinds.spec.ts | 72 +++++++++++++++++++ 3 files changed, 111 insertions(+), 5 deletions(-) diff --git a/tests/helpers/commands.ts b/tests/helpers/commands.ts index 247e9cd6c6..13df60114b 100644 --- a/tests/helpers/commands.ts +++ b/tests/helpers/commands.ts @@ -26,6 +26,8 @@ let friendsScreen = new FriendsScreen(); const saveRecoverySeed = new SaveRecoverySeedScreen(); let welcomeScreen = new WelcomeScreen(); +export type MyKey = keyof typeof CustomKey; + // Users cache helper functions export async function deleteCache() { @@ -505,15 +507,31 @@ export async function getUplinkWindowHandle() { // Key Combinations Commands export async function keyboardShortcutPaste() { - await keyboard.type(Key.LeftControl, Key.V); + await keyboard.type(4, 66); } export async function keyboardShiftEnter() { - await keyboard.pressKey(Key.LeftShift); - await keyboard.type(Key.Enter); - await keyboard.releaseKey(Key.LeftShift); + await keyboard.pressKey(7); + await keyboard.type(101); + await keyboard.releaseKey(7); } export async function pressEscKey() { - await keyboard.type(Key.Escape); + await keyboard.type(1); +} + +export async function sendCustomKeybinds(...keys: number[]) { + // To find the number associated for each key to send on keybind, refer to node_modules/@nut-tree/nut-js/dist/lib/key.enum.d.ts + for (let i = 0; i < keys.length - 1; i++) { + await keyboard.pressKey(keys[i]); + console.log("Pressed key: " + keys[i]); + } + + await keyboard.type(keys[keys.length - 1]); + console.log("Typed key: " + keys[keys.length - 1]); + + for (let i = keys.length - 2; i >= 0; i--) { + await keyboard.releaseKey(keys[i]); + console.log("Released key: " + keys[i]); + } } diff --git a/tests/screenobjects/settings/SettingsKeybindsScreen.ts b/tests/screenobjects/settings/SettingsKeybindsScreen.ts index fbd6ca5040..0cd5eaf8f0 100644 --- a/tests/screenobjects/settings/SettingsKeybindsScreen.ts +++ b/tests/screenobjects/settings/SettingsKeybindsScreen.ts @@ -478,4 +478,20 @@ export default class SettingsKeybindsScreen extends SettingsBaseScreen { const revertButton = await this.toggleMuteResetKeybindButton; await revertButton.click(); } + + // Edit Keybinds + async editKeybind(section: Keybinds) { + let sectionToEdit; + const currentDriver = await this.getCurrentDriver(); + if (currentDriver === MACOS_DRIVER) { + sectionToEdit = await $(`~${section}-section`).$( + SELECTORS.KEYBIND_SECTION_KEYS, + ); + } else if (currentDriver === WINDOWS_DRIVER) { + sectionToEdit = await $(`[name="${section}-section"]`).$( + SELECTORS.KEYBIND_SECTION_KEYS, + ); + } + await sectionToEdit?.click(); + } } diff --git a/tests/specs/18-settings-keybinds.spec.ts b/tests/specs/18-settings-keybinds.spec.ts index 8a9fffff83..4011659b3d 100644 --- a/tests/specs/18-settings-keybinds.spec.ts +++ b/tests/specs/18-settings-keybinds.spec.ts @@ -1,4 +1,5 @@ require("module-alias/register"); +import { sendCustomKeybinds } from "@helpers/commands"; import { MACOS_DRIVER } from "@helpers/constants"; import SettingsExtensionsScreen from "@screenobjects/settings/SettingsExtensionsScreen"; import SettingsKeybindsScreen from "@screenobjects/settings/SettingsKeybindsScreen"; @@ -119,4 +120,75 @@ export default async function settingsKeybindsTests() { await settingsKeybinds.getKeybinds("hide-focus-uplink"); await expect(hideFocusUplinkKeybind).toEqual(["CONTROL", "SHIFT", "U"]); }); + + it("Settings Keyboards Shortcuts - Change Increase Font Size Keybind", async () => { + // Type Ctrl + Shift + = + await sendCustomKeybinds(4, 7, 73); + await settingsKeybinds.editKeybind("increase-font-size"); + // Type Ctrl + A + await sendCustomKeybinds(4, 45); + + const increaseFontSizeKeybind = + await settingsKeybinds.getKeybinds("increase-font-size"); + await expect(increaseFontSizeKeybind).toEqual(["CONTROL", "A"]); + }); + + it("Settings Keyboards Shortcuts - Reset Increase Font Size Keybind", async () => { + await settingsKeybinds.clickOnRevertIncreaseFontSize(); + const increaseFontSizeKeybind = + await settingsKeybinds.getKeybinds("increase-font-size"); + await expect(increaseFontSizeKeybind).toEqual(["CONTROL", "SHIFT", "="]); + }); + + it("Settings Keyboards Shortcuts - User can update more than one keybind", async () => { + // Change at least two different keybinds. First, change Decrease Font Size Keybind, by typing Ctrl + Shift + - + await sendCustomKeybinds(4, 7, 72); + // Edit Decrease Font Size Keybind to Ctrl + B + await settingsKeybinds.editKeybind("decrease-font-size"); + await sendCustomKeybinds(4, 46); + + // Validate change was applied correctly to Decrease Font Size Keybind + const decreaseFontSizeKeybind = + await settingsKeybinds.getKeybinds("decrease-font-size"); + await expect(decreaseFontSizeKeybind).toEqual(["CONTROL", "B"]); + + // Now, change Hide/Focus Uplink Keybind by typing Ctrl + Shift + U + await sendCustomKeybinds(4, 7, 65); + await settingsKeybinds.editKeybind("hide-focus-uplink"); + // Type Ctrl + Alt + Shift + P + await sendCustomKeybinds(4, 3, 7, 60); + + // Validate change was applied correctly to Hide/Focus Uplink Keybind + const hideFocusUplinkKeybind = + await settingsKeybinds.getKeybinds("hide-focus-uplink"); + await expect(hideFocusUplinkKeybind).toEqual([ + "CONTROL", + "ALT", + "SHIFT", + "P", + ]); + }); + + it("Settings Keyboards Shortcuts - User can revert all Keybinds to Default Values", async () => { + // Click on Revert all keybinds + await settingsKeybinds.clickOnRevertAllKeybinds(); + + // Validate default keys are assigned for Decrease Font Size Keybind (Ctrl + Shift + -) + const decreaseFontSizeKeybindDefault = + await settingsKeybinds.getKeybinds("decrease-font-size"); + await expect(decreaseFontSizeKeybindDefault).toEqual([ + "CONTROL", + "SHIFT", + "-", + ]); + + // Validate default keys are assigned for Hide/Show Uplink Keybind (Ctrl + Shift + U) + const hideFocusUplinkKeybindDefault = + await settingsKeybinds.getKeybinds("hide-focus-uplink"); + await expect(hideFocusUplinkKeybindDefault).toEqual([ + "CONTROL", + "SHIFT", + "U", + ]); + }); } From f1aecac36987fa3bb13881433d70bccd9146efc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:16:22 -0600 Subject: [PATCH 2/4] chore(appium): remove unnecessary import --- tests/helpers/commands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helpers/commands.ts b/tests/helpers/commands.ts index 13df60114b..851c402fd3 100644 --- a/tests/helpers/commands.ts +++ b/tests/helpers/commands.ts @@ -18,7 +18,7 @@ import { const { readFileSync, rmSync, writeFileSync } = require("fs"); const { execSync } = require("child_process"); const fsp = require("fs").promises; -const { clipboard, keyboard, Key, mouse, Button } = require("@nut-tree/nut-js"); +const { clipboard, keyboard, mouse, Button } = require("@nut-tree/nut-js"); const createOrImport = new CreateOrImportScreen(); let createPin = new CreatePinScreen(); let createUser = new CreateUserScreen(); From 7efa06a5c4211a944eed522cc0ea3a7f4102b7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:17:27 -0600 Subject: [PATCH 3/4] chore(appium): remove unnecessary console logs --- tests/helpers/commands.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/helpers/commands.ts b/tests/helpers/commands.ts index 851c402fd3..2a2a27c9bc 100644 --- a/tests/helpers/commands.ts +++ b/tests/helpers/commands.ts @@ -524,14 +524,11 @@ export async function sendCustomKeybinds(...keys: number[]) { // To find the number associated for each key to send on keybind, refer to node_modules/@nut-tree/nut-js/dist/lib/key.enum.d.ts for (let i = 0; i < keys.length - 1; i++) { await keyboard.pressKey(keys[i]); - console.log("Pressed key: " + keys[i]); } await keyboard.type(keys[keys.length - 1]); - console.log("Typed key: " + keys[keys.length - 1]); for (let i = keys.length - 2; i >= 0; i--) { await keyboard.releaseKey(keys[i]); - console.log("Released key: " + keys[i]); } } From 22cd7ad4c44695af46f99cba5bedc313b6f7cc22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:11:40 -0600 Subject: [PATCH 4/4] test(update): update keys for custom keybind with 4 chars --- tests/specs/18-settings-keybinds.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/specs/18-settings-keybinds.spec.ts b/tests/specs/18-settings-keybinds.spec.ts index 4011659b3d..f3c2a4ad3f 100644 --- a/tests/specs/18-settings-keybinds.spec.ts +++ b/tests/specs/18-settings-keybinds.spec.ts @@ -155,15 +155,15 @@ export default async function settingsKeybindsTests() { // Now, change Hide/Focus Uplink Keybind by typing Ctrl + Shift + U await sendCustomKeybinds(4, 7, 65); await settingsKeybinds.editKeybind("hide-focus-uplink"); - // Type Ctrl + Alt + Shift + P - await sendCustomKeybinds(4, 3, 7, 60); + // Type Alt + Ctrl + Shift + P + await sendCustomKeybinds(3, 4, 7, 60); // Validate change was applied correctly to Hide/Focus Uplink Keybind const hideFocusUplinkKeybind = await settingsKeybinds.getKeybinds("hide-focus-uplink"); await expect(hideFocusUplinkKeybind).toEqual([ - "CONTROL", "ALT", + "CONTROL", "SHIFT", "P", ]);