fix(vscode): support Codex business spend limits

This commit is contained in:
Bohdan Triapitsyn
2026-07-29 18:32:27 +03:00
parent 4a56527d1b
commit d5e63467cf
2 changed files with 47 additions and 0 deletions
@@ -7,6 +7,7 @@ import fs from 'node:fs';
// configured and proceed straight to fetch.
const ORIGINAL_FS = { ...fs };
const AUTH = JSON.stringify({
openai: { access: 'test-token' },
crof: { key: 'test-token' },
neuralwatt: { key: 'test-token' },
});
@@ -112,6 +113,31 @@ describe('Crof quota provider (VS Code parity)', () => {
});
});
describe('Codex quota provider (VS Code parity)', () => {
test('surfaces spend_control individual limit for business accounts', async () => {
stubFetchReturning(() => Promise.resolve(mockResponse({
plan_type: 'business',
rate_limit: null,
credits: { has_credits: true, unlimited: false, balance: null },
spend_control: {
individual_limit: {
limit: '7500',
used: '2674.8724080324173',
remaining: '4825.127591967583',
used_percent: 36,
remaining_percent: 64,
},
},
})));
const result = await fetchQuotaForProvider('codex');
assert.equal(result.ok, true);
assert.equal(result.usage!.windows.credits!.usedPercent, 36);
assert.equal(result.usage!.windows.credits!.valueLabel, '2675 / 7500 used');
});
});
describe('NeuralWatt quota provider (VS Code parity)', () => {
test('builds subscription window keyed by plan name (windowSeconds null)', async () => {
stubFetchReturning(() => Promise.resolve(mockResponse(DOCUMENTED_SUBSCRIPTION_PAYLOAD)));