Review changes batch 6 of 6
This commit is contained in:
@@ -42,12 +42,31 @@ const waitFor = async (send, expression, message) => {
|
||||
}
|
||||
throw new Error(message)
|
||||
}
|
||||
const open = async (send, query, selector) => {
|
||||
const waitForPageLoad = async (socket, trigger) => new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
socket.removeEventListener('message', onMessage)
|
||||
reject(new Error('G05 reload did not emit Page.loadEventFired'))
|
||||
}, 4000)
|
||||
const onMessage = (event) => {
|
||||
const message = JSON.parse(event.data)
|
||||
if (message.method !== 'Page.loadEventFired') return
|
||||
clearTimeout(timeout)
|
||||
socket.removeEventListener('message', onMessage)
|
||||
resolve()
|
||||
}
|
||||
socket.addEventListener('message', onMessage)
|
||||
Promise.resolve().then(trigger).catch((error) => {
|
||||
clearTimeout(timeout)
|
||||
socket.removeEventListener('message', onMessage)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
const open = async (socket, send, query, selector) => {
|
||||
const url = `${origin}/#${route}${query}`
|
||||
await send('Page.navigate', { url })
|
||||
await waitFor(send, `location.href === ${JSON.stringify(url)}`, 'G05 navigation failed')
|
||||
const documentTimeOrigin = await valueOf(send, 'performance.timeOrigin')
|
||||
await send('Page.reload')
|
||||
await waitForPageLoad(socket, () => send('Page.reload'))
|
||||
await waitFor(send, `performance.timeOrigin !== ${JSON.stringify(documentTimeOrigin)}`, `G05 ${query} did not reload into a fresh document`)
|
||||
await waitFor(send, `Boolean(document.querySelector(${JSON.stringify(selector)}))`, `G05 ${query} did not render`)
|
||||
}
|
||||
@@ -57,27 +76,27 @@ const run = async () => {
|
||||
try {
|
||||
await send('Page.enable')
|
||||
await send('Runtime.enable')
|
||||
await open(send, '?state=empty', '.overview-state--empty')
|
||||
await open(send, '?state=error&genealogyId=1001', '.overview-state--error')
|
||||
await open(send, '?state=no-permission&genealogyId=1001', '.overview-state--no-permission')
|
||||
await open(send, '?mode=public&genealogyId=2001', '.overview-public')
|
||||
await open(socket, send, '?state=empty', '.overview-state--empty')
|
||||
await open(socket, send, '?state=error&genealogyId=1001', '.overview-state--error')
|
||||
await open(socket, send, '?state=no-permission&genealogyId=1001', '.overview-state--no-permission')
|
||||
await open(socket, send, '?mode=public&genealogyId=2001', '.overview-public')
|
||||
if ((await valueOf(send, "document.querySelectorAll('.overview-public__details > uni-view').length")) !== 5) throw new Error('G05 public preview is missing identity details')
|
||||
if (await valueOf(send, "Boolean(document.querySelector('.overview-actions'))")) throw new Error('G05 public preview exposed member actions')
|
||||
await valueOf(send, "document.querySelector('.overview-public__action').click()")
|
||||
await waitFor(send, "location.href.includes('/pages/genealogy/g08-join-application?source=search&genealogyId=2001')", 'G05 public apply action did not open G08 search source')
|
||||
|
||||
await open(send, '?role=member&genealogyId=1001', '.overview-ready')
|
||||
await open(socket, send, '?role=member&genealogyId=1001', '.overview-ready')
|
||||
if ((await valueOf(send, "document.querySelectorAll('.overview-action').length")) !== 2) throw new Error('G05 member overview exposed owner actions')
|
||||
if (await valueOf(send, "document.querySelector('.header-action')?.textContent.trim().length > 0")) throw new Error('G05 member overview exposed management action')
|
||||
|
||||
await open(send, '?genealogyId=1001', '.overview-ready')
|
||||
await open(socket, send, '?genealogyId=1001', '.overview-ready')
|
||||
if ((await valueOf(send, "document.querySelectorAll('.overview-action').length")) !== 4) throw new Error('G05 owner overview is missing management actions')
|
||||
await valueOf(send, "document.querySelector('.overview-action--ancestor')?.click()")
|
||||
await waitFor(send, "location.href.includes('/pages/genealogy/g03-create-genealogy?step=ancestor&genealogyId=1001')", 'G05 ancestor action did not open the G03 ancestor step')
|
||||
|
||||
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 })
|
||||
await open(send, '?mode=public&genealogyId=2001', '.overview-public')
|
||||
await open(socket, send, '?mode=public&genealogyId=2001', '.overview-public')
|
||||
const width = await valueOf(send, 'document.documentElement.scrollWidth')
|
||||
if (width > size.width + 1) throw new Error(`G05 has horizontal overflow at ${size.width}x${size.height}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user