mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 10:18:14 +00:00
fix(accounts): simplify codex free tier badges
This commit is contained in:
1 parent
154c7d0e9c
commit
72ea1fc9d6
11 files changed
+227
-96
No files matched your search
@@ -87,11 +87,11 @@ const groupedAccount: AccountData = {
|
||||
isDefault: true,
|
||||
successCount: 4,
|
||||
failureCount: 1,
|
||||
audience: 'personal',
|
||||
audienceLabel: 'Personal',
|
||||
detailLabel: 'Free',
|
||||
compactDetailLabel: 'Free',
|
||||
inlineLabel: 'Personal · Free',
|
||||
audience: 'free',
|
||||
audienceLabel: 'Free',
|
||||
detailLabel: null,
|
||||
compactDetailLabel: null,
|
||||
inlineLabel: 'Free',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -99,9 +99,11 @@ const groupedAccount: AccountData = {
|
||||
const groupedAccountWithProPersonal: AccountData = {
|
||||
...groupedAccount,
|
||||
variants: groupedAccount.variants?.map((variant) =>
|
||||
variant.audience === 'personal'
|
||||
variant.audience === 'free'
|
||||
? {
|
||||
...variant,
|
||||
audience: 'personal',
|
||||
audienceLabel: 'Personal',
|
||||
detailLabel: 'Pro',
|
||||
compactDetailLabel: 'Pro',
|
||||
inlineLabel: 'Personal · Pro',
|
||||
@@ -148,9 +150,7 @@ describe('AccountCard grouped quota tooltip', () => {
|
||||
/>
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByTitle('Business · Workspace 04a0f049 • Personal · Free')
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByTitle('Business · Workspace 04a0f049 • Free')).toBeInTheDocument();
|
||||
expect(screen.getByText('Biz')).toBeInTheDocument();
|
||||
|
||||
await userEvent.hover(screen.getByText('Business · Workspace 04a0f049'));
|
||||
@@ -164,7 +164,14 @@ describe('AccountCard grouped quota tooltip', () => {
|
||||
expect(tooltipContent?.className).toContain('text-popover-foreground');
|
||||
expect(tooltipContent?.className).toContain('max-w-[calc(100vw-2rem)]');
|
||||
|
||||
await userEvent.hover(screen.getByText('Personal · Free'));
|
||||
const freeLabels = screen.getAllByText('Free');
|
||||
const quotaLabel = freeLabels[freeLabels.length - 1];
|
||||
expect(quotaLabel).toBeDefined();
|
||||
if (!quotaLabel) {
|
||||
throw new Error('Expected a Free quota label');
|
||||
}
|
||||
|
||||
await userEvent.hover(quotaLabel);
|
||||
const personalPlan = (await screen.findAllByText('Plan: free')).find((node) =>
|
||||
node.closest('[data-slot="tooltip-content"]')
|
||||
);
|
||||
@@ -193,6 +200,6 @@ describe('AccountCard grouped quota tooltip', () => {
|
||||
|
||||
expect(screen.getByTitle('Business · Workspace 04a0f049 • Personal · Pro')).toBeInTheDocument();
|
||||
expect(screen.getByText('Personal · Pro')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Personal · Free')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Free')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -57,7 +57,7 @@ describe('AccountSurfaceCard', () => {
|
||||
expect(screen.getByText('pro')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows both personal identity and free-tier detail for compact Codex cards', () => {
|
||||
it('shows free Codex accounts as a single standalone audience badge', () => {
|
||||
render(
|
||||
<AccountSurfaceCard
|
||||
mode="compact"
|
||||
@@ -70,12 +70,12 @@ describe('AccountSurfaceCard', () => {
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Pers')).toBeInTheDocument();
|
||||
expect(screen.getByTitle('Personal')).toBeInTheDocument();
|
||||
expect(screen.getByText('Free')).toBeInTheDocument();
|
||||
expect(screen.getByTitle('Free')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Pers')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps richer token-derived Codex personal detail when live quota planType is coarser', () => {
|
||||
it('keeps the simplified personal audience when live quota planType is coarser', () => {
|
||||
render(
|
||||
<AccountSurfaceCard
|
||||
mode="compact"
|
||||
@@ -89,7 +89,24 @@ describe('AccountSurfaceCard', () => {
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Pro')).toBeInTheDocument();
|
||||
expect(screen.getByText('Pers')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Free')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('falls back to a single free badge when Codex quota detects a free plan', () => {
|
||||
render(
|
||||
<AccountSurfaceCard
|
||||
mode="compact"
|
||||
provider="codex"
|
||||
accountId="user@example.com"
|
||||
email="user@example.com"
|
||||
displayEmail="user@example.com"
|
||||
quota={createCodexQuotaResult({ planType: 'free' })}
|
||||
showQuota={false}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Free')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Pers')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -39,14 +39,33 @@ describe('account identity presentation', () => {
|
||||
).toBe('Business · Workspace 04a0f049');
|
||||
});
|
||||
|
||||
it('formats personal codex plans deliberately instead of leaking raw free suffixes', () => {
|
||||
it('classifies free codex accounts as a standalone audience', () => {
|
||||
const presentation = getAccountIdentityPresentation(
|
||||
'kaidu.kd@gmail.com',
|
||||
'kaidu.kd@gmail.com',
|
||||
'codex-kaidu.kd@gmail.com-free.json'
|
||||
);
|
||||
|
||||
expect(presentation.audience).toBe('free');
|
||||
expect(presentation.audienceLabel).toBe('Free');
|
||||
expect(presentation.detailLabel).toBeNull();
|
||||
expect(
|
||||
formatAccountDisplayName(
|
||||
'kaidu.kd@gmail.com',
|
||||
'kaidu.kd@gmail.com',
|
||||
'codex-kaidu.kd@gmail.com-free.json'
|
||||
)
|
||||
).toBe('kaidu.kd@gmail.com (Personal · Free)');
|
||||
).toBe('kaidu.kd@gmail.com (Free)');
|
||||
});
|
||||
|
||||
it('collapses paid codex personal plans into a single personal audience label', () => {
|
||||
expect(
|
||||
formatAccountDisplayName(
|
||||
'kaidu.kd@gmail.com',
|
||||
'kaidu.kd@gmail.com',
|
||||
'codex-kaidu.kd@gmail.com-plus.json'
|
||||
)
|
||||
).toBe('kaidu.kd@gmail.com (Personal)');
|
||||
});
|
||||
|
||||
it('leaves plain accounts without inferred state untouched', () => {
|
||||
|
||||
Reference in new issue
Block a user