Skip to content

Commit 2ac4e07

Browse files
author
shenxiaojie.316
committed
chore: Publish feat/refactor
1 parent e91e396 commit 2ac4e07

4 files changed

Lines changed: 37 additions & 18 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze/api",
5+
"comment": "Publish feat/refactor",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@coze/api",
10+
"email": "shenxiaojie.316@bytedance.com"
11+
}

packages/coze-js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coze/api",
3-
"version": "1.3.0",
3+
"version": "1.3.0-beta.1",
44
"description": "Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中",
55
"keywords": [
66
"coze",
@@ -116,4 +116,4 @@
116116
"agora-rtc-sdk-ng": "$agora-rtc-sdk-ng"
117117
}
118118
}
119-
}
119+
}

packages/coze-js/test/ws-tools/chat.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ vi.mock('@ws-tools/index', () => ({
3838
setDenoiserLevel: vi.fn(),
3939
setDenoiserMode: vi.fn(),
4040
getRawMediaStream: vi.fn().mockReturnValue(new MediaStream()),
41-
audioTrack: true
41+
audioTrack: true,
4242
})),
4343
}));
4444

@@ -109,6 +109,7 @@ vi.mock('@ws-tools/utils', () => ({
109109
}),
110110
isBrowserExtension: vi.fn().mockReturnValue(false),
111111
setValueByPath: vi.fn(),
112+
isHarmonOS: vi.fn().mockReturnValue(false),
112113
}));
113114

114115
describe('WebSocket Chat Tools', () => {
@@ -192,22 +193,22 @@ describe('WebSocket Chat Tools', () => {
192193
// mock
193194
const mockWebsocket = new WebSocketAPI('wss://coze.ai/test-url');
194195
vi.spyOn(client as any, 'init').mockResolvedValue(mockWebsocket);
195-
196+
196197
// Prepare recorder mocks
197198
const getStatusSpy = vi.spyOn(client['recorder'], 'getStatus');
198199
getStatusSpy.mockReturnValue('ended');
199-
200+
200201
// The implementation now calls startRecord() in setAudioEnable when audioTrack is not available
201202
// So we need to mock startRecord as a method on the client
202203
const mockStartRecord = vi.fn().mockResolvedValue(undefined);
203204
client['startRecord'] = mockStartRecord;
204-
205+
205206
// Set audioTrack to undefined to force startRecord path
206207
Object.defineProperty(client['recorder'], 'audioTrack', {
207208
get: vi.fn(() => undefined),
208-
configurable: true
209+
configurable: true,
209210
});
210-
211+
211212
client['isMuted'] = true;
212213

213214
// act

packages/coze-js/test/ws-tools/utils.spec.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import AgoraRTC from 'agora-rtc-sdk-ng';
1919
vi.mock('agora-rtc-sdk-ng', () => ({
2020
default: {
2121
registerExtensions: vi.fn(),
22+
disableLogUpload: vi.fn(),
23+
setLogLevel: vi.fn(),
2224
},
2325
}));
2426

@@ -129,16 +131,16 @@ describe('WS Tools Utils', () => {
129131
expect(result).toBeInstanceOf(Int16Array);
130132
expect(result.length).toBe(input.length);
131133
expect(result[0]).toBe(0); // Zero remains zero
132-
134+
133135
// Instead of checking exact values with toBeCloseTo, check the values are proportionally correct
134136
// For positive values, check they're between 0 and 0x7fff (32767)
135137
expect(result[1]).toBeGreaterThan(0);
136138
expect(result[1]).toBeLessThanOrEqual(0x7fff);
137-
139+
138140
// For negative values, check they're between -0x8000 (-32768) and 0
139141
expect(result[2]).toBeLessThan(0);
140142
expect(result[2]).toBeGreaterThanOrEqual(-0x8000);
141-
143+
142144
// Check that max values map to extremes
143145
expect(result[3]).toBe(0x7fff); // 1.0 maps to max positive
144146
expect(result[4]).toBe(-0x8000); // -1.0 maps to max negative
@@ -226,10 +228,13 @@ describe('WS Tools Utils', () => {
226228
it('should use cached denoiser support value when available', () => {
227229
// Set the support value before calling the function
228230
window.__denoiserSupported = true;
229-
const checkCompatibilitySpy = vi.spyOn(mockDenoiser, 'checkCompatibility');
230-
231+
const checkCompatibilitySpy = vi.spyOn(
232+
mockDenoiser,
233+
'checkCompatibility',
234+
);
235+
231236
const result = checkDenoiserSupport();
232-
237+
233238
expect(result).toBe(true);
234239
// Should not check compatibility again
235240
expect(checkCompatibilitySpy).not.toHaveBeenCalled();
@@ -238,8 +243,10 @@ describe('WS Tools Utils', () => {
238243

239244
describe('isBrowserExtension', () => {
240245
// Save original chrome reference and ensure TypeScript is happy
241-
const originalChrome = typeof window !== 'undefined' ? (window as any).chrome : undefined;
242-
const originalGlobalChrome = typeof global !== 'undefined' ? (global as any).chrome : undefined;
246+
const originalChrome =
247+
typeof window !== 'undefined' ? (window as any).chrome : undefined;
248+
const originalGlobalChrome =
249+
typeof global !== 'undefined' ? (global as any).chrome : undefined;
243250

244251
afterEach(() => {
245252
// Restore original chrome references
@@ -251,8 +258,8 @@ describe('WS Tools Utils', () => {
251258
// Mock both window.chrome and global chrome
252259
const mockChrome = {
253260
runtime: {
254-
id: 'test-extension-id'
255-
}
261+
id: 'test-extension-id',
262+
},
256263
};
257264
(window as any).chrome = mockChrome;
258265
// In jsdom, we need to set the global chrome object as well

0 commit comments

Comments
 (0)