Files
SubTracker/apps/web/tests/unit/composables/api-summary-timeout.test.ts
SmileQWQ dc5bade56a feat: sync lite locale and notification surfaces
## 中文
- 接入 shared locale-core、i18n 导出与 /api/v1/app/locale,让 lite 支持中英文切换与请求级语言透传。
- 为 App 壳子、登录页、设置页和离散消息接入本地化文案,并恢复 lite 的品牌与 Worker 提示语境。
- 同步通知模板、Apprise/Bark/NotifyX、Telegram MarkdownV2 与通知渠道设置面,保留 Worker 下仅支持 Resend、Webhook/Gotify 禁用忽略 SSL 的边界。

## English
- Add shared locale-core exports, i18n helpers, and /api/v1/app/locale so lite can switch locales and send request-scoped locale headers.
- Localize the app shell, login page, settings page, and discrete messages while restoring lite branding and Worker-specific wording.
- Sync notification templates, Apprise/Bark/NotifyX, Telegram MarkdownV2, and notification settings surfaces while keeping the Worker-only Resend and ignore-SSL restrictions.
2026-05-30 15:30:16 +08:00

84 lines
1.9 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest'
const { postMock, getMock, requestUseMock, responseUseMock } = vi.hoisted(() => ({
postMock: vi.fn(),
getMock: vi.fn(),
requestUseMock: vi.fn(),
responseUseMock: vi.fn()
}))
vi.mock('axios', () => ({
default: {
create: vi.fn(() => ({
post: postMock,
get: getMock,
patch: vi.fn(),
put: vi.fn(),
delete: vi.fn(),
interceptors: {
request: {
use: requestUseMock
},
response: {
use: responseUseMock
}
}
}))
}
}))
vi.mock('@/utils/auth-storage', () => ({
clearAuthSession: vi.fn(),
getStoredToken: vi.fn(() => null)
}))
vi.mock('@/utils/api-base', () => ({
getApiBaseUrl: vi.fn(() => '/api')
}))
vi.mock('@/utils/api-error', () => ({
normalizeApiErrorMessage: vi.fn((error: { message?: string }) => error.message || '请求失败')
}))
import { api } from '../../../src/composables/api'
describe('api dashboard summary timeout', () => {
beforeEach(() => {
postMock.mockReset()
getMock.mockReset()
requestUseMock.mockReset()
responseUseMock.mockReset()
})
it('uses a dedicated longer timeout when generating dashboard summary', async () => {
postMock.mockResolvedValueOnce({
data: {
data: {
scope: 'dashboard-overview',
status: 'success',
content: '## 总览',
previewContent: '总览',
errorMessage: null,
generatedAt: '2026-05-04T00:00:00.000Z',
updatedAt: '2026-05-04T00:00:00.000Z',
sourceDataHash: 'hash',
fromCache: false,
isStale: false,
canGenerate: true,
needsGeneration: false
}
}
})
await api.generateDashboardAiSummary()
expect(postMock).toHaveBeenCalledWith(
'/ai/summary/dashboard/generate',
undefined,
expect.objectContaining({
timeout: 65000
})
)
})
})