Skip to content

Commit

Permalink
Merge pull request #1460 from jdi-testing/issue_1441
Browse files Browse the repository at this point in the history
Issue 1441: fixed xpaths calculation not starting when using a filter
  • Loading branch information
Iogsotot authored Aug 17, 2023
2 parents 624cf1b + 3f2e925 commit 0d1f624
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 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.558",
"version": "3.13.559",
"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.558",
"version": "3.13.559",
"description": "jdn-ai chrome extension",
"scripts": {
"start": "webpack --watch --env devenv",
Expand Down
4 changes: 2 additions & 2 deletions src/features/locators/components/LocatorsTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const LocatorsTree: React.FC<LocatorTreeProps> = ({ locatorIds, viewProps
}, [expandedKeys]);

return (
<React.Fragment>
<>
<div ref={containerRef} className="jdn__locatorsTree-container">
{/* incompatible type of Key */}
{/* eslint-disable-next-line */}
Expand All @@ -176,6 +176,6 @@ export const LocatorsTree: React.FC<LocatorTreeProps> = ({ locatorIds, viewProps
/>
</div>
<LocatorsProgress />
</React.Fragment>
</>
);
};
24 changes: 16 additions & 8 deletions src/features/locators/reducers/runLocatorsGeneration.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/features/locators/utils/filterLocators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
3 changes: 2 additions & 1 deletion src/features/pageObjects/components/PageObjList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ interface Props {
template?: Blob;
}

const DEFAULT_ACTIVE_KEY = "0";

export const PageObjList: React.FC<Props> = (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 =>
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const manifest = {
path: join(__dirname, "dist"),
publicPath: "./",
assetModuleFilename: "[name][ext]",
clean: true,
clean: false,
},
module: {
rules: [
Expand Down

0 comments on commit 0d1f624

Please sign in to comment.