Skip to content

Commit

Permalink
Merge pull request #1434 from jdi-testing/issue_1428
Browse files Browse the repository at this point in the history
Issue 1428, issue 1422: fix locator edit, add trigger for locator autogeneration
  • Loading branch information
MariiaNebesnova authored Aug 2, 2023
2 parents a2f05e4 + 1c2701e commit e4c52b7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 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.542",
"version": "3.13.543",
"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.542",
"version": "3.13.543",
"description": "jdn-ai chrome extension",
"scripts": {
"start": "webpack --watch --env devenv",
Expand Down
11 changes: 9 additions & 2 deletions src/app/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { logger } from "./middlewares/logger";
import { scriptNotifier } from "../../pageServices/scriptNotifier";
import { changePageMiddleware } from "./middlewares/changePage.middleware";
import { updateSocketMessageHandler } from "../../services/webSocketMessageHandler";
import { onSetActive } from "../../features/locators/reducers/onSetActive.middleware";
import { shouldRunGeneration } from "../../features/locators/reducers/shouldRunGeneration.middleware";
import { quitThrottlerMiddleware } from "../../common/utils/throttler";

const rootReducer = {
Expand All @@ -34,7 +34,14 @@ export const store = configureStore({
"main/setScriptMessage",
],
},
}).concat([logger, scriptNotifier, cancellableActions, changePageMiddleware, onSetActive, quitThrottlerMiddleware]),
}).concat([
logger,
scriptNotifier,
cancellableActions,
changePageMiddleware,
shouldRunGeneration,
quitThrottlerMiddleware,
]),
});

store.subscribe(() => updateMessageHandler(store.dispatch, store.getState()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Middleware } from "@reduxjs/toolkit";
import { Locator } from "../types/locator.types";
import { ElementId, Locator } from "../types/locator.types";
import { runLocatorsGeneration } from "./runLocatorsGeneration.thunk";
import { getNoLocatorsElements, hasAllLocators } from "../utils/utils";
import { selectLocatorById } from "../selectors/locators.selectors";

export const onSetActive: Middleware = (store) => (next) => (action) => {
export const shouldRunGeneration: Middleware = (store) => (next) => (action) => {
const { type, payload } = action;
const state = store.getState();

switch (type) {
case "locators/elementGroupSetActive": {
Expand All @@ -20,14 +22,19 @@ export const onSetActive: Middleware = (store) => (next) => (action) => {
}
break;
}
case "locators/toggleElementGeneration":
case "locators/setActiveSingle":
case "locators/elementSetActive": {
const noLocators = !hasAllLocators(payload);
const _locator =
typeof payload === "string" ? selectLocatorById(state, payload as ElementId) : (payload as Locator);
if (!_locator) break;

const noLocators = !hasAllLocators(_locator);
if (noLocators) {
store.dispatch(
// @ts-ignore
runLocatorsGeneration({
locators: [payload as Locator],
locators: [_locator as Locator],
generateMissingLocator: true,
})
);
Expand Down
3 changes: 3 additions & 0 deletions src/features/onboarding/OnboardingProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export const OnboardingProvider: FC<Props> = ({ children }) => {
onClickPrev?: (...args: any) => void
) => {
setStepRefs((prevRefs) => {
/* case for skippeed step, see `locatorPageSteps` at useOnBoardingRef.ts */
if (!prevRefs[name]) return prevRefs;

const { target: currentTarget, onClickNext: currentNext, onClickPrev: currentPrev } = prevRefs[name];
return {
...prevRefs,
Expand Down

0 comments on commit e4c52b7

Please sign in to comment.