diff --git a/manifest.json b/manifest.json index 907406b5..8bff19e6 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.558", + "version": "3.13.559", "icons": { "128": "icon128.png" }, diff --git a/package.json b/package.json index 9af72d63..08b45835 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.13.558", + "version": "3.13.559", "description": "jdn-ai chrome extension", "scripts": { "start": "webpack --watch --env devenv", diff --git a/src/features/locators/components/LocatorsTree.tsx b/src/features/locators/components/LocatorsTree.tsx index 39074215..5c02d91a 100644 --- a/src/features/locators/components/LocatorsTree.tsx +++ b/src/features/locators/components/LocatorsTree.tsx @@ -162,7 +162,7 @@ export const LocatorsTree: React.FC = ({ locatorIds, viewProps }, [expandedKeys]); return ( - + <>
{/* incompatible type of Key */} {/* eslint-disable-next-line */} @@ -176,6 +176,6 @@ export const LocatorsTree: React.FC = ({ locatorIds, viewProps />
-
+ ); }; diff --git a/src/features/locators/reducers/runLocatorsGeneration.thunk.ts b/src/features/locators/reducers/runLocatorsGeneration.thunk.ts index d571bc6d..56da1217 100644 --- a/src/features/locators/reducers/runLocatorsGeneration.thunk.ts +++ b/src/features/locators/reducers/runLocatorsGeneration.thunk.ts @@ -7,7 +7,7 @@ import { runCssSelectorGeneration } from "../utils/runCssSelectorGeneration"; import { updateLocatorGroup } from "../locators.slice"; import { selectCurrentPageObject } from "../../pageObjects/selectors/pageObjects.selectors"; import { filterLocatorsByClassFilter } from "../utils/filterLocators"; -import { selectClassFilterByPO } from "../../filter/filter.selectors"; +import { LocalStorageKey, getLocalStorage } from "../../../common/utils/localStorage"; interface Meta { locators: Locator[]; @@ -26,16 +26,24 @@ export const runLocatorsGeneration = createAsyncThunk( async (meta: Meta, thunkAPI) => { const state = thunkAPI.getState() as RootState; + const currentPageObjLibrary = selectCurrentPageObject(state)?.library; const { locators, maxGenerationTime, generateXpath, generateCssSelector, generateMissingLocator } = meta; - const filter = selectClassFilterByPO(state); - const toGenerateXpaths = maxGenerationTime - ? locators - : generateMissingLocator || generateXpath - ? filterLocatorsByClassFilter(locators, filter).filter( + const filter = getLocalStorage(LocalStorageKey.Filter)[currentPageObjLibrary ?? ""]; + + const getXpathsForGeneration = (): Locator[] => { + if (maxGenerationTime) { + return locators; + } else if (generateMissingLocator || generateXpath) { + return filterLocatorsByClassFilter(locators, filter).filter( ({ locator }) => !locator || !locator.xPath || locator.xPath === locator.fullXpath || !locator.fullXpath - ) - : []; + ); + } else { + return []; + } + }; + + const toGenerateXpaths: Locator[] = getXpathsForGeneration(); const toGenerateCss = generateMissingLocator || generateCssSelector diff --git a/src/features/locators/utils/filterLocators.ts b/src/features/locators/utils/filterLocators.ts index d8d3cf29..f121cfa6 100644 --- a/src/features/locators/utils/filterLocators.ts +++ b/src/features/locators/utils/filterLocators.ts @@ -4,9 +4,9 @@ import { ClassFilterValue } from "../../filter/types/filter.types"; export const filterLocatorsByClassFilter = (locators: Locator[], filter: ClassFilterValue) => { if (!filter) return locators; - const _locators = locators?.filter((loc) => { + const _locators = locators?.filter((locator) => { const filterValue = filter; - return Object.hasOwn(filterValue, loc.type) ? get(filterValue, loc.type) : true; + return Object.hasOwn(filterValue, locator.type) ? get(filterValue, locator.type) : true; }); return _locators; }; diff --git a/src/features/pageObjects/components/PageObjList.tsx b/src/features/pageObjects/components/PageObjList.tsx index 521e3ed5..80c2f39d 100644 --- a/src/features/pageObjects/components/PageObjList.tsx +++ b/src/features/pageObjects/components/PageObjList.tsx @@ -25,8 +25,9 @@ interface Props { template?: Blob; } +const DEFAULT_ACTIVE_KEY = "0"; + export const PageObjList: React.FC = (props) => { - const DEFAULT_ACTIVE_KEY = "0"; const state = useSelector((state) => state); // due to antd types: onChange?: (key: string | string[]) => void; const currentPageObject = useSelector((state: RootState): string | undefined => diff --git a/webpack.config.js b/webpack.config.js index 3addf500..75613a1e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -155,7 +155,7 @@ const manifest = { path: join(__dirname, "dist"), publicPath: "./", assetModuleFilename: "[name][ext]", - clean: true, + clean: false, }, module: { rules: [