import { chromium } from 'playwright'
const b = await chromium.launch()
const ctx = await b.newContext({ viewport: { width: 1600, height: 1000 } })
const p = await ctx.newPage()
await p.goto('http://localhost:8080/')
await p.fill('input[placeholder="请输入账号"]', 'admin')
await p.fill('input[placeholder="请输入密码"]', '123456')
await p.click('button.login-btn')
await p.waitForTimeout(1500)
await p.goto('http://localhost:8080/#/customization/hsbc/equity-products/add')
await p.waitForTimeout(2000)
const dims = await p.evaluate(() => {
  const cs = document.querySelectorAll('.ql-container')
  return Array.from(cs).map(c => ({ w: getComputedStyle(c).width, h: getComputedStyle(c).height }))
})
console.log('CONTAINERS:', JSON.stringify(dims))
// scroll to find the editor
await p.evaluate(() => { document.querySelector('.ql-toolbar')?.scrollIntoView({ block: 'center' }) })
await p.waitForTimeout(500)
await p.screenshot({ path: 'scripts/shot-quill-fixed.png' })
await b.close()
