chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -26,10 +26,10 @@ import {
import { useAuthStore } from '../../src/auth';
// 模拟全局变量
// simulated global variable
vi.stubGlobal('IS_DEV_MODE', false);
// 模拟依赖
// simulated dependency
vi.mock('@coze-arch/bot-api', () => ({
PlaygroundApi: {
DraftBotCollaboration: vi.fn().mockResolvedValue({
@@ -75,7 +75,7 @@ vi.mock('@coze-arch/bot-api', () => ({
},
}));
// 模拟 logger
// Analog logger
vi.mock('@coze-arch/logger', () => ({
reporter: {
error: vi.fn(),
@@ -85,7 +85,7 @@ vi.mock('@coze-arch/logger', () => ({
},
}));
// 模拟 CustomError
// Simulate CustomError
vi.mock('@coze-arch/bot-error', () => ({
CustomError: vi.fn(),
}));
@@ -107,7 +107,7 @@ describe('auth', () => {
beforeEach(() => {
vi.clearAllMocks();
// 重置 store 状态
// Reset store state
act(() => {
useAuthStore.setState({
collaboratorsMap: {
@@ -115,12 +115,12 @@ describe('auth', () => {
[ResourceType.Workflow]: {},
[ResourceType.Intelligence]: {},
} as any,
// 确保 getCachedCollaborators 方法返回一个空数组
// Ensure getCachedCollaborators method returns an empty array
getCachedCollaborators: vi.fn().mockReturnValue([]),
});
});
// 模拟 API 响应
// Simulate API response
(PlaygroundApi.DraftBotCollaboration as any).mockResolvedValue({
data: mockCreators,
});
@@ -149,7 +149,7 @@ describe('auth', () => {
it('当缓存中有协作者时应该返回缓存的协作者', () => {
const { result } = renderHook(() => useAuthStore());
// 先设置缓存
// Set up the cache first
act(() => {
useAuthStore.setState({
collaboratorsMap: {
@@ -267,7 +267,7 @@ describe('auth', () => {
it('当资源类型为 Bot 时应该调用 patPermissionApi.AddCollaborator', async () => {
const { result } = renderHook(() => useAuthStore());
// 确保 getCachedCollaborators 返回一个空数组
// Make sure getCachedCollaborators return an empty array
vi.spyOn(result.current, 'getCachedCollaborators').mockReturnValue([]);
(patPermissionApi.AddCollaborator as any).mockResolvedValue({});
@@ -380,7 +380,7 @@ describe('auth', () => {
it('当资源类型为 Bot 时应该调用 patPermissionApi.AddCollaborator', async () => {
const { result } = renderHook(() => useAuthStore());
// 确保 getCachedCollaborators 返回一个空数组
// Make sure getCachedCollaborators return an empty array
vi.spyOn(result.current, 'getCachedCollaborators').mockReturnValue([]);
const mockUsers = [

View File

@@ -21,11 +21,11 @@ import { workflowApi } from '@coze-arch/bot-api';
import { useSpaceGrayStore, TccKey } from '../../src/space-gray';
// 模拟全局变量
// simulated global variable
vi.stubGlobal('IS_DEV_MODE', false);
vi.stubGlobal('IS_BOT_OP', false);
// 模拟依赖
// simulated dependency
vi.mock('@coze-arch/logger', () => ({
reporter: {
error: vi.fn(),
@@ -51,7 +51,7 @@ describe('space-gray', () => {
beforeEach(() => {
vi.clearAllMocks();
// 重置 store 状态
// Reset store state
act(() => {
useSpaceGrayStore.setState({
spaceId: '',
@@ -59,7 +59,7 @@ describe('space-gray', () => {
});
});
// 模拟 API 响应
// Simulate API response
(workflowApi.GetWorkflowGrayFeature as any).mockResolvedValue({
data: mockFeatureItems,
});
@@ -104,7 +104,7 @@ describe('space-gray', () => {
});
it('当 IS_BOT_OP 为 true 时应该调用 OPGetWorkflowGrayFeature API', async () => {
// 设置 IS_BOT_OP true
// Set IS_BOT_OP to true
vi.stubGlobal('IS_BOT_OP', true);
const { result } = renderHook(() => useSpaceGrayStore());
@@ -120,22 +120,22 @@ describe('space-gray', () => {
expect(result.current.spaceId).toBe(mockSpaceId);
expect(result.current.grayFeatureItems).toEqual(mockFeatureItems);
// 恢复 IS_BOT_OP false
// Restore IS_BOT_OP to false
vi.stubGlobal('IS_BOT_OP', false);
});
it('当 spaceId 与缓存的相同时不应该调用 API', async () => {
const { result } = renderHook(() => useSpaceGrayStore());
// 先加载一次
// Load once first
await act(async () => {
await result.current.load(mockSpaceId);
});
// 清除之前的调用记录
// Clear previous call history
vi.clearAllMocks();
// 再次加载相同的 spaceId
// Load the same spaceId again.
await act(async () => {
await result.current.load(mockSpaceId);
});
@@ -167,7 +167,7 @@ describe('space-gray', () => {
it('当特性在灰度列表中且 in_gray 为 true 时应该返回 true', async () => {
const { result } = renderHook(() => useSpaceGrayStore());
// 先加载灰度特性
// Load grey release feature first
await act(async () => {
await result.current.load(mockSpaceId);
});
@@ -193,7 +193,7 @@ describe('space-gray', () => {
const { result } = renderHook(() => useSpaceGrayStore());
// 先加载灰度特性
// Load grey release feature first
await act(async () => {
await result.current.load(mockSpaceId);
});
@@ -208,12 +208,12 @@ describe('space-gray', () => {
it('当特性不在灰度列表中时应该返回 false', async () => {
const { result } = renderHook(() => useSpaceGrayStore());
// 先加载灰度特性
// Load grey release feature first
await act(async () => {
await result.current.load(mockSpaceId);
});
// 使用一个不存在的 key
// Use a non-existent key
const isHit = result.current.isHitSpaceGray('NonExistentKey' as TccKey);
expect(isHit).toBe(false);

View File

@@ -16,7 +16,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
// 导入被测试的模块
// Import the tested module
import localForage from 'localforage';
import { getStorage, clearStorage } from '../../src/utils/get-storage';