Skip to content

Commit 98fda1a

Browse files
fix(desktop): 修复 CI 测试基线
1 parent b925ca3 commit 98fda1a

13 files changed

Lines changed: 67 additions & 19 deletions

app/desktop/src/__tests__/DiffReviewPanel.test.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ function makeFile(overrides: Partial<DiffReviewFile> = {}): DiffReviewFile {
3333
};
3434
}
3535

36+
function getLineContents(text: string): HTMLElement[] {
37+
return screen.getAllByText((_, node) => (
38+
node instanceof HTMLElement &&
39+
node.className.includes('lineContent') &&
40+
node.textContent === text
41+
));
42+
}
43+
3644
describe('DiffReviewPanel', () => {
3745
// ── Test 1: Renders empty state when no files ──────────────────────────
3846
it('renders empty state when there are no files', () => {
@@ -61,15 +69,15 @@ describe('DiffReviewPanel', () => {
6169
render(<DiffReviewPanel files={files} />);
6270

6371
// Context lines appear in both left and right columns
64-
const contextLines = screen.getAllByText('import React from "react";');
72+
const contextLines = getLineContents('import React from "react";');
6573
expect(contextLines.length).toBe(2); // one in each column
66-
expect(screen.getAllByText('export default App;').length).toBe(2);
74+
expect(getLineContents('export default App;').length).toBe(2);
6775

6876
// Deleted line (old) should be visible in left column
69-
expect(screen.getByText('const x = 1;')).toBeInTheDocument();
77+
expect(getLineContents('const x = 1;')[0]).toBeInTheDocument();
7078

7179
// Added line (new) should be visible in right column
72-
expect(screen.getByText('const x = 2;')).toBeInTheDocument();
80+
expect(getLineContents('const x = 2;')[0]).toBeInTheDocument();
7381
});
7482

7583
// ── Test 4: Renders the Accept All and Reject All toolbar buttons ───────
@@ -160,7 +168,7 @@ describe('DiffReviewPanel', () => {
160168
expect(firstTab).toHaveAttribute('aria-selected', 'false');
161169

162170
// The second file's content should be visible
163-
expect(screen.getByText('new file content')).toBeInTheDocument();
171+
expect(getLineContents('new file content')[0]).toBeInTheDocument();
164172
});
165173

166174
// ── Test 10: Accepting a line dims it and highlights the accept button ──

app/desktop/src/__tests__/hubClient.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
22
import { createHubClient, HubError } from '../api/hubClient';
33
import type { AuthResponse, UserProfile } from '../api/hubClient';
44
import { createHubAuth } from '../api/hubAuth';
5+
import { HUB_URL } from '../config';
56
import {
67
clearStoredHubAccessToken,
78
clearStoredHubRefreshToken,
@@ -516,13 +517,13 @@ describe('hubClient', () => {
516517
expect(fetchSpy.mock.calls[0]?.[0]).toBe('http://test.local/client/auth/me');
517518
});
518519

519-
it('uses the Desktop HUB_URL default when baseUrl is omitted', async () => {
520+
it('uses the Desktop HUB_URL config value when baseUrl is omitted', async () => {
520521
const client = createHubClient();
521522
const fetchSpy = mockFetch(200, mockUser);
522523

523524
await client.me();
524525

525-
expect(fetchSpy.mock.calls[0]?.[0]).toBe('https://api.hub.vectorcontrol.tech/client/auth/me');
526+
expect(fetchSpy.mock.calls[0]?.[0]).toBe(`${HUB_URL.replace(/\/+$/, '')}/client/auth/me`);
526527
});
527528
});
528529
});

app/desktop/src/api/eventClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ export function createEventStream(cursorOrUrl?: string, opts?: EventStreamOption
182182
try {
183183
const data = JSON.parse(event.data as string);
184184
handleMessage(data);
185-
} catch (_e) {
186-
// Parse errors are silently ignored — malformed frames are dropped
185+
} catch (error) {
186+
console.error('[EventStream] Dropping malformed WebSocket frame', error);
187187
}
188188
};
189189

app/desktop/src/api/transport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ export class WebSocketTransport implements Transport {
182182
} else {
183183
(handler as TransportMessageHandler)(data);
184184
}
185-
} catch (_e) {
186-
// Handler errors are silently ignored — one broken listener must not break others
185+
} catch (error) {
186+
console.error('[WebSocketTransport] Handler error ignored', error);
187187
}
188188
}
189189
}

