Files
cc-1c-skills/tests/web-test/14-multi-context-routing.test.mjs
T
Nick Shirokov 3f1168b975 feat(web-test): управление пулом контекстов/лицензий в раннере
Раннер регресса теперь держит пул 1С-сеансов сам, вместо накопления контекстов
между тестами и ручного закрытия в хуках. Три необязательных поля webtest.config.mjs
(без них поведение прежнее):
- maxContexts     — потолок одновременно живых сеансов (null = без лимита);
- contextPolicy   — 'reuse' (держать открытыми в пределах лимита) | 'strict'
                    (закрывать non-pinned контексты теста сразу после него);
- pinnedContexts  — не вытесняются LRU (default = [defaultContext]; [] делает
                    default вытесняемым на тесном стенде).

Перед setup каждого теста LRU-вытеснение освобождает слот под нужды теста;
уже открытые нужные контексты переиспользуются. Default больше не вечно-pinned.
Исчерпание пула даёт внятную ошибку вместо маскирующего «Browser not connected».

- new: cli/test-runner/context-pool.mjs — чистый планировщик planEviction + LRU.
- cli/commands/test.mjs (v1.4): парсинг/валидация полей, вытеснение с фолбэк-парковкой
  на нужный контекст (нельзя закрыть единственный активный), strict-закрытие, LRU-трекинг.
- Доки: regression-spec (§7/§8/глоссарий), regression-guide (рецепт), regress.md.
- Регресс дай-фудит фичу: 14-multi-context-routing роутит в 3-й контекст c,
  15-multi-context-handover проверяет вытеснение c на границе; конфиг maxContexts:2.

Юнит-краёв планировщика — в debug/ (gitignored). Live-регресс: 25/25 зелёных.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-15 14:57:56 +03:00

25 lines
1.1 KiB
JavaScript

export const name = 'Multi-context: routing single test to non-default context';
export const tags = ['multi-context', 'smoke'];
export const context = 'c';
export const timeout = 60000;
export default async function({ getPageState, navigateSection, openCommand, closeForm, assert, step, log }) {
await step('Active context is c', async () => {
// Sanity check — ensure we are routed into c's session (a third, non-default context).
// Leaving c open here is intentional: it becomes the LRU eviction candidate at the
// 14→15 boundary under maxContexts:2 (asserted in 15-multi-context-handover).
const state = await getPageState();
assert.ok(Array.isArray(state.sections) && state.sections.length, 'Sections should be visible');
log('Sections in c: ' + state.sections.map(s => s.name).join(', '));
});
await step('Open Контрагенты in context c', async () => {
await navigateSection('Склад');
const state = await openCommand('Контрагенты');
assert.ok(state.form != null, 'List form should open');
log('Opened in c: ' + state.title);
await closeForm();
});
}