fix: zero expired codex windows in backend, use /usage API as single frontend data source

This commit is contained in:
Ethan0x0000
2026-03-16 19:46:07 +08:00
parent aa5846b282
commit 7fde9ebbc2
6 changed files with 61 additions and 394 deletions

View File

@@ -198,7 +198,7 @@ describe('AccountUsageCell', () => {
expect(wrapper.text()).toContain('7d|77|300')
})
it('OpenAI OAuth 有现成快照时首屏先显示快照再加载 usage 覆盖', async () => {
it('OpenAI OAuth 有 codex 快照时仍然使用 /usage API 数据渲染', async () => {
getUsage.mockResolvedValue({
five_hour: {
utilization: 18,
@@ -254,8 +254,8 @@ describe('AccountUsageCell', () => {
await flushPromises()
// 始终拉 usagefetched data 优先显示(包含 window_stats
expect(getUsage).toHaveBeenCalledWith(2001)
// 单一数据源:始终使用 /usage API 返回值,忽略 codex 快照
expect(wrapper.text()).toContain('5h|18|900')
expect(wrapper.text()).toContain('7d|36|900')
})
@@ -326,7 +326,7 @@ describe('AccountUsageCell', () => {
// 手动刷新再拉一次
expect(getUsage).toHaveBeenCalledTimes(2)
expect(getUsage).toHaveBeenCalledWith(2010)
// fetched data 优先显示,包含 window_stats
// 单一数据源:始终使用 /usage API 值
expect(wrapper.text()).toContain('5h|18|900')
})
@@ -458,7 +458,7 @@ describe('AccountUsageCell', () => {
expect(wrapper.text()).toContain('5h|0|200')
})
it('OpenAI OAuth 已限额时首屏优先展示重新查询后的 usage而不是旧 codex 快照', async () => {
it('OpenAI OAuth 已限额时显示 /usage API 返回的限额数据', async () => {
getUsage.mockResolvedValue({
five_hour: {
utilization: 100,
@@ -515,7 +515,6 @@ describe('AccountUsageCell', () => {
expect(getUsage).toHaveBeenCalledWith(2004)
expect(wrapper.text()).toContain('5h|100|106540000')
expect(wrapper.text()).toContain('7d|100|106540000')
expect(wrapper.text()).not.toContain('5h|0|')
})
it('Key 账号会展示 today stats 徽章并带 A/U 提示', async () => {