app/desktop/vite.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import path from 'path';
55
export default defineConfig({
66
plugins: [react()],
77
resolve: {
8+
dedupe: ['react', 'react-dom'],
89
alias: {
910
'@': path.resolve(__dirname, 'src'),
1011
'@shared': path.resolve(__dirname, '..', 'shared', 'src'),
12+
'lucide-react': path.resolve(__dirname, 'node_modules', 'lucide-react'),
13+
'react': path.resolve(__dirname, 'node_modules', 'react'),
14+
'react-dom': path.resolve(__dirname, 'node_modules', 'react-dom'),
15+
'react-i18next': path.resolve(__dirname, 'node_modules', 'react-i18next'),
1116
},
1217
},
1318
clearScreen: false,

app/desktop/vitest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import path from 'path';
33

44
export default defineConfig({
55
resolve: {
6+
dedupe: ['react', 'react-dom'],
67
alias: {
78
'@': path.resolve(__dirname, 'src'),
89
'@shared': path.resolve(__dirname, '..', 'shared', 'src'),
10+
'lucide-react': path.resolve(__dirname, 'node_modules', 'lucide-react'),
11+
'react': path.resolve(__dirname, 'node_modules', 'react'),
12+
'react-dom': path.resolve(__dirname, 'node_modules', 'react-dom'),
13+
'react-i18next': path.resolve(__dirname, 'node_modules', 'react-i18next'),
914
},
1015
},
1116
server: { fs: { allow: ['..'] } },

app/desktop/vitest.desktop-ci.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import path from 'path';
33

44
export default defineConfig({
55
resolve: {
6+
dedupe: ['react', 'react-dom'],
67
alias: {
78
'@': path.resolve(__dirname, 'src'),
89
'@shared': path.resolve(__dirname, '..', 'shared', 'src'),
10+
'lucide-react': path.resolve(__dirname, 'node_modules', 'lucide-react'),
11+
'react': path.resolve(__dirname, 'node_modules', 'react'),
12+
'react-dom': path.resolve(__dirname, 'node_modules', 'react-dom'),
13+
'react-i18next': path.resolve(__dirname, 'node_modules', 'react-i18next'),
914
},
1015
},
1116
server: { fs: { allow: ['..'] } },

app/desktop/vitest.desktop-ts-ci.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import path from 'path';
33

44
export default defineConfig({
55
resolve: {
6+
dedupe: ['react', 'react-dom'],
67
alias: {
78
'@': path.resolve(__dirname, 'src'),
89
'@shared': path.resolve(__dirname, '..', 'shared', 'src'),
10+
'lucide-react': path.resolve(__dirname, 'node_modules', 'lucide-react'),
11+
'react': path.resolve(__dirname, 'node_modules', 'react'),
12+
'react-dom': path.resolve(__dirname, 'node_modules', 'react-dom'),
13+
'react-i18next': path.resolve(__dirname, 'node_modules', 'react-i18next'),
914
},
1015
},
1116
server: { fs: { allow: ['..'] } },

app/desktop/vitest.desktop-tsx-ci.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import path from 'path';
33

44
export default defineConfig({
55
resolve: {
6+
dedupe: ['react', 'react-dom'],
67
alias: {
78
'@': path.resolve(__dirname, 'src'),
89
'@shared': path.resolve(__dirname, '..', 'shared', 'src'),
10+
'lucide-react': path.resolve(__dirname, 'node_modules', 'lucide-react'),
11+
'react': path.resolve(__dirname, 'node_modules', 'react'),
12+
'react-dom': path.resolve(__dirname, 'node_modules', 'react-dom'),
13+
'react-i18next': path.resolve(__dirname, 'node_modules', 'react-i18next'),
914
},
1015
},
1116
server: { fs: { allow: ['..'] } },

app/desktop/vitest.edge-integration-ci.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import path from 'path';
33

44
export default defineConfig({
55
resolve: {
6+
dedupe: ['react', 'react-dom'],
67
alias: {
78
'@': path.resolve(__dirname, 'src'),
89
'@shared': path.resolve(__dirname, '..', 'shared', 'src'),
10+
'lucide-react': path.resolve(__dirname, 'node_modules', 'lucide-react'),
11+
'react': path.resolve(__dirname, 'node_modules', 'react'),
12+
'react-dom': path.resolve(__dirname, 'node_modules', 'react-dom'),
13+
'react-i18next': path.resolve(__dirname, 'node_modules', 'react-i18next'),
914
},
1015
},
1116
server: { fs: { allow: ['..'] } },

0 commit comments

Comments
 (0)