mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 08:18:04 +00:00
Merge pull request #1425 from kaitranntt/codex/fix-unvalidated-codex-quota-labels
fix(cliproxy): sanitize Codex quota labels
This commit is contained in:
5 files changed
+129
-11
No files matched your search
@@ -84,3 +84,48 @@ describe('cliproxy quota subcommand failure formatting', () => {
|
||||
expect(resolveDisplayedTier('pro', 'unknown')).toBe('pro');
|
||||
});
|
||||
});
|
||||
|
||||
describe('cliproxy quota subcommand Codex label formatting', () => {
|
||||
it('falls back to the cached window label for invalid Codex feature labels', async () => {
|
||||
const { getCodexWindowDisplayLabel } = await loadQuotaCommandTestExports();
|
||||
|
||||
const cases = [
|
||||
{ featureLabel: '', cadence: '5h', expected: 'Codex Spark (5h)' },
|
||||
{ featureLabel: ' ', cadence: 'weekly', expected: 'Codex Spark (weekly)' },
|
||||
{
|
||||
featureLabel: '\u001b[2J\u001b]52;c;payload\u0007',
|
||||
cadence: '5h',
|
||||
expected: 'Codex Spark (5h)',
|
||||
},
|
||||
{ featureLabel: { unexpected: true }, cadence: '5h', expected: 'Codex Spark (5h)' },
|
||||
] as const;
|
||||
|
||||
for (const { featureLabel, cadence, expected } of cases) {
|
||||
const label = getCodexWindowDisplayLabel({
|
||||
label: 'GPT-5.3-Codex-Spark',
|
||||
resetAfterSeconds: 3600,
|
||||
category: 'additional',
|
||||
cadence,
|
||||
featureLabel,
|
||||
} as never);
|
||||
|
||||
expect(label).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
it('removes terminal control characters from cached Codex feature labels', async () => {
|
||||
const { getCodexWindowDisplayLabel } = await loadQuotaCommandTestExports();
|
||||
|
||||
const label = getCodexWindowDisplayLabel({
|
||||
label: 'ignored',
|
||||
resetAfterSeconds: 3600,
|
||||
category: 'additional',
|
||||
cadence: 'weekly',
|
||||
featureLabel: '\u001b[2JGPT-5.3-Codex-Spark\u001b]52;c;payload\u0007',
|
||||
});
|
||||
|
||||
expect(label).toBe('Codex Spark (weekly)');
|
||||
expect(label).not.toContain('\u001b');
|
||||
expect(label).not.toContain('\u0007');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user