chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -22,24 +22,24 @@ import { chatBackgroundConfig } from '../../../../../src/save-manager/auto-save/
|
||||
|
||||
describe('chatBackgroundConfig', () => {
|
||||
it('应该具有正确的配置属性', () => {
|
||||
// 验证配置的基本属性
|
||||
// Verify the basic properties of the configuration
|
||||
expect(chatBackgroundConfig).toHaveProperty('key');
|
||||
expect(chatBackgroundConfig).toHaveProperty('selector');
|
||||
expect(chatBackgroundConfig).toHaveProperty('debounce');
|
||||
expect(chatBackgroundConfig).toHaveProperty('middleware');
|
||||
|
||||
// 验证 middleware 存在且有 onBeforeSave 属性
|
||||
// Verify that middleware exists and has an onBeforeSave attribute
|
||||
expect(chatBackgroundConfig.middleware).toBeDefined();
|
||||
if (chatBackgroundConfig.middleware) {
|
||||
expect(chatBackgroundConfig.middleware).toHaveProperty('onBeforeSave');
|
||||
}
|
||||
|
||||
// 验证属性值
|
||||
// Validate attribute value
|
||||
expect(chatBackgroundConfig.key).toBe(ItemTypeExtra.ChatBackGround);
|
||||
expect(chatBackgroundConfig.debounce).toBe(DebounceTime.Immediate);
|
||||
expect(typeof chatBackgroundConfig.selector).toBe('function');
|
||||
|
||||
// 验证 onBeforeSave 是函数
|
||||
// Verify that onBeforeSave is a function
|
||||
if (
|
||||
chatBackgroundConfig.middleware &&
|
||||
chatBackgroundConfig.middleware.onBeforeSave
|
||||
@@ -51,49 +51,49 @@ describe('chatBackgroundConfig', () => {
|
||||
});
|
||||
|
||||
it('selector 应该返回 store 的 backgroundImageInfoList 属性', () => {
|
||||
// 创建模拟 store
|
||||
// Create mock store
|
||||
const mockStore = {
|
||||
backgroundImageInfoList: [
|
||||
{ id: 'bg1', url: 'http://example.com/bg1.jpg' },
|
||||
],
|
||||
};
|
||||
|
||||
// 调用 selector 函数
|
||||
// 注意:这里我们假设 selector 是一个函数,如果它是一个复杂对象,可能需要调整测试
|
||||
// Call the selector function
|
||||
// Note: Here we assume that the selector is a function, and if it is a complex object, the test may need to be adjusted
|
||||
const { selector } = chatBackgroundConfig;
|
||||
let result;
|
||||
|
||||
if (typeof selector === 'function') {
|
||||
result = selector(mockStore as any);
|
||||
// 验证结果
|
||||
// validation result
|
||||
expect(result).toBe(mockStore.backgroundImageInfoList);
|
||||
} else {
|
||||
// 如果 selector 不是函数,跳过这个测试
|
||||
// If the selector is not a function, skip this test
|
||||
expect(true).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('middleware.onBeforeSave 应该正确转换数据', () => {
|
||||
// 创建模拟数据
|
||||
// Create simulated data
|
||||
const mockData = [
|
||||
{ id: 'bg1', url: 'http://example.com/bg1.jpg' },
|
||||
{ id: 'bg2', url: 'http://example.com/bg2.jpg' },
|
||||
];
|
||||
|
||||
// 确保 middleware 和 onBeforeSave 存在
|
||||
// Make sure middleware and onBeforeSave exist
|
||||
if (
|
||||
chatBackgroundConfig.middleware &&
|
||||
chatBackgroundConfig.middleware.onBeforeSave
|
||||
) {
|
||||
// 调用 onBeforeSave 函数
|
||||
// Call the onBeforeSave function
|
||||
const result = chatBackgroundConfig.middleware.onBeforeSave(mockData);
|
||||
|
||||
// 验证结果
|
||||
// validation result
|
||||
expect(result).toEqual({
|
||||
background_image_info_list: mockData,
|
||||
});
|
||||
} else {
|
||||
// 如果 middleware 或 onBeforeSave 不存在,跳过这个测试
|
||||
// If middleware or onBeforeSave does not exist, skip this test
|
||||
expect(true).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ import { knowledgeConfig } from '../../../../../src/save-manager/auto-save/bot-s
|
||||
import { chatBackgroundConfig } from '../../../../../src/save-manager/auto-save/bot-skill/configs/chat-background';
|
||||
import { registers } from '../../../../../src/save-manager/auto-save/bot-skill/configs';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock(
|
||||
'../../../../../src/save-manager/auto-save/bot-skill/configs/workflows',
|
||||
() => ({
|
||||
@@ -101,7 +101,7 @@ vi.mock(
|
||||
|
||||
describe('bot-skill configs', () => {
|
||||
it('应该正确注册所有配置', () => {
|
||||
// 验证 registers 数组包含所有配置
|
||||
// Verify that the registers array contains all configurations
|
||||
expect(registers).toContain(pluginConfig);
|
||||
expect(registers).toContain(chatBackgroundConfig);
|
||||
expect(registers).toContain(onboardingConfig);
|
||||
@@ -113,7 +113,7 @@ describe('bot-skill configs', () => {
|
||||
expect(registers).toContain(workflowsConfig);
|
||||
expect(registers).toContain(voicesInfoConfig);
|
||||
|
||||
// 验证 registers 数组长度
|
||||
// Verify the length of the registers array
|
||||
expect(registers.length).toBe(10);
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('knowledgeConfig', () => {
|
||||
expect(knowledgeConfig).toHaveProperty('debounce');
|
||||
expect(knowledgeConfig).toHaveProperty('middleware');
|
||||
expect(knowledgeConfig.key).toBe(ItemType.DataSet);
|
||||
// 验证 debounce 配置
|
||||
// Verify debounce configuration
|
||||
if (typeof knowledgeConfig.debounce === 'object') {
|
||||
expect(knowledgeConfig.debounce).toHaveProperty('default');
|
||||
expect(knowledgeConfig.debounce).toHaveProperty('dataSetInfo.min_score');
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('onboardingConfig', () => {
|
||||
expect(onboardingConfig).toHaveProperty('debounce');
|
||||
expect(onboardingConfig).toHaveProperty('middleware');
|
||||
expect(onboardingConfig.key).toBe(ItemType.ONBOARDING);
|
||||
// 验证 debounce 配置
|
||||
// Verify debounce configuration
|
||||
if (typeof onboardingConfig.debounce === 'object') {
|
||||
expect(onboardingConfig.debounce).toHaveProperty('default');
|
||||
expect(onboardingConfig.debounce).toHaveProperty('prologue');
|
||||
|
||||
@@ -18,7 +18,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
import { botSkillSaveManager } from '../../../../src/save-manager/auto-save/bot-skill';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-studio/autosave', () => {
|
||||
const mockStartFn = vi.fn();
|
||||
const mockCloseFn = vi.fn();
|
||||
@@ -52,16 +52,16 @@ describe('botSkillSaveManager', () => {
|
||||
});
|
||||
|
||||
it('应该是 AutosaveManager 的实例', () => {
|
||||
// 验证 botSkillSaveManager 是 AutosaveManager 的实例
|
||||
// Verify that botSkillSaveManager is an instance of AutosaveManager
|
||||
expect(botSkillSaveManager).toBeDefined();
|
||||
// 由于我们模拟了 AutosaveManager,我们不能直接检查实例类型
|
||||
// 但可以检查它是否具有 AutosaveManager 实例应有的属性和方法
|
||||
// Since we simulate AutosaveManager, we cannot directly check the instance type
|
||||
// But you can check if it has the properties and methods that an AutosaveManager instance should have
|
||||
expect(botSkillSaveManager).toHaveProperty('start');
|
||||
expect(botSkillSaveManager).toHaveProperty('close');
|
||||
});
|
||||
|
||||
it('应该具有 start 和 close 方法', () => {
|
||||
// 验证 botSkillSaveManager 具有 start 和 close 方法
|
||||
// Verify botSkillSaveManager has a start and close method
|
||||
expect(botSkillSaveManager.start).toBeDefined();
|
||||
expect(botSkillSaveManager.close).toBeDefined();
|
||||
expect(typeof botSkillSaveManager.start).toBe('function');
|
||||
@@ -69,16 +69,16 @@ describe('botSkillSaveManager', () => {
|
||||
});
|
||||
|
||||
it('调用 start 方法应该正常工作', () => {
|
||||
// 调用 start 方法
|
||||
// Call the start method
|
||||
botSkillSaveManager.start();
|
||||
// 由于我们已经模拟了 start 方法,这里只需验证它可以被调用而不会抛出错误
|
||||
// Since we have already simulated the start method, we just need to verify that it can be called without throwing an error
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it('调用 close 方法应该正常工作', () => {
|
||||
// 调用 close 方法
|
||||
// Call the close method
|
||||
botSkillSaveManager.close();
|
||||
// 由于我们已经模拟了 close 方法,这里只需验证它可以被调用而不会抛出错误
|
||||
// Since we have simulated the close method, we just need to verify that it can be called without throwing an error
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ import { modelSaveManager } from '../../../src/save-manager/auto-save/model';
|
||||
import { autosaveManager } from '../../../src/save-manager/auto-save/index';
|
||||
import { botSkillSaveManager } from '../../../src/save-manager/auto-save/bot-skill';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/save-manager/auto-save/persona', () => ({
|
||||
personaSaveManager: {
|
||||
start: vi.fn(),
|
||||
@@ -46,24 +46,24 @@ vi.mock('../../../src/save-manager/auto-save/bot-skill', () => ({
|
||||
describe('autosave manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
// 正确模拟 console.log
|
||||
// Correctly emulate console.log
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {
|
||||
// 什么都不做
|
||||
// Do nothing.
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// 恢复原始的 console.log
|
||||
// Restore the original console.log
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('应该在启动时调用所有管理器的 start 方法', () => {
|
||||
autosaveManager.start();
|
||||
|
||||
// 验证 console.log 被调用
|
||||
// Verify that console.log is called
|
||||
expect(console.log).toHaveBeenCalledWith('start:>>');
|
||||
|
||||
// 验证所有管理器的 start 方法被调用
|
||||
// Verify that the start method of all managers is called
|
||||
expect(personaSaveManager.start).toHaveBeenCalledTimes(1);
|
||||
expect(botSkillSaveManager.start).toHaveBeenCalledTimes(1);
|
||||
expect(modelSaveManager.start).toHaveBeenCalledTimes(1);
|
||||
@@ -72,10 +72,10 @@ describe('autosave manager', () => {
|
||||
it('应该在关闭时调用所有管理器的 close 方法', () => {
|
||||
autosaveManager.close();
|
||||
|
||||
// 验证 console.log 被调用
|
||||
// Verify that console.log is called
|
||||
expect(console.log).toHaveBeenCalledWith('close:>>');
|
||||
|
||||
// 验证所有管理器的 close 方法被调用
|
||||
// Verify that all managers' close methods are called
|
||||
expect(personaSaveManager.close).toHaveBeenCalledTimes(1);
|
||||
expect(botSkillSaveManager.close).toHaveBeenCalledTimes(1);
|
||||
expect(modelSaveManager.close).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -22,7 +22,7 @@ import { useBotInfoStore } from '../../../src/store/bot-info';
|
||||
import { saveFetcher } from '../../../src/save-manager/utils/save-fetcher';
|
||||
import { saveRequest } from '../../../src/save-manager/auto-save/request';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/bot-api', () => ({
|
||||
PlaygroundApi: {
|
||||
UpdateDraftBotInfoAgw: vi.fn(),
|
||||
@@ -53,7 +53,7 @@ describe('auto-save request', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
botId: mockBotId,
|
||||
});
|
||||
@@ -71,19 +71,19 @@ describe('auto-save request', () => {
|
||||
it('应该使用正确的参数调用 saveFetcher', async () => {
|
||||
await saveRequest(mockPayload, mockItemType);
|
||||
|
||||
// 验证 saveFetcher 被调用
|
||||
// Verify that saveFetcher is called
|
||||
expect(saveFetcher).toHaveBeenCalledTimes(1);
|
||||
// 验证 saveFetcher 的第二个参数是正确的 itemType
|
||||
// Verify that the second argument of saveFetcher is the correct itemType.
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
mockItemType,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateDraftBotInfoAgw 被调用,并且参数正确
|
||||
// Verify that UpdateDraftBotInfoAgw is called and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateDraftBotInfoAgw).toHaveBeenCalledWith({
|
||||
bot_info: {
|
||||
bot_id: mockBotId,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from '../../../src/save-manager/utils/save-fetcher';
|
||||
import { saveDevHooksConfig } from '../../../src/save-manager/manual-save/dev-hooks';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -45,7 +45,7 @@ describe('dev-hooks save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
devHooks: mockDevHooks,
|
||||
});
|
||||
@@ -66,12 +66,12 @@ describe('dev-hooks save manager', () => {
|
||||
} as any as HookInfo;
|
||||
await saveDevHooksConfig(newConfig);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
hook_info: newConfig,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemType.HOOKINFO,
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from '../../../src/save-manager/utils/save-fetcher';
|
||||
import { saveTableMemory } from '../../../src/save-manager/manual-save/memory-table';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -49,7 +49,7 @@ describe('memory-table save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
databaseList: mockDatabaseList,
|
||||
transformVo2Dto: mockTransformVo2Dto,
|
||||
@@ -68,17 +68,17 @@ describe('memory-table save manager', () => {
|
||||
it('应该正确保存内存表变量', async () => {
|
||||
await saveTableMemory();
|
||||
|
||||
// 验证 transformVo2Dto.databaseList 被调用
|
||||
// Verify that transformVo2Dto.DatabaseList is called
|
||||
expect(mockTransformVo2Dto.databaseList).toHaveBeenCalledWith(
|
||||
mockDatabaseList,
|
||||
);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
database_list: { transformed: mockDatabaseList },
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemType.TABLE,
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
saveConnectorType,
|
||||
} from '../../../src/save-manager/manual-save/multi-agent';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/bot-api', () => ({
|
||||
PlaygroundApi: {
|
||||
UpdateAgentV2: vi.fn(),
|
||||
@@ -68,7 +68,7 @@ vi.mock('../../../src/save-manager/utils/save-fetcher', () => ({
|
||||
describe('multi-agent save manager', () => {
|
||||
const mockBotId = 'mock-bot-id';
|
||||
const mockSpaceId = 'mock-space-id';
|
||||
// 创建一个符合 Agent 类型的模拟对象
|
||||
// Create a mock object that conforms to the Agent type
|
||||
const mockAgent = {
|
||||
id: 'agent-1',
|
||||
name: 'Agent 1',
|
||||
@@ -99,7 +99,7 @@ describe('multi-agent save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
botId: mockBotId,
|
||||
});
|
||||
@@ -133,22 +133,22 @@ describe('multi-agent save manager', () => {
|
||||
it('应该正确更新代理', async () => {
|
||||
await saveUpdateAgents(mockAgent as any);
|
||||
|
||||
// 验证 transformVo2Dto.agent 被调用
|
||||
// Verify that transformVo2Dato.agent is called
|
||||
expect(
|
||||
useMultiAgentStore.getState().transformVo2Dto.agent,
|
||||
).toHaveBeenCalledWith(mockAgent);
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.MultiAgent,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateAgentV2 被调用,并且参数正确
|
||||
// Verify that UpdateAgentV2 is called and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateAgentV2).toHaveBeenCalledWith({
|
||||
...mockAgentDto,
|
||||
bot_id: mockBotId,
|
||||
@@ -163,17 +163,17 @@ describe('multi-agent save manager', () => {
|
||||
const agentId = 'agent-to-delete';
|
||||
await saveDeleteAgents(agentId);
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.MultiAgent,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateAgentV2 被调用,并且参数正确
|
||||
// Verify that UpdateAgentV2 is called and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateAgentV2).toHaveBeenCalledWith({
|
||||
bot_id: mockBotId,
|
||||
space_id: mockSpaceId,
|
||||
@@ -188,17 +188,17 @@ describe('multi-agent save manager', () => {
|
||||
it('应该正确保存多代理数据', async () => {
|
||||
await saveMultiAgentData();
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.MultiAgent,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateMultiAgent 被调用,并且参数正确
|
||||
// Verify that UpdateMultiAgent is invoked and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateMultiAgent).toHaveBeenCalledWith({
|
||||
space_id: mockSpaceId,
|
||||
bot_id: mockBotId,
|
||||
@@ -210,21 +210,21 @@ describe('multi-agent save manager', () => {
|
||||
|
||||
describe('saveConnectorType', () => {
|
||||
it('应该正确保存连接器类型', async () => {
|
||||
// 使用数字代替枚举值
|
||||
const connectorType = 0; // 假设 0 代表 Straight
|
||||
// Using numbers instead of enumerated values
|
||||
const connectorType = 0; // Assume 0 is Straight
|
||||
await saveConnectorType(connectorType as any);
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.ConnectorType,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateMultiAgent 被调用,并且参数正确
|
||||
// Verify that UpdateMultiAgent is invoked and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateMultiAgent).toHaveBeenCalledWith({
|
||||
space_id: mockSpaceId,
|
||||
bot_id: mockBotId,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { updateQueryCollect } from '../../../src/save-manager/manual-save/query-collect';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/query-collect', () => ({
|
||||
useQueryCollectStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -46,7 +46,7 @@ describe('query-collect save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useQueryCollectStore.getState as any).mockReturnValue({
|
||||
...mockQueryCollect,
|
||||
});
|
||||
@@ -62,18 +62,18 @@ describe('query-collect save manager', () => {
|
||||
});
|
||||
|
||||
it('应该正确保存 query collect 配置', async () => {
|
||||
// 创建一个符合 UserQueryCollectConf 类型的对象作为参数
|
||||
// Create an object of UserQueryCollectConf type as a parameter
|
||||
const queryCollectConf =
|
||||
mockQueryCollect as unknown as UserQueryCollectConf;
|
||||
|
||||
await updateQueryCollect(queryCollectConf);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
user_query_collect_conf: queryCollectConf,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.QueryCollect,
|
||||
@@ -84,7 +84,7 @@ describe('query-collect save manager', () => {
|
||||
const mockError = new Error('Save failed');
|
||||
(saveFetcher as any).mockRejectedValue(mockError);
|
||||
|
||||
// 创建一个符合 UserQueryCollectConf 类型的对象作为参数
|
||||
// Create an object of UserQueryCollectConf type as a parameter
|
||||
const queryCollectConf =
|
||||
mockQueryCollect as unknown as UserQueryCollectConf;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { updateShortcutSort } from '../../../src/save-manager/manual-save/shortcuts';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -46,7 +46,7 @@ describe('shortcuts save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
shortcut: mockShortcut,
|
||||
transformVo2Dto: mockTransformVo2Dto,
|
||||
@@ -66,12 +66,12 @@ describe('shortcuts save manager', () => {
|
||||
const newSort = ['shortcut-2', 'shortcut-1'];
|
||||
await updateShortcutSort(newSort);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
shortcut_sort: newSort,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.Shortcut,
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { saveTimeCapsule } from '../../../src/save-manager/manual-save/time-capsule';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -54,7 +54,7 @@ describe('time-capsule save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
timeCapsule: mockTimeCapsule,
|
||||
transformVo2Dto: mockTransformVo2Dto,
|
||||
@@ -73,17 +73,17 @@ describe('time-capsule save manager', () => {
|
||||
it('应该正确保存 time capsule 配置', async () => {
|
||||
await saveTimeCapsule();
|
||||
|
||||
// 验证 transformVo2Dto.timeCapsule 被调用,参数应该是包含 time_capsule_mode 和 disable_prompt_calling 的对象
|
||||
// Verify that transformVo2To.timeCapsule is called, the argument should be an object containing time_capsule_mode and disable_prompt_calling
|
||||
expect(mockTransformVo2Dto.timeCapsule).toHaveBeenCalledWith({
|
||||
time_capsule_mode: mockTimeCapsule.time_capsule_mode,
|
||||
disable_prompt_calling: mockTimeCapsule.disable_prompt_calling,
|
||||
});
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
bot_tag_info: mockTransformedTimeCapsule,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.TimeCapsule,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { saveTTSConfig } from '../../../src/save-manager/manual-save/tts';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('lodash-es', () => ({
|
||||
cloneDeep: vi.fn(obj => JSON.parse(JSON.stringify(obj))),
|
||||
merge: vi.fn((target, ...sources) => Object.assign({}, target, ...sources)),
|
||||
@@ -73,7 +73,7 @@ describe('tts save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
tts: mockTTS,
|
||||
voicesInfo: mockVoicesInfo,
|
||||
@@ -93,21 +93,21 @@ describe('tts save manager', () => {
|
||||
it('应该正确保存 TTS 配置', async () => {
|
||||
await saveTTSConfig();
|
||||
|
||||
// 验证 transformVo2Dto.tts 被调用
|
||||
// Verify that transformVo2To.tts is called
|
||||
expect(mockTransformVo2Dto.tts).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证传递给 transformVo2Dto.tts 的参数是 tts 的克隆
|
||||
// Verify that the parameter passed to transformVo2To.tts is a clone of tts
|
||||
const ttsArg = mockTransformVo2Dto.tts.mock.calls[0][0];
|
||||
expect(ttsArg).toEqual(mockTTS);
|
||||
expect(ttsArg).not.toBe(mockTTS); // 确保是克隆而不是原始对象
|
||||
expect(ttsArg).not.toBe(mockTTS); // Make sure it's a clone and not the original object
|
||||
|
||||
// 验证 cloneDeep 被调用
|
||||
// Verify that cloneDeep is called
|
||||
expect(cloneDeep).toHaveBeenCalledTimes(3);
|
||||
|
||||
// 验证 transformVo2Dto.voicesInfo 被调用
|
||||
// Verify that transformVo2To.voicesInfo is called
|
||||
expect(mockTransformVo2Dto.voicesInfo).toHaveBeenCalledWith(mockVoicesInfo);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
voices_info: {
|
||||
muted: mockTTS.muted,
|
||||
@@ -120,7 +120,7 @@ describe('tts save manager', () => {
|
||||
},
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.TTS,
|
||||
|
||||
@@ -25,7 +25,7 @@ import { useBotSkillStore } from '../../../src/store/bot-skill';
|
||||
import { useBotInfoStore } from '../../../src/store/bot-info';
|
||||
import { getBotDetailDtoInfo } from '../../../src/save-manager/utils/bot-dto-info';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/report-events', () => ({
|
||||
REPORT_EVENTS: {
|
||||
botDebugSaveAll: 'botDebugSaveAll',
|
||||
@@ -130,7 +130,7 @@ describe('bot-dto-info utils', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
mode: BotMode.SingleMode,
|
||||
});
|
||||
@@ -156,18 +156,18 @@ describe('bot-dto-info utils', () => {
|
||||
it('应该正确转换所有 bot 信息为 DTO 格式', () => {
|
||||
const result = getBotDetailDtoInfo();
|
||||
|
||||
// 验证 bot skill info
|
||||
// Verify bot skill info
|
||||
const { botSkillInfo } = result;
|
||||
|
||||
// 验证 persona 转换
|
||||
// Validate persona conversion
|
||||
expect(mockPersona.transformVo2Dto).toHaveBeenCalledWith(
|
||||
mockPersona.systemMessage,
|
||||
);
|
||||
|
||||
// 验证 model 转换
|
||||
// Validation model transformation
|
||||
expect(mockModel.transformVo2Dto).toHaveBeenCalledWith(mockModel.config);
|
||||
|
||||
// 验证 bot skill 转换
|
||||
// Verify bot skill conversion
|
||||
expect(mockTransformVo2Dto.knowledge).toHaveBeenCalledWith(
|
||||
mockBotSkill.knowledge,
|
||||
);
|
||||
@@ -203,17 +203,17 @@ describe('bot-dto-info utils', () => {
|
||||
mockBotSkill.voicesInfo,
|
||||
);
|
||||
|
||||
// 验证 queryCollect 转换
|
||||
// Verify queryCollect conversion
|
||||
expect(mockQueryCollect.transformVo2Dto).toHaveBeenCalledWith(
|
||||
mockQueryCollect,
|
||||
);
|
||||
|
||||
// 验证结果结构
|
||||
// Validation result structure
|
||||
expect(botSkillInfo).toBeDefined();
|
||||
});
|
||||
|
||||
it('在多智能体模式下应该正确转换', () => {
|
||||
// 设置为多智能体模式
|
||||
// Set to multi-agent mode
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
mode: BotMode.MultiMode,
|
||||
});
|
||||
@@ -221,12 +221,12 @@ describe('bot-dto-info utils', () => {
|
||||
const result = getBotDetailDtoInfo();
|
||||
const { botSkillInfo } = result;
|
||||
|
||||
// 验证多智能体模式下的转换
|
||||
// Verify transitions in multi-agent mode
|
||||
expect(mockMultiAgent.transformVo2Dto.agent).toHaveBeenCalledWith(
|
||||
mockMultiAgent.agents[0],
|
||||
);
|
||||
|
||||
// 验证多智能体模式下某些字段应该是 undefined
|
||||
// Verify that some fields should be undefined in multi-agent mode
|
||||
expect(botSkillInfo).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
updateBotRequest,
|
||||
} from '../../../src/save-manager/utils/save-fetcher';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/logger', () => ({
|
||||
reporter: {
|
||||
successEvent: vi.fn(),
|
||||
@@ -84,7 +84,7 @@ describe('save-fetcher utils', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: false,
|
||||
@@ -118,7 +118,7 @@ describe('save-fetcher utils', () => {
|
||||
|
||||
describe('saveFetcher', () => {
|
||||
it('应该在只读模式下不执行任何操作', async () => {
|
||||
// 设置为只读模式
|
||||
// Set to read-only mode
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: false,
|
||||
isPreview: false,
|
||||
@@ -134,7 +134,7 @@ describe('save-fetcher utils', () => {
|
||||
});
|
||||
|
||||
it('应该在预览模式下不执行任何操作', async () => {
|
||||
// 设置为预览模式
|
||||
// Set to preview mode
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: true,
|
||||
@@ -150,7 +150,7 @@ describe('save-fetcher utils', () => {
|
||||
});
|
||||
|
||||
it('应该在探索模式下不执行任何操作', async () => {
|
||||
// 设置为探索模式
|
||||
// Set to exploration mode
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: false,
|
||||
@@ -166,7 +166,7 @@ describe('save-fetcher utils', () => {
|
||||
});
|
||||
|
||||
it('应该在未初始化时不执行任何操作', async () => {
|
||||
// 设置为未初始化
|
||||
// Set to uninitialized
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: false,
|
||||
@@ -184,32 +184,32 @@ describe('save-fetcher utils', () => {
|
||||
it('应该在可编辑模式下正确执行保存操作', async () => {
|
||||
await saveFetcher(mockSaveRequest, mockScopeKey as any);
|
||||
|
||||
// 验证设置保存状态
|
||||
// Verify settings save state
|
||||
expect(mockSetPageRuntimeByImmer).toHaveBeenCalledTimes(3);
|
||||
// 验证第一次调用 - 设置保存中状态
|
||||
// Verify First Call - Set Saved State
|
||||
const firstCall = mockSetPageRuntimeByImmer.mock.calls[0][0];
|
||||
const mockState1 = { savingInfo: {} };
|
||||
firstCall(mockState1);
|
||||
expect(mockState1.savingInfo.saving).toBe(true);
|
||||
expect(mockState1.savingInfo.scopeKey).toBe(String(mockScopeKey));
|
||||
|
||||
// 验证保存请求被调用
|
||||
// Verify that the save request was invoked
|
||||
expect(mockSaveRequest).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证第二次调用 - 设置保存完成状态
|
||||
// Verify Second Call - Set Save Complete Status
|
||||
const secondCall = mockSetPageRuntimeByImmer.mock.calls[1][0];
|
||||
const mockState2 = { savingInfo: {} };
|
||||
secondCall(mockState2);
|
||||
expect(mockState2.savingInfo.saving).toBe(false);
|
||||
expect(mockState2.savingInfo.time).toBe('12:34:56');
|
||||
|
||||
// 验证第三次调用 - 设置未发布变更状态
|
||||
// Verify Third Call - Set Unpublished Change Status
|
||||
const thirdCall = mockSetPageRuntimeByImmer.mock.calls[2][0];
|
||||
const mockState3 = {};
|
||||
thirdCall(mockState3);
|
||||
expect(mockState3.hasUnpublishChange).toBe(true);
|
||||
|
||||
// 验证设置协作状态
|
||||
// Verify settings collaboration status
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalledTimes(1);
|
||||
const collaborationCall = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockCollabState = { branch: { id: 'branch-id' } };
|
||||
@@ -217,7 +217,7 @@ describe('save-fetcher utils', () => {
|
||||
expect(mockCollabState.sameWithOnline).toBe(false);
|
||||
expect(mockCollabState.branch).toEqual({ id: 'updated-branch-id' });
|
||||
|
||||
// 验证成功事件被报告
|
||||
// Validation success events are reported
|
||||
expect(reporter.successEvent).toHaveBeenCalledWith({
|
||||
eventName: REPORT_EVENTS.AutosaveSuccess,
|
||||
meta: { itemType: mockScopeKey },
|
||||
@@ -230,13 +230,13 @@ describe('save-fetcher utils', () => {
|
||||
|
||||
await saveFetcher(mockSaveRequest, mockScopeKey as any);
|
||||
|
||||
// 验证设置保存中状态
|
||||
// Verify settings save status
|
||||
expect(mockSetPageRuntimeByImmer).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证保存请求被调用
|
||||
// Verify that the save request was invoked
|
||||
expect(mockSaveRequest).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证错误事件被报告
|
||||
// Validation error events are reported
|
||||
expect(reporter.errorEvent).toHaveBeenCalledWith({
|
||||
eventName: REPORT_EVENTS.AutosaveError,
|
||||
error: mockError,
|
||||
@@ -249,19 +249,19 @@ describe('save-fetcher utils', () => {
|
||||
data: {
|
||||
has_change: true,
|
||||
same_with_online: false,
|
||||
// 没有 branch 信息
|
||||
// No branch information
|
||||
},
|
||||
});
|
||||
|
||||
await saveFetcher(mockSaveRequest, mockScopeKey as any);
|
||||
|
||||
// 验证设置协作状态
|
||||
// Verify settings collaboration status
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalledTimes(1);
|
||||
const collaborationCall = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockCollabState = { branch: { id: 'branch-id' } };
|
||||
collaborationCall(mockCollabState);
|
||||
expect(mockCollabState.sameWithOnline).toBe(false);
|
||||
// 分支信息应该保持不变
|
||||
// Branch information should remain unchanged
|
||||
expect(mockCollabState.branch).toEqual({ id: 'branch-id' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
|
||||
describe('diff-task store', () => {
|
||||
beforeEach(() => {
|
||||
// 每个测试前重置 store 状态
|
||||
// Reset the stored state before each test
|
||||
useDiffTaskStore.getState().clear();
|
||||
});
|
||||
|
||||
@@ -99,7 +99,7 @@ describe('diff-task store', () => {
|
||||
|
||||
const state = useDiffTaskStore.getState();
|
||||
expect(state.diffTask).toBe('model');
|
||||
// promptDiffInfo 应该保持不变
|
||||
// promptDiffInfo should remain unchanged
|
||||
expect(state.promptDiffInfo).toEqual(
|
||||
getDefaultDiffTaskStore().promptDiffInfo,
|
||||
);
|
||||
@@ -108,43 +108,43 @@ describe('diff-task store', () => {
|
||||
test('exitDiffMode 应该调用 clear 方法', () => {
|
||||
const { enterDiffMode, exitDiffMode, clear } = useDiffTaskStore.getState();
|
||||
|
||||
// 模拟 clear 方法
|
||||
// Simulated clearing method
|
||||
const mockClear = vi.fn();
|
||||
useDiffTaskStore.setState(state => ({ ...state, clear: mockClear }));
|
||||
|
||||
// 先进入 diff 模式
|
||||
// Enter diff mode first
|
||||
enterDiffMode({ diffTask: 'prompt' });
|
||||
|
||||
// 退出 diff 模式
|
||||
// Exit diff mode
|
||||
exitDiffMode();
|
||||
|
||||
// 验证 clear 被调用
|
||||
// Verify clear is called
|
||||
expect(mockClear).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 恢复原始的 clear 方法
|
||||
// Restore the original clear method
|
||||
useDiffTaskStore.setState(state => ({ ...state, clear }));
|
||||
});
|
||||
|
||||
test('clear 应该重置状态到默认值', () => {
|
||||
const { setDiffTask, clear } = useDiffTaskStore.getState();
|
||||
|
||||
// 修改状态
|
||||
// Modify state
|
||||
setDiffTask({
|
||||
diffTask: 'model',
|
||||
hasContinueTask: true,
|
||||
continueTask: 'prompt',
|
||||
});
|
||||
|
||||
// 验证状态已更改
|
||||
// Verification status has changed
|
||||
let state = useDiffTaskStore.getState();
|
||||
expect(state.diffTask).toBe('model');
|
||||
expect(state.hasContinueTask).toBe(true);
|
||||
expect(state.continueTask).toBe('prompt');
|
||||
|
||||
// 重置状态
|
||||
// reset state
|
||||
clear();
|
||||
|
||||
// 验证状态已重置
|
||||
// Verification status reset
|
||||
state = useDiffTaskStore.getState();
|
||||
expect(state).toEqual({
|
||||
...getDefaultDiffTaskStore(),
|
||||
|
||||
@@ -665,9 +665,9 @@ describe('resetHostAgent', () => {
|
||||
});
|
||||
|
||||
useBotInfoStore.getState().setBotInfo(getOverall());
|
||||
// 接口错误返回
|
||||
// interface error return
|
||||
expect(await useMultiAgentStore.getState().addAgent({})).toBeUndefined();
|
||||
// 接口错误返回走default
|
||||
// Interface error return go default
|
||||
expect(useCollaborationStore.getState().sameWithOnline).toEqual(
|
||||
getDefaultCollaborationStore().sameWithOnline,
|
||||
);
|
||||
@@ -1051,7 +1051,7 @@ describe('addAgentIntent', () => {
|
||||
};
|
||||
useMultiAgentStore.getState().addAgent2Store(agent);
|
||||
const findAgent = useMultiAgentStore.getState().agents?.[0];
|
||||
// 这里想要mock findTargetAgent的返回值
|
||||
// Here I want to mock the return value of findTargetAgent
|
||||
const mockFindAgent = vi
|
||||
.spyOn(findAgentModule, 'findTargetAgent')
|
||||
.mockReturnValueOnce({
|
||||
|
||||
@@ -19,7 +19,7 @@ import { globalVars } from '@coze-arch/web-context';
|
||||
|
||||
import { getExecuteDraftBotRequestId } from '../../src/utils/execute-draft-bot-request-id';
|
||||
|
||||
// 模拟 globalVars
|
||||
// Simulate globalVars
|
||||
vi.mock('@coze-arch/web-context', () => ({
|
||||
globalVars: {
|
||||
LAST_EXECUTE_ID: 'mock-execute-id',
|
||||
@@ -35,14 +35,14 @@ describe('execute-draft-bot-request-id utils', () => {
|
||||
});
|
||||
|
||||
it('应该在 LAST_EXECUTE_ID 变化时返回新值', () => {
|
||||
// 修改模拟的 LAST_EXECUTE_ID
|
||||
// Modify the simulated LAST_EXECUTE_ID
|
||||
(globalVars as any).LAST_EXECUTE_ID = 'new-execute-id';
|
||||
|
||||
const result = getExecuteDraftBotRequestId();
|
||||
|
||||
expect(result).toBe('new-execute-id');
|
||||
|
||||
// 恢复原始值,避免影响其他测试
|
||||
// Restore the original value to avoid affecting other tests
|
||||
(globalVars as any).LAST_EXECUTE_ID = 'mock-execute-id';
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
} from '../../src/types/generate-image';
|
||||
import { useBotSkillStore } from '../../src/store/bot-skill';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -124,8 +124,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.Generating) // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.None); // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.Generating) // static graph state
|
||||
.mockReturnValueOnce(DotStatus.None); // animation status
|
||||
|
||||
getInitBackgroundInfo(data, state);
|
||||
|
||||
@@ -173,8 +173,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.None) // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.Success); // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.None) // static graph state
|
||||
.mockReturnValueOnce(DotStatus.Success); // animation status
|
||||
|
||||
getInitBackgroundInfo(data, state);
|
||||
|
||||
@@ -276,13 +276,13 @@ describe('generate-image utils', () => {
|
||||
|
||||
(getDotStatus as any).mockReturnValue(DotStatus.None);
|
||||
|
||||
// 在调用函数前,先准备一个空的任务对象,模拟函数内部的行为
|
||||
// Before calling the function, prepare an empty task object to simulate the behavior inside the function
|
||||
const emptyTask = {
|
||||
id: '',
|
||||
img_info: {},
|
||||
};
|
||||
|
||||
// 修改测试数据,添加一个空任务
|
||||
// Modify the test data and add an empty task
|
||||
data.tasks = [emptyTask as any];
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
@@ -291,9 +291,9 @@ describe('generate-image utils', () => {
|
||||
expect(state.gif.loading).toBe(false);
|
||||
expect(state.image.loading).toBe(false);
|
||||
|
||||
// 直接修改 state.selectedImage,使其与预期值匹配
|
||||
// Modify state.selectedImage directly to match the expected value
|
||||
state.selectedImage = emptyTask;
|
||||
// 修改断言,与实际函数行为一致
|
||||
// Modify the assertion to match the actual function behavior
|
||||
expect(state.selectedImage).toEqual(emptyTask);
|
||||
});
|
||||
|
||||
@@ -340,8 +340,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.None) // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.Success); // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.None) // animation status
|
||||
.mockReturnValueOnce(DotStatus.Success); // static graph state
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
|
||||
@@ -398,8 +398,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.Generating) // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.None); // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.Generating) // animation status
|
||||
.mockReturnValueOnce(DotStatus.None); // static graph state
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
|
||||
@@ -473,8 +473,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.Success) // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.Success); // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.Success) // animation status
|
||||
.mockReturnValueOnce(DotStatus.Success); // static graph state
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { DotStatus } from '../../src/types/generate-image';
|
||||
|
||||
// 模拟 PicType 枚举
|
||||
// Analog PicType Enumeration
|
||||
enum MockPicType {
|
||||
AVATAR = 1,
|
||||
BACKGROUND = 2,
|
||||
}
|
||||
|
||||
// 模拟 GetPicTaskData 类型
|
||||
// Emulate the GetPicTaskData type
|
||||
interface MockTask {
|
||||
type: MockPicType;
|
||||
status: number;
|
||||
@@ -40,7 +40,7 @@ interface MockGetPicTaskData {
|
||||
notices?: MockNotice[];
|
||||
}
|
||||
|
||||
// 简化版的 getDotStatus 函数
|
||||
// Simplified version of getDotStatus function
|
||||
function simplifiedGetDotStatus(
|
||||
data: MockGetPicTaskData | null,
|
||||
picType: MockPicType,
|
||||
|
||||
@@ -20,7 +20,7 @@ import { type Branch, type Committer } from '@coze-arch/bot-api/developer_api';
|
||||
import { updateHeaderStatus } from '../../src/utils/handle-status';
|
||||
import { useCollaborationStore } from '../../src/store/collaboration';
|
||||
|
||||
// 模拟 useCollaborationStore
|
||||
// Analog useCollaborationStore
|
||||
vi.mock('../../src/store/collaboration', () => ({
|
||||
useCollaborationStore: {
|
||||
getState: vi.fn().mockReturnValue({
|
||||
@@ -59,7 +59,7 @@ describe('handle-status utils', () => {
|
||||
expect(useCollaborationStore.getState).toHaveBeenCalled();
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalled();
|
||||
|
||||
// 验证 setCollaborationByImmer 的回调函数
|
||||
// Validate setCollaborationByImmer callback function
|
||||
const callback = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockStore = {
|
||||
sameWithOnline: false,
|
||||
@@ -91,7 +91,7 @@ describe('handle-status utils', () => {
|
||||
setCollaborationByImmer: mockSetCollaborationByImmer,
|
||||
});
|
||||
|
||||
// 只提供部分参数
|
||||
// Only some parameters are provided
|
||||
const mockProps = {
|
||||
same_with_online: true,
|
||||
};
|
||||
@@ -101,7 +101,7 @@ describe('handle-status utils', () => {
|
||||
expect(useCollaborationStore.getState).toHaveBeenCalled();
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalled();
|
||||
|
||||
// 验证 setCollaborationByImmer 的回调函数
|
||||
// Validate setCollaborationByImmer callback function
|
||||
const callback = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockStore = {
|
||||
sameWithOnline: false,
|
||||
@@ -114,7 +114,7 @@ describe('handle-status utils', () => {
|
||||
|
||||
callback(mockStore);
|
||||
|
||||
// 只有 sameWithOnline 应该被更新
|
||||
// Only sameWithOnline should be updated
|
||||
expect(mockStore).toEqual({
|
||||
sameWithOnline: true,
|
||||
commit_time: 'old_time',
|
||||
@@ -133,13 +133,13 @@ describe('handle-status utils', () => {
|
||||
|
||||
const mockProps = {
|
||||
committer: {
|
||||
// commit_time 和 name 都是 undefined
|
||||
// commit_time and name are both undefined.
|
||||
} as Committer,
|
||||
};
|
||||
|
||||
updateHeaderStatus(mockProps);
|
||||
|
||||
// 验证 setCollaborationByImmer 的回调函数
|
||||
// Validate setCollaborationByImmer callback function
|
||||
const callback = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockStore = {
|
||||
sameWithOnline: true,
|
||||
@@ -149,7 +149,7 @@ describe('handle-status utils', () => {
|
||||
|
||||
callback(mockStore);
|
||||
|
||||
// 应该使用空字符串作为默认值
|
||||
// Should use empty string as default
|
||||
expect(mockStore).toEqual({
|
||||
sameWithOnline: false,
|
||||
commit_time: '',
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
describe('plugin-apis', () => {
|
||||
describe('getPluginApisFilterExample', () => {
|
||||
it('应该过滤掉所有插件API中的debug_example字段', () => {
|
||||
// 使用 as unknown as PluginApi[] 来绕过类型检查
|
||||
// Use as unknown as PluginApi [] to bypass type checking
|
||||
const mockPluginApis = [
|
||||
{
|
||||
name: 'plugin1',
|
||||
@@ -56,7 +56,7 @@ describe('plugin-apis', () => {
|
||||
|
||||
describe('getSinglePluginApiFilterExample', () => {
|
||||
it('应该过滤掉单个插件API中的debug_example字段', () => {
|
||||
// 使用 as unknown as PluginApi 来绕过类型检查
|
||||
// Use as unknown as PluginApi to bypass type checking
|
||||
const mockPluginApi = {
|
||||
name: 'plugin1',
|
||||
debug_example: 'example1',
|
||||
|
||||
@@ -30,20 +30,20 @@ describe('replacedBotPrompt', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 检查系统提示
|
||||
// Check system prompt
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '这是一个系统提示',
|
||||
record_id: '123456',
|
||||
});
|
||||
|
||||
// 检查用户前缀
|
||||
// Check user prefix
|
||||
expect(result[1]).toEqual({
|
||||
prompt_type: PromptType.USERPREFIX,
|
||||
data: '',
|
||||
});
|
||||
|
||||
// 检查用户后缀
|
||||
// Check user suffix
|
||||
expect(result[2]).toEqual({
|
||||
prompt_type: PromptType.USERSUFFIX,
|
||||
data: '',
|
||||
@@ -60,20 +60,20 @@ describe('replacedBotPrompt', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 检查系统提示
|
||||
// Check system prompt
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '',
|
||||
record_id: '',
|
||||
});
|
||||
|
||||
// 检查用户前缀
|
||||
// Check user prefix
|
||||
expect(result[1]).toEqual({
|
||||
prompt_type: PromptType.USERPREFIX,
|
||||
data: '',
|
||||
});
|
||||
|
||||
// 检查用户后缀
|
||||
// Check user suffix
|
||||
expect(result[2]).toEqual({
|
||||
prompt_type: PromptType.USERSUFFIX,
|
||||
data: '',
|
||||
@@ -89,7 +89,7 @@ describe('replacedBotPrompt', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 检查系统提示
|
||||
// Check system prompt
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '这是一个系统提示',
|
||||
|
||||
@@ -20,7 +20,7 @@ import { PromptType } from '@coze-arch/bot-api/developer_api';
|
||||
import { getReplacedBotPrompt } from '../../src/utils/save';
|
||||
import { usePersonaStore } from '../../src/store/persona';
|
||||
|
||||
// 模拟 usePersonaStore
|
||||
// emulation usePersonaStore
|
||||
vi.mock('../../src/store/persona', () => ({
|
||||
usePersonaStore: {
|
||||
getState: vi.fn().mockReturnValue({
|
||||
@@ -38,19 +38,19 @@ describe('save utils', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 验证系统消息
|
||||
// Verify system message
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '模拟的系统消息',
|
||||
});
|
||||
|
||||
// 验证用户前缀
|
||||
// validate user prefix
|
||||
expect(result[1]).toEqual({
|
||||
prompt_type: PromptType.USERPREFIX,
|
||||
data: '',
|
||||
});
|
||||
|
||||
// 验证用户后缀
|
||||
// validate user suffix
|
||||
expect(result[2]).toEqual({
|
||||
prompt_type: PromptType.USERSUFFIX,
|
||||
data: '',
|
||||
|
||||
@@ -20,7 +20,7 @@ import { setterActionFactory } from '../../src/utils/setter-factory';
|
||||
|
||||
describe('setterActionFactory', () => {
|
||||
it('应该创建一个增量更新函数', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn(updater => {
|
||||
if (typeof updater === 'function') {
|
||||
return updater({ a: 1, b: 2 });
|
||||
@@ -28,37 +28,37 @@ describe('setterActionFactory', () => {
|
||||
return updater;
|
||||
});
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行增量更新
|
||||
// Call setter for incremental update
|
||||
setter({ a: 3 });
|
||||
|
||||
// 验证 set 函数被调用
|
||||
// Verify that the set function is called
|
||||
expect(mockSet).toHaveBeenCalled();
|
||||
|
||||
// 验证更新后的状态
|
||||
// Verify the updated status
|
||||
const updater = mockSet.mock.calls[0][0];
|
||||
const result = updater({ a: 1, b: 2 });
|
||||
expect(result).toEqual({ a: 3, b: 2 });
|
||||
});
|
||||
|
||||
it('应该创建一个全量更新函数', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn();
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行全量更新
|
||||
// Call setter for full update
|
||||
setter({ a: 3 }, { replace: true });
|
||||
|
||||
// 验证 set 函数被调用,并且传入了正确的参数
|
||||
// Verify that the set function is called and the correct parameters are passed in
|
||||
expect(mockSet).toHaveBeenCalledWith({ a: 3 });
|
||||
});
|
||||
|
||||
it('应该处理空对象的增量更新', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn(updater => {
|
||||
if (typeof updater === 'function') {
|
||||
return updater({});
|
||||
@@ -66,43 +66,43 @@ describe('setterActionFactory', () => {
|
||||
return updater;
|
||||
});
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行增量更新
|
||||
// Call setter for incremental update
|
||||
setter({ a: 1 });
|
||||
|
||||
// 验证 set 函数被调用
|
||||
// Verify that the set function is called
|
||||
expect(mockSet).toHaveBeenCalled();
|
||||
|
||||
// 验证更新后的状态
|
||||
// Verify the updated status
|
||||
const updater = mockSet.mock.calls[0][0];
|
||||
const result = updater({});
|
||||
expect(result).toEqual({ a: 1 });
|
||||
});
|
||||
|
||||
it('应该处理空对象的全量更新', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn();
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行全量更新
|
||||
// Call setter for full update
|
||||
setter({}, { replace: true });
|
||||
|
||||
// 验证 set 函数被调用,并且传入了正确的参数
|
||||
// Verify that the set function is called and the correct parameters are passed in
|
||||
expect(mockSet).toHaveBeenCalledWith({});
|
||||
});
|
||||
|
||||
it('应该处理复杂对象的增量更新', () => {
|
||||
// 创建一个复杂的初始状态
|
||||
// Create a complex initial state
|
||||
const initialState = {
|
||||
user: { name: 'John', age: 30 },
|
||||
settings: { theme: 'dark', notifications: true },
|
||||
};
|
||||
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn(updater => {
|
||||
if (typeof updater === 'function') {
|
||||
return updater(initialState);
|
||||
@@ -110,22 +110,22 @@ describe('setterActionFactory', () => {
|
||||
return updater;
|
||||
});
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行增量更新
|
||||
// Call setter for incremental update
|
||||
setter({
|
||||
user: { name: 'Jane', age: 25 },
|
||||
});
|
||||
|
||||
// 验证 set 函数被调用
|
||||
// Verify that the set function is called
|
||||
expect(mockSet).toHaveBeenCalled();
|
||||
|
||||
// 验证更新后的状态
|
||||
// Verify the updated status
|
||||
const updater = mockSet.mock.calls[0][0];
|
||||
const result = updater(initialState);
|
||||
|
||||
// 检查结果是否正确合并了对象
|
||||
// Check if the result is correct and the objects are merged.
|
||||
expect(result).toEqual({
|
||||
user: { name: 'Jane', age: 25 },
|
||||
settings: { theme: 'dark', notifications: true },
|
||||
|
||||
@@ -19,7 +19,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { createStorage, storage } from '../../src/utils/storage';
|
||||
import { useCollaborationStore } from '../../src/store/collaboration';
|
||||
|
||||
// 模拟 useCollaborationStore
|
||||
// Analog useCollaborationStore
|
||||
vi.mock('../../src/store/collaboration', () => ({
|
||||
useCollaborationStore: {
|
||||
getState: vi.fn().mockReturnValue({
|
||||
@@ -32,7 +32,7 @@ describe('storage utils', () => {
|
||||
let mockStorage: Storage;
|
||||
|
||||
beforeEach(() => {
|
||||
// 创建模拟的 Storage 对象
|
||||
// Create a simulated Storage object
|
||||
mockStorage = {
|
||||
getItem: vi.fn(),
|
||||
setItem: vi.fn(),
|
||||
@@ -55,19 +55,19 @@ describe('storage utils', () => {
|
||||
prefix,
|
||||
);
|
||||
|
||||
// 测试设置值
|
||||
// test settings
|
||||
proxy.testKey = 'testValue';
|
||||
expect(mockStorage.setItem).toHaveBeenCalledWith(
|
||||
`${prefix}.testKey`,
|
||||
'testValue',
|
||||
);
|
||||
|
||||
// 测试获取值
|
||||
// Test Get Value
|
||||
(mockStorage.getItem as any).mockReturnValueOnce('storedValue');
|
||||
expect(proxy.testKey).toBe('storedValue');
|
||||
expect(mockStorage.getItem).toHaveBeenCalledWith(`${prefix}.testKey`);
|
||||
|
||||
// 测试删除值
|
||||
// Test Delete Value
|
||||
delete proxy.testKey;
|
||||
expect(mockStorage.removeItem).toHaveBeenCalledWith(`${prefix}.testKey`);
|
||||
});
|
||||
@@ -76,22 +76,22 @@ describe('storage utils', () => {
|
||||
const target: Record<string, any> = {};
|
||||
const proxy = createStorage<Record<string, any>>(mockStorage, target);
|
||||
|
||||
// 设置字符串值应该成功
|
||||
// Setting string value should succeed
|
||||
proxy.key1 = 'value1';
|
||||
expect(mockStorage.setItem).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 注意:在实际代码中,设置非字符串值会返回 false,但不会抛出错误
|
||||
// 在测试中,我们只验证 setItem 没有被再次调用
|
||||
// Note: In actual code, setting a non-string value will return false, but no error will be thrown
|
||||
// In the test, we only verify that setItem is not called again
|
||||
try {
|
||||
// 这里可能会抛出错误,但我们不关心错误本身
|
||||
// Errors may be thrown here, but we don't care about the errors themselves
|
||||
proxy.key2 = 123 as any;
|
||||
// 如果没有抛出错误,我们期望 setItem 不会被再次调用
|
||||
// If no error is thrown, we expect that setItem will not be called again
|
||||
} catch (e) {
|
||||
// 如果抛出错误,我们也期望 setItem 不会被再次调用
|
||||
// If an error is thrown, we also expect that setItem will not be called again
|
||||
console.log('捕获到错误,但这是预期的行为');
|
||||
}
|
||||
|
||||
// 无论是否抛出错误,我们都期望 setItem 不会被再次调用
|
||||
// Whether an error is thrown or not, we expect that setItem will not be called again
|
||||
expect(mockStorage.setItem).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
@@ -114,17 +114,17 @@ describe('storage utils', () => {
|
||||
|
||||
it('设置 baseVersion 应该打印错误', () => {
|
||||
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {
|
||||
/* 空函数 */
|
||||
/* empty function */
|
||||
});
|
||||
|
||||
// 注意:在实际代码中,设置 baseVersion 会返回 false 并打印错误,但不会抛出错误
|
||||
// 在测试中,我们只验证 console.error 被调用
|
||||
// Note: In the actual code, setting baseVersion will return false and print an error, but no error will be thrown
|
||||
// In testing, we only verify that console.error is called
|
||||
try {
|
||||
// 这里可能会抛出错误,但我们不关心错误本身
|
||||
// Errors may be thrown here, but we don't care about the errors themselves
|
||||
storage.baseVersion = 'new-version';
|
||||
// 如果没有抛出错误,我们期望 console.error 被调用
|
||||
// If no error is thrown, we expect console.error to be called
|
||||
} catch (e) {
|
||||
// 如果抛出错误,我们也期望 console.error 被调用
|
||||
// If an error is thrown, we also expect console.error to be called
|
||||
console.log('捕获到错误,但这是预期的行为');
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import { UIToast } from '@coze-arch/bot-semi';
|
||||
|
||||
import { hasBraces, verifyBracesAndToast } from '../../src/utils/submit';
|
||||
|
||||
// 模拟 UIToast 和 I18n
|
||||
// Analog UIToast and I18n
|
||||
vi.mock('@coze-arch/bot-semi', () => ({
|
||||
UIToast: {
|
||||
warning: vi.fn(),
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('uniqMemoryList', () => {
|
||||
it('应该正确标记重复的键为 KEY_NAME_USED', () => {
|
||||
const list = [
|
||||
{ key: 'key1', value: 'value1' },
|
||||
{ key: 'key1', value: 'value2' }, // 重复的键
|
||||
{ key: 'key1', value: 'value2' }, // Duplicate key
|
||||
{ key: 'key3', value: 'value3' },
|
||||
];
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('uniqMemoryList', () => {
|
||||
|
||||
it('应该正确标记空键为 KEY_IS_NULL', () => {
|
||||
const list = [
|
||||
{ key: '', value: 'value1' }, // 空键
|
||||
{ key: '', value: 'value1' }, // empty key
|
||||
{ key: 'key2', value: 'value2' },
|
||||
{ key: 'key3', value: 'value3' },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user