Skip to content

Commit e86fde2

Browse files
authored
test(e2e): playwright support lazyCompilation after Rsbuild 1.4.0, remove env variable (#2319)
1 parent 2de9231 commit e86fde2

File tree

30 files changed

+153
-66
lines changed

30 files changed

+153
-66
lines changed

e2e/fixtures/banner/index.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getPort, killProcess, runDevCommand } from '../../utils/runCommands';
33

44
test.describe('tabs-component test', async () => {
55
let appPort: number;
6-
let app;
6+
let app: Awaited<ReturnType<typeof runDevCommand>> | null;
77

88
test.beforeAll(async () => {
99
const appDir = __dirname;
@@ -18,7 +18,9 @@ test.describe('tabs-component test', async () => {
1818
});
1919

2020
test('Banner close hides banner and persists state', async ({ page }) => {
21-
await page.goto(`http://localhost:${appPort}`);
21+
await page.goto(`http://localhost:${appPort}`, {
22+
waitUntil: 'networkidle',
23+
});
2224
await page.waitForSelector('.rp-banner');
2325

2426
const closeButton = page.locator('.rp-banner__close');

e2e/fixtures/basic/index.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ test.describe('basic test', async () => {
1717
});
1818

1919
test('Index page', async ({ page }) => {
20-
await page.goto(`http://localhost:${appPort}`);
20+
await page.goto(`http://localhost:${appPort}`, {
21+
waitUntil: 'networkidle',
22+
});
2123
await expect(page.locator('h1')).toContainText('Hello world');
2224
const headerAnchor = page.locator('.rp-header-anchor').first();
2325
await expect(headerAnchor).toHaveAttribute('href', '#hello-world');
@@ -47,7 +49,9 @@ test.describe('basic test', async () => {
4749
});
4850

4951
test('Hover over social links', async ({ page }) => {
50-
await page.goto(`http://localhost:${appPort}`);
52+
await page.goto(`http://localhost:${appPort}`, {
53+
waitUntil: 'networkidle',
54+
});
5155
const socialLinks = page.locator('.rp-social-links').first();
5256
await socialLinks.hover();
5357
await expect(
@@ -56,7 +60,9 @@ test.describe('basic test', async () => {
5660
});
5761

5862
test('globalStyles should work', async ({ page }) => {
59-
await page.goto(`http://localhost:${appPort}`);
63+
await page.goto(`http://localhost:${appPort}`, {
64+
waitUntil: 'networkidle',
65+
});
6066
const link = page.locator('.rp-doc a').first();
6167
await expect(link).toHaveCSS('color', 'rgb(255, 165, 0)');
6268
});

e2e/fixtures/custom-home-footer/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ test.describe('home footer test', async () => {
1717
});
1818

1919
test('custom home footer', async ({ page }) => {
20-
await page.goto(`http://localhost:${appPort}`);
20+
await page.goto(`http://localhost:${appPort}`, {
21+
waitUntil: 'networkidle',
22+
});
2123
const footer = page.locator('footer');
2224
await expect(footer).toBeVisible();
2325
await expect(footer.locator('a')).toBeVisible();

e2e/fixtures/github-alert-mdxjs/index.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { expect, test } from '@playwright/test';
22
import { getPort, killProcess, runDevCommand } from '../../utils/runCommands';
33

44
test.describe('github alert syntax in mdx-js', async () => {
5-
let appPort;
6-
let app;
5+
let appPort: number;
6+
let app: Awaited<ReturnType<typeof runDevCommand>> | null;
77
test.beforeAll(async () => {
88
const appDir = __dirname;
99
appPort = await getPort();
@@ -19,7 +19,9 @@ test.describe('github alert syntax in mdx-js', async () => {
1919
test('should transform github alert syntax to contain syntax', async ({
2020
page,
2121
}) => {
22-
await page.goto(`http://localhost:${appPort}`);
22+
await page.goto(`http://localhost:${appPort}`, {
23+
waitUntil: 'networkidle',
24+
});
2325

2426
const topLevelCallouts = page.locator('.rspress-doc > .rp-callout');
2527
await expect(topLevelCallouts).toHaveCount(7);

e2e/fixtures/hmr/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ test.describe('hmr test', async () => {
4141
});
4242

4343
test('Test page', async ({ page }) => {
44-
await page.goto(`http://localhost:${appPort}/guide/test.html`);
44+
await page.goto(`http://localhost:${appPort}/guide/test.html`, {
45+
waitUntil: 'networkidle',
46+
});
4547

4648
// basic
4749
const helloParagraph = page.locator('p', { hasText: 'Hello world' });

e2e/fixtures/i18n/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ test.describe('i18n test', async () => {
208208
hasText: 'English',
209209
});
210210
await englishOption.click();
211+
await page.waitForURL(/\/en\//);
211212

212213
const newLanguageSwitcher = page
213214
.locator('.rp-nav-menu__item')

e2e/fixtures/issue-1309/index.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ test.describe('issue-1309', async () => {
1818
});
1919

2020
test('should not generate the sidebar in homePage', async ({ page }) => {
21-
await page.goto(`http://localhost:${appPort}`);
21+
await page.goto(`http://localhost:${appPort}`, {
22+
waitUntil: 'networkidle',
23+
});
2224
const navItems = getNavbarItems(page);
2325
await expect(navItems).toHaveCount(1);
2426

@@ -29,7 +31,9 @@ test.describe('issue-1309', async () => {
2931
test('should render the sidebar correctly in guide page', async ({
3032
page,
3133
}) => {
32-
await page.goto(`http://localhost:${appPort}/guide`);
34+
await page.goto(`http://localhost:${appPort}/guide`, {
35+
waitUntil: 'networkidle',
36+
});
3337
const navItems = getNavbarItems(page);
3438
await expect(navItems).toHaveCount(1);
3539

e2e/fixtures/markdown-link-asset/index.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
} from '../../utils/runCommands';
88

99
test.describe('basic test', async () => {
10-
let appPort;
11-
let app;
10+
let appPort: number;
11+
let app: Awaited<ReturnType<typeof runPreviewCommand>> | null;
1212
test.afterAll(async () => {
1313
if (app) {
1414
await killProcess(app);
@@ -21,12 +21,15 @@ test.describe('basic test', async () => {
2121
cleanUrls: boolean,
2222
) {
2323
if (isI18n) {
24-
await page.goto(`http://localhost:${appPort}/base/zh/public-asset-test`);
24+
await page.goto(`http://localhost:${appPort}/base/zh/public-asset-test`, {
25+
waitUntil: 'networkidle',
26+
});
2527
} else {
26-
await page.goto(`http://localhost:${appPort}/base/public-asset-test`);
28+
await page.goto(`http://localhost:${appPort}/base/public-asset-test`, {
29+
waitUntil: 'networkidle',
30+
});
2731
}
2832

29-
await page.waitForLoadState('networkidle');
3033
const links = await page.locator('.rspress-doc p>a').all();
3134
expect(links.length).toBe(6);
3235

e2e/fixtures/markdown-link/index.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { expect, test } from '@playwright/test';
22
import { getPort, killProcess, runDevCommand } from '../../utils/runCommands';
33

44
test.describe('basic test', async () => {
5-
let appPort;
6-
let app;
5+
let appPort: number;
6+
let app: Awaited<ReturnType<typeof runDevCommand>> | null;
77
test.beforeAll(async () => {
88
const appDir = __dirname;
99
appPort = await getPort();
@@ -17,7 +17,9 @@ test.describe('basic test', async () => {
1717
});
1818

1919
test('all links should be normalized', async ({ page }) => {
20-
await page.goto(`http://localhost:${appPort}/base/guide`);
20+
await page.goto(`http://localhost:${appPort}/base/guide`, {
21+
waitUntil: 'networkidle',
22+
});
2123
const links = page.locator('.rspress-doc ul li a');
2224
const count = await links.count();
2325
const urls = await Promise.all(

e2e/fixtures/multi-version/index.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,33 @@ test.describe('Multi version test', async () => {
1717
});
1818

1919
test('Default version and default language', async ({ page }) => {
20-
await page.goto(`http://localhost:${appPort}`);
20+
await page.goto(`http://localhost:${appPort}`, {
21+
waitUntil: 'networkidle',
22+
});
2123
const h1 = page.locator('h1');
2224
await expect(h1).toContainText('v1');
2325
});
2426

2527
test('Not Default version default language', async ({ page }) => {
26-
await page.goto(`http://localhost:${appPort}/v2`);
28+
await page.goto(`http://localhost:${appPort}/v2`, {
29+
waitUntil: 'networkidle',
30+
});
2731
const h1 = page.locator('h1');
2832
await expect(h1).toContainText('v2');
2933
});
3034

3135
test('Default version not default language', async ({ page }) => {
32-
await page.goto(`http://localhost:${appPort}/zh`);
36+
await page.goto(`http://localhost:${appPort}/zh`, {
37+
waitUntil: 'networkidle',
38+
});
3339
const h1 = page.locator('h1');
3440
await expect(h1).toContainText('v1 中文');
3541
});
3642

3743
test('Not default version not default language', async ({ page }) => {
38-
await page.goto(`http://localhost:${appPort}/v2/zh`);
44+
await page.goto(`http://localhost:${appPort}/v2/zh`, {
45+
waitUntil: 'networkidle',
46+
});
3947
const h1 = page.locator('h1');
4048
await expect(h1).toContainText('v2 中文');
4149
});

0 commit comments

Comments
 (0)