Files
Edu/apps/teacher-portal/vitest.polyfills.ts
SpecialX 0b42302a64 docs(admin-portal): 新增 nextstep-v2.md 记录下游核查结果
v1 声称完成的下游工作经核查实际未完成:
- api-gateway: /api/admin/graphql 路由未注册,go vet 编译失败
- teacher-bff: resolver 已完成但 schema 未同步(命名空间 vs 扁平)
- iam: proto 缺 BatchGetUsers rpc 声明

v2 记录详细核查证据和修复要求
2026-07-14 08:26:27 +08:00

26 lines
959 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Vitest 前置 polyfills - 在 vitest.setup.ts 之前运行
*
* 必须独立文件vitest.setup.ts 顶部 import { server } 会触发
* handlers.ts → user.ts 的模块加载链user.ts 顶层调用 btoa() 处理
* 含中文字符的 mockUserInfojsdom 的 btoa 对非 Latin1 字符抛
* InvalidCharacterError。本文件无 import在 setupFiles 数组中
* 排在 vitest.setup.ts 之前,确保 polyfill 先生效。
*/
// btoa Unicode 兼容 polyfilljsdom 的 btoa 对非 Latin1 字符抛 InvalidCharacterError
// mockToken = btoa(JSON.stringify(mockUserInfo)) 含中文字符,需 UTF-8 安全编码
const originalBtoa = globalThis.btoa;
globalThis.btoa = (str: string): string => {
try {
return originalBtoa(str);
} catch {
const bytes = new TextEncoder().encode(str);
let binary = "";
for (const byte of bytes) {
binary += String.fromCharCode(byte);
}
return originalBtoa(binary);
}
};