From bb209f70757c925f4dc73511fa05eda191db1f3f Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Tue, 18 Jul 2023 16:50:09 +0300 Subject: [PATCH] fix tests --- src/__tests__/__mocks__/locator.mock.js | 5 +++-- src/__tests__/locators/locatorsSlice.test.js | 4 ++-- .../selectLocatorsByPageObject.mock.ts | 19 ++++++++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/__tests__/__mocks__/locator.mock.js b/src/__tests__/__mocks__/locator.mock.js index a43b4856..4b6a74c8 100644 --- a/src/__tests__/__mocks__/locator.mock.js +++ b/src/__tests__/__mocks__/locator.mock.js @@ -6,6 +6,7 @@ export const locator1 = { xPath: "//*[@class='sidebar-menu left']", output: "//*[@class='sidebar-menu left']", taskStatus: "SUCCESS", + xPathStatus: "SUCCESS", cssSelector: ".sidebar-menu.left", }, name: "radiobuttonsUl", @@ -28,7 +29,7 @@ export const locator2 = { locator: { xPath: "//*[@class='sidebar-menu left']", cssSelector: "", - taskStatus: "SUCCESS", + xPathStatus: "SUCCESS", }, name: "radiobuttonsUl", predictedAttrId: "", @@ -49,7 +50,7 @@ export const locator3 = { locator: { xPath: "//*[@class='sidebar-menu left']", cssSelector: "", - taskStatus: "SUCCESS", + xPathStatus: "SUCCESS", }, name: "radiobuttonsUl", predictedAttrId: "", diff --git a/src/__tests__/locators/locatorsSlice.test.js b/src/__tests__/locators/locatorsSlice.test.js index fff5d0e3..47179350 100644 --- a/src/__tests__/locators/locatorsSlice.test.js +++ b/src/__tests__/locators/locatorsSlice.test.js @@ -59,7 +59,7 @@ describe("changeLocatorAttributes reducer", () => { expect(changeElementNameSpy).toHaveBeenCalledWith(locator); }); - test("edit type, custom name stays the same", () => { + test("edit type, custom name remains the same", () => { store.dispatch( changeLocatorAttributes({ element_id: "8736312404689610766421832473", @@ -96,7 +96,7 @@ describe("changeLocatorAttributes reducer", () => { expect(locator.isCustomLocator).toBeTruthy(); expect(locator.isCustomName).toBeTruthy(); expect(locator.locator.xPath).toBe("//*[@class='any-class']"); - expect(locator.locator.taskStatus).toBe(LocatorTaskStatus.SUCCESS); + expect(locator.locator.xPathStatus).toBe(LocatorTaskStatus.SUCCESS); }); test("warned validation", () => { diff --git a/src/__tests__/pageObject/__mocks__/selectLocatorsByPageObject.mock.ts b/src/__tests__/pageObject/__mocks__/selectLocatorsByPageObject.mock.ts index c7c29b05..adfaf137 100644 --- a/src/__tests__/pageObject/__mocks__/selectLocatorsByPageObject.mock.ts +++ b/src/__tests__/pageObject/__mocks__/selectLocatorsByPageObject.mock.ts @@ -66,7 +66,8 @@ export const getRootState = (_pageObject: PageObject) => ({ locator: { cssSelector: ".main-content", output: ".main-content", - taskStatus: "SUCCESS", + xPathStatus: "SUCCESS", + cssSelectorStatus: "SUCCESS", xPath: "//*[@class='main-content']", }, locatorType: LocatorType.cssSelector, @@ -88,7 +89,8 @@ export const getRootState = (_pageObject: PageObject) => ({ locator: { cssSelector: ".uui-navigation.nav.navbar-nav.m-l8.any", output: "//*[@class='uui-navigation nav navbar-nav m-l8 any']", - taskStatus: "SUCCESS", + xPathStatus: "SUCCESS", + cssSelectorStatus: "PENDING", xPath: "//*[@class='uui-navigation nav navbar-nav m-l8 any']", }, name: "homeContactFormServiceSupportDatesSearchComplexTableSimpleTa", @@ -112,7 +114,8 @@ export const getRootState = (_pageObject: PageObject) => ({ elemAriaLabel: null, locator: { cssSelector: '[index="5"] > ul', - taskStatus: "SUCCESS", + xPathStatus: "SUCCESS", + cssSelectorStatus: "FAILURE", xPath: "//*[@index='5']/ul", output: "//*[@index='5']/ul", }, @@ -141,6 +144,8 @@ export const selectMockedLocators = (pageObject: PageObject) => [ elemAriaLabel: null, locator: { taskStatus: "SUCCESS", + cssSelectorStatus: "SUCCESS", + xPathStatus: "SUCCESS", xPath: "//*[@class='main-content']", output: ".main-content", cssSelector: ".main-content", @@ -163,7 +168,9 @@ export const selectMockedLocators = (pageObject: PageObject) => [ elemAriaLabel: null, ...(pageObject.locatorType === LocatorType.cssSelector ? { locatorType: LocatorType.cssSelector } : null), locator: { - taskStatus: "SUCCESS", + taskStatus: "PENDING", + xPathStatus: "SUCCESS", + cssSelectorStatus: "PENDING", xPath: "//*[@class='uui-navigation nav navbar-nav m-l8 any']", cssSelector: ".uui-navigation.nav.navbar-nav.m-l8.any", output: @@ -191,7 +198,9 @@ export const selectMockedLocators = (pageObject: PageObject) => [ elemText: "HTML 5", elemAriaLabel: null, locator: { - taskStatus: "SUCCESS", + taskStatus: "FAILURE", + xPathStatus: "SUCCESS", + cssSelectorStatus: "FAILURE", xPath: "//*[@index='5']/ul", output: "//*[@index='5']/ul", cssSelector: '[index="5"] > ul',