// Run against the isolated fixture from start_admin_test_server.ps1, never production. const fs = require('node:fs'); const path = require('node:path'); const assert = require('node:assert/strict'); const { chromium } = require(process.env.PLAYWRIGHT_MODULE || 'playwright'); const repo = path.resolve(__dirname, '..'); const run = JSON.parse(fs.readFileSync(path.join(repo, 'artifacts/admin-local-server.json'), 'utf8').replace(/^\uFEFF/, '')); const fixture = JSON.parse(fs.readFileSync(path.join(repo, 'artifacts/admin-ui-fixture.json'), 'utf8')); if (run.url !== 'http://127.0.0.1:15199') throw new Error('Only the loopback fixture is allowed'); (async () => { const browser = await chromium.launch({headless: true, executablePath: process.env.ADMIN_BROWSER || 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'}); try { const page = await browser.newPage({viewport: {width: 1440, height: 1000}}); page.setDefaultTimeout(15000); const errors = []; page.on('pageerror', e => errors.push(e.message)); page.on('dialog', d => d.accept()); await page.goto(run.url + '/admin/'); await page.locator('#loginUsername').fill('admin-test'); await page.locator('#loginPassword').fill('test-only-password'); await page.locator('#loginForm button').click(); await page.waitForFunction(() => document.querySelector('#usersCount').textContent.includes('пользователей')); assert.equal(await page.locator('#adminIdentity').textContent(), 'admin-test'); await page.screenshot({path: path.join(repo, 'artifacts/admin-overview.png'), fullPage: true}); await page.locator('.nav-item[data-section=users]').click(); await page.locator('#usersPager [data-page="2"]').click(); await page.waitForFunction(() => document.querySelector('#usersPager').textContent.includes('Страница 2')); await page.locator('#globalSearch').fill('UI пользователь