Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

chore(frontend): remove low-signal unit tests (#8815)

Andrew Huang6e24de3b4b1e
diff --git a/frontend/src/components/analytics/experiments/signupFlow/signupExperimentConfig.test.ts b/frontend/src/components/analytics/experiments/signupFlow/signupExperimentConfig.test.ts
deleted file mode 100644
index 22848488db..0000000000
--- a/frontend/src/components/analytics/experiments/signupFlow/signupExperimentConfig.test.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import { resolveSignupFlowVariant, SignupFlowVariant } from "./signupExperimentConfig";
-
-describe("resolveSignupFlowVariant", () => {
- it("keeps assigned experiment variants sticky", () => {
- expect(resolveSignupFlowVariant("control")).toEqual({
- variant: SignupFlowVariant.Control,
- shouldPersist: true
- });
- expect(resolveSignupFlowVariant("test")).toEqual({
- variant: SignupFlowVariant.DashboardPreview,
- shouldPersist: true
- });
- });
-
- it("falls back without persisting inactive or unavailable flags", () => {
- [false, undefined, "unexpected-variant"].forEach((value) => {
- expect(resolveSignupFlowVariant(value)).toEqual({
- variant: SignupFlowVariant.Control,
- shouldPersist: false
- });
- });
- });
-});
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/azure-sql-database-contract.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/azure-sql-database-contract.test.ts
deleted file mode 100644
index a44b4a7a4b..0000000000
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/azure-sql-database-contract.test.ts
+++ /dev/null
@@ -1,141 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
-
-import {
- azureSqlCreateFormSchema,
- getAzureSqlCreateDefaultValues,
- getAzureSqlCreatePayload,
- getAzureSqlEditDefaultValues,
- getAzureSqlEditPayload,
- normalizeAzureSqlGatewayValueForMode
-} from "./providerDefinitions/azureSqlDatabaseContract";
-import type {
- TCreateDynamicSecretProviderFormContext,
- TEditDynamicSecretProviderFormContext
-} from "./types";
-
-const environment = { id: "env-id", name: "Development", slug: "dev", position: 1 };
-const createContext: TCreateDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environments: [environment],
- isSingleEnvironmentMode: true
-};
-const inputs = {
- host: "sql.example.com",
- port: 1433,
- database: "application",
- username: "admin",
- password: "masked-or-new-password",
- masterCreationStatement: "create login",
- creationStatement: "create user",
- revocationStatement: "drop user",
- renewStatement: "",
- sslEnabled: true,
- sslRejectUnauthorized: true,
- ca: "certificate",
- gatewayId: "gateway",
- gatewayPoolId: "pool",
- passwordRequirements: {
- length: 12,
- required: { lowercase: 1, uppercase: 1, digits: 1, symbols: 1 },
- allowedSymbols: "-_"
- }
-};
-const editContext: TEditDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environment: "dev",
- dynamicSecret: {
- id: "dynamic-secret-id",
- name: "azure-sql",
- type: DynamicSecretProviders.AzureSqlDatabase,
- createdAt: "2026-01-01",
- updatedAt: "2026-01-01",
- defaultTTL: "1h",
- maxTTL: "24h",
- usernameTemplate: null,
- metadata: [{ key: "owner", value: "platform" }],
- inputs: {
- ...inputs,
- password: "********",
- ca: "********",
- gatewayId: null,
- gatewayPoolId: null
- }
- }
-};
-
-describe("Azure SQL Database provider contract", () => {
- it("hydrates defaults and preserves masked edit values", () => {
- const create = getAzureSqlCreateDefaultValues(createContext);
- assert.equal(create.inputs.port, 1433);
- assert.equal(create.inputs.passwordRequirements?.length, 48);
- assert.deepEqual(create.environment, environment);
-
- const edit = getAzureSqlEditDefaultValues(editContext);
- assert.equal(edit.inputs.password, "********");
- assert.equal(edit.inputs.ca, "********");
- assert.equal(edit.inputs.gatewayId, null);
- assert.deepEqual(edit.metadata, [{ key: "owner", value: "platform" }]);
- });
-
- it("validates password requirement totals against the configured length", () => {
- const defaults = getAzureSqlCreateDefaultValues(createContext);
- const parsed = azureSqlCreateFormSchema.safeParse({
- ...defaults,
- name: "azure-sql",
- inputs: {
- ...inputs,
- passwordRequirements: {
- length: 2,
- required: { lowercase: 1, uppercase: 1, digits: 1, symbols: 0 }
- }
- }
- });
- assert.equal(parsed.success, false);
- if (!parsed.success) {
- assert.equal(
- parsed.error.issues.at(-1)?.message,
- "Sum of required characters cannot exceed the total length"
- );
- }
- });
-
- it("adds the master database and preserves metadata/template create semantics", () => {
- const defaults = getAzureSqlCreateDefaultValues(createContext);
- const payload = getAzureSqlCreatePayload(
- { ...defaults, name: "azure-sql", metadata: [{ key: "owner", value: "platform" }], inputs },
- createContext
- );
- assert.equal(payload.provider.inputs.masterDatabase, "master");
- assert.equal(payload.usernameTemplate, undefined);
- assert.deepEqual(payload.metadata, [{ key: "owner", value: "platform" }]);
- });
-
- it("keeps edit gateway nulls, rename behavior, and masked secrets", () => {
- const values = getAzureSqlEditDefaultValues(editContext);
- const payload = getAzureSqlEditPayload({ ...values, name: "renamed-azure-sql" }, editContext);
- const payloadInputs = payload.data.inputs as {
- masterDatabase: string;
- password: string;
- ca: string;
- gatewayId: null;
- gatewayPoolId: null;
- };
- assert.equal(payloadInputs.masterDatabase, "master");
- assert.equal(payloadInputs.password, "********");
- assert.equal(payloadInputs.ca, "********");
- assert.equal(payloadInputs.gatewayId, null);
- assert.equal(payloadInputs.gatewayPoolId, null);
- assert.equal(payload.data.newName, "renamed-azure-sql");
- assert.equal(payload.data.usernameTemplate, null);
- });
-
- it("normalizes cleared gateway values by mode", () => {
- assert.equal(normalizeAzureSqlGatewayValueForMode("create", null), undefined);
- assert.equal(normalizeAzureSqlGatewayValueForMode("edit", null), null);
- });
-});
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/clickhouse-contract.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/clickhouse-contract.test.ts
deleted file mode 100644
index 6247b1d387..0000000000
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/clickhouse-contract.test.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
-
-import {
- clickHouseCreateFormSchema,
- getClickHouseCreateDefaultValues,
- getClickHouseCreatePayload,
- getClickHouseEditDefaultValues,
- getClickHouseEditPayload
-} from "./providerDefinitions/clickHouseContract";
-import type {
- TCreateDynamicSecretProviderFormContext,
- TEditDynamicSecretProviderFormContext
-} from "./types";
-
-const environment = { id: "env-id", name: "Development", slug: "dev", position: 1 };
-const createContext: TCreateDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environments: [environment],
- isSingleEnvironmentMode: true
-};
-
-describe("ClickHouse dynamic-secret provider contract", () => {
- it("preserves create defaults, metadata, and exact payload", () => {
- const defaults = getClickHouseCreateDefaultValues(createContext);
- assert.equal(defaults.inputs.port, 8123);
- assert.equal(typeof defaults.inputs.port, "number");
- assert.equal(defaults.inputs.database, "default");
- assert.deepEqual(defaults.inputs.passwordRequirements?.required, {
- lowercase: 1,
- uppercase: 1,
- digits: 1,
- symbols: 1
- });
-
- const values = {
- ...defaults,
- name: "clickhouse-secret",
- metadata: [{ key: "owner", value: "platform" }],
- inputs: {
- ...defaults.inputs,
- host: "clickhouse.example.com",
- username: "admin",
- password: "password"
- }
- };
- assert.equal(clickHouseCreateFormSchema.safeParse(values).success, true);
- const payload = getClickHouseCreatePayload(values, createContext);
- assert.equal(payload.provider.type, DynamicSecretProviders.Clickhouse);
- assert.equal(payload.provider.inputs.port, 8123);
- assert.equal(typeof payload.provider.inputs.port, "number");
- assert.equal(payload.environmentSlug, "dev");
- assert.deepEqual(payload.metadata, [{ key: "owner", value: "platform" }]);
- assert.equal(payload.usernameTemplate, undefined);
- });
-
- it("rejects the browser string regression for numeric inputs", () => {
- const defaults = getClickHouseCreateDefaultValues(createContext);
- const result = clickHouseCreateFormSchema.safeParse({
- ...defaults,
- name: "clickhouse-secret",
- inputs: {
- ...defaults.inputs,
- host: "clickhouse.example.com",
- port: "8123",
- username: "admin",
- password: "password"
- }
- });
-
- assert.equal(result.success, false);
- if (!result.success) {
- assert.deepEqual(result.error.issues[0]?.path, ["inputs", "port"]);
- }
- });
-
- it("preserves password-policy messages", () => {
- const defaults = getClickHouseCreateDefaultValues(createContext);
- const result = clickHouseCreateFormSchema.safeParse({
- ...defaults,
- name: "clickhouse-secret",
- inputs: {
- ...defaults.inputs,
- host: "clickhouse.example.com",
- username: "admin",
- password: "password",
- passwordRequirements: {
- ...defaults.inputs.passwordRequirements,
- length: 2
- }
- }
- });
- assert.equal(result.success, false);
- if (!result.success) {
- assert.equal(
- result.error.issues[0]?.message,
- "Sum of required characters cannot exceed the total length"
- );
- }
- });
-
- it("hydrates masked credentials and normalizes cleared edit gateways to null", () => {
- const context: TEditDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environment: "dev",
- dynamicSecret: {
- id: "dynamic-secret-id",
- name: "existing-clickhouse",
- type: DynamicSecretProviders.Clickhouse,
- createdAt: "2026-01-01T00:00:00.000Z",
- updatedAt: "2026-01-01T00:00:00.000Z",
- defaultTTL: "1h",
- maxTTL: "24h",
- usernameTemplate: null,
- metadata: [{ key: "owner", value: "platform" }],
- inputs: {
- host: "clickhouse.example.com",
- port: 8123,
- database: "default",
- username: "admin",
- password: "********",
- ca: "********",
- creationStatement: "CREATE USER '{{username}}'",
- revocationStatement: "DROP USER '{{username}}'"
- }
- }
- };
- const defaults = getClickHouseEditDefaultValues(context);
- assert.equal(defaults.inputs.password, "********");
- assert.equal(defaults.inputs.ca, "********");
- const payload = getClickHouseEditPayload({ ...defaults, name: "renamed-clickhouse" }, context);
- assert.equal(payload.data.newName, "renamed-clickhouse");
- assert.equal((payload.data.inputs as { password: string }).password, "********");
- assert.equal((payload.data.inputs as { ca: string }).ca, "********");
- assert.equal((payload.data.inputs as { gatewayId: null }).gatewayId, null);
- assert.equal((payload.data.inputs as { gatewayPoolId: null }).gatewayPoolId, null);
- assert.equal(payload.data.usernameTemplate, null);
- assert.deepEqual(payload.data.metadata, [{ key: "owner", value: "platform" }]);
- });
-});
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/dynamic-secret-provider-contract.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/dynamic-secret-provider-contract.test.ts
deleted file mode 100644
index e073d2a860..0000000000
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/dynamic-secret-provider-contract.test.ts
+++ /dev/null
@@ -1,454 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-import { z } from "zod";
-
-import { DynamicSecretProviders, SqlProviders } from "@app/hooks/api/dynamicSecret/types";
-
-import { submitDynamicSecretCreatePayloads } from "./createSubmission";
-import { testDynamicSecretProviderContract } from "./providerContractTestHarness";
-import { createDynamicSecretProviderRegistry, defineDynamicSecretProviderModule } from "./registry";
-import { parseDynamicSecretProviderNumberInput } from "./scalarValues";
-import {
- createDynamicSecretProviderFormSchema,
- DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE,
- editDynamicSecretProviderFormSchema,
- normalizeDynamicSecretGatewayValueForMode,
- normalizeDynamicSecretUsernameTemplateForCreate,
- normalizeDynamicSecretUsernameTemplateForEdit
-} from "./schemas";
-import {
- defineDynamicSecretProvider,
- TCreateDynamicSecretProviderFormContext,
- TEditDynamicSecretProviderFormContext
-} from "./types";
-
-const createInputsSchema = z.object({
- host: z.string().min(1, "Host is required"),
- port: z.number().int().positive(),
- password: z.string().min(1, "Password is required"),
- engine: z.literal("postgres"),
- enabled: z.boolean(),
- connection: z.object({
- gatewayId: z.string().optional(),
- gatewayPoolId: z.string().optional()
- }),
- statements: z.object({
- creation: z.string().min(1),
- revocation: z.string().min(1)
- })
-});
-
-const editInputsSchema = createInputsSchema.extend({
- connection: z.object({
- gatewayId: z.string().nullable().optional(),
- gatewayPoolId: z.string().nullable().optional()
- })
-});
-
-const createFormSchema = createDynamicSecretProviderFormSchema(createInputsSchema);
-const editFormSchema = editDynamicSecretProviderFormSchema(editInputsSchema);
-
-type TCreateFixtureValues = z.infer<typeof createFormSchema>;
-type TEditFixtureValues = z.infer<typeof editFormSchema>;
-
-const FixtureCustomRenderer = () => null;
-
-const fixtureDefinition = defineDynamicSecretProvider<
- DynamicSecretProviders.SqlDatabase,
- TCreateFixtureValues,
- TEditFixtureValues
->({
- provider: DynamicSecretProviders.SqlDatabase,
- label: "Test SQL",
- fields: [
- { name: "inputs.host", type: "text", label: "Host", layout: "half" },
- { name: "inputs.port", type: "number", label: "Port", layout: "half", min: 1 },
- {
- name: "inputs.password",
- type: "secret",
- label: "Password",
- autoComplete: "new-password"
- },
- {
- name: "inputs.engine",
- type: "select",
- label: "Engine",
- options: [{ label: "PostgreSQL", value: "postgres" }]
- },
- { name: "inputs.enabled", type: "switch", label: "Enabled" },
- {
- kind: "group",
- id: "statements",
- presentation: "collapse",
- title: "Statements",
- fields: [
- { name: "inputs.statements.creation", type: "textarea", label: "Creation Statement" },
- { name: "inputs.statements.revocation", type: "textarea", label: "Revocation Statement" }
- ]
- }
- ],
- customRenderer: {
- reasons: ["remote-options", "non-scalar-value"],
- Component: FixtureCustomRenderer
- },
- create: {
- schema: createFormSchema,
- getDefaultValues: (context) => ({
- name: "",
- defaultTTL: "1h",
- maxTTL: "24h",
- environment: context.isSingleEnvironmentMode ? context.environments[0] : undefined,
- usernameTemplate: DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE,
- inputs: {
- host: "",
- port: 5432,
- password: "",
- engine: "postgres",
- enabled: true,
- connection: {
- gatewayId: undefined,
- gatewayPoolId: undefined
- },
- statements: {
- creation: "CREATE USER",
- revocation: "DROP USER"
- }
- }
- }),
- toPayload: (values, context) => {
- const gatewayId = normalizeDynamicSecretGatewayValueForMode(
- "create",
- values.inputs.connection.gatewayId
- );
- const usernameTemplate = normalizeDynamicSecretUsernameTemplateForCreate(
- values.usernameTemplate
- );
-
- return {
- projectSlug: context.projectSlug,
- path: context.secretPath,
- name: values.name,
- environmentSlug: values.environment.slug,
- defaultTTL: values.defaultTTL,
- ...(values.maxTTL ? { maxTTL: values.maxTTL } : {}),
- ...(usernameTemplate ? { usernameTemplate } : {}),
- provider: {
- type: DynamicSecretProviders.SqlDatabase,
- inputs: {
- client: SqlProviders.Postgres,
- host: values.inputs.host,
- port: values.inputs.port,
- database: "postgres",
- username: "postgres",
- password: values.inputs.password,
- creationStatement: values.inputs.statements.creation,
- revocationStatement: values.inputs.statements.revocation,
- ...(gatewayId ? { gatewayId } : {})
- }
- }
- };
- },
- submitLabel: "Create Dynamic Secret"
- },
- edit: {
- schema: editFormSchema,
- getDefaultValues: (context) => ({
- name: context.dynamicSecret.name,
- defaultTTL: context.dynamicSecret.defaultTTL,
- maxTTL: context.dynamicSecret.maxTTL ?? null,
- usernameTemplate:
- context.dynamicSecret.usernameTemplate ?? DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE,
- inputs: context.dynamicSecret.inputs as TEditFixtureValues["inputs"]
- }),
- toPayload: (values, context) => ({
- projectSlug: context.projectSlug,
- path: context.secretPath,
- environmentSlug: context.environment,
- name: context.dynamicSecret.name,
- data: {
- newName: values.name,
- defaultTTL: values.defaultTTL,
- maxTTL: values.maxTTL,
- usernameTemplate: normalizeDynamicSecretUsernameTemplateForEdit(values.usernameTemplate),
- inputs: {
- ...values.inputs,
- connection: {
- gatewayId: normalizeDynamicSecretGatewayValueForMode(
- "edit",
- values.inputs.connection.gatewayId
- ),
- gatewayPoolId: normalizeDynamicSecretGatewayValueForMode(
- "edit",
- values.inputs.connection.gatewayPoolId
- )
- }
- }
- }
- }),
- submitLabel: "Save Changes",
- successMessage: "Dynamic secret updated"
- }
-});
-
-const environment = { id: "env-id", name: "Development", slug: "dev" };
-const createContext: TCreateDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environments: [environment],
- isSingleEnvironmentMode: true
-};
-const editInputs: TEditFixtureValues["inputs"] = {
- host: "database.example.com",
- port: 5432,
- password: "********",
- engine: "postgres",
- enabled: true,
- connection: { gatewayId: null, gatewayPoolId: null },
- statements: { creation: "CREATE USER", revocation: "DROP USER" }
-};
-const editContext: TEditDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environment: "dev",
- dynamicSecret: {
- id: "dynamic-secret-id",
- name: "existing-secret",
- type: DynamicSecretProviders.SqlDatabase,
- createdAt: "2026-08-01T00:00:00.000Z",
- updatedAt: "2026-08-01T00:00:00.000Z",
- defaultTTL: "1h",
- maxTTL: "24h",
- usernameTemplate: null,
- inputs: editInputs
- }
-};
-const createValues: TCreateFixtureValues = {
- name: "test-secret",
- defaultTTL: "1h",
- maxTTL: "24h",
- environment,
- usernameTemplate: DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE,
- inputs: {
- host: "database.example.com",
- port: 5432,
- password: "new-password",
- engine: "postgres",
- enabled: true,
- connection: { gatewayId: undefined, gatewayPoolId: undefined },
- statements: { creation: "CREATE USER", revocation: "DROP USER" }
- }
-};
-const editValues: TEditFixtureValues = {
- name: "renamed-secret",
- defaultTTL: "2h",
- maxTTL: null,
- usernameTemplate: DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE,
- inputs: editInputs
-};
-
-testDynamicSecretProviderContract({
- name: "test-only SQL fixture",
- definition: fixtureDefinition,
- create: {
- context: createContext,
- defaultValues: {
- name: "",
- defaultTTL: "1h",
- maxTTL: "24h",
- environment,
- usernameTemplate: DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE,
- inputs: {
- host: "",
- port: 5432,
- password: "",
- engine: "postgres",
- enabled: true,
- connection: { gatewayId: undefined, gatewayPoolId: undefined },
- statements: { creation: "CREATE USER", revocation: "DROP USER" }
- }
- },
- validValues: createValues,
- payload: {
- projectSlug: "project",
- path: "/folder",
- name: "test-secret",
- environmentSlug: "dev",
- defaultTTL: "1h",
- maxTTL: "24h",
- provider: {
- type: DynamicSecretProviders.SqlDatabase,
- inputs: {
- client: SqlProviders.Postgres,
- host: "database.example.com",
- port: 5432,
- database: "postgres",
- username: "postgres",
- password: "new-password",
- creationStatement: "CREATE USER",
- revocationStatement: "DROP USER"
- }
- }
- },
- invalidValues: [
- {
- name: "provider validation paths",
- values: {
- ...createValues,
- inputs: { ...createValues.inputs, host: "", password: "" }
- },
- issuePaths: [
- ["inputs", "host"],
- ["inputs", "password"]
- ]
- }
- ]
- },
- edit: {
- context: editContext,
- defaultValues: {
- name: "existing-secret",
- defaultTTL: "1h",
- maxTTL: "24h",
- usernameTemplate: DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE,
- inputs: editInputs
- },
- validValues: editValues,
- payload: {
- projectSlug: "project",
- path: "/folder",
- environmentSlug: "dev",
- name: "existing-secret",
- data: {
- newName: "renamed-secret",
- defaultTTL: "2h",
- maxTTL: null,
- usernameTemplate: null,
- inputs: editInputs
- }
- },
- maskedValues: [
- {
- name: "provider password",
- expected: "********",
- defaultValuePath: ["inputs", "password"],
- payloadValuePath: ["data", "inputs", "password"]
- }
- ]
- }
-});
-
-describe("shared dynamic-secret scalar behavior", () => {
- it("emits numbers before z.number validation", () => {
- const parsedPort = parseDynamicSecretProviderNumberInput("6432");
-
- assert.equal(parsedPort, 6432);
- assert.equal(typeof parsedPort, "number");
- assert.equal(
- createFormSchema.safeParse({
- ...createValues,
- inputs: { ...createValues.inputs, port: parsedPort }
- }).success,
- true
- );
- assert.equal(parseDynamicSecretProviderNumberInput(""), undefined);
- assert.equal(parseDynamicSecretProviderNumberInput("not-a-number"), undefined);
- });
-});
-
-describe("shared dynamic-secret normalization", () => {
- it("preserves TTL bounds and messages", () => {
- const missingDefault = createFormSchema.safeParse({ ...createValues, defaultTTL: "" });
- const malformedDefault = createFormSchema.safeParse({ ...createValues, defaultTTL: "abc" });
- const malformedMaximum = createFormSchema.safeParse({ ...createValues, maxTTL: "abc" });
- const belowMinimum = createFormSchema.safeParse({ ...createValues, defaultTTL: "30s" });
- const aboveMaximum = createFormSchema.safeParse({ ...createValues, defaultTTL: "11y" });
-
- assert.equal(missingDefault.success, false);
- assert.equal(malformedDefault.success, false);
- assert.equal(malformedMaximum.success, false);
- assert.equal(belowMinimum.success, false);
- assert.equal(aboveMaximum.success, false);
- if (!missingDefault.success) {
- assert.equal(missingDefault.error.issues[0]?.message, "TTL is required");
- }
- if (!malformedDefault.success) {
- assert.equal(malformedDefault.error.issues[0]?.message, "TTL must be a valid duration");
- }
- if (!malformedMaximum.success) {
- assert.equal(malformedMaximum.error.issues[0]?.message, "TTL must be a valid duration");
- }
- if (!belowMinimum.success) {
- assert.equal(belowMinimum.error.issues[0]?.message, "TTL must be a greater than 1min");
- }
- if (!aboveMaximum.success) {
- assert.equal(aboveMaximum.error.issues[0]?.message, "TTL must be less than 10 years");
- }
- });
-
- it("keeps username-template and gateway create/edit semantics distinct", () => {
- assert.equal(
- normalizeDynamicSecretUsernameTemplateForCreate(DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE),
- undefined
- );
- assert.equal(
- normalizeDynamicSecretUsernameTemplateForEdit(DEFAULT_DYNAMIC_SECRET_USERNAME_TEMPLATE),
- null
- );
- assert.equal(normalizeDynamicSecretGatewayValueForMode("create", null), undefined);
- assert.equal(normalizeDynamicSecretGatewayValueForMode("edit", null), null);
- assert.equal(normalizeDynamicSecretGatewayValueForMode("edit", "gateway-id"), "gateway-id");
- });
-});
-
-describe("shared dynamic-secret create submission", () => {
- it("reports partial success without rejecting completed items", async () => {
- const attemptedPayloads: number[] = [];
- const result = await submitDynamicSecretCreatePayloads([1, 2, 3], async (payload) => {
- attemptedPayloads.push(payload);
- if (payload === 2) throw new Error("create failed");
- return `created-${payload}`;
- });
-
- assert.deepEqual(attemptedPayloads, [1, 2, 3]);
- assert.deepEqual(result, {
- successfulResults: ["created-1", "created-3"],
- failedCount: 1
- });
- });
-});
-
-describe("dynamic-secret provider registry composition", () => {
- const fixtureModule = defineDynamicSecretProviderModule({
- id: "test-only",
- definitions: [fixtureDefinition]
- });
-
- it("composes batch modules without exposing mutable registry state", () => {
- const registry = createDynamicSecretProviderRegistry(fixtureModule);
-
- assert.deepEqual(registry.providers, [DynamicSecretProviders.SqlDatabase]);
- assert.equal(registry.getDefinition(DynamicSecretProviders.SqlDatabase), fixtureDefinition);
- assert.equal(registry.getDefinition(DynamicSecretProviders.Redis), undefined);
- assert.equal(registry.getDocsSlug(DynamicSecretProviders.SqlDatabase), "postgresql");
- assert.equal(Object.isFrozen(registry.providers), true);
- assert.equal(Object.isFrozen(registry.definitions), true);
- });
-
- it("rejects duplicate modules and providers", () => {
- assert.throws(
- () => createDynamicSecretProviderRegistry(fixtureModule, fixtureModule),
- /module "test-only" was registered more than once/
- );
- assert.throws(
- () =>
- createDynamicSecretProviderRegistry(
- fixtureModule,
- defineDynamicSecretProviderModule({
- id: "duplicate-provider",
- definitions: [fixtureDefinition]
- })
- ),
- /provider "sql-database" was registered more than once/
- );
- });
-});
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/productionRegistry.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/productionRegistry.test.ts
deleted file mode 100644
index c4c935905c..0000000000
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/productionRegistry.test.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
-
-import { dynamicSecretProviderRegistry } from "./productionRegistry";
-import { DYNAMIC_SECRET_PROVIDER_PICKER_ORDER } from "./registry";
-
-describe("dynamicSecretProviderRegistry", () => {
- it("composes every provider exactly once in product picker order", () => {
- assert.deepEqual(dynamicSecretProviderRegistry.providers, DYNAMIC_SECRET_PROVIDER_PICKER_ORDER);
- assert.equal(dynamicSecretProviderRegistry.definitions.length, 29);
- assert.equal(new Set(dynamicSecretProviderRegistry.providers).size, 29);
- assert.equal(Object.values(DynamicSecretProviders).length, 29);
- });
-
- it("preserves provider labels and documentation slugs", () => {
- dynamicSecretProviderRegistry.providers.forEach((provider) => {
- assert.ok(dynamicSecretProviderRegistry.requireDefinition(provider).label);
- assert.ok(dynamicSecretProviderRegistry.getDocsSlug(provider));
- });
- assert.equal(
- dynamicSecretProviderRegistry.getDocsSlug(DynamicSecretProviders.SqlDatabase),
- "postgresql"
- );
- assert.equal(
- dynamicSecretProviderRegistry.getDocsSlug(DynamicSecretProviders.MongoAtlas),
- "mongo-atlas"
- );
- });
-});
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/registry.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/registry.ts
index 4f53b6ed4e..4958340b38 100644
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/registry.ts
+++ b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/registry.ts
@@ -58,6 +58,16 @@ export const DYNAMIC_SECRET_PROVIDER_PICKER_ORDER = [
DynamicSecretProviders.Kafka
] as const satisfies readonly DynamicSecretProviders[];
+type TProvidersMissingFromPickerOrder = Exclude<
+ DynamicSecretProviders,
+ (typeof DYNAMIC_SECRET_PROVIDER_PICKER_ORDER)[number]
+>;
+export const isDynamicSecretProviderPickerOrderExhaustive: [
+ TProvidersMissingFromPickerOrder
+] extends [never]
+ ? true
+ : TProvidersMissingFromPickerOrder = true;
+
const DYNAMIC_SECRET_PROVIDER_DOCS_SLUG: Partial<Record<DynamicSecretProviders, string>> = {
[DynamicSecretProviders.SqlDatabase]: "postgresql",
[DynamicSecretProviders.MongoAtlas]: "mongo-atlas"
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/relational-gateway-contract.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/relational-gateway-contract.test.ts
deleted file mode 100644
index f34720ee43..0000000000
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/relational-gateway-contract.test.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
-
-import {
- getVerticaCreateDefaultValues,
- getVerticaCreatePayload,
- getVerticaEditDefaultValues,
- getVerticaEditPayload,
- verticaCreateFormSchema
-} from "./providerDefinitions/verticaContract";
-import type {
- TCreateDynamicSecretProviderFormContext,
- TEditDynamicSecretProviderFormContext
-} from "./types";
-
-const environment = { id: "env-id", name: "Development", slug: "dev", position: 1 };
-
-const createContext: TCreateDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environments: [environment],
- isSingleEnvironmentMode: true
-};
-
-const getEditContext = (inputs: unknown) =>
- ({
- projectSlug: "project",
- secretPath: "/folder",
- environment: "dev",
- dynamicSecret: {
- name: "vertica-secret",
- defaultTTL: "1h",
- maxTTL: "24h",
- usernameTemplate: null,
- inputs
- }
- }) as TEditDynamicSecretProviderFormContext;
-
-describe("relational gateway dynamic-secret contracts", () => {
- it("retains Vertica defaults and validates required connection fields", () => {
- const values = getVerticaCreateDefaultValues(createContext);
- assert.equal(values.inputs.port, 5433);
- assert.equal(values.inputs.passwordRequirements?.length, 48);
- assert.match(values.inputs.creationStatement, /CREATE USER/);
- assert.equal(verticaCreateFormSchema.safeParse(values).success, false);
- });
-
- it("builds the Vertica create DTO without inventing cleared gateways", () => {
- const values = getVerticaCreateDefaultValues(createContext);
- Object.assign(values, { name: "vertica-secret" });
- Object.assign(values.inputs, {
- host: "vertica.example.com",
- database: "analytics",
- username: "admin",
- password: "secret"
- });
-
- const payload = getVerticaCreatePayload(values, createContext);
- assert.equal(payload.provider.type, DynamicSecretProviders.Vertica);
- assert.equal(payload.environmentSlug, "dev");
- assert.equal(payload.usernameTemplate, undefined);
- assert.equal((payload.provider.inputs as { gatewayId?: string }).gatewayId, undefined);
- });
-
- it("passes masked edit credentials through and clears both gateway selectors with null", () => {
- const context = getEditContext({
- host: "vertica.example.com",
- port: 5433,
- database: "analytics",
- username: "admin",
- password: "********",
- creationStatement: "create",
- revocationStatement: "revoke"
- });
- const values = getVerticaEditDefaultValues(context);
- const payload = getVerticaEditPayload(values, context);
- const inputs = payload.data.inputs as {
- password?: string;
- gatewayId?: string | null;
- gatewayPoolId?: string | null;
- };
-
- assert.equal(values.inputs.password, "********");
- assert.equal(inputs.password, "********");
- assert.equal(inputs.gatewayId, null);
- assert.equal(inputs.gatewayPoolId, null);
- assert.equal(payload.data.usernameTemplate, null);
- });
-});
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/runtimeMetadata.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/runtimeMetadata.test.ts
deleted file mode 100644
index 48ace2a462..0000000000
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/runtimeMetadata.test.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
-
-import { getDynamicSecretProviderRuntimeMetadata } from "./runtimeMetadata";
-
-describe("dynamic-secret provider runtime metadata", () => {
- it("defines presentation and lease behavior for every provider", () => {
- Object.values(DynamicSecretProviders).forEach((provider) => {
- const metadata = getDynamicSecretProviderRuntimeMetadata(provider);
-
- assert.ok(metadata.presentation.providerFamily);
- assert.ok(metadata.leaseCapabilities.provisioner);
- assert.ok(metadata.leaseCapabilities.output.type);
-
- if (metadata.leaseCapabilities.output.type === "fields") {
- assert.ok(metadata.leaseCapabilities.output.fields.length > 0);
- assert.equal(
- new Set(metadata.leaseCapabilities.output.fields.map(({ key }) => key)).size,
- metadata.leaseCapabilities.output.fields.length
- );
- }
- });
- });
-
- it("keeps special provisioning and renewal capabilities explicit", () => {
- assert.equal(
- getDynamicSecretProviderRuntimeMetadata(DynamicSecretProviders.Kubernetes).leaseCapabilities
- .provisioner,
- "kubernetes"
- );
- assert.equal(
- getDynamicSecretProviderRuntimeMetadata(DynamicSecretProviders.Ssh).leaseCapabilities
- .provisioner,
- "ssh"
- );
- assert.equal(
- getDynamicSecretProviderRuntimeMetadata(DynamicSecretProviders.Totp).leaseCapabilities
- .autoGenerate,
- true
- );
- assert.equal(
- getDynamicSecretProviderRuntimeMetadata(DynamicSecretProviders.Github).leaseCapabilities
- .fixedTtl,
- "1h"
- );
-
- [
- DynamicSecretProviders.Github,
- DynamicSecretProviders.Ssh,
- DynamicSecretProviders.Tailscale,
- DynamicSecretProviders.OAuth2
- ].forEach((provider) => {
- assert.equal(
- getDynamicSecretProviderRuntimeMetadata(provider).leaseCapabilities.supportsRenewal,
- false
- );
- });
- });
-});
diff --git a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/simple-sql-contract.test.ts b/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/simple-sql-contract.test.ts
deleted file mode 100644
index 3821589537..0000000000
--- a/frontend/src/components/dynamic-secrets/DynamicSecretProviderForm/simple-sql-contract.test.ts
+++ /dev/null
@@ -1,197 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
-
-import {
- getSapAseCreateDefaultValues,
- getSapAseCreatePayload,
- getSapAseEditDefaultValues,
- getSapAseEditPayload,
- sapAseCreateFormSchema,
- sapAseEditFormSchema
-} from "./providerDefinitions/sapAseContract";
-import {
- getSapHanaCreateDefaultValues,
- getSapHanaCreatePayload,
- getSapHanaEditDefaultValues,
- getSapHanaEditPayload,
- sapHanaCreateFormSchema
-} from "./providerDefinitions/sapHanaContract";
-import {
- getSnowflakeCreateDefaultValues,
- getSnowflakeCreatePayload,
- getSnowflakeEditDefaultValues,
- getSnowflakeEditPayload,
- snowflakeCreateFormSchema
-} from "./providerDefinitions/snowflakeContract";
-import type {
- TCreateDynamicSecretProviderFormContext,
- TEditDynamicSecretProviderFormContext
-} from "./types";
-
-const environment = { id: "env-id", name: "Development", slug: "dev", position: 1 };
-
-const createContext: TCreateDynamicSecretProviderFormContext = {
- projectSlug: "project",
- secretPath: "/folder",
- environments: [environment],
- isSingleEnvironmentMode: true
-};
-
-const getEditContext = (
- inputs: unknown,
- overrides: Partial<TEditDynamicSecretProviderFormContext["dynamicSecret"]> = {}
-) =>
- ({
- projectSlug: "project",
- secretPath: "/folder",
- environment: "dev",
- dynamicSecret: {
- name: "existing-secret",
- defaultTTL: "1h",
- maxTTL: "24h",
- usernameTemplate: null,
- inputs,
- ...overrides
- }
- }) as TEditDynamicSecretProviderFormContext;
-
-describe("simple SQL dynamic-secret contracts", () => {
- it("preserves provider-specific defaults and validates required connection inputs", () => {
- const sapHana = getSapHanaCreateDefaultValues(createContext);
- const sapAse = getSapAseCreateDefaultValues(createContext);
- const snowflake = getSnowflakeCreateDefaultValues(createContext);
-
- assert.equal(sapHana.inputs.port, 443);
- assert.equal(sapHana.inputs.sslRejectUnauthorized, true);
- assert.match(sapHana.inputs.creationStatement, /CREATE USER/);
- assert.match(sapHana.inputs.revocationStatement, /DROP USER/);
- assert.match(sapHana.inputs.renewStatement ?? "", /ALTER USER/);
- assert.equal(sapAse.inputs.port, 5000);
- assert.equal(sapAse.inputs.database, "master");
- assert.match(sapAse.inputs.creationStatement, /sp_addlogin/);
- assert.match(sapAse.inputs.revocationStatement, /sp_droplogin/);
- assert.match(snowflake.inputs.creationStatement, /DAYS_TO_EXPIRY/);
- assert.match(snowflake.inputs.revocationStatement, /DROP USER/);
- assert.match(snowflake.inputs.renewStatement ?? "", /ALTER USER/);
-
- assert.equal(sapHanaCreateFormSchema.safeParse(sapHana).success, false);
- assert.equal(sapAseCreateFormSchema.safeParse(sapAse).success, false);
- assert.equal(snowflakeCreateFormSchema.safeParse(snowflake).success, false);
- });
-
- it("builds create payloads with exact provider discriminators and username normalization", () => {
- const sapHanaValues = getSapHanaCreateDefaultValues(createContext);
- Object.assign(sapHanaValues.inputs, {
- host: "hana.example.com",
- username: "admin",
- password: "secret"
- });
- const sapAseValues = getSapAseCreateDefaultValues(createContext);
- Object.assign(sapAseValues.inputs, {
- host: "ase.example.com",
- username: "admin",
- password: "secret"
- });
- const snowflakeValues = getSnowflakeCreateDefaultValues(createContext);
- Object.assign(snowflakeValues.inputs, {
- accountId: "account",
- orgId: "organization",
- username: "admin",
- password: "token"
- });
-
- sapHanaValues.name = "hana-secret";
- sapAseValues.name = "ase-secret";
- snowflakeValues.name = "snowflake-secret";
-
- const sapHanaPayload = getSapHanaCreatePayload(sapHanaValues, createContext);
- const sapAsePayload = getSapAseCreatePayload(sapAseValues, createContext);
- const snowflakePayload = getSnowflakeCreatePayload(snowflakeValues, createContext);
-
- assert.equal(sapHanaPayload.provider.type, DynamicSecretProviders.SapHana);
- assert.equal(sapAsePayload.provider.type, DynamicSecretProviders.SapAse);
- assert.equal(snowflakePayload.provider.type, DynamicSecretProviders.Snowflake);
- assert.equal(sapHanaPayload.environmentSlug, "dev");
- assert.equal(sapHanaPayload.usernameTemplate, undefined);
- });
-
- it("retains masked edit secrets and existing rename/template semantics", () => {
- const hanaContext = getEditContext({
- host: "hana.example.com",
- password: "********",
- ca: "********"
- });
- const hanaValues = getSapHanaEditDefaultValues(hanaContext);
- const hanaPayload = getSapHanaEditPayload(
- { ...hanaValues, name: "renamed-hana-secret" },
- hanaContext
- );
- const snowflakeContext = getEditContext({ accountId: "account", password: "********" });
- const snowflakeValues = getSnowflakeEditDefaultValues(snowflakeContext);
- const snowflakePayload = getSnowflakeEditPayload(snowflakeValues, snowflakeContext);
-
- assert.equal(hanaValues.inputs.password, "********");
- assert.equal(hanaValues.inputs.ca, "********");
- assert.equal(hanaValues.inputs.sslRejectUnauthorized, true);
- assert.equal(snowflakeValues.inputs.password, "********");
- assert.equal((hanaPayload.data.inputs as { password?: string }).password, "********");
- assert.equal((hanaPayload.data.inputs as { ca?: string }).ca, "********");
- assert.equal(
- (hanaPayload.data.inputs as { sslRejectUnauthorized?: boolean }).sslRejectUnauthorized,
- true
- );
- assert.equal((snowflakePayload.data.inputs as { password?: string }).password, "********");
- assert.equal(hanaPayload.data.newName, "renamed-hana-secret");
- assert.equal(hanaPayload.data.usernameTemplate, null);
- assert.equal(snowflakePayload.data.usernameTemplate, null);
- });
-
- it("strips the unsupported SAP ASE CA from edit values and payloads", () => {
- const createValues = getSapAseCreateDefaultValues(createContext);
- assert.equal("ca" in createValues.inputs, false);
-
- const editContext = getEditContext({
- host: "ase.example.com",
- port: 5000,
- database: "master",
- username: "admin",
- password: "********",
- creationStatement: "create",
- revocationStatement: "revoke",
- ca: "********"
- });
- const editValues = getSapAseEditDefaultValues(editContext);
- assert.equal("ca" in editValues.inputs, false);
- assert.equal(sapAseEditFormSchema.safeParse(editValues).success, true);
-
- const payload = getSapAseEditPayload(editValues, editContext);
- assert.equal("ca" in (payload.data.inputs as Record<string, unknown>), false);
- });
-
- it("defaults missing SAP HANA TLS verification to true and preserves explicit false", () => {
- const enabledContext = getEditContext({ host: "hana.example.com" });
- const enabledValues = getSapHanaEditDefaultValues(enabledContext);
- const enabledPayload = getSapHanaEditPayload(enabledValues, enabledContext);
-
- assert.equal(enabledValues.inputs.sslRejectUnauthorized, true);
- assert.equal(
- (enabledPayload.data.inputs as { sslRejectUnauthorized?: boolean }).sslRejectUnauthorized,
- true
- );
-
- const disabledContext = getEditContext({
- host: "hana.example.com",
- sslRejectUnauthorized: false
- });
- const disabledValues = getSapHanaEditDefaultValues(disabledContext);
- const disabledPayload = getSapHanaEditPayload(disabledValues, disabledContext);
-
- assert.equal(disabledValues.inputs.sslRejectUnauthorized, false);
- assert.equal(
- (disabledPayload.data.inputs as { sslRejectUnauthorized?: boolean }).sslRejectUnauthorized,
- false
- );
- });
-});
diff --git a/frontend/src/components/external-migrations/VaultRoleImportModal.utils.test.ts b/frontend/src/components/external-migrations/VaultRoleImportModal.utils.test.ts
deleted file mode 100644
index c3a8231a26..0000000000
--- a/frontend/src/components/external-migrations/VaultRoleImportModal.utils.test.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import type { VaultDatabaseRole } from "@app/hooks/api/migration/types";
-
-import {
- getVaultRoleImportMounts,
- getVaultRoleImportRoles,
- VAULT_ROLE_IMPORT_CONFIG
-} from "./VaultRoleImportModal.utils";
-
-describe("Vault role import configuration", () => {
- it("keeps each provider on its supported Vault mount type", () => {
- const mounts = [
- { path: "ldap/", type: "ldap" },
- { path: "database/", type: "database" },
- { path: "kubernetes/", type: "kubernetes" }
- ];
-
- assert.deepEqual(getVaultRoleImportMounts("ldap", mounts), [mounts[0]]);
- assert.deepEqual(getVaultRoleImportMounts("sqlDatabase", mounts), [mounts[1]]);
- assert.deepEqual(getVaultRoleImportMounts("cassandra", mounts), [mounts[1]]);
- assert.deepEqual(getVaultRoleImportMounts("kubernetes", mounts), [mounts[2]]);
- assert.deepEqual(getVaultRoleImportMounts("kubernetesAuth", mounts), [mounts[2]]);
- });
-
- it("limits Cassandra imports to Cassandra database plugins", () => {
- const roles: VaultDatabaseRole[] = [
- {
- name: "cassandra-role",
- mountPath: "database",
- db_name: "cassandra",
- config: {
- plugin_name: "cassandra-database-plugin",
- connection_details: {}
- }
- },
- {
- name: "postgres-role",
- mountPath: "database",
- db_name: "postgres",
- config: {
- plugin_name: "postgresql-database-plugin",
- connection_details: {}
- }
- }
- ];
-
- assert.deepEqual(getVaultRoleImportRoles("cassandra", roles), [roles[0]]);
- assert.deepEqual(getVaultRoleImportRoles("sqlDatabase", roles), roles);
- });
-
- it("keeps organization Kubernetes auth behavior distinct from dynamic secrets", () => {
- const auth = VAULT_ROLE_IMPORT_CONFIG.kubernetesAuth;
-
- assert.equal(auth.title, "Load Kubernetes Auth from HashiCorp Vault");
- assert.equal(auth.mountLabel, "Auth Engine");
- assert.equal(auth.actionLabel, "Load");
- assert.equal(auth.scope, "org");
- assert.equal(auth.infoText, undefined);
- assert.equal(VAULT_ROLE_IMPORT_CONFIG.kubernetes.actionLabel, "Load Configuration");
- });
-});
diff --git a/frontend/src/components/external-migrations/vaultImportSelection.test.ts b/frontend/src/components/external-migrations/vaultImportSelection.test.ts
deleted file mode 100644
index 14234510c2..0000000000
--- a/frontend/src/components/external-migrations/vaultImportSelection.test.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { createVaultImportSelection, vaultImportSelectionReducer } from "./vaultImportSelection";
-
-describe("Vault import selection", () => {
- it("selects the only available app connection by default", () => {
- assert.deepEqual(createVaultImportSelection<string>(["connection-id"]), {
- connectionId: "connection-id",
- namespace: null,
- mountPath: null,
- selection: null
- });
- assert.equal(createVaultImportSelection<string>(["one", "two"]).connectionId, null);
- });
-
- it("clears every dependent selection when the connection changes", () => {
- const result = vaultImportSelectionReducer(
- {
- connectionId: "old-connection",
- namespace: "admin",
- mountPath: "database",
- selection: "role"
- },
- { type: "connection", value: "new-connection" }
- );
-
- assert.deepEqual(result, {
- connectionId: "new-connection",
- namespace: null,
- mountPath: null,
- selection: null
- });
- });
-
- it("clears downstream values as namespace and mount selections change", () => {
- const initial = {
- connectionId: "connection",
- namespace: "old-namespace",
- mountPath: "old-mount",
- selection: ["old-path"]
- };
- const namespaceResult = vaultImportSelectionReducer(initial, {
- type: "namespace",
- value: "new-namespace"
- });
- const mountResult = vaultImportSelectionReducer(namespaceResult, {
- type: "mount",
- value: "new-mount"
- });
-
- assert.deepEqual(namespaceResult, {
- connectionId: "connection",
- namespace: "new-namespace",
- mountPath: null,
- selection: null
- });
- assert.deepEqual(mountResult, {
- connectionId: "connection",
- namespace: "new-namespace",
- mountPath: "new-mount",
- selection: null
- });
- });
-});
diff --git a/frontend/src/components/license/UpgradeGate/capability-upgrade-intents.test.ts b/frontend/src/components/license/UpgradeGate/capability-upgrade-intents.test.ts
deleted file mode 100644
index 4fbbcc8bb2..0000000000
--- a/frontend/src/components/license/UpgradeGate/capability-upgrade-intents.test.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import {
- getCapabilityUpgradeUrl,
- GroupsUpgradeIntent,
- InstanceUserManagementUpgradeIntent
-} from "./capability-upgrade-intents";
-
-describe("capability upgrade intents", () => {
- it("routes platform capabilities to root organization billing", () => {
- expect(getCapabilityUpgradeUrl(GroupsUpgradeIntent, { id: "child", rootOrgId: "root" })).toBe(
- "/organizations/root/billing"
- );
- expect(getCapabilityUpgradeUrl(GroupsUpgradeIntent, { id: "org" })).toBe(
- "/organizations/org/billing"
- );
- });
-
- it("routes instance capabilities to sales instead of organization checkout", () => {
- expect(getCapabilityUpgradeUrl(InstanceUserManagementUpgradeIntent, { id: "org" })).toBe(
- "https://infisical.com/talk-to-us"
- );
- });
-});
diff --git a/frontend/src/components/v3/generic/Combobox/combobox-accessibility.test.ts b/frontend/src/components/v3/generic/Combobox/combobox-accessibility.test.ts
deleted file mode 100644
index c74c9b073d..0000000000
--- a/frontend/src/components/v3/generic/Combobox/combobox-accessibility.test.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { getComboboxInputAriaLabel } from "./combobox-accessibility";
-
-describe("Combobox input accessible name", () => {
- it("lets an associated field label name an input with an ID", () => {
- assert.equal(
- getComboboxInputAriaLabel({ id: "projects", searchAriaLabel: "Search projects" }),
- undefined
- );
- });
-
- it("lets aria-labelledby take precedence over the search hint", () => {
- assert.equal(
- getComboboxInputAriaLabel({
- ariaLabelledBy: "projects-label",
- searchAriaLabel: "Search projects"
- }),
- undefined
- );
- });
-
- it("preserves explicit aria-label and unlabeled search fallback compatibility", () => {
- assert.equal(
- getComboboxInputAriaLabel({
- ariaLabel: "Project picker",
- id: "projects",
- searchAriaLabel: "Search projects"
- }),
- "Project picker"
- );
- assert.equal(
- getComboboxInputAriaLabel({ searchAriaLabel: "Search projects" }),
- "Search projects"
- );
- });
-});
diff --git a/frontend/src/hooks/api/pkiDiscovery/polling.test.ts b/frontend/src/hooks/api/pkiDiscovery/polling.test.ts
deleted file mode 100644
index 59c3c58afa..0000000000
--- a/frontend/src/hooks/api/pkiDiscovery/polling.test.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import {
- getPkiDiscoveryRefetchInterval,
- isPkiDiscoveryScanInFlight,
- SCAN_IDLE_POLL_MS,
- SCAN_IN_FLIGHT_POLL_MS
-} from "./polling";
-import { PkiDiscoveryScanStatus } from "./types";
-
-describe("isPkiDiscoveryScanInFlight", () => {
- it("is true while a scan is pending or running", () => {
- assert.equal(isPkiDiscoveryScanInFlight(PkiDiscoveryScanStatus.Pending), true);
- assert.equal(isPkiDiscoveryScanInFlight(PkiDiscoveryScanStatus.Running), true);
- });
-
- it("is false for terminal or missing statuses", () => {
- assert.equal(isPkiDiscoveryScanInFlight(PkiDiscoveryScanStatus.Completed), false);
- assert.equal(isPkiDiscoveryScanInFlight(PkiDiscoveryScanStatus.Failed), false);
- assert.equal(isPkiDiscoveryScanInFlight(null), false);
- assert.equal(isPkiDiscoveryScanInFlight(undefined), false);
- });
-});
-
-describe("getPkiDiscoveryRefetchInterval", () => {
- it("polls fast while a scan is in flight", () => {
- assert.equal(
- getPkiDiscoveryRefetchInterval(PkiDiscoveryScanStatus.Pending),
- SCAN_IN_FLIGHT_POLL_MS
- );
- assert.equal(
- getPkiDiscoveryRefetchInterval(PkiDiscoveryScanStatus.Running),
- SCAN_IN_FLIGHT_POLL_MS
- );
- });
-
- it("falls back to the slow idle poll once a scan is terminal", () => {
- assert.equal(
- getPkiDiscoveryRefetchInterval(PkiDiscoveryScanStatus.Completed),
- SCAN_IDLE_POLL_MS
- );
- assert.equal(getPkiDiscoveryRefetchInterval(PkiDiscoveryScanStatus.Failed), SCAN_IDLE_POLL_MS);
- assert.equal(getPkiDiscoveryRefetchInterval(null), SCAN_IDLE_POLL_MS);
- assert.equal(getPkiDiscoveryRefetchInterval(undefined), SCAN_IDLE_POLL_MS);
- });
-
- it("keeps polling while idle so a newly started scan is noticed", () => {
- assert.notEqual(getPkiDiscoveryRefetchInterval(PkiDiscoveryScanStatus.Completed), false);
- assert.ok(SCAN_IDLE_POLL_MS > SCAN_IN_FLIGHT_POLL_MS);
- });
-});
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/createSecretFormState.test.ts b/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/createSecretFormState.test.ts
deleted file mode 100644
index e08db2c8b7..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/createSecretFormState.test.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { didAllSecretCreationsSucceed } from "./createSecretFormState";
-
-describe("create secret form state", () => {
- it("closes after every secret creation succeeds", () => {
- assert.equal(
- didAllSecretCreationsSucceed([{ status: "fulfilled" }, { status: "fulfilled" }]),
- true
- );
- });
-
- it("stays open when any secret creation fails", () => {
- assert.equal(
- didAllSecretCreationsSucceed([{ status: "fulfilled" }, { status: "rejected" }]),
- false
- );
- });
-
- it("stays open when no secret creation ran", () => {
- assert.equal(didAllSecretCreationsSucceed([]), false);
- });
-});
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/InviteMembersNudge/resolveActivationVariant.test.ts b/frontend/src/pages/secret-manager/OverviewPage/components/InviteMembersNudge/resolveActivationVariant.test.ts
deleted file mode 100644
index 282a8fad94..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/InviteMembersNudge/resolveActivationVariant.test.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import assert from "node:assert/strict";
-import type { PostHog } from "posthog-js";
-import { afterEach, describe, it, vi } from "vitest";
-
-import { ACTIVATION_PRESENTATION_FLAG, resolveActivationVariant } from "./resolveActivationVariant";
-
-const createClient = (value?: string | boolean, immediate = false) => {
- let listener: Parameters<PostHog["onFeatureFlags"]>[0] = () => {};
- const emit = (errorsLoading = false) => listener([], {}, { errorsLoading });
- const unsubscribe = vi.fn();
- const client = {
- getFeatureFlag: vi.fn(() => value),
- onFeatureFlags: (callback: typeof listener) => {
- listener = callback;
- if (immediate) emit();
- return unsubscribe;
- }
- };
- return { client, emit, unsubscribe };
-};
-
-describe("resolveActivationVariant", () => {
- afterEach(() => vi.useRealTimers());
-
- it("uses the original modal without enrolling when telemetry is unavailable", () => {
- const resolved = vi.fn();
- resolveActivationVariant(undefined, resolved)();
- assert.deepEqual(resolved.mock.calls, [[null]]);
- });
-
- ["control", "card", false, true, undefined, "unknown"].forEach((value) => {
- it(`resolves ${String(value)} without emitting an early exposure`, () => {
- const resolved = vi.fn();
- const { client, unsubscribe } = createClient(value, true);
- const cancel = resolveActivationVariant(client, resolved);
- assert.equal(
- resolved.mock.calls[0][0],
- value === "control" || value === "card" ? value : null
- );
- assert.deepEqual(client.getFeatureFlag.mock.calls[0], [
- ACTIVATION_PRESENTATION_FLAG,
- { send_event: false, fresh: true }
- ]);
- assert.equal(unsubscribe.mock.calls.length, 1);
- cancel();
- });
- });
-
- it("waits for flags, freezes the assignment, and unsubscribes", () => {
- const { client, emit, unsubscribe } = createClient("card");
- const resolved = vi.fn();
- const cancel = resolveActivationVariant(client, resolved);
- assert.equal(resolved.mock.calls.length, 0);
- emit();
- client.getFeatureFlag.mockImplementation(() => "control");
- emit();
- assert.equal(resolved.mock.calls.length, 1);
- assert.equal(resolved.mock.calls[0][0], "card");
- assert.equal(unsubscribe.mock.calls.length, 1);
- cancel();
- });
-
- it("falls back after a loading error without using cached flags", () => {
- const resolved = vi.fn();
- const { client, emit } = createClient("card");
- const cancel = resolveActivationVariant(client, resolved);
- emit(true);
- assert.equal(resolved.mock.calls[0][0], null);
- assert.equal(client.getFeatureFlag.mock.calls.length, 0);
- cancel();
- });
-
- it("times out after three seconds and ignores late flags", () => {
- vi.useFakeTimers();
- const { client, emit } = createClient("card");
- const resolved = vi.fn();
- const cancel = resolveActivationVariant(client, resolved);
- vi.advanceTimersByTime(2999);
- assert.equal(resolved.mock.calls.length, 0);
- vi.advanceTimersByTime(1);
- emit();
- assert.deepEqual(resolved.mock.calls, [[null]]);
- cancel();
- });
-
- it("cancels pending resolution when the nudge unmounts", () => {
- vi.useFakeTimers();
- const { client, emit, unsubscribe } = createClient("card");
- const resolved = vi.fn();
- const cancel = resolveActivationVariant(client, resolved);
- cancel();
- emit();
- vi.advanceTimersByTime(3000);
- assert.equal(resolved.mock.calls.length, 0);
- assert.equal(unsubscribe.mock.calls.length, 1);
- });
-});
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.test.ts b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.test.ts
deleted file mode 100644
index 19e5a8baa2..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.test.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { getResourceSearchStateTransition } from "./resourceSearchState";
-
-describe("Resource search state", () => {
- it("syncs an external navigation without re-emitting the stale debounced value", () => {
- assert.deepEqual(
- getResourceSearchStateTransition({
- externalValue: "DATABASE_URL",
- previousExternalValue: "api",
- debouncedInputValue: "api",
- lastEmittedValue: "api"
- }),
- { type: "sync", value: "DATABASE_URL" }
- );
- });
-
- it("emits a locally debounced search change", () => {
- assert.deepEqual(
- getResourceSearchStateTransition({
- externalValue: "api",
- previousExternalValue: "api",
- debouncedInputValue: "api-key",
- lastEmittedValue: "api"
- }),
- { type: "emit", value: "api-key" }
- );
- });
-
- it("does nothing when external and local search state are synchronized", () => {
- assert.equal(
- getResourceSearchStateTransition({
- externalValue: "api",
- previousExternalValue: "api",
- debouncedInputValue: "api",
- lastEmittedValue: "api"
- }),
- undefined
- );
- });
-});
diff --git a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/approvalPolicyFormUtils.test.ts b/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/approvalPolicyFormUtils.test.ts
deleted file mode 100644
index a19cf38ae8..0000000000
--- a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/approvalPolicyFormUtils.test.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { getEmptyApprovalStepIndexes } from "./approvalPolicyFormUtils";
-
-describe("approval policy form steps", () => {
- it("identifies every access-policy sequence without an approver", () => {
- const emptySteps = getEmptyApprovalStepIndexes([
- { user: [{ id: "user-id" }], group: [] },
- { user: [], group: [] },
- { user: [], group: [{ id: "group-id" }] },
- { user: [], group: [] }
- ]);
-
- assert.deepEqual(emptySteps, [1, 3]);
- });
-});
diff --git a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/approvalPolicyRowUtils.test.ts b/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/approvalPolicyRowUtils.test.ts
deleted file mode 100644
index 977a96b449..0000000000
--- a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/approvalPolicyRowUtils.test.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import assert from "node:assert/strict";
-import { describe, it } from "vitest";
-
-import { Approver, ApproverType } from "@app/hooks/api/accessApproval/types";
-
-import { groupApproversBySequence } from "./approvalPolicyRowUtils";
-
-const approver = (overrides: Partial<Approver>): Approver => ({
- id: "approver-id",
- type: ApproverType.User,
- isOrgMembershipActive: true,
- ...overrides
-});
-
-describe("approval policy sequence details", () => {
- it("sorts and groups approvers by their actual sequence without mutating query data", () => {
- const approvers = [
- approver({ id: "step-2-user", sequence: 2, approvalsRequired: 2 }),
- approver({
- id: "step-1-group",
- type: ApproverType.Group,
- sequence: 1,
- approvalsRequired: 1
- }),
- approver({ id: "step-1-user", sequence: 1, approvalsRequired: 1 })
- ];
- const originalOrder = approvers.map(({ id }) => id);
-
- const steps = groupApproversBySequence(approvers, 3);
-
- assert.deepEqual(
- steps.map(({ sequence, approvals, user, group }) => ({
- sequence,
- approvals,
- users: user.map(({ id }) => id),
- groups: group.map(({ id }) => id)
- })),
- [
- {
- sequence: 1,
- approvals: 1,
- users: ["step-1-user"],
- groups: ["step-1-group"]
- },
- { sequence: 2, approvals: 2, users: ["step-2-user"], groups: [] }
- ]
- );
- assert.deepEqual(
- approvers.map(({ id }) => id),
- originalOrder
- );
- });
-
- it("uses sequence one and the policy approval count for legacy approvers", () => {
- const steps = groupApproversBySequence([approver({})], 4);
-
- assert.equal(steps[0].sequence, 1);
- assert.equal(steps[0].approvals, 4);
- });
-});