|
1 |
| -import type { Page } from '@playwright/test'; |
| 1 | +import { test, expect, type Page } from '@playwright/test'; |
2 | 2 | import { Constants } from '../../cypress-e2e/fixtures/constants';
|
3 |
| -import { test, expect } from '../../playwright-e2e/common/testFixtures'; |
4 | 3 |
|
5 | 4 | interface AppConfig {
|
6 | 5 | name: string;
|
@@ -107,6 +106,12 @@ const buildPathRegex = (port: number, path: string): RegExp => {
|
107 | 106 | return new RegExp(`^http://localhost:${port}${escapedPath}(?:\\/)?$`);
|
108 | 107 | };
|
109 | 108 |
|
| 109 | +async function openLocalhost(page: Page, { port, path }: { port: number; path?: string }): Promise<void> { |
| 110 | + const normalizedPath = path ? (path.startsWith('/') ? path : `/${path}`) : ''; |
| 111 | + const url = `http://localhost:${port}${normalizedPath}`; |
| 112 | + await page.goto(url, { waitUntil: 'networkidle' }); |
| 113 | +} |
| 114 | + |
110 | 115 | const expectSharedNavigation = async (page: Page): Promise<void> => {
|
111 | 116 | const nav = page.locator('nav');
|
112 | 117 | await expect(nav).toBeVisible();
|
@@ -189,49 +194,49 @@ const expectNavigationFlow = async (page: Page, port: number): Promise<void> =>
|
189 | 194 | test.describe('NextJS SSR', () => {
|
190 | 195 | for (const { name, port } of appsUnderTest) {
|
191 | 196 | test.describe(`${name} host`, () => {
|
192 |
| - test(`Home page renders shared navigation in ${name}`, async ({ basePage, page }) => { |
193 |
| - await basePage.openLocalhost({ port }); |
| 197 | + test(`Home page renders shared navigation in ${name}`, async ({ page }) => { |
| 198 | + await openLocalhost(page, { port }); |
194 | 199 | await expectSharedNavigation(page);
|
195 | 200 | });
|
196 | 201 |
|
197 |
| - test(`Home page renders federated content in ${name}`, async ({ basePage, page }) => { |
198 |
| - await basePage.openLocalhost({ port }); |
| 202 | + test(`Home page renders federated content in ${name}`, async ({ page }) => { |
| 203 | + await openLocalhost(page, { port }); |
199 | 204 | await expectHomePageContent(page);
|
200 | 205 | await expectHomeTiles(page);
|
201 | 206 | });
|
202 | 207 |
|
203 |
| - test(`Home page navigation works in ${name}`, async ({ basePage, page }) => { |
204 |
| - await basePage.openLocalhost({ port }); |
| 208 | + test(`Home page navigation works in ${name}`, async ({ page }) => { |
| 209 | + await openLocalhost(page, { port }); |
205 | 210 | await expectNavigationFlow(page, port);
|
206 | 211 | });
|
207 | 212 |
|
208 |
| - test(`Shop page renders shared navigation in ${name}`, async ({ basePage, page }) => { |
209 |
| - await basePage.openLocalhost({ port, path: Constants.hrefs.nextJsSsrApp.shop }); |
| 213 | + test(`Shop page renders shared navigation in ${name}`, async ({ page }) => { |
| 214 | + await openLocalhost(page, { port, path: Constants.hrefs.nextJsSsrApp.shop }); |
210 | 215 | await expectSharedNavigation(page);
|
211 | 216 | });
|
212 | 217 |
|
213 |
| - test(`Shop page renders federated content in ${name}`, async ({ basePage, page }) => { |
214 |
| - await basePage.openLocalhost({ port, path: Constants.hrefs.nextJsSsrApp.shop }); |
| 218 | + test(`Shop page renders federated content in ${name}`, async ({ page }) => { |
| 219 | + await openLocalhost(page, { port, path: Constants.hrefs.nextJsSsrApp.shop }); |
215 | 220 | await expectShopContent(page);
|
216 | 221 | });
|
217 | 222 |
|
218 |
| - test(`Shop page navigation works in ${name}`, async ({ basePage, page }) => { |
219 |
| - await basePage.openLocalhost({ port, path: Constants.hrefs.nextJsSsrApp.shop }); |
| 223 | + test(`Shop page navigation works in ${name}`, async ({ page }) => { |
| 224 | + await openLocalhost(page, { port, path: Constants.hrefs.nextJsSsrApp.shop }); |
220 | 225 | await expectNavigationFlow(page, port);
|
221 | 226 | });
|
222 | 227 |
|
223 |
| - test(`Checkout page renders shared navigation in ${name}`, async ({ basePage, page }) => { |
224 |
| - await basePage.openLocalhost({ port, path: Constants.hrefs.nextJsSsrApp.checkout }); |
| 228 | + test(`Checkout page renders shared navigation in ${name}`, async ({ page }) => { |
| 229 | + await openLocalhost(page, { port, path: Constants.hrefs.nextJsSsrApp.checkout }); |
225 | 230 | await expectSharedNavigation(page);
|
226 | 231 | });
|
227 | 232 |
|
228 |
| - test(`Checkout page renders federated content in ${name}`, async ({ basePage, page }) => { |
229 |
| - await basePage.openLocalhost({ port, path: Constants.hrefs.nextJsSsrApp.checkout }); |
| 233 | + test(`Checkout page renders federated content in ${name}`, async ({ page }) => { |
| 234 | + await openLocalhost(page, { port, path: Constants.hrefs.nextJsSsrApp.checkout }); |
230 | 235 | await expectCheckoutContent(page);
|
231 | 236 | });
|
232 | 237 |
|
233 |
| - test(`Checkout page navigation works in ${name}`, async ({ basePage, page }) => { |
234 |
| - await basePage.openLocalhost({ port, path: Constants.hrefs.nextJsSsrApp.checkout }); |
| 238 | + test(`Checkout page navigation works in ${name}`, async ({ page }) => { |
| 239 | + await openLocalhost(page, { port, path: Constants.hrefs.nextJsSsrApp.checkout }); |
235 | 240 | await expectNavigationFlow(page, port);
|
236 | 241 | });
|
237 | 242 | });
|
|
0 commit comments