import { chromium } from 'playwright'
const b = await chromium.launch()
const ctx = await b.newContext({ viewport: { width: 1400, height: 900 } })
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 r = await p.evaluate(() => {
  const fi = document.querySelector('.ql-toolbar')?.closest('.el-form-item')
  return {
    formItemHeight: fi ? getComputedStyle(fi).height : null,
    containerHeight: getComputedStyle(document.querySelector('.ql-container')).height,
    toolbarHeight: getComputedStyle(document.querySelector('.ql-toolbar')).height
  }
})
console.log(JSON.stringify(r))
const tb = await p.$('.ql-toolbar')
const box = await tb.boundingBox()
await p.evaluate((y) => window.scrollTo(0, y - 200), box.y)
await p.waitForTimeout(500)
await p.screenshot({ path: 'scripts/shot-quill-fixed2.png' })
await b.close()
