diff --git a/src/renderer/src/components/settings/cloud-api/CloudApiKeysPane.test.tsx b/src/renderer/src/components/settings/cloud-api/CloudApiKeysPane.test.tsx index 903ce1ff0d6..c99a44680f2 100644 --- a/src/renderer/src/components/settings/cloud-api/CloudApiKeysPane.test.tsx +++ b/src/renderer/src/components/settings/cloud-api/CloudApiKeysPane.test.tsx @@ -3,7 +3,7 @@ // Enterprise audit log now, so this pane must never call an audit route (the control plane // refuses those without the entitlement) and must never show an error because of one. import { cleanup, render, screen, waitFor } from '@testing-library/react' -import { afterEach, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, expect, it, vi } from 'vitest' import type { CloudApiKeyList, CloudApiMe, @@ -12,12 +12,18 @@ import type { import { TooltipProvider } from '@/components/ui/tooltip' import { CloudApiKeysPane } from './CloudApiKeysPane' +beforeEach(() => { + vi.useFakeTimers({ now: NOW, toFake: ['Date'] }) +}) + afterEach(() => { cleanup() + vi.useRealTimers() vi.unstubAllGlobals() }) -const NOW = Date.now() +// A fixed clock, so "5 minutes ago" never depends on when the test runs. +const NOW = Date.UTC(2026, 10, 12, 17, 30) const ME: CloudApiMe = { accountId: 'org:acme', userId: 'u_ada', diff --git a/src/renderer/src/components/settings/enterprise/EnterpriseAuditLog.tsx b/src/renderer/src/components/settings/enterprise/EnterpriseAuditLog.tsx index 5a7d950a4d2..a93d6afb4df 100644 --- a/src/renderer/src/components/settings/enterprise/EnterpriseAuditLog.tsx +++ b/src/renderer/src/components/settings/enterprise/EnterpriseAuditLog.tsx @@ -158,8 +158,10 @@ function Filters({ value={filters.category ?? ALL} disabled={disabled} onValueChange={(value) => - // SAFETY: every option's value is ALL or a member of CLOUD_AUDIT_CATEGORIES. - onFilter({ ...filters, category: value === ALL ? null : (value as CloudAuditCategory) }) + onFilter({ + ...filters, + category: CLOUD_AUDIT_CATEGORIES.find((category) => category === value) ?? null + }) } >