From a99ae6d512e1b34150fba2de7efdda287fb25548 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 12 Nov 2026 20:52:30 -0800 Subject: [PATCH] fix(cloud): ENTERPRISE-AUDIT lint gates: fixture data filename, no cast in the category filter, fixed clock in the pane test --- .../settings/cloud-api/CloudApiKeysPane.test.tsx | 10 ++++++++-- .../settings/enterprise/EnterpriseAuditLog.tsx | 6 ++++-- .../enterprise/EnterpriseSettingsView.fixture.tsx | 2 +- .../enterprise/EnterpriseSettingsView.test.tsx | 2 +- ...se-fixture-data.ts => enterprise-audit.fixtures.ts} | 0 5 files changed, 14 insertions(+), 6 deletions(-) rename src/renderer/src/components/settings/enterprise/{enterprise-fixture-data.ts => enterprise-audit.fixtures.ts} (100%) 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 + }) } >