From 5aa1632011a8ca326dcc24784d700d8cf7d68e00 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 24 Jul 2026 20:11:59 -0700 Subject: [PATCH] test(data-drains): cover the migrated detail and create surfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Executes the two new views rather than reasoning about them, and locks the behaviours this migration could silently drop: - the detail carries every column the table used to show (source, destination, cadence, last run) and never renders credentials - run sizes report sub-kilobyte writes instead of flooring to '0 Bytes', and a multi-gigabyte run stays in GB - Run now stays disabled while a drain is disabled, as the row menu did - delete leaves only after the request resolves, and stays put on failure - create gates on name plus a complete destination, sends the right destination branch, and toasts on failure - every labelled field in all seven destination forms resolves to a real control id, and every select carries an accessible name The first run caught a defect: dropping toLowerCase from humanizeConfigKey left keys rendering Title Case ('Force Path Style') while the TSDoc still promised sentence case. Now sentence case with initialisms preserved — 'Access key ID', 'Service account JSON'. --- .../components/data-drain-create.test.tsx | 315 ++++++++++++++++ .../components/data-drain-detail.test.tsx | 351 ++++++++++++++++++ .../components/data-drain-detail.tsx | 24 +- 3 files changed, 687 insertions(+), 3 deletions(-) create mode 100644 apps/sim/ee/data-drains/components/data-drain-create.test.tsx create mode 100644 apps/sim/ee/data-drains/components/data-drain-detail.test.tsx diff --git a/apps/sim/ee/data-drains/components/data-drain-create.test.tsx b/apps/sim/ee/data-drains/components/data-drain-create.test.tsx new file mode 100644 index 00000000000..d235c93bd21 --- /dev/null +++ b/apps/sim/ee/data-drains/components/data-drain-create.test.tsx @@ -0,0 +1,315 @@ +/** + * @vitest-environment jsdom + */ +import { act, type ReactNode } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { DESTINATION_TYPES } from '@/lib/data-drains/types' + +const { mockToastError, mockToastSuccess, mockUseCreateDataDrain, mockGuardBack } = vi.hoisted( + () => ({ + mockToastError: vi.fn(), + mockToastSuccess: vi.fn(), + mockUseCreateDataDrain: vi.fn(), + mockGuardBack: vi.fn((onLeave: () => void) => onLeave()), + }) +) + +interface SelectProps { + value?: string + onChange?: (value: string) => void + options?: { value: string; label: string }[] + 'aria-label'?: string +} + +vi.mock('@sim/emcn', () => ({ + // A real