test: 冒烟新增逐席对话截图(--each),验证十席各切独立会话
|
|
@ -103,6 +103,22 @@ async function main() {
|
|||
await shot('live-05-report.png')
|
||||
}
|
||||
|
||||
if (process.argv.includes('--each')) {
|
||||
result.each = []
|
||||
const n = await evaluate("document.querySelectorAll('.ssw-seat').length")
|
||||
for (let i = 0; i < n; i++) {
|
||||
await evaluate(`(() => { const s = document.querySelectorAll('.ssw-seat'); if (s[${i}]) s[${i}].click(); return true })()`)
|
||||
await sleep(1200)
|
||||
const info = await evaluate(`(() => ({
|
||||
name: document.querySelector('.ssw-current-name')?.innerText?.trim() ?? null,
|
||||
notice: document.querySelector('.ssw-notice')?.innerText?.trim() ?? null,
|
||||
selected: document.querySelector('.ssw-seat[aria-pressed=true] .ssw-role-name')?.innerText?.trim() ?? null,
|
||||
}))()`)
|
||||
await shot('seat-' + String(i + 1).padStart(2, '0') + '.png')
|
||||
result.each.push({ i: i + 1, ...info })
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv.includes('--seat')) {
|
||||
const clicked = await evaluate("(() => { const s = document.querySelectorAll('.ssw-seat'); if (s.length >= 10) { s[9].click(); return true } return false })()")
|
||||
await sleep(1500)
|
||||
|
|
@ -130,7 +146,8 @@ async function main() {
|
|||
}
|
||||
}
|
||||
result.pass = !!(result.entry?.found && result.workbench?.found && (result.workbench?.seatCount === 10 || result.workbench?.enableText)
|
||||
&& (!process.argv.includes('--report') || (result.report?.count === 10 && result.report.items.every(it => it.name && it.text))))
|
||||
&& (!process.argv.includes('--report') || (result.report?.count === 10 && result.report.items.every(it => it.name && it.text)))
|
||||
&& (!process.argv.includes('--each') || result.each?.length === 10))
|
||||
}
|
||||
|
||||
try { await main() } catch (error) { result.fatal = String(error?.stack ?? error) } finally { try { ws?.close() } catch {}; try { browser?.kill() } catch {} }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
from PIL import Image, ImageDraw, ImageFont
|
||||
seats = [("丞相","e35483b1"),("中书","4e278758"),("尚书","2e65d691"),("门下","78223c4a"),("吏部","cf800860"),
|
||||
("户部","82262be8"),("礼部","1f2aeec7"),("兵部","2ce3587b"),("刑部","57f94de8"),("工部","857831f9")]
|
||||
crop = (772, 0, 1440, 900)
|
||||
tw, th = 300, 397
|
||||
cols, rows, pad, labelh = 5, 2, 10, 24
|
||||
tiles = []
|
||||
for i in range(1, 11):
|
||||
im = Image.open(f"preview/seat-{i:02d}.png").convert("RGB").crop(crop).resize((tw, th))
|
||||
tiles.append(im)
|
||||
W = cols * tw + (cols + 1) * pad
|
||||
H = rows * (th + labelh) + (rows + 1) * pad
|
||||
canvas = Image.new("RGB", (W, H), "white")
|
||||
d = ImageDraw.Draw(canvas)
|
||||
try:
|
||||
font = ImageFont.truetype("C:/Windows/Fonts/msyh.ttc", 15)
|
||||
except Exception:
|
||||
font = ImageFont.load_default()
|
||||
for idx, (name, sid) in enumerate(seats):
|
||||
r, c = idx // cols, idx % cols
|
||||
x = pad + c * (tw + pad)
|
||||
y = pad + r * (th + labelh + pad)
|
||||
canvas.paste(tiles[idx], (x, y))
|
||||
d.rectangle([x, y + th, x + tw, y + th + labelh], fill="#eef4ff")
|
||||
d.text((x + 6, y + th + 4), f"{name} {sid}", fill="#1f2a3a", font=font)
|
||||
canvas.save("preview/seats-contact.png")
|
||||
print("saved", canvas.size)
|
||||
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
|
@ -0,0 +1,10 @@
|
|||
import fs from 'node:fs'
|
||||
const r = JSON.parse(fs.readFileSync('preview/each.json', 'utf8'))
|
||||
const st = JSON.parse(fs.readFileSync('C:/Users/qyh15/.dsh-test-b/sansheng/state.json', 'utf8'))
|
||||
const proj = Object.values(st.projects)[0]
|
||||
const seats = proj ? Object.values(proj.seats) : []
|
||||
console.log(JSON.stringify({
|
||||
pass: r.pass,
|
||||
each: r.each,
|
||||
seats: seats.map(s => ({ seat: s.seatId, session: (s.sessionId || '').slice(0, 8), status: s.status })),
|
||||
}, null, 2))
|
||||