Unverified Commit 22e61a3c authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

test: align existing testing util (#75844)

parent fe45b74f
......@@ -36,10 +36,6 @@ export { shouldRunTurboDevTest }
export const nextServer = server
export const pkg = _pkg
// TODO(jiwon): Remove this once we have a new dev overlay at stable.
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
export function initNextServerScript(
scriptPath: string,
successRegexp: RegExp,
......@@ -939,13 +935,7 @@ export async function getToastErrorCount(
*/
export async function openRedbox(browser: BrowserInterface): Promise<void> {
try {
//TODO(jiwon): data-nextjs-toast won't open red box in new UI.
if (isNewDevOverlay) {
await browser.waitForElementByCss('[data-error-expanded="true"]')
await browser.waitForElementByCss('[data-issues-open]').click()
} else {
await browser.waitForElementByCss('[data-nextjs-toast]').click()
}
await browser.waitForElementByCss('[data-issues]').click()
} catch (cause) {
const error = new Error('No Redbox to open.', { cause })
Error.captureStackTrace(error, openRedbox)
......@@ -1007,28 +997,21 @@ export function getRedboxHeader(browser: BrowserInterface) {
})
}
export function getRedboxNavText(browser: BrowserInterface): Promise<string> {
return browser.eval(() => {
export async function getRedboxTotalErrorCount(
browser: BrowserInterface
): Promise<number> {
const text = await browser.eval(() => {
const portal = [].slice
.call(document.querySelectorAll('nextjs-portal'))
.find((p) =>
p.shadowRoot.querySelector('[data-nextjs-error-overlay-nav]')
p.shadowRoot.querySelector('[data-nextjs-dialog-header-total-count]')
)
const root = portal.shadowRoot
return root.querySelector('[data-nextjs-error-overlay-nav]')?.innerText
})
}
export async function getRedboxTotalErrorCount(browser: BrowserInterface) {
// TODO(jiwon): Remove this once we have a new dev overlay at stable.
if (isNewDevOverlay) {
// N/M\nNext.js X.Y.Z -> M
const text = (await getRedboxNavText(browser)) || ''
return parseInt(text.match(/\/(\d+)/)?.[1])
}
const header = (await getRedboxHeader(browser)) || ''
return parseInt(header.match(/\d+ of (\d+) issue/)?.[1], 10)
const root = portal?.shadowRoot
return root?.querySelector('[data-nextjs-dialog-header-total-count]')
?.innerText
})
return parseInt(text || '-1')
}
export async function getRedboxSource(browser: BrowserInterface) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment