mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? Migrate remaining direct `next-webdriver` test callers that have a `NextInstance` to `next.browser()`, and expose the shared `Playwright` browser type from `e2e-utils`. ### Why? `NextInstance.browser` should be the supported browser-opening interface for test fixtures, with `next-webdriver` kept as the private implementation detail. ### How? Updated affected development, e2e, and production tests to call `next.browser()` directly, passing `baseUrl` where tests intentionally target a manually spawned or proxied server. Shared helpers now receive browser callbacks from the test context, and browser types import `Playwright` from `e2e-utils` instead of deriving from `next.browser` or importing from private paths. <!-- NEXT_JS_LLM_PR -->
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { nextTestSetup, type Playwright } from 'e2e-utils'
|
|
|
|
describe('parallel-routes-catchall-css', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
async function getChildrenBackgroundColor(browser: Playwright) {
|
|
return browser.eval(
|
|
`window.getComputedStyle(document.getElementById('main')).backgroundColor`
|
|
)
|
|
}
|
|
|
|
async function getSlotBackgroundColor(browser: Playwright) {
|
|
return browser.eval(
|
|
`window.getComputedStyle(document.getElementById('slot')).backgroundColor`
|
|
)
|
|
}
|
|
|
|
it('should properly load the Head content from multiple leaf segments', async () => {
|
|
const browser = await next.browser('/')
|
|
|
|
// the page background should be blue
|
|
expect(await getChildrenBackgroundColor(browser)).toBe('rgb(0, 0, 255)')
|
|
|
|
expect(await browser.elementByCss('title').text()).toBe('Home Page')
|
|
expect(await browser.elementsByCss('title')).toHaveLength(1)
|
|
|
|
// navigate to the page that matches a parallel route
|
|
await browser.elementByCss("[href='/nested']").click()
|
|
await browser.waitForElementByCss('#slot')
|
|
|
|
// the slot's background color should be red
|
|
expect(await getSlotBackgroundColor(browser)).toBe('rgb(255, 0, 0)')
|
|
|
|
// the main element should either not exist or not be visible
|
|
const mainDisplay = await browser.eval(
|
|
`document.querySelector('#main') ? window.getComputedStyle(document.querySelector('#main')).display : null`
|
|
)
|
|
expect(mainDisplay === null || mainDisplay === 'none').toBe(true)
|
|
|
|
// the slot background should still be red on a fresh load
|
|
await browser.refresh()
|
|
expect(await getSlotBackgroundColor(browser)).toBe('rgb(255, 0, 0)')
|
|
|
|
// when we navigate from the route that matched the catch-all, we should see the CSS for the main element
|
|
await browser.elementByCss("[href='/']").click()
|
|
await browser.waitForElementByCss('#main')
|
|
|
|
expect(await getChildrenBackgroundColor(browser)).toBe('rgb(0, 0, 255)')
|
|
})
|
|
})
|