From fd872bfb9c43f3b3a28ebe02af5e56324a921919 Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Thu, 27 Jul 2023 16:22:34 +0300 Subject: [PATCH] remove hash from invalid locator --- .../components/notification/useNotifications.tsx | 1 - src/features/locators/locators.slice.ts | 3 +++ src/pageServices/contentScripts/selectable.js | 12 +++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/components/notification/useNotifications.tsx b/src/common/components/notification/useNotifications.tsx index e04669f4..2478c3f2 100644 --- a/src/common/components/notification/useNotifications.tsx +++ b/src/common/components/notification/useNotifications.tsx @@ -56,7 +56,6 @@ export const useNotifications = (container?: HTMLElement | null) => { notification[type]({ message: _message, description, - duration: 500, getContainer: () => container || document.body, placement: "bottom", bottom, diff --git a/src/features/locators/locators.slice.ts b/src/features/locators/locators.slice.ts index 142c4988..4039447b 100644 --- a/src/features/locators/locators.slice.ts +++ b/src/features/locators/locators.slice.ts @@ -23,6 +23,7 @@ import { LocatorCalculationPriority, JDNHash, LocatorValue, + LocatorValidationWarnings, } from "./types/locator.types"; import { checkLocatorsValidityReducer } from "./reducers/checkLocatorValidity.thunk"; import { LocatorType } from "../../common/types/common"; @@ -73,6 +74,8 @@ const locatorsSlice = createSlice({ newValue.locator.xPath = locator; } + if (rest.message === LocatorValidationWarnings.NotFound) newValue.jdnHash = ""; + locatorsAdapter.upsertOne(state, newValue); }, changeIdentificationStatus(state, { payload }: PayloadAction) { diff --git a/src/pageServices/contentScripts/selectable.js b/src/pageServices/contentScripts/selectable.js index 97590e62..25fce3e1 100644 --- a/src/pageServices/contentScripts/selectable.js +++ b/src/pageServices/contentScripts/selectable.js @@ -38,11 +38,13 @@ export const selectable = () => { }); } else query = `[id='${payload.jdnHash}']`; - this.foreach(document.querySelectorAll(query), (element) => { - if (element.classList.contains(opt.selectedClass)) { - element.classList.remove(opt.selectedClass); - } - }); + if (query.length) { + this.foreach(document.querySelectorAll(query), (element) => { + if (element.classList.contains(opt.selectedClass)) { + element.classList.remove(opt.selectedClass); + } + }); + } }; Selectables.prototype.setSelect = function (payload) {