Skip to content

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

jkomyno6e010c7b5781
diff --git a/ts/e2e-tests/_utils/src/config.ts b/ts/e2e-tests/_utils/src/config.ts
index b2ad5e61c..845765286 100644
--- a/ts/e2e-tests/_utils/src/config.ts
+++ b/ts/e2e-tests/_utils/src/config.ts
@@ -2,7 +2,7 @@ import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { readFileSync } from 'node:fs';
import process from 'node:process';
-import type { NodeVersionMeta, NodeVersionFromUser, SkipInCI } from './types';
+import type { NodeVersionMeta, NodeVersionFromUser, SkipInCI, NonEmptyArray } from './types';
declare module 'bun' {
interface Env {
@@ -11,8 +11,6 @@ declare module 'bun' {
}
}
-type NonEmptyArray<T> = [T, ...T[]];
-
/**
* Determine if we're running in a Continuous Integration suite.
*/
diff --git a/ts/e2e-tests/_utils/src/runner.ts b/ts/e2e-tests/_utils/src/runner.ts
index 9e14a7756..779379621 100644
--- a/ts/e2e-tests/_utils/src/runner.ts
+++ b/ts/e2e-tests/_utils/src/runner.ts
@@ -1,7 +1,7 @@
import { describe, beforeAll, afterAll, it } from 'bun:test';
import { appendFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
-import type { DefineTestsContext, E2EConfig, E2ETestResult, E2ETestResultWithSetup, NodeVersionMeta, RunFixtureOptions } from './types';
+import type { DefineTestsContext, E2EConfig, E2ETestResult, E2ETestResultWithSetup, NodeVersionMeta, NonEmptyString, RunFixtureOptions } from './types';
import { getRepoRoot, resolveNodeVersionMetaList } from './config';
import { ensureNodeImage, runNodeContainer } from './image-lifecycle';
import { WELL_KNOWN_ENV_VARS } from './const';
@@ -190,41 +190,6 @@ class DebugLogManager {
}
}
-// ============================================================================
-// Legacy debug log support (for backward compatibility with runCmd)
-// ============================================================================
-
-/**
- * Debug log entry metadata.
- * @deprecated Use DebugLogManager for new code
- */
-interface DebugLogEntry {
- nodeVersion: string;
- command: string;
- containerName: string;
- result: E2ETestResult;
- /** Optional phase indicator for multi-step operations */
- phase?:
- // Setup phase before fixture is run, often used for install commands
- | 'setup'
- // Actual test fixture phase
- | 'fixture';
-}
-
-/**
- * Writes Docker run output to DEBUG.log in the test directory.
- * @deprecated Use DebugLogManager for new code - this is kept for runCmd() compatibility
- */
-async function writeDebugLog(
- _repoRoot: string,
- _testDirRelative: string,
- _entry: DebugLogEntry
-): Promise<void> {
- // No-op: logging is now handled by DebugLogManager at the version level
- // The runCmd function still calls this for API compatibility, but actual
- // logging happens through writeVersionSection in runFixture
-}
-
/**
* Builds environment variables to pass to the container.
* Merges auto-passthrough vars with explicitly provided env vars.
@@ -352,8 +317,8 @@ function createDockerExecutors(
* With setup: Creates a Docker volume, runs setup command with volume mounted
* read-write, then runs the fixture with volume mounted read-only.
*/
- function runFixture(options: { filename: string }): Promise<E2ETestResult>;
- function runFixture(options: { filename: string; setup: string }): Promise<E2ETestResultWithSetup>;
+ function runFixture<const F extends string>(options: { filename: NonEmptyString<F> }): Promise<E2ETestResult>;
+ function runFixture<const F extends string, const S extends string>(options: { filename: NonEmptyString<F>; setup: NonEmptyString<S> }): Promise<E2ETestResultWithSetup>;
async function runFixture(options: RunFixtureOptions): Promise<E2ETestResult | E2ETestResultWithSetup> {
const { filename, setup } = options;
@@ -547,7 +512,7 @@ export function runE2E(config: RunE2EInternalConfig): void {
// Call user's defineTests with bun:test functions and Docker utilities
defineTests({
runCmd: (cmd) => executors.runCmd(cmd),
- runFixture: ((opts) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
+ runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
});
// Write version section after all tests for this version complete
diff --git a/ts/e2e-tests/_utils/src/types.ts b/ts/e2e-tests/_utils/src/types.ts
index 9445f2607..dc859aa7a 100644
--- a/ts/e2e-tests/_utils/src/types.ts
+++ b/ts/e2e-tests/_utils/src/types.ts
@@ -1,5 +1,18 @@
import { WELL_KNOWN_NODE_VERSIONS } from './const';
+export type NonEmptyArray<T> = [T, ...T[]];
+
+/**
+ * Enforces that a string literal type is non-empty.
+ * Used with `const` type parameters to catch empty string literals at compile time.
+ *
+ * @example
+ * function greet<const T extends string>(name: NonEmptyString<T>) { ... }
+ * greet('Alice'); // OK
+ * greet(''); // Error: Type 'string' is not assignable to type 'never'
+ */
+export type NonEmptyString<T extends string> = T extends '' ? never : T;
+
export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];
/**
@@ -80,8 +93,11 @@ export interface DefineTestsContext {
* expect(result.setup.exitCode).toBe(0);
*/
runFixture: {
- (options: { filename: string }): Promise<E2ETestResult>;
- (options: { filename: string; setup: string }): Promise<E2ETestResultWithSetup>;
+ <const F extends string>(options: { filename: NonEmptyString<F> }): Promise<E2ETestResult>;
+ <const F extends string, const S extends string>(options: {
+ filename: NonEmptyString<F>;
+ setup: NonEmptyString<S>;
+ }): Promise<E2ETestResultWithSetup>;
};
}