From 9e22d90d48b6ad1ab6ae0bd728e35b081ab32409 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Wed, 18 Sep 2024 19:03:06 +0530 Subject: [PATCH] Refactor converter.ts to handle keyDown and keyUp actions --- apps/acf-extension/src/devtools/converter.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/acf-extension/src/devtools/converter.ts b/apps/acf-extension/src/devtools/converter.ts index ff40aac7..aebfc028 100644 --- a/apps/acf-extension/src/devtools/converter.ts +++ b/apps/acf-extension/src/devtools/converter.ts @@ -2,6 +2,8 @@ import { Action, CONFIG_SOURCE, Configuration, getDefaultAction, getDefaultConfi import { Recording, Step } from './index.types'; +let ELEMENT_FINDER: string; + const getProps = (selectors: Array>) => { let elementFinder = ''; let name = ''; @@ -17,6 +19,7 @@ const getProps = (selectors: Array>) => { } return true; }); + ELEMENT_FINDER = elementFinder; return { elementFinder, name }; }; @@ -47,6 +50,12 @@ export const ConvertStep = (step: Step) => { break; case 'keyDown': case 'keyUp': + { + action.elementFinder = ELEMENT_FINDER; + action.name = step.key; + action.value = `KeyboardEvents::${step.key}`; + } + break; case 'navigate': case 'setViewport': break; @@ -76,6 +85,8 @@ export const ConvertRecording = (recording: Recording) => { console.assert(navigate.url, 'URL is required for navigate step'); config = getConfig(navigate.url); configs.push(config); + } else { + console.assert(false, 'First step should be navigate'); } console.assert(steps.length === 0, 'No steps found in recording');