Skip to content

Commit fb76211

Browse files
alswlcursoragent
andcommitted
fix(e2e): 工具栏测试使用 .ant-btn 排除仅表名 Switch,修复 CI 失败
- 将 .zoom-toolbar button 改为 .zoom-toolbar .ant-btn,避免点到 Switch 的 button - 修复 should zoom in / zoom out / reset view 三个用例 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 483c90c commit fb76211

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

tests/e2e/toolbar.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ test.describe('Toolbar - Zoom Controls', () => {
2222
const initialZoom = await zoomLevel.textContent();
2323
const initialValue = parseInt(initialZoom || '100', 10);
2424

25-
// Click zoom in button (first button with PlusOutlined)
26-
const zoomInButton = page.locator('.zoom-toolbar button').first();
25+
// Use .ant-btn to exclude Switch: order is Zoom in, Zoom out, Fit, Reset
26+
const zoomInButton = page.locator('.zoom-toolbar .ant-btn').first();
2727
await zoomInButton.click();
2828
await page.waitForTimeout(500);
2929

@@ -36,16 +36,16 @@ test.describe('Toolbar - Zoom Controls', () => {
3636
test('should zoom out', async ({ page }) => {
3737
const zoomLevel = page.locator('.zoom-level');
3838

39-
// First zoom in to ensure we can zoom out
40-
const zoomInButton = page.locator('.zoom-toolbar button').first();
39+
// First zoom in to ensure we can zoom out (.ant-btn excludes Switch)
40+
const zoomInButton = page.locator('.zoom-toolbar .ant-btn').first();
4141
await zoomInButton.click();
4242
await page.waitForTimeout(500);
4343

4444
const afterZoomIn = await zoomLevel.textContent();
4545
const afterZoomInValue = parseInt(afterZoomIn || '100', 10);
4646

47-
// Click zoom out button (second button with MinusOutlined)
48-
const zoomOutButton = page.locator('.zoom-toolbar button').nth(1);
47+
// Click zoom out button (second .ant-btn)
48+
const zoomOutButton = page.locator('.zoom-toolbar .ant-btn').nth(1);
4949
await zoomOutButton.click();
5050
await page.waitForTimeout(500);
5151

@@ -58,8 +58,8 @@ test.describe('Toolbar - Zoom Controls', () => {
5858
test('should fit to screen', async ({ page }) => {
5959
const zoomLevel = page.locator('.zoom-level');
6060

61-
// First zoom in multiple times
62-
const zoomInButton = page.locator('.zoom-toolbar button').first();
61+
// First zoom in multiple times (.ant-btn = Zoom in, Zoom out, Fit, Reset)
62+
const zoomInButton = page.locator('.zoom-toolbar .ant-btn').first();
6363
for (let i = 0; i < 3; i++) {
6464
await zoomInButton.click();
6565
await page.waitForTimeout(300);
@@ -69,8 +69,8 @@ test.describe('Toolbar - Zoom Controls', () => {
6969
const beforeFitValue = parseInt(beforeFit || '100', 10);
7070
expect(beforeFitValue).toBeGreaterThan(100);
7171

72-
// Click fit to screen button (third button with CompressOutlined)
73-
const fitButton = page.locator('.zoom-toolbar button').nth(2);
72+
// Click fit to screen button (third .ant-btn)
73+
const fitButton = page.locator('.zoom-toolbar .ant-btn').nth(2);
7474
await fitButton.click();
7575
await page.waitForTimeout(500);
7676

@@ -84,8 +84,8 @@ test.describe('Toolbar - Zoom Controls', () => {
8484
test('should reset view', async ({ page }) => {
8585
const zoomLevel = page.locator('.zoom-level');
8686

87-
// First zoom in multiple times
88-
const zoomInButton = page.locator('.zoom-toolbar button').first();
87+
// First zoom in multiple times (.ant-btn = Zoom in, Zoom out, Fit, Reset)
88+
const zoomInButton = page.locator('.zoom-toolbar .ant-btn').first();
8989
for (let i = 0; i < 3; i++) {
9090
await zoomInButton.click();
9191
await page.waitForTimeout(300);
@@ -95,8 +95,8 @@ test.describe('Toolbar - Zoom Controls', () => {
9595
const beforeResetValue = parseInt(beforeReset || '100', 10);
9696
expect(beforeResetValue).toBeGreaterThan(100);
9797

98-
// Click reset button (fourth button with RedoOutlined)
99-
const resetButton = page.locator('.zoom-toolbar button').nth(3);
98+
// Click reset button (fourth .ant-btn)
99+
const resetButton = page.locator('.zoom-toolbar .ant-btn').nth(3);
100100
await resetButton.click();
101101
await page.waitForTimeout(500);
102102

@@ -116,7 +116,7 @@ test.describe('Toolbar - Zoom Controls', () => {
116116
});
117117

118118
test('should have tooltip on zoom in button', async ({ page }) => {
119-
const zoomInButton = page.locator('.zoom-toolbar button').first();
119+
const zoomInButton = page.locator('.zoom-toolbar .ant-btn').first();
120120

121121
// Hover to show tooltip
122122
await zoomInButton.hover();

0 commit comments

Comments
 (0)