From 7dd05fa20b11c689e8e1bcece34a06e87ee82277 Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Fri, 28 Jul 2023 17:04:16 +0300 Subject: [PATCH 1/3] fix onboarding for context menu --- src/features/locators/Locator.tsx | 2 +- src/features/onboarding/utils/tourSteps.tsx | 4 +--- src/features/onboarding/utils/useOnboardingRef.ts | 10 +++++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/features/locators/Locator.tsx b/src/features/locators/Locator.tsx index 5bd446cf..65b07ab5 100644 --- a/src/features/locators/Locator.tsx +++ b/src/features/locators/Locator.tsx @@ -52,7 +52,7 @@ export const Locator: React.FC = ({ element, currentPage, searchState, de const dispatch = useDispatch(); const [isEditModalOpen, setIsEditModalOpen] = useState(false); - const { isOpen: isCustomLocatorFlow } = useContext(OnboardingContext); + const { isCustomLocatorFlow } = useContext(OnboardingContext); const { element_id, type, name, locator, generate, message, deleted, active, isCustomLocator } = element; diff --git a/src/features/onboarding/utils/tourSteps.tsx b/src/features/onboarding/utils/tourSteps.tsx index eb2d428c..a9940130 100644 --- a/src/features/onboarding/utils/tourSteps.tsx +++ b/src/features/onboarding/utils/tourSteps.tsx @@ -176,9 +176,7 @@ export const createPOSteps = (refs: Record) => [ ]; export const addLocatorsSteps = (refs: Record, isCustomLocatorFlow: boolean) => { - // if (!isCustomLocatorFlow) { - // return [customLocator(refs, isCustomLocatorFlow), contextMenu(refs), addToPO(refs), saveLocators(refs)]; - // } + return [ customLocator(refs, isCustomLocatorFlow), isCustomLocatorFlow ? createCustomLocator(refs) : contextMenu(refs), diff --git a/src/features/onboarding/utils/useOnboardingRef.ts b/src/features/onboarding/utils/useOnboardingRef.ts index cc9a45b1..b9f3e65d 100644 --- a/src/features/onboarding/utils/useOnboardingRef.ts +++ b/src/features/onboarding/utils/useOnboardingRef.ts @@ -4,6 +4,8 @@ import { OnbrdStep } from "../types/constants"; import { useSelector } from "react-redux"; import { selectFirstLocatorByPO } from "../../locators/selectors/locatorsByPO.selectors"; +const locatorPageSteps = [OnbrdStep.CustomLocator, OnbrdStep.EditLocator, OnbrdStep.AddToPO, OnbrdStep.SaveLocators]; + export const useOnBoardingRef = ( refName: OnbrdStep, onClickNext?: (...args: any) => void, @@ -12,16 +14,18 @@ export const useOnBoardingRef = ( ) => { const ref = useRef(null); - const { addRef, isCustomLocatorFlow } = useContext(OnboardingContext); + const { addRef, isCustomLocatorFlow, isOpen } = useContext(OnboardingContext); const isFirstLocatorChecked = useSelector(selectFirstLocatorByPO)?.generate; + /* if unboarding is closed, no need to save these refs */ + const isRedundantStep = !isOpen && locatorPageSteps.includes(refName); useLayoutEffect(() => { const _ref = refName === OnbrdStep.EditLocator && isCustomLocatorFlow && ref.current ? { current: ref.current.closest(".ant-modal-content") } : ref; - !isSkipHook && addRef(refName, _ref, onClickNext, onClickPrev); + (!isSkipHook && !isRedundantStep) && addRef(refName, _ref, onClickNext, onClickPrev); }, [ref, isFirstLocatorChecked]); - return !isSkipHook ? ref : null; + return (!isSkipHook && !isRedundantStep) ? ref : null; }; From af1af6ba78c07d846b3b16866513d4104c87c2d8 Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Fri, 28 Jul 2023 17:07:03 +0300 Subject: [PATCH 2/3] clean up redundant context updates --- src/features/onboarding/utils/tourSteps.tsx | 1 - src/features/onboarding/utils/useOnboardingRef.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/features/onboarding/utils/tourSteps.tsx b/src/features/onboarding/utils/tourSteps.tsx index a9940130..f72f902b 100644 --- a/src/features/onboarding/utils/tourSteps.tsx +++ b/src/features/onboarding/utils/tourSteps.tsx @@ -176,7 +176,6 @@ export const createPOSteps = (refs: Record) => [ ]; export const addLocatorsSteps = (refs: Record, isCustomLocatorFlow: boolean) => { - return [ customLocator(refs, isCustomLocatorFlow), isCustomLocatorFlow ? createCustomLocator(refs) : contextMenu(refs), diff --git a/src/features/onboarding/utils/useOnboardingRef.ts b/src/features/onboarding/utils/useOnboardingRef.ts index b9f3e65d..240be0e5 100644 --- a/src/features/onboarding/utils/useOnboardingRef.ts +++ b/src/features/onboarding/utils/useOnboardingRef.ts @@ -24,8 +24,8 @@ export const useOnBoardingRef = ( refName === OnbrdStep.EditLocator && isCustomLocatorFlow && ref.current ? { current: ref.current.closest(".ant-modal-content") } : ref; - (!isSkipHook && !isRedundantStep) && addRef(refName, _ref, onClickNext, onClickPrev); + !isSkipHook && !isRedundantStep && addRef(refName, _ref, onClickNext, onClickPrev); }, [ref, isFirstLocatorChecked]); - return (!isSkipHook && !isRedundantStep) ? ref : null; + return !isSkipHook && !isRedundantStep ? ref : null; }; From 3f2a79eb6c587f549e674440cd0850462e90bc03 Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Fri, 28 Jul 2023 18:41:20 +0300 Subject: [PATCH 3/3] ver up --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index c22f9c8e..38f40171 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "JDN", "description": "JDN – helps Test Automation Engineer to create Page Objects in the test automation framework and speed up test development", "devtools_page": "index.html", - "version": "3.13.539", + "version": "3.13.540", "icons": { "128": "icon128.png" }, diff --git a/package.json b/package.json index ea644150..97dfb9bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.13.539", + "version": "3.13.540", "description": "jdn-ai chrome extension", "scripts": { "start": "webpack --watch --env devenv",