From 9b7be83a2a051848d6d8fe74a11cf4e6be09948b Mon Sep 17 00:00:00 2001 From: Anna Iustus Date: Thu, 15 Aug 2024 17:59:16 +0200 Subject: [PATCH 1/2] feat: add viewport resolution info in predict endpoint payload --- src/common/utils/getViewportResolution.ts | 10 ++++++++++ src/pageServices/pageDataHandlers.ts | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/common/utils/getViewportResolution.ts diff --git a/src/common/utils/getViewportResolution.ts b/src/common/utils/getViewportResolution.ts new file mode 100644 index 00000000..ddcd1842 --- /dev/null +++ b/src/common/utils/getViewportResolution.ts @@ -0,0 +1,10 @@ +import connector from '../../pageServices/connector'; + +export const getViewportResolution = async () => { + return await connector.attachContentScript(() => { + const width = window.innerWidth; + const height = window.innerHeight; + + return { width, height }; + }); +}; diff --git a/src/pageServices/pageDataHandlers.ts b/src/pageServices/pageDataHandlers.ts index 7d5842b3..923eff1b 100644 --- a/src/pageServices/pageDataHandlers.ts +++ b/src/pageServices/pageDataHandlers.ts @@ -6,6 +6,7 @@ import { getFullDocumentWithStyles } from '../common/utils/getFullDocumentWithSt import { ILocator, PredictedEntity } from '../features/locators/types/locator.types'; import { getLibrarySelectors } from '../services/rules/createSelector'; import { VueRules } from '../services/rules/Vue.rules'; +import { getViewportResolution } from '../common/utils/getViewportResolution'; // /* global chrome */ let overlayID: string; @@ -59,10 +60,13 @@ Function returns predicted elements. */ export const predictElements = (endpoint: HttpEndpoint): PredictElementsType => { let pageData: string; - return Promise.all([sendMessage.getPageData(), getFullDocumentWithStyles()]) - .then(([pageDataResult, documentResult]) => { + return Promise.all([sendMessage.getPageData(), getFullDocumentWithStyles(), getViewportResolution()]) + .then(([pageDataResult, documentResult, viewportResolution]) => { pageData = pageDataResult[0]; - const payload = { elements: pageData, document: documentResult }; + + const viewport = JSON.stringify(viewportResolution[0].result); + const payload = { elements: pageData, document: documentResult, viewport }; + return sendToModel(payload, endpoint); }) .then( From 388e065552e5130acfba94e2a924a28cc5f93adb Mon Sep 17 00:00:00 2001 From: Anna Iustus Date: Thu, 15 Aug 2024 17:59:26 +0200 Subject: [PATCH 2/2] update version --- manifest.json | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 5f4bbb53..83d9db7d 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "JDN — Page Object Generator", "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.16.4", + "version": "3.16.5", "icons": { "128": "icon128.png" }, diff --git a/package-lock.json b/package-lock.json index 0f960651..5643d707 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.16.4", + "version": "3.16.5", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index b76b2e28..ab44a7fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.16.4", + "version": "3.16.5", "description": "jdn-ai chrome extension", "scripts": { "start": "webpack --watch --env devenv",