Skip to content

Commit 66d0a6f

Browse files
test(e2e): fix remaining failures
- nextjs-ssr: use local @playwright/test (drop shared fixtures), add helper openLocalhost - federated-css-react-ssr: switch to Playwright selectors/constants; wait for federated button
1 parent 3127716 commit 66d0a6f

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

federated-css-react-ssr/e2e/common-checks.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect, test } from '@playwright/test';
22
import type { Page } from '@playwright/test';
3-
import { selectors } from '../../cypress-e2e/common/selectors';
3+
import { selectors } from '../../playwright-e2e/common/selectors';
44
import { CssAttr } from '../../cypress-e2e/types/cssAttr';
5-
import { Constants } from '../../cypress-e2e/fixtures/constants';
5+
import { Constants } from '../../playwright-e2e/fixtures/constants';
66

77
const {
88
css,
@@ -66,6 +66,7 @@ const buildUrl = (port: number, path?: string): string => {
6666
};
6767

6868
const expectButtonsInOrder = async (page: Page, buttons: ButtonConfig[]) => {
69+
await page.waitForSelector(selectors.federatedCssButton, { timeout: 30_000 });
6970
const buttonLocator = page.locator(selectors.federatedCssButton);
7071
await expect(buttonLocator).toHaveCount(buttons.length);
7172

@@ -76,6 +77,7 @@ const expectButtonsInOrder = async (page: Page, buttons: ButtonConfig[]) => {
7677
};
7778

7879
const expectAllButtonsMatch = async (page: Page, expected: ButtonConfig) => {
80+
await page.waitForSelector(selectors.federatedCssButton, { timeout: 30_000 });
7981
const buttonLocator = page.locator(selectors.federatedCssButton);
8082
await expect(buttonLocator).not.toHaveCount(0);
8183

nextjs-ssr/e2e/checkNextjsSsr.spec.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { Page } from '@playwright/test';
1+
import { test, expect, type Page } from '@playwright/test';
22
import { Constants } from '../../cypress-e2e/fixtures/constants';
3-
import { test, expect } from '../../playwright-e2e/common/testFixtures';
43

54
interface AppConfig {
65
name: string;
@@ -107,6 +106,12 @@ const buildPathRegex = (port: number, path: string): RegExp => {
107106
return new RegExp(`^http://localhost:${port}${escapedPath}(?:\\/)?$`);
108107
};
109108

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+
110115
const expectSharedNavigation = async (page: Page): Promise<void> => {
111116
const nav = page.locator('nav');
112117
await expect(nav).toBeVisible();
@@ -189,49 +194,49 @@ const expectNavigationFlow = async (page: Page, port: number): Promise<void> =>
189194
test.describe('NextJS SSR', () => {
190195
for (const { name, port } of appsUnderTest) {
191196
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 });
194199
await expectSharedNavigation(page);
195200
});
196201

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 });
199204
await expectHomePageContent(page);
200205
await expectHomeTiles(page);
201206
});
202207

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 });
205210
await expectNavigationFlow(page, port);
206211
});
207212

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 });
210215
await expectSharedNavigation(page);
211216
});
212217

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 });
215220
await expectShopContent(page);
216221
});
217222

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 });
220225
await expectNavigationFlow(page, port);
221226
});
222227

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 });
225230
await expectSharedNavigation(page);
226231
});
227232

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 });
230235
await expectCheckoutContent(page);
231236
});
232237

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 });
235240
await expectNavigationFlow(page, port);
236241
});
237242
});

0 commit comments

Comments
 (0)