feat: add Gitea integration, E2E booking flow, Docker DNS fix, browser-launcher module

- 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
This commit is contained in:
NW
2026-04-17 09:27:27 +01:00
parent 3a8aa6b416
commit c258d16ef5
13 changed files with 1149 additions and 238 deletions

View File

@@ -11,16 +11,20 @@
* TARGET_URL - App URL (default: http://host.docker.internal:3000)
* PIXELMATCH_THRESHOLD - Diff threshold (default: 0.05 = 5%)
* PAGES - Comma-separated page paths (default: /,/admin/login)
* GITEA_ISSUE - Gitea issue number to post results (optional)
*/
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');
const gitea = require('./lib/gitea-client');
const { BASE_ARGS } = require('./lib/browser-launcher');
const TARGET_URL = process.argv[2] || process.env.TARGET_URL || 'http://host.docker.internal:3000';
const THRESHOLD = parseFloat(process.env.PIXELMATCH_THRESHOLD || '0.05');
const PAGES_ARG = process.env.PAGES || '/,/admin/login';
const PAGE_PATHS = PAGES_ARG.split(',').map(p => p.trim()).filter(Boolean);
const GITEA_ISSUE = parseInt(process.env.GITEA_ISSUE, 10) || null;
const VISUAL_DIR = path.join(__dirname, '..', 'visual');
const BASELINE_DIR = path.join(VISUAL_DIR, 'baseline');
@@ -128,7 +132,8 @@ async function capturePage(browser, pageConf, vp, outputDir, mode) {
try {
console.log(` Capturing: ${pageConf.name} @ ${vp.name} (${vp.width}x${vp.height})`);
const response = await page.goto(url, { waitUntil: 'networkidle', timeout: 20000 });
const response = await page.goto(url, { waitUntil: 'commit', timeout: 30000 });
await page.waitForLoadState('domcontentloaded', { timeout: 15000 }).catch(() => {});
await page.waitForTimeout(1500);
await page.screenshot({ path: filePath, fullPage: true });
@@ -161,7 +166,7 @@ async function captureAll(mode) {
console.log(` Pages: ${PAGES.map(p => p.path).join(', ')}`);
console.log(` Output: ${outputDir}\n`);
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
const browser = await chromium.launch({ headless: true, args: [...BASE_ARGS, '--disable-setuid-sandbox'] });
const results = [];
for (const pageConf of PAGES) {
@@ -319,6 +324,33 @@ async function main() {
console.log(`\n 📄 Report: ${reportPath}`);
console.log('═══════════════════════════════════════════════════\n');
if (GITEA_ISSUE) {
try {
console.log(`📤 Posting results to Gitea Issue #${GITEA_ISSUE}...`);
const commentBody = gitea.formatVisualReport(report);
const diffFiles = fs.existsSync(DIFF_DIR)
? fs.readdirSync(DIFF_DIR).filter(f => f.endsWith('.png')).map(f => path.join(DIFF_DIR, f))
: [];
const currentFiles = fs.existsSync(CURRENT_DIR)
? fs.readdirSync(CURRENT_DIR).filter(f => f.endsWith('.png')).map(f => path.join(CURRENT_DIR, f))
: [];
if (diffFiles.length > 0) {
await gitea.uploadAndComment(GITEA_ISSUE, diffFiles, commentBody);
console.log(` ✅ Posted comment with ${diffFiles.length} diff screenshots`);
} else if (currentFiles.length > 0) {
await gitea.uploadAndComment(GITEA_ISSUE, currentFiles, commentBody);
console.log(` ✅ Posted comment with ${currentFiles.length} current screenshots`);
} else {
await gitea.postComment(GITEA_ISSUE, commentBody);
console.log(' ✅ Posted comment (no screenshots to upload)');
}
} catch (err) {
console.error(` ❌ Gitea posting failed: ${err.message}`);
}
}
process.exit(report.summary.overallPassed ? 0 : 1);
}