include remaining workspace changes

This commit is contained in:
cita
2026-03-16 19:29:26 +08:00
parent 52441f2634
commit bec0457a92
15 changed files with 419 additions and 93 deletions
+43
View File
@@ -317,6 +317,49 @@ describe('DownstreamKeys page', () => {
}
});
it('does not refetch drawer trend repeatedly after a trend error toast', async () => {
apiMock.getDownstreamApiKeyTrend
.mockRejectedValueOnce(new Error('function date_trunc(unknown, text) does not exist'))
.mockResolvedValue({
success: true,
buckets: [
{ startUtc: '2026-03-15T08:00:00.000Z', totalRequests: 2, totalTokens: 1200, totalCost: 0.12, successRate: 100 },
],
});
let root: ReturnType<typeof create> | null = null;
try {
await act(async () => {
root = create(
<MemoryRouter initialEntries={['/downstream-keys']}>
<ToastProvider>
<DownstreamKeys />
</ToastProvider>
</MemoryRouter>,
);
});
await flushMicrotasks();
const row = root!.root.findAll((node) => node.type === 'tr' && typeof node.props.onClick === 'function')[0];
await act(async () => {
row.props.onClick();
});
await flushMicrotasks();
await flushMicrotasks();
expect(apiMock.getDownstreamApiKeyOverview).toHaveBeenCalledTimes(1);
expect(apiMock.getDownstreamApiKeyTrend).toHaveBeenCalledTimes(1);
const toastMessages = root!.root.findAll((node) => {
if (typeof node.props.className !== 'string') return false;
return node.props.className.includes('toast-error') && collectText(node).includes('function date_trunc(unknown, text) does not exist');
});
expect(toastMessages).toHaveLength(1);
} finally {
root?.unmount();
}
});
it('separates exact models from group routes in advanced config and uses single-column layout', async () => {
let root: ReturnType<typeof create> | null = null;
try {
+1 -1
View File
@@ -1031,7 +1031,7 @@ export default function TokenRoutes() {
className="btn btn-ghost"
style={{ border: '1px solid var(--color-border)', padding: '8px 14px' }}
>
{tr('显示 0 通道路由')}
{showZeroChannelRoutes ? tr('隐藏 0 通道路由') : tr('显示 0 通道路由')}
</button>
</div>
@@ -326,6 +326,7 @@ describe('TokenRoutes grouped source models', () => {
});
await flushMicrotasks();
expect(collectText(root.root)).toContain('隐藏 0 通道路由');
expect(collectText(root.root)).toContain('gpt-5.2-codex');
expect(collectText(root.root)).toContain('claude-opus-4-6');
expect(collectText(root.root)).toContain('未生成');