- Add tests/scripts/lib/gitea-client.js: Gitea API client with auth, comments,
attachments, and Markdown report formatters for visual and console reports
- Add tests/scripts/lib/browser-launcher.js: shared Playwright launch config with
--dns-resolution-order=hostname-first, realistic UA, and navigateTo() helper
using waitUntil:'commit' + waitForLoadState('domcontentloaded')
- Add tests/scripts/e2e-booking-flow-v2.js: full E2E scenario for irina-vik.ru
(register → book service → login → personal cabinet) with Gitea reporting
- Update visual-test-pipeline.js: GITEA_ISSUE env var, Gitea comment+attachment
posting, browser-launcher integration, waitUntil:'commit' navigation
- Update console-error-monitor-standalone.js: same Gitea + DNS fixes
- Update capture-screenshots.js: browser-launcher integration, DNS fix
- Update docker-compose.web-testing.yml: NETWORK_MODE env var (bridge),
DNS_RESOLUTION_ORDER, GITEA_USER/PASSWORD env passthrough, e2e-booking service
- Update tests/package.json: pin playwright to exact 1.52.0 (matches Docker image)
- Update .gitignore: add tests/visual/e2e/ for E2E screenshots
- Update .kilo/agents/visual-tester.md: Docker networking note, Gitea scripts,
e2e-booking service, updated script table
- Update .kilo/commands/web-test.md: Docker Networking section, --issue flag,
Gitea Integration section, e2e-booking service
- Update .kilo/commands/e2e-test.md: complete rewrite — Docker-based Playwright,
no more MCP dependency, proper service table, Gitea integration docs
- Update .kilo/capability-index.yaml: add gitea_integration, e2e_booking_flow,
docker_networking capabilities to visual-tester; add routing entries
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
/**
|
|
* Shared browser launch configuration and navigation helpers.
|
|
*
|
|
* Fixes:
|
|
* - DNS resolution inside Docker (--dns-resolution-order=hostname-first)
|
|
* - Slow sites: uses waitUntil: 'commit' + waitForLoadState instead of 'networkidle'
|
|
* - UA fingerprinting: realistic Chrome user agent
|
|
*
|
|
* Usage:
|
|
* const { launchBrowser, navigateTo } = require('./lib/browser-launcher');
|
|
* const browser = await launchBrowser();
|
|
* const page = ...;
|
|
* await navigateTo(page, 'https://example.com');
|
|
*/
|
|
|
|
const { chromium } = require('playwright');
|
|
|
|
const USE_DNS_FIX = process.env.DNS_RESOLUTION_ORDER === 'hostname-first';
|
|
|
|
const BASE_ARGS = [
|
|
'--no-sandbox',
|
|
'--disable-setuid-sandbox',
|
|
'--disable-gpu',
|
|
'--disable-dev-shm-usage',
|
|
'--disable-blink-features=AutomationControlled',
|
|
...(USE_DNS_FIX ? ['--dns-resolution-order=hostname-first'] : []),
|
|
];
|
|
|
|
const DEFAULT_UA = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36';
|
|
|
|
async function launchBrowser(options = {}) {
|
|
const args = [...BASE_ARGS, ...(options.extraArgs || [])];
|
|
return chromium.launch({
|
|
headless: options.headless !== undefined ? options.headless : true,
|
|
args,
|
|
});
|
|
}
|
|
|
|
async function newContext(browser, options = {}) {
|
|
return browser.newContext({
|
|
viewport: { width: 1280, height: 720 },
|
|
deviceScaleFactor: 1,
|
|
userAgent: DEFAULT_UA,
|
|
...options,
|
|
});
|
|
}
|
|
|
|
async function navigateTo(page, url, options = {}) {
|
|
const waitUntil = options.waitUntil || 'commit';
|
|
const timeout = options.timeout || 60000;
|
|
|
|
const response = await page.goto(url, { waitUntil, timeout });
|
|
|
|
if (options.waitForDom !== false) {
|
|
await page.waitForLoadState('domcontentloaded', { timeout: options.domTimeout || 15000 }).catch(() => {});
|
|
}
|
|
|
|
const delay = options.delay || 2000;
|
|
if (delay > 0) await page.waitForTimeout(delay);
|
|
|
|
return response;
|
|
}
|
|
|
|
module.exports = { launchBrowser, newContext, navigateTo, BASE_ARGS, DEFAULT_UA }; |