import { createRequire } from 'node:module' const require = createRequire(process.argv[2] + '/apps/app/package.json') const pw = require('@playwright/test') const sizes = [[320,568],[360,640],[375,667],[390,844],[1280,800]] const browser = await pw.chromium.launch() for (const [w,h] of sizes) { const ctx = await browser.newContext({ viewport: { width: w, height: h }, locale: 'fr-FR', hasTouch: w < 500, isMobile: w < 500 }) const page = await ctx.newPage() await page.goto('http://127.0.0.1:5197/new') await page.getByLabel('Nom complet').first().fill('P F') await page.getByLabel("Nom de l'animal").first().fill('A F') await page.getByLabel('Nom du propriétaire').first().fill('O F') await page.getByRole('button',{name:'Démarrer le bilan'}).click() await page.waitForURL(/editor/) const dlg = page.getByRole('dialog'); if (await dlg.count()) { await page.keyboard.press('Escape') } await page.locator('[data-anno-id="hock"]').first().waitFor({ state: 'attached' }) const m = await page.evaluate(() => { const svg = document.querySelector('.svg-canvas svg'); const r = svg.getBoundingClientRect() const vb = svg.viewBox.baseVal const twins = [...svg.querySelectorAll('circle[pointer-events="none"]')].map(c => c.getBoundingClientRect().width) return { svgW: r.width, svgH: r.height, vbW: vb.width, vbH: vb.height, scale: Math.min(r.width / vb.width, r.height / vb.height), twinMin: Math.min(...twins), twinMax: Math.max(...twins) } }) // detail modal await page.locator('[data-anno-id="head-trigger"]').first().dispatchEvent('click') let d = null try { await page.locator('dialog [data-anno-id="atm"]').first().waitFor({ state: 'attached', timeout: 5000 }) d = await page.evaluate(() => { const svg = document.querySelector('dialog .svg-canvas svg'); const r = svg.getBoundingClientRect(); const vb = svg.viewBox.baseVal const twins = [...svg.querySelectorAll('circle[pointer-events="none"]')].map(c => c.getBoundingClientRect().width) return { svgW: r.width, svgH: r.height, vbW: vb.width, vbH: vb.height, scale: Math.min(r.width / vb.width, r.height / vb.height), twinMin: Math.min(...twins) } }) } catch (e) { d = String(e).slice(0,100) } console.log(w, h, JSON.stringify(m), 'detail', JSON.stringify(d)) await ctx.close() } await browser.close()