Skip to content

Commit

Permalink
Merge pull request #1419 from jdi-testing/issue_1415
Browse files Browse the repository at this point in the history
Issue 1415: fix onboarding step for context menu
  • Loading branch information
MariiaNebesnova authored Jul 28, 2023
2 parents 51b9874 + 3f2a79e commit d1da3ff
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/features/locators/Locator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Locator: React.FC<Props> = ({ 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;

Expand Down
3 changes: 0 additions & 3 deletions src/features/onboarding/utils/tourSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ export const createPOSteps = (refs: Record<OnbrdStep, StepRef>) => [
];

export const addLocatorsSteps = (refs: Record<OnbrdStep, StepRef>, isCustomLocatorFlow: boolean) => {
// if (!isCustomLocatorFlow) {
// return [customLocator(refs, isCustomLocatorFlow), contextMenu(refs), addToPO(refs), saveLocators(refs)];
// }
return [
customLocator(refs, isCustomLocatorFlow),
isCustomLocatorFlow ? createCustomLocator(refs) : contextMenu(refs),
Expand Down
10 changes: 7 additions & 3 deletions src/features/onboarding/utils/useOnboardingRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,16 +14,18 @@ export const useOnBoardingRef = (
) => {
const ref = useRef<HTMLDivElement>(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;
};

0 comments on commit d1da3ff

Please sign in to comment.