@devries-cameron20 / composio-1 / commits / 6e010c7b5
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(ts/e2e): enforce non-empty strings in runFixture with const type params; remove unused definitions

fix(ts/e2e): enforce non-empty strings in runFixture with const type params; remove unused definitions

jkomyno committed Feb 1, 2026 at 12:17 UTC 6e010c7b5781aedd7a4dfa9f74adc56c62863f2f
3 files changed +23 -44
ts/e2e-tests/_utils/src/config.ts
+1 -3
@@ -2,7 +2,7 @@ import { dirname, resolve } from 'node:path';
2 import { fileURLToPath } from 'node:url';
3 import { readFileSync } from 'node:fs';
4 import process from 'node:process';
5 -import type { NodeVersionMeta, NodeVersionFromUser, SkipInCI } from './types';
5 +import type { NodeVersionMeta, NodeVersionFromUser, SkipInCI, NonEmptyArray } from './types';
6
7 declare module 'bun' {
8 interface Env {
@@ -11,8 +11,6 @@ declare module 'bun' {
11 }
12 }
13
14 -type NonEmptyArray<T> = [T, ...T[]];
15 -
14 /**
15 * Determine if we're running in a Continuous Integration suite.
16 */
ts/e2e-tests/_utils/src/runner.ts
+4 -39
@@ -1,7 +1,7 @@
1 import { describe, beforeAll, afterAll, it } from 'bun:test';
2 import { appendFile, writeFile } from 'node:fs/promises';
3 import { resolve } from 'node:path';
4 -import type { DefineTestsContext, E2EConfig, E2ETestResult, E2ETestResultWithSetup, NodeVersionMeta, RunFixtureOptions } from './types';
4 +import type { DefineTestsContext, E2EConfig, E2ETestResult, E2ETestResultWithSetup, NodeVersionMeta, NonEmptyString, RunFixtureOptions } from './types';
5 import { getRepoRoot, resolveNodeVersionMetaList } from './config';
6 import { ensureNodeImage, runNodeContainer } from './image-lifecycle';
7 import { WELL_KNOWN_ENV_VARS } from './const';
@@ -190,41 +190,6 @@ class DebugLogManager {
190 }
191 }
192
193 -// ============================================================================
194 -// Legacy debug log support (for backward compatibility with runCmd)
195 -// ============================================================================
196 -
197 -/**
198 - * Debug log entry metadata.
199 - * @deprecated Use DebugLogManager for new code
200 - */
201 -interface DebugLogEntry {
202 - nodeVersion: string;
203 - command: string;
204 - containerName: string;
205 - result: E2ETestResult;
206 - /** Optional phase indicator for multi-step operations */
207 - phase?:
208 - // Setup phase before fixture is run, often used for install commands
209 - | 'setup'
210 - // Actual test fixture phase
211 - | 'fixture';
212 -}
213 -
214 -/**
215 - * Writes Docker run output to DEBUG.log in the test directory.
216 - * @deprecated Use DebugLogManager for new code - this is kept for runCmd() compatibility
217 - */
218 -async function writeDebugLog(
219 - _repoRoot: string,
220 - _testDirRelative: string,
221 - _entry: DebugLogEntry
222 -): Promise<void> {
223 - // No-op: logging is now handled by DebugLogManager at the version level
224 - // The runCmd function still calls this for API compatibility, but actual
225 - // logging happens through writeVersionSection in runFixture
226 -}
227 -
193 /**
194 * Builds environment variables to pass to the container.
195 * Merges auto-passthrough vars with explicitly provided env vars.
@@ -352,8 +317,8 @@ function createDockerExecutors(
317 * With setup: Creates a Docker volume, runs setup command with volume mounted
318 * read-write, then runs the fixture with volume mounted read-only.
319 */
355 - function runFixture(options: { filename: string }): Promise<E2ETestResult>;
356 - function runFixture(options: { filename: string; setup: string }): Promise<E2ETestResultWithSetup>;
320 + function runFixture<const F extends string>(options: { filename: NonEmptyString<F> }): Promise<E2ETestResult>;
321 + function runFixture<const F extends string, const S extends string>(options: { filename: NonEmptyString<F>; setup: NonEmptyString<S> }): Promise<E2ETestResultWithSetup>;
322 async function runFixture(options: RunFixtureOptions): Promise<E2ETestResult | E2ETestResultWithSetup> {
323 const { filename, setup } = options;
324
@@ -547,7 +512,7 @@ export function runE2E(config: RunE2EInternalConfig): void {
512 // Call user's defineTests with bun:test functions and Docker utilities
513 defineTests({
514 runCmd: (cmd) => executors.runCmd(cmd),
550 - runFixture: ((opts) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
515 + runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
516 });
517
518 // Write version section after all tests for this version complete
ts/e2e-tests/_utils/src/types.ts
+18 -2
@@ -1,5 +1,18 @@
1 import { WELL_KNOWN_NODE_VERSIONS } from './const';
2
3 +export type NonEmptyArray<T> = [T, ...T[]];
4 +
5 +/**
6 + * Enforces that a string literal type is non-empty.
7 + * Used with `const` type parameters to catch empty string literals at compile time.
8 + *
9 + * @example
10 + * function greet<const T extends string>(name: NonEmptyString<T>) { ... }
11 + * greet('Alice'); // OK
12 + * greet(''); // Error: Type 'string' is not assignable to type 'never'
13 + */
14 +export type NonEmptyString<T extends string> = T extends '' ? never : T;
15 +
16 export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];
17
18 /**
@@ -80,8 +93,11 @@ export interface DefineTestsContext {
93 * expect(result.setup.exitCode).toBe(0);
94 */
95 runFixture: {
83 - (options: { filename: string }): Promise<E2ETestResult>;
84 - (options: { filename: string; setup: string }): Promise<E2ETestResultWithSetup>;
96 + <const F extends string>(options: { filename: NonEmptyString<F> }): Promise<E2ETestResult>;
97 + <const F extends string, const S extends string>(options: {
98 + filename: NonEmptyString<F>;
99 + setup: NonEmptyString<S>;
100 + }): Promise<E2ETestResultWithSetup>;
101 };
102 }
103