feat(web-test): normalize navigateLink URLs

- Auto-prepend e1cib/list/ when missing
- Translate English type names to Russian (AccumulationRegister → РегистрНакопления, etc.)
- Accepts: full e1cib/..., short Тип.Имя, or English Type.Имя

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-02-28 15:46:30 +03:00
parent e58f5c1f82
commit a17a81fe98
2 changed files with 44 additions and 4 deletions
+7 -3
View File
@@ -218,13 +218,17 @@ Hint: if `readTable()` returns `hierarchical: true`, the list has groups.
### Navigation links
```js
// Open any form directly by 1C navigation link (e1cib/...)
// Full e1cib link
await navigateLink('e1cib/list/РегистрНакопления.ЗаказыКлиентов');
await navigateLink('e1cib/list/Документ.ЗаказКлиента');
await navigateLink('e1cib/list/Справочник.Контрагенты');
// Short form — auto-prepends e1cib/list/
await navigateLink('Документ.ЗаказКлиента');
// English type names — auto-translated to Russian
await navigateLink('AccumulationRegister.ЗаказыКлиентов');
await navigateLink('Catalog.Контрагенты');
```
Bypasses section/command navigation. Useful for registers, journals, and any form with a known path.
Auto-normalizes: `e1cib/list/` prefix + English→Russian type translation.
### Submenu navigation
+37 -1
View File
@@ -340,14 +340,50 @@ export async function switchTab(name) {
return await getFormState();
}
// English → Russian metadata type mapping for e1cib navigation links
const E1CIB_TYPE_MAP = {
'catalog': 'Справочник', 'catalogs': 'Справочник',
'document': 'Документ', 'documents': 'Документ',
'commonmodule': 'ОбщийМодуль',
'enum': 'Перечисление', 'enums': 'Перечисление',
'dataprocessor': 'Обработка', 'dataprocessors': 'Обработка',
'report': 'Отчет', 'reports': 'Отчет',
'accumulationregister': 'РегистрНакопления',
'informationregister': 'РегистрСведений',
'accountingregister': 'РегистрБухгалтерии',
'calculationregister': 'РегистрРасчета',
'chartofaccounts': 'ПланСчетов',
'chartofcharacteristictypes': 'ПланВидовХарактеристик',
'chartofcalculationtypes': 'ПланВидовРасчета',
'businessprocess': 'БизнесПроцесс',
'task': 'Задача',
'exchangeplan': 'ПланОбмена',
'constant': 'Константа',
};
function normalizeE1cibUrl(url) {
// Already a full e1cib link
if (url.startsWith('e1cib/')) return url;
// "ТипОбъекта.Имя" or "EnglishType.Имя" — prepend e1cib/list/ and translate type if needed
const dot = url.indexOf('.');
if (dot > 0) {
const typePart = url.substring(0, dot);
const namePart = url.substring(dot + 1);
const ruType = E1CIB_TYPE_MAP[typePart.toLowerCase()] || typePart;
return `e1cib/list/${ruType}.${namePart}`;
}
return `e1cib/list/${url}`;
}
/** Navigate to a 1C navigation link via Shift+F11 dialog. Returns new form state. */
export async function navigateLink(url) {
ensureConnected();
await dismissPendingErrors();
const link = normalizeE1cibUrl(url);
const formBefore = await page.evaluate(detectFormScript());
// Copy link to clipboard, press Shift+F11 (opens "Go to link" dialog with clipboard content)
await page.evaluate(`navigator.clipboard.writeText(${JSON.stringify(url)})`);
await page.evaluate(`navigator.clipboard.writeText(${JSON.stringify(link)})`);
await page.keyboard.press('Shift+F11');
await waitForStable();