Skip to content

Commit 3e54268

Browse files
alswlcursoragent
andcommitted
fix(e2e): replace networkidle with load + element wait, wait for diagram text before assert
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 86be429 commit 3e54268

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

tests/e2e/editor.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { expect, test } from '@playwright/test';
33
test.describe('DBML Editor - Basic Features', () => {
44
test.beforeEach(async ({ page }) => {
55
await page.goto('/');
6-
await page.waitForLoadState('networkidle');
6+
await page.waitForLoadState('load');
7+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
78
});
89

910
test('should load homepage', async ({ page }) => {
@@ -42,7 +43,8 @@ test.describe('DBML Editor - Basic Features', () => {
4243
test.describe('DBML Editor - Editing Features', () => {
4344
test.beforeEach(async ({ page }) => {
4445
await page.goto('/');
45-
await page.waitForLoadState('networkidle');
46+
await page.waitForLoadState('load');
47+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
4648
});
4749

4850
test('should edit DBML code', async ({ page }) => {
@@ -97,7 +99,8 @@ Table orders {
9799
test.describe('DBML Editor - Import Features', () => {
98100
test.beforeEach(async ({ page }) => {
99101
await page.goto('/');
100-
await page.waitForLoadState('networkidle');
102+
await page.waitForLoadState('load');
103+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
101104
});
102105

103106
test('should open import dialog', async ({ page }) => {
@@ -154,7 +157,8 @@ test.describe('DBML Editor - Import Features', () => {
154157
test.describe('DBML Editor - Export Features', () => {
155158
test.beforeEach(async ({ page }) => {
156159
await page.goto('/');
157-
await page.waitForLoadState('networkidle');
160+
await page.waitForLoadState('load');
161+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
158162
});
159163

160164
test('should open export dialog', async ({ page }) => {
@@ -208,7 +212,8 @@ test.describe('DBML Editor - Export Features', () => {
208212
test.describe('DBML Editor - Error Handling', () => {
209213
test.beforeEach(async ({ page }) => {
210214
await page.goto('/');
211-
await page.waitForLoadState('networkidle');
215+
await page.waitForLoadState('load');
216+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
212217
});
213218

214219
test('should display syntax error message', async ({ page }) => {

tests/e2e/er-diagram.spec.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { expect, test } from '@playwright/test';
33
test.describe('ER Diagram - Interaction', () => {
44
test.beforeEach(async ({ page }) => {
55
await page.goto('/');
6-
await page.waitForLoadState('networkidle');
6+
await page.waitForLoadState('load');
7+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
78
await page.waitForSelector('svg', { timeout: 10000 });
89
});
910

@@ -21,6 +22,12 @@ test.describe('ER Diagram - Interaction', () => {
2122
});
2223

2324
test('should display table names', async ({ page }) => {
25+
// 等待 ER 图节点和文字渲染完成(layout 与 X6 渲染为异步)
26+
await expect(page.locator('svg g[data-cell-id]').first()).toBeVisible({
27+
timeout: 15000,
28+
});
29+
await expect(page.locator('svg text').first()).toBeVisible({ timeout: 15000 });
30+
2431
const tableNames = page.locator('svg text');
2532
const textCount = await tableNames.count();
2633
expect(textCount).toBeGreaterThan(0);
@@ -106,7 +113,8 @@ Ref: posts.user_id > users.id
106113
test.describe('ER Diagram - Layout', () => {
107114
test.beforeEach(async ({ page }) => {
108115
await page.goto('/');
109-
await page.waitForLoadState('networkidle');
116+
await page.waitForLoadState('load');
117+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
110118
await page.waitForSelector('svg', { timeout: 10000 });
111119
});
112120

@@ -178,7 +186,8 @@ Table products {
178186
test.describe('ER Diagram - Visual', () => {
179187
test.beforeEach(async ({ page }) => {
180188
await page.goto('/');
181-
await page.waitForLoadState('networkidle');
189+
await page.waitForLoadState('load');
190+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
182191
await page.waitForSelector('svg', { timeout: 10000 });
183192
await page.waitForTimeout(1000);
184193
});
@@ -194,6 +203,7 @@ test.describe('ER Diagram - Visual', () => {
194203
const rectCount = await rects.count();
195204
expect(rectCount).toBeGreaterThan(0);
196205

206+
await expect(page.locator('svg text').first()).toBeVisible({ timeout: 15000 });
197207
const texts = page.locator('svg text');
198208
const textCount = await texts.count();
199209
expect(textCount).toBeGreaterThan(0);

tests/e2e/export.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { expect, test } from '@playwright/test';
33
test.describe('Export - SQL Export Functionality', () => {
44
test.beforeEach(async ({ page }) => {
55
await page.goto('/');
6-
await page.waitForLoadState('networkidle');
6+
await page.waitForLoadState('load');
7+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
78
});
89

910
test('should open export modal', async ({ page }) => {

tests/e2e/toolbar.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { expect, test } from '@playwright/test';
33
test.describe('Toolbar - Zoom Controls', () => {
44
test.beforeEach(async ({ page }) => {
55
await page.goto('/');
6-
await page.waitForLoadState('networkidle');
6+
await page.waitForLoadState('load');
7+
await expect(page.locator('.react-shape-app')).toBeVisible({ timeout: 15000 });
78
await page.waitForSelector('.zoom-toolbar', { timeout: 10000 });
89
await page.waitForTimeout(2000); // Wait for initial render
910
});

0 commit comments

Comments
 (0)