Unverified Commit 7131d706 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Fix flakey devtools test (#81127)

A regression from #81085 @huozhi 


The problem is that `openDevToolsIndicatorPopover` doesn't tell anymore whether the popup menu is open, but if the panel is open, but the "Try Turbopack" text is in the popup menu (only in the old UI).
parent 9c3b6f76
...@@ -2,12 +2,12 @@ import { FileRef } from 'e2e-utils' ...@@ -2,12 +2,12 @@ import { FileRef } from 'e2e-utils'
import { Playwright } from 'next-webdriver' import { Playwright } from 'next-webdriver'
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { join } from 'path' import { join } from 'path'
import { openDevToolsIndicatorPopover, retry } from 'next-test-utils' import { assertHasDevToolsIndicator, retry } from 'next-test-utils'
describe('client-dev-overlay', () => { describe('client-dev-overlay', () => {
const { next, isTurbopack } = nextTestSetup({ const { next, isTurbopack } = nextTestSetup({
files: { files: {
pages: new FileRef(join(__dirname, 'app/pages')), pages: new FileRef(join(__dirname, 'pages')),
}, },
env: { env: {
// Disable the cooldown period for the dev indicator so that hiding the indicator in a test doesn't // Disable the cooldown period for the dev indicator so that hiding the indicator in a test doesn't
...@@ -124,7 +124,14 @@ describe('client-dev-overlay', () => { ...@@ -124,7 +124,14 @@ describe('client-dev-overlay', () => {
it('should nudge to use Turbopack unless Turbopack is disabled', async () => { it('should nudge to use Turbopack unless Turbopack is disabled', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
await openDevToolsIndicatorPopover(browser) // Don't use openDevToolsIndicatorPopover because this is asserting something in the old dev tools menu which isn't preset yet in the new UI.
const devToolsIndicator = await assertHasDevToolsIndicator(browser)
try {
await devToolsIndicator.click()
} catch (cause) {
const error = new Error('No DevTools Indicator to open.', { cause })
throw error
}
const devtoolsMenu = await browser.elementByCss('#nextjs-dev-tools-menu') const devtoolsMenu = await browser.elementByCss('#nextjs-dev-tools-menu')
if (isTurbopack) { if (isTurbopack) {
......
...@@ -969,12 +969,10 @@ export async function openDevToolsIndicatorPopover( ...@@ -969,12 +969,10 @@ export async function openDevToolsIndicatorPopover(
export async function hasDevToolsPanel(browser: Playwright) { export async function hasDevToolsPanel(browser: Playwright) {
const result = await browser.eval(() => { const result = await browser.eval(() => {
const portal = [].slice const portal = document.querySelector('nextjs-portal')
.call(document.querySelectorAll('nextjs-portal')) return (
.find((p) => p.shadowRoot.querySelector('[data-nextjs-dialog-overlay]')) portal?.shadowRoot?.querySelector('[data-nextjs-dialog-overlay]') != null
)
const root = portal?.shadowRoot
return root?.querySelector('[data-nextjs-dialog-overlay]') != null
}) })
return result return result
} }
......
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