Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MariiaNebesnova committed Aug 1, 2023
1 parent a2f05e4 commit 897efea
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/features/locators/reducers/createLocators.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface Meta {
library: ElementLibrary;
}

/* this thunk collects data from page, needed for locators business logic,
finds child-parent connections and then saves locators to state */
export const createLocators = createAsyncThunk("locators/createLocators", async (payload: Meta, thunkAPI) => {
const { predictedElements, library } = payload;
const state = thunkAPI.getState();
Expand Down
7 changes: 6 additions & 1 deletion src/features/locators/reducers/identifyElements.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ interface Meta {
}

export const identifyElements = createAsyncThunk("locators/identifyElements", async ({ pageObj }: Meta, thunkAPI) => {
/* set current page object and filter */
thunkAPI.dispatch(setCurrentPageObj(pageObj));

/* set filter, if any exists in local storage */
const state = thunkAPI.getState() as RootState;
const library = selectPageObjById(state, pageObj)?.library || defaultLibrary;
const savedFilters = getLocalStorage(LocalStorageKey.Filter);

if (savedFilters && savedFilters[library]) {
thunkAPI.dispatch(setFilter({ pageObjectId: pageObj, JDIclassFilter: savedFilters[library] }));
}

/* Identify elements, needed for testing purposes. Depend on selected element library,
elements will be identified by predictElements() or findByRules().
Then adds needed locators to state and runs locator value generation. */
try {
const endpoint = predictEndpoints[library];
const { data: res, pageData } =
Expand Down
4 changes: 4 additions & 0 deletions src/features/locators/reducers/runLocatorsGeneration.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ interface Meta {
generateMissingLocator?: boolean;
}

/* Purpose of this thunk is to start locators generation.
It's used for initial locators generation, or can be called on demand for particular locator type
or with parameters.
*/
export const runLocatorsGeneration = createAsyncThunk(
"locators/runLocatorsGeneration",
async (meta: Meta, thunkAPI) => {
Expand Down
1 change: 1 addition & 0 deletions src/features/locators/utils/generationButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { sendMessage } from "../../../pageServices/connector";
import { getLibrarySelectors } from "../../../services/rules/createSelector";
import { VueRules } from "../../../services/rules/Vue.rules";

/* Runs elements identification based on algoritmic rules */
export const findByRules = () => {
const selectors = getLibrarySelectors(VueRules);
return sendMessage
Expand Down
3 changes: 3 additions & 0 deletions src/pageServices/pageDataHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const sendToModel = async (payload, endpoint) => {
return response;
};

/* First, plugin collects necessary data from the page.
And then tha data is sent to endpoint, according to selected library.
Function returns predicted elements. */
export const predictElements = (endpoint) => {
let pageData;
return sendMessage
Expand Down

0 comments on commit 897efea

Please sign in to comment.