验收20%
This commit is contained in:
@@ -13,8 +13,10 @@ const connect = async () => {
|
||||
|
||||
let id = 0
|
||||
const pending = new Map()
|
||||
const exceptions = []
|
||||
socket.addEventListener('message', (event) => {
|
||||
const message = JSON.parse(event.data)
|
||||
if (message.method === 'Runtime.exceptionThrown') exceptions.push(message.params.exceptionDetails.text)
|
||||
const request = pending.get(message.id)
|
||||
if (!request) return
|
||||
pending.delete(message.id)
|
||||
@@ -28,11 +30,12 @@ const connect = async () => {
|
||||
socket.send(JSON.stringify({ id, method, params }))
|
||||
})
|
||||
|
||||
return { socket, send }
|
||||
return { socket, send, exceptions }
|
||||
}
|
||||
|
||||
const valueOf = async (send, expression) => {
|
||||
const result = await send('Runtime.evaluate', { expression, returnByValue: true })
|
||||
if (result.exceptionDetails) throw new Error(result.exceptionDetails.exception?.description || result.exceptionDetails.text)
|
||||
return result.result?.value
|
||||
}
|
||||
|
||||
@@ -64,7 +67,7 @@ const openEmptyG01 = async (send) => {
|
||||
}
|
||||
|
||||
const run = async () => {
|
||||
const { socket, send } = await connect()
|
||||
const { socket, send, exceptions } = await connect()
|
||||
|
||||
try {
|
||||
await send('Page.enable')
|
||||
@@ -78,6 +81,10 @@ const run = async () => {
|
||||
await valueOf(send, "document.querySelector('.empty-search-action')?.click()")
|
||||
await waitFor(send, "location.href.includes('/pages/genealogy/g06-search-genealogies')", 'G01 empty search action did not open G06')
|
||||
|
||||
await openEmptyG01(send)
|
||||
await valueOf(send, "document.querySelector('.empty-invite-action')?.click()")
|
||||
await waitFor(send, "location.href.includes('/pages/genealogy/g06-search-genealogies?mode=invite')", 'G01 empty invite action did not open G06 invite mode')
|
||||
|
||||
const defaultUrl = nextUrl()
|
||||
await send('Page.navigate', { url: defaultUrl })
|
||||
await waitFor(send, "location.href.endsWith('/pages/genealogy/g01-my-genealogies')", 'Did not navigate to default G01')
|
||||
@@ -85,9 +92,43 @@ const run = async () => {
|
||||
if (await valueOf(send, "Boolean(document.querySelector('.genealogy-empty-state'))")) {
|
||||
throw new Error('Default G01 must not render the empty state')
|
||||
}
|
||||
if ((await valueOf(send, "document.querySelectorAll('.application-record').length")) !== 3) {
|
||||
throw new Error('Default G01 must render the application status group')
|
||||
}
|
||||
|
||||
await valueOf(send, "document.querySelector('.create-action').click()")
|
||||
await waitFor(send, "Boolean(document.querySelector('.add-dialog-layer'))", 'G01 add action did not open the custom add dialog')
|
||||
if ((await valueOf(send, "document.querySelectorAll('.add-dialog .dialog-primary, .add-dialog .dialog-secondary, .add-dialog .dialog-create').length")) !== 3) {
|
||||
throw new Error('G01 add dialog must keep search, invite, and create visible together')
|
||||
}
|
||||
await valueOf(send, "document.querySelector('.dialog-close').click()")
|
||||
await waitFor(send, "!document.querySelector('.add-dialog-layer')", 'G01 add dialog did not close')
|
||||
|
||||
await valueOf(send, "document.querySelector('.current-slip').click()")
|
||||
await waitFor(send, "Boolean(document.querySelector('.genealogy-switcher-layer'))", 'G01 current genealogy did not open the switcher')
|
||||
await valueOf(send, "document.querySelectorAll('.switcher-item')[1].click()")
|
||||
await waitFor(send, "document.querySelector('.current-name')?.textContent.includes('汤氏宗谱')", 'G01 switcher did not change the displayed current genealogy')
|
||||
|
||||
for (const state of ['loading', 'error']) {
|
||||
const stateUrl = nextUrl(`?state=${state}`)
|
||||
await send('Page.navigate', { url: stateUrl })
|
||||
await waitFor(send, `Boolean(document.querySelector('.state-panel--${state}'))`, `G01 did not render ${state}`)
|
||||
}
|
||||
|
||||
for (const size of [{ width: 320, height: 568 }, { width: 360, height: 800 }, { width: 412, height: 915 }]) {
|
||||
await send('Emulation.setDeviceMetricsOverride', { ...size, deviceScaleFactor: 1, mobile: true })
|
||||
const responsiveUrl = nextUrl()
|
||||
await send('Page.navigate', { url: responsiveUrl })
|
||||
await waitFor(send, "Boolean(document.querySelector('.current-slip'))", `G01 did not render at ${size.width}x${size.height}`)
|
||||
const width = await valueOf(send, 'document.documentElement.scrollWidth')
|
||||
if (width > size.width + 1) throw new Error(`G01 has horizontal overflow at ${size.width}x${size.height}`)
|
||||
}
|
||||
|
||||
if (exceptions.length) throw new Error(`G01 raised browser exceptions: ${exceptions.join('; ')}`)
|
||||
|
||||
process.stdout.write('G01-EMPTY-STATE-RUNTIME-SMOKE PASS\n')
|
||||
} finally {
|
||||
try { await send('Emulation.clearDeviceMetricsOverride') } catch (_) {}
|
||||
socket.close()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user