Files
SubTracker/apps/web/tests/unit/utils/api-error.test.ts
SmileQWQ ab924fed91 perf: consolidate worker lite optimizations
- combine the worker-lite performance and reliability work into one coherent commit for the cf-worker branch
- reduce duplicate submissions and repeated settings fetches on the frontend, add clearer saving/recognition states, and keep Worker-limit error messaging focused on real failures
- refactor worker hot paths around D1/KV usage with short-lived caching, lighter settings/auth access, lazy Prisma creation, slimmer statistics/calendar queries, and safer exchange-rate reads
- simplify logo search and remote-logo handling for Lite constraints, keep cron and notification flows aligned with Worker Free limits, and preserve current Lite-specific UX decisions
- remove unsupported Prisma interactive transactions for D1, batch Wallos import writes, chunk D1 tag joins, and fix Cloudflare-specific issues such as KV minimum TTL handling and remote reset execution on Windows
- include the latest Lite-side cleanup: route-level tags caching, skipping unnecessary tag reads in statistics when tag budgets are disabled, removing calendar adjacent-month prefetching, and executing remote reset SQL through a temp file
2026-04-22 23:47:44 +08:00

38 lines
956 B
TypeScript

import { describe, expect, it } from 'vitest'
import { normalizeApiErrorMessage } from '@/utils/api-error'
describe('normalizeApiErrorMessage', () => {
it('converts worker cpu limit errors to a clearer Worker limit hint', () => {
expect(
normalizeApiErrorMessage({
message: 'Worker exceeded CPU time limit.',
response: {
status: 503
}
})
).toContain('Cloudflare Worker 免费版限制')
})
it('adds a Worker limit hint for generic 503 errors', () => {
expect(
normalizeApiErrorMessage({
message: 'Request failed with status code 503',
response: {
status: 503
}
})
).toContain('服务暂时不可用')
})
it('keeps non-503 errors unchanged', () => {
expect(
normalizeApiErrorMessage({
message: '字段校验失败',
response: {
status: 400
}
})
).toBe('字段校验失败')
})
})