mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-06 19:50:20 +03:00
refactor(web-test): этап B.5.4 — readEdd хелпер (2 копии в fillReferenceField)
В fillReferenceField было два места с одинаковым page.evaluate-скриптом
чтения #editDropDown (DLB-popup перед paste и autocomplete после Ctrl+V).
core/helpers.mjs: readEdd() → { visible, items?: [{ name, x, y }] }.
selectValue использует свой clickEddItem через dispatchEvent (bypass div.surface) —
оставлен как есть, специфика API там сильно отличается.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
09b2084672
commit
e215957344
@@ -143,7 +143,7 @@ import {
|
|||||||
_detectPlatformDialogs, _closePlatformDialogs,
|
_detectPlatformDialogs, _closePlatformDialogs,
|
||||||
} from './core/errors.mjs';
|
} from './core/errors.mjs';
|
||||||
import {
|
import {
|
||||||
safeClick, findFieldInputId,
|
safeClick, findFieldInputId, readEdd,
|
||||||
detectNewForm as helperDetectNewForm,
|
detectNewForm as helperDetectNewForm,
|
||||||
} from './core/helpers.mjs';
|
} from './core/helpers.mjs';
|
||||||
// Re-export only what was publicly exported before the refactor.
|
// Re-export only what was publicly exported before the refactor.
|
||||||
@@ -1456,18 +1456,7 @@ async function fillReferenceField(selector, fieldName, value, formNum) {
|
|||||||
if (dlbVisible) {
|
if (dlbVisible) {
|
||||||
await page.click(dlbSelector);
|
await page.click(dlbSelector);
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
const eddState = await page.evaluate(`(() => {
|
const eddState = await readEdd();
|
||||||
const edd = document.getElementById('editDropDown');
|
|
||||||
if (!edd || edd.offsetWidth === 0) return { visible: false };
|
|
||||||
const eddTexts = [...edd.querySelectorAll('.eddText')].filter(el => el.offsetWidth > 0);
|
|
||||||
return {
|
|
||||||
visible: true,
|
|
||||||
items: eddTexts.map(el => {
|
|
||||||
const r = el.getBoundingClientRect();
|
|
||||||
return { name: el.innerText?.trim() || '', x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
|
||||||
})
|
|
||||||
};
|
|
||||||
})()`);
|
|
||||||
if (eddState.visible && eddState.items?.length > 0) {
|
if (eddState.visible && eddState.items?.length > 0) {
|
||||||
const target = normYo(text.toLowerCase());
|
const target = normYo(text.toLowerCase());
|
||||||
const candidates = eddState.items.filter(i => !i.name.startsWith('Создать'));
|
const candidates = eddState.items.filter(i => !i.name.startsWith('Создать'));
|
||||||
@@ -1515,18 +1504,7 @@ async function fillReferenceField(selector, fieldName, value, formNum) {
|
|||||||
await page.waitForTimeout(2000);
|
await page.waitForTimeout(2000);
|
||||||
|
|
||||||
// 4. Check editDropDown for autocomplete suggestions
|
// 4. Check editDropDown for autocomplete suggestions
|
||||||
const eddState = await page.evaluate(`(() => {
|
const eddState = await readEdd();
|
||||||
const edd = document.getElementById('editDropDown');
|
|
||||||
if (!edd || edd.offsetWidth === 0) return { visible: false };
|
|
||||||
const eddTexts = [...edd.querySelectorAll('.eddText')].filter(el => el.offsetWidth > 0);
|
|
||||||
return {
|
|
||||||
visible: true,
|
|
||||||
items: eddTexts.map(el => {
|
|
||||||
const r = el.getBoundingClientRect();
|
|
||||||
return { name: el.innerText?.trim() || '', x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
|
||||||
})
|
|
||||||
};
|
|
||||||
})()`);
|
|
||||||
|
|
||||||
if (eddState.visible && eddState.items?.length > 0) {
|
if (eddState.visible && eddState.items?.length > 0) {
|
||||||
const target = normYo(text.toLowerCase());
|
const target = normYo(text.toLowerCase());
|
||||||
|
|||||||
@@ -83,3 +83,25 @@ export async function detectNewForm(prevFormNum, { strict = false } = {}) {
|
|||||||
return nums.length > 0 ? Math.max(...nums) : null;
|
return nums.length > 0 ? Math.max(...nums) : null;
|
||||||
})()`);
|
})()`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the `#editDropDown` autocomplete popup. Returns whether it's visible
|
||||||
|
* and, when visible, an array of `.eddText` items with display name and
|
||||||
|
* center coordinates (suitable for page.mouse.click).
|
||||||
|
*
|
||||||
|
* @returns {Promise<{visible: boolean, items?: Array<{name:string, x:number, y:number}>}>}
|
||||||
|
*/
|
||||||
|
export async function readEdd() {
|
||||||
|
return await page.evaluate(`(() => {
|
||||||
|
const edd = document.getElementById('editDropDown');
|
||||||
|
if (!edd || edd.offsetWidth === 0) return { visible: false };
|
||||||
|
const eddTexts = [...edd.querySelectorAll('.eddText')].filter(el => el.offsetWidth > 0);
|
||||||
|
return {
|
||||||
|
visible: true,
|
||||||
|
items: eddTexts.map(el => {
|
||||||
|
const r = el.getBoundingClientRect();
|
||||||
|
return { name: el.innerText?.trim() || '', x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})()`);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user