@devries-cameron20 / composio Mirror · read-only / commits / 060e25b26
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 08:15 UTC

feat(ts/e2e): make E2ETestResultWithFiles generic over file keys

Thread `const F` through the runCmd overload so TypeScript infers precise file keys from the `files` array literal, eliminating the need for `?? ''` fallbacks when accessing captured file contents.

jkomyno committed Feb 18, 2026 at 15:33 UTC 060e25b266ec3aca3ec8f428172c9455e8cfeab6
3 files changed +11 -11
ts/e2e-tests/_utils/src/runner.ts
+3 -3
@@ -906,7 +906,7 @@ export function runE2E(config: RunE2EInternalConfig): void {
906
907 defineTests({
908 runtime: 'node',
909 - runCmd: (cmd) => executors.runCmd(cmd),
909 + runCmd: ((cmd: RunCmdInput) => executors.runCmd(cmd)) as DefineTestsContext['runCmd'],
910 runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
911 });
912
@@ -950,7 +950,7 @@ export function runE2E(config: RunE2EInternalConfig): void {
950
951 defineTests({
952 runtime: 'deno',
953 - runCmd: (cmd) => executors.runCmd(cmd),
953 + runCmd: ((cmd: RunCmdInput) => executors.runCmd(cmd)) as DefineTestsContext['runCmd'],
954 runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
955 });
956
@@ -994,7 +994,7 @@ export function runE2E(config: RunE2EInternalConfig): void {
994
995 defineTests({
996 runtime: 'cli',
997 - runCmd: (cmd) => executors.runCmd(cmd),
997 + runCmd: ((cmd: RunCmdInput) => executors.runCmd(cmd)) as DefineTestsContext['runCmd'],
998 runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],
999 });
1000
ts/e2e-tests/_utils/src/types.ts
+3 -3
@@ -80,9 +80,9 @@ export interface E2ETestResult {
80 /**
81 * Result of executing a command with requested file captures.
82 */
83 -export interface E2ETestResultWithFiles extends E2ETestResult {
83 +export interface E2ETestResultWithFiles<F extends string = string> extends E2ETestResult {
84 /** Captured file contents keyed by requested file path */
85 - files: Record<string, string>;
85 + files: { [K in F]: string };
86 }
87
88 /**
@@ -128,7 +128,7 @@ export interface DefineTestsContext {
128 /** Run an arbitrary command in the Docker container */
129 runCmd: {
130 <const C extends string>(command: NonEmptyString<C>): Promise<E2ETestResult>;
131 - <const C extends string>(options: { command: NonEmptyString<C>; files: NonEmptyArray<string> }): Promise<E2ETestResultWithFiles>;
131 + <const C extends string, const F extends string>(options: { command: NonEmptyString<C>; files: NonEmptyArray<F> }): Promise<E2ETestResultWithFiles<F>>;
132 };
133 /**
134 * Run a fixture file with Node.js.
ts/e2e-tests/cli/version/e2e.test.ts
+5 -5
@@ -16,7 +16,7 @@ e2e(import.meta.url, {
16 defineTests: ({ runCmd }) => {
17 const expectedVersion = String(cliPkg.version ?? '').trim();
18 let versionResult: E2ETestResult;
19 - let redirectedResult: E2ETestResultWithFiles;
19 + let redirectedResult: E2ETestResultWithFiles<'out.txt'>;
20
21 beforeAll(async () => {
22 versionResult = await runCmd('composio version');
@@ -36,7 +36,7 @@ e2e(import.meta.url, {
36 });
37
38 it('stderr matches snapshot', () => {
39 - expect(sanitizeOutput(versionResult.stderr)).toBe('');
39 + expect(versionResult.stderr).toBe('');
40 });
41 });
42
@@ -46,15 +46,15 @@ e2e(import.meta.url, {
46 });
47
48 it('stdout is empty', () => {
49 - expect(sanitizeOutput(redirectedResult.stdout)).toBe('');
49 + expect(redirectedResult.stdout).toBe('');
50 });
51
52 it('stderr is empty', () => {
53 - expect(sanitizeOutput(redirectedResult.stderr)).toBe('');
53 + expect(redirectedResult.stderr).toBe('');
54 });
55
56 it('out.txt matches snapshot', () => {
57 - expect(sanitizeOutput(redirectedResult.files['out.txt'] ?? '')).toBe(expectedVersion);
57 + expect(sanitizeOutput(redirectedResult.files['out.txt'])).toBe(expectedVersion);
58 });
59 });
60 },