@elaraai/e3-api-tests 0.0.2-beta.13 → 0.0.2-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli.d.ts +71 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +139 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/context.d.ts +49 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/context.js +108 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/fixtures.d.ts +61 -0
- package/dist/src/fixtures.d.ts.map +1 -0
- package/dist/src/fixtures.js +107 -0
- package/dist/src/fixtures.js.map +1 -0
- package/dist/src/index.d.ts +65 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +85 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/suites/cli.d.ts +15 -0
- package/dist/src/suites/cli.d.ts.map +1 -0
- package/dist/src/suites/cli.js +152 -0
- package/dist/src/suites/cli.js.map +1 -0
- package/dist/src/suites/dataflow.d.ts +12 -0
- package/dist/src/suites/dataflow.d.ts.map +1 -0
- package/dist/src/suites/dataflow.js +167 -0
- package/dist/src/suites/dataflow.js.map +1 -0
- package/dist/src/suites/datasets.d.ts +12 -0
- package/dist/src/suites/datasets.d.ts.map +1 -0
- package/dist/src/suites/datasets.js +88 -0
- package/dist/src/suites/datasets.js.map +1 -0
- package/dist/src/suites/packages.d.ts +12 -0
- package/dist/src/suites/packages.d.ts.map +1 -0
- package/dist/src/suites/packages.js +86 -0
- package/dist/src/suites/packages.js.map +1 -0
- package/dist/src/suites/platform.d.ts +12 -0
- package/dist/src/suites/platform.d.ts.map +1 -0
- package/dist/src/suites/platform.js +114 -0
- package/dist/src/suites/platform.js.map +1 -0
- package/dist/src/suites/repository.d.ts +12 -0
- package/dist/src/suites/repository.d.ts.map +1 -0
- package/dist/src/suites/repository.js +93 -0
- package/dist/src/suites/repository.js.map +1 -0
- package/dist/src/suites/workspaces.d.ts +12 -0
- package/dist/src/suites/workspaces.d.ts.map +1 -0
- package/dist/src/suites/workspaces.js +127 -0
- package/dist/src/suites/workspaces.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Result from running a CLI command.
|
|
7
|
+
*/
|
|
8
|
+
export interface CliResult {
|
|
9
|
+
exitCode: number;
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Options for running an e3 CLI command.
|
|
15
|
+
*/
|
|
16
|
+
export interface RunE3Options {
|
|
17
|
+
/** Optional stdin input */
|
|
18
|
+
input?: string;
|
|
19
|
+
/** Environment variables to add/override */
|
|
20
|
+
env?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the path to the e3 CLI binary.
|
|
24
|
+
*
|
|
25
|
+
* Resolves the path from the package location to the CLI binary.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getE3CliPath(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Run an e3 CLI command and wait for it to complete.
|
|
30
|
+
*
|
|
31
|
+
* @param args - Command arguments (e.g., ['repo', 'create', '.'])
|
|
32
|
+
* @param cwd - Working directory for the command
|
|
33
|
+
* @param options - Optional settings (input, env)
|
|
34
|
+
* @returns Promise with exit code, stdout, and stderr
|
|
35
|
+
*/
|
|
36
|
+
export declare function runE3Command(args: string[], cwd: string, options?: RunE3Options | string): Promise<CliResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Handle to a running CLI process that can be signaled.
|
|
39
|
+
*/
|
|
40
|
+
export interface RunningCliProcess {
|
|
41
|
+
/** Send a signal to the process */
|
|
42
|
+
kill: (signal: NodeJS.Signals) => void;
|
|
43
|
+
/** Promise that resolves when process exits */
|
|
44
|
+
result: Promise<CliResult>;
|
|
45
|
+
/** The child process PID */
|
|
46
|
+
pid: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Spawn an e3 CLI command that can be signaled.
|
|
50
|
+
*
|
|
51
|
+
* Unlike runE3Command, this returns immediately with a handle to the running
|
|
52
|
+
* process, allowing tests to send signals (SIGINT, SIGTERM) to it.
|
|
53
|
+
*
|
|
54
|
+
* @param args - Command arguments (e.g., ['start', '.', 'ws'])
|
|
55
|
+
* @param cwd - Working directory for the command
|
|
56
|
+
* @param options - Optional settings (env)
|
|
57
|
+
* @returns Handle to the running process
|
|
58
|
+
*/
|
|
59
|
+
export declare function spawnE3Command(args: string[], cwd: string, options?: {
|
|
60
|
+
env?: Record<string, string>;
|
|
61
|
+
}): RunningCliProcess;
|
|
62
|
+
/**
|
|
63
|
+
* Wait for a condition with timeout.
|
|
64
|
+
*
|
|
65
|
+
* @param condition - Function that returns true when condition is met
|
|
66
|
+
* @param timeoutMs - Maximum time to wait in milliseconds (default: 5000)
|
|
67
|
+
* @param checkIntervalMs - How often to check the condition (default: 100)
|
|
68
|
+
* @returns Promise that resolves when condition is met or rejects on timeout
|
|
69
|
+
*/
|
|
70
|
+
export declare function waitFor(condition: () => Promise<boolean> | boolean, timeoutMs?: number, checkIntervalMs?: number): Promise<void>;
|
|
71
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAUrC;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,GAC9B,OAAO,CAAC,SAAS,CAAC,CA4CpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC;IACvC,+CAA+C;IAC/C,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3B,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACzC,iBAAiB,CAyCnB;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EAC3C,SAAS,GAAE,MAAa,EACxB,eAAe,GAAE,MAAY,GAC5B,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* CLI execution utilities for testing.
|
|
7
|
+
*
|
|
8
|
+
* Helpers for running e3 CLI commands and capturing output.
|
|
9
|
+
*/
|
|
10
|
+
import { spawn } from 'node:child_process';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { dirname, join } from 'node:path';
|
|
13
|
+
/**
|
|
14
|
+
* Get the path to the e3 CLI binary.
|
|
15
|
+
*
|
|
16
|
+
* Resolves the path from the package location to the CLI binary.
|
|
17
|
+
*/
|
|
18
|
+
export function getE3CliPath() {
|
|
19
|
+
// From packages/e3-api-tests/dist/src/cli.js we need to find packages/e3-cli/dist/src/cli.js
|
|
20
|
+
// packages/e3-api-tests/dist/src/cli.js -> packages/e3-api-tests/dist/src -> ... -> packages/e3-cli/dist/src/cli.js
|
|
21
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
22
|
+
const srcDir = dirname(currentFile); // dist/src
|
|
23
|
+
const distDir = dirname(srcDir); // dist
|
|
24
|
+
const packageDir = dirname(distDir); // e3-api-tests
|
|
25
|
+
const packagesDir = dirname(packageDir); // packages
|
|
26
|
+
const cliPath = join(packagesDir, 'e3-cli', 'dist', 'src', 'cli.js');
|
|
27
|
+
return cliPath;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run an e3 CLI command and wait for it to complete.
|
|
31
|
+
*
|
|
32
|
+
* @param args - Command arguments (e.g., ['repo', 'create', '.'])
|
|
33
|
+
* @param cwd - Working directory for the command
|
|
34
|
+
* @param options - Optional settings (input, env)
|
|
35
|
+
* @returns Promise with exit code, stdout, and stderr
|
|
36
|
+
*/
|
|
37
|
+
export async function runE3Command(args, cwd, options) {
|
|
38
|
+
// Support legacy signature: runE3Command(args, cwd, input)
|
|
39
|
+
const opts = typeof options === 'string' ? { input: options } : (options ?? {});
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const cliPath = getE3CliPath();
|
|
42
|
+
const child = spawn('node', [cliPath, ...args], {
|
|
43
|
+
cwd,
|
|
44
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
45
|
+
env: { ...process.env, ...opts.env },
|
|
46
|
+
});
|
|
47
|
+
let stdout = '';
|
|
48
|
+
let stderr = '';
|
|
49
|
+
child.stdout.on('data', (data) => {
|
|
50
|
+
stdout += data.toString();
|
|
51
|
+
});
|
|
52
|
+
child.stderr.on('data', (data) => {
|
|
53
|
+
stderr += data.toString();
|
|
54
|
+
});
|
|
55
|
+
child.on('error', (error) => {
|
|
56
|
+
reject(error);
|
|
57
|
+
});
|
|
58
|
+
child.on('close', (code) => {
|
|
59
|
+
resolve({
|
|
60
|
+
exitCode: code ?? 1,
|
|
61
|
+
stdout,
|
|
62
|
+
stderr,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
// Write input if provided
|
|
66
|
+
if (opts.input !== undefined) {
|
|
67
|
+
child.stdin.write(opts.input);
|
|
68
|
+
child.stdin.end();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
child.stdin.end();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Spawn an e3 CLI command that can be signaled.
|
|
77
|
+
*
|
|
78
|
+
* Unlike runE3Command, this returns immediately with a handle to the running
|
|
79
|
+
* process, allowing tests to send signals (SIGINT, SIGTERM) to it.
|
|
80
|
+
*
|
|
81
|
+
* @param args - Command arguments (e.g., ['start', '.', 'ws'])
|
|
82
|
+
* @param cwd - Working directory for the command
|
|
83
|
+
* @param options - Optional settings (env)
|
|
84
|
+
* @returns Handle to the running process
|
|
85
|
+
*/
|
|
86
|
+
export function spawnE3Command(args, cwd, options) {
|
|
87
|
+
const cliPath = getE3CliPath();
|
|
88
|
+
const child = spawn('node', [cliPath, ...args], {
|
|
89
|
+
cwd,
|
|
90
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
91
|
+
env: { ...process.env, ...options?.env },
|
|
92
|
+
});
|
|
93
|
+
let stdout = '';
|
|
94
|
+
let stderr = '';
|
|
95
|
+
child.stdout.on('data', (data) => {
|
|
96
|
+
stdout += data.toString();
|
|
97
|
+
});
|
|
98
|
+
child.stderr.on('data', (data) => {
|
|
99
|
+
stderr += data.toString();
|
|
100
|
+
});
|
|
101
|
+
const result = new Promise((resolve, reject) => {
|
|
102
|
+
child.on('error', (error) => {
|
|
103
|
+
reject(error);
|
|
104
|
+
});
|
|
105
|
+
child.on('close', (code) => {
|
|
106
|
+
resolve({
|
|
107
|
+
exitCode: code ?? 1,
|
|
108
|
+
stdout,
|
|
109
|
+
stderr,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
child.stdin.end();
|
|
114
|
+
return {
|
|
115
|
+
kill: (signal) => child.kill(signal),
|
|
116
|
+
result,
|
|
117
|
+
pid: child.pid,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Wait for a condition with timeout.
|
|
122
|
+
*
|
|
123
|
+
* @param condition - Function that returns true when condition is met
|
|
124
|
+
* @param timeoutMs - Maximum time to wait in milliseconds (default: 5000)
|
|
125
|
+
* @param checkIntervalMs - How often to check the condition (default: 100)
|
|
126
|
+
* @returns Promise that resolves when condition is met or rejects on timeout
|
|
127
|
+
*/
|
|
128
|
+
export async function waitFor(condition, timeoutMs = 5000, checkIntervalMs = 100) {
|
|
129
|
+
const startTime = Date.now();
|
|
130
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
131
|
+
const result = await condition();
|
|
132
|
+
if (result) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
await new Promise(resolve => setTimeout(resolve, checkIntervalMs));
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`Timeout waiting for condition after ${timeoutMs}ms`);
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;A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K,UAAU,OAAO,CAC3B,SAA2C,EAC3C,YAAoB,IAAI,EACxB,kBAA0B,GAAG;IAE7B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,SAAS,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,uCAAuC,SAAS,IAAI,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { RequestOptions } from '@elaraai/e3-api-client';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for running API compliance tests.
|
|
8
|
+
*/
|
|
9
|
+
export interface TestConfig {
|
|
10
|
+
/** Base URL of the API server (e.g., "http://localhost:3000") */
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** Function that returns an auth token */
|
|
13
|
+
getToken: () => Promise<string>;
|
|
14
|
+
/** Optional: use an existing repo instead of creating one */
|
|
15
|
+
repoName?: string;
|
|
16
|
+
/** Whether to clean up created resources (default: true) */
|
|
17
|
+
cleanup?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Context provided to each test suite.
|
|
21
|
+
*/
|
|
22
|
+
export interface TestContext {
|
|
23
|
+
/** The test configuration */
|
|
24
|
+
config: TestConfig;
|
|
25
|
+
/** Repository name being tested */
|
|
26
|
+
repoName: string;
|
|
27
|
+
/** Temporary directory for test artifacts */
|
|
28
|
+
tempDir: string;
|
|
29
|
+
/** Get request options with current token */
|
|
30
|
+
opts: () => Promise<RequestOptions>;
|
|
31
|
+
/** Create a test package and return path to zip file */
|
|
32
|
+
createPackage: (name: string, version: string) => Promise<string>;
|
|
33
|
+
/** Import a package from a zip file */
|
|
34
|
+
importPackage: (zipPath: string) => Promise<void>;
|
|
35
|
+
/** Create a workspace */
|
|
36
|
+
createWorkspace: (name: string) => Promise<void>;
|
|
37
|
+
/** Deploy a package to a workspace */
|
|
38
|
+
deployPackage: (workspace: string, pkgRef: string) => Promise<void>;
|
|
39
|
+
/** Clean up all test resources */
|
|
40
|
+
cleanup: () => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a test context for API compliance tests.
|
|
44
|
+
*
|
|
45
|
+
* @param config - Test configuration
|
|
46
|
+
* @returns Test context with helpers for test setup
|
|
47
|
+
*/
|
|
48
|
+
export declare function createTestContext(config: TestConfig): Promise<TestContext>;
|
|
49
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAW7D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAEhB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,MAAM,EAAE,UAAU,CAAC;IAEnB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IAEjB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAEhB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IAEpC,wDAAwD;IACxD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAElE,uCAAuC;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD,yBAAyB;IACzB,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD,sCAAsC;IACtC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE,kCAAkC;IAClC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAgCD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CA0EhF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Test context and configuration for API compliance tests.
|
|
7
|
+
*/
|
|
8
|
+
import { mkdtempSync, rmSync, readFileSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
11
|
+
import { repoCreate, repoRemove, packageImport, workspaceCreate, workspaceDeploy, } from '@elaraai/e3-api-client';
|
|
12
|
+
import { createPackageZip } from './fixtures.js';
|
|
13
|
+
/**
|
|
14
|
+
* Track parent temp directories for cleanup.
|
|
15
|
+
*/
|
|
16
|
+
const tempDirParents = new Map();
|
|
17
|
+
/**
|
|
18
|
+
* Create a temporary directory for test artifacts.
|
|
19
|
+
*/
|
|
20
|
+
function createTempDir() {
|
|
21
|
+
const parentDir = mkdtempSync(join(tmpdir(), 'e3-api-tests-'));
|
|
22
|
+
const testDir = join(parentDir, 'test');
|
|
23
|
+
tempDirParents.set(testDir, parentDir);
|
|
24
|
+
return testDir;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Remove a temporary directory and its parent.
|
|
28
|
+
*/
|
|
29
|
+
function removeTempDir(testDir) {
|
|
30
|
+
const parentDir = tempDirParents.get(testDir);
|
|
31
|
+
if (parentDir) {
|
|
32
|
+
try {
|
|
33
|
+
rmSync(parentDir, { recursive: true, force: true });
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Ignore cleanup errors
|
|
37
|
+
}
|
|
38
|
+
tempDirParents.delete(testDir);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a test context for API compliance tests.
|
|
43
|
+
*
|
|
44
|
+
* @param config - Test configuration
|
|
45
|
+
* @returns Test context with helpers for test setup
|
|
46
|
+
*/
|
|
47
|
+
export async function createTestContext(config) {
|
|
48
|
+
const tempDir = createTempDir();
|
|
49
|
+
// Track created resources for cleanup
|
|
50
|
+
const createdWorkspaces = [];
|
|
51
|
+
const createdPackages = [];
|
|
52
|
+
let createdRepo = false;
|
|
53
|
+
// Determine repo name - use provided or generate unique one
|
|
54
|
+
const repoName = config.repoName ?? `test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
55
|
+
// Create repo if not using an existing one
|
|
56
|
+
if (!config.repoName) {
|
|
57
|
+
const token = await config.getToken();
|
|
58
|
+
await repoCreate(config.baseUrl, repoName, { token });
|
|
59
|
+
createdRepo = true;
|
|
60
|
+
}
|
|
61
|
+
const context = {
|
|
62
|
+
config,
|
|
63
|
+
repoName,
|
|
64
|
+
tempDir,
|
|
65
|
+
opts: async () => ({ token: await config.getToken() }),
|
|
66
|
+
createPackage: async (name, version) => {
|
|
67
|
+
const zipPath = await createPackageZip(tempDir, name, version);
|
|
68
|
+
return zipPath;
|
|
69
|
+
},
|
|
70
|
+
importPackage: async (zipPath) => {
|
|
71
|
+
const token = await config.getToken();
|
|
72
|
+
const packageZip = readFileSync(zipPath);
|
|
73
|
+
const result = await packageImport(config.baseUrl, repoName, packageZip, { token });
|
|
74
|
+
createdPackages.push({ name: result.name, version: result.version });
|
|
75
|
+
},
|
|
76
|
+
createWorkspace: async (name) => {
|
|
77
|
+
const token = await config.getToken();
|
|
78
|
+
await workspaceCreate(config.baseUrl, repoName, name, { token });
|
|
79
|
+
createdWorkspaces.push(name);
|
|
80
|
+
},
|
|
81
|
+
deployPackage: async (workspace, pkgRef) => {
|
|
82
|
+
const token = await config.getToken();
|
|
83
|
+
await workspaceDeploy(config.baseUrl, repoName, workspace, pkgRef, { token });
|
|
84
|
+
},
|
|
85
|
+
cleanup: async () => {
|
|
86
|
+
if (config.cleanup === false) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const token = await config.getToken();
|
|
90
|
+
const opts = { token };
|
|
91
|
+
// Clean up in reverse order: workspaces, packages, repo
|
|
92
|
+
// Note: We don't clean up workspaces/packages individually since
|
|
93
|
+
// removing the repo will clean everything up
|
|
94
|
+
if (createdRepo) {
|
|
95
|
+
try {
|
|
96
|
+
await repoRemove(config.baseUrl, repoName, opts);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Ignore cleanup errors
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Clean up temp directory
|
|
103
|
+
removeTempDir(tempDir);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
return context;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,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SL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Create a simple compute package for testing.
|
|
7
|
+
*
|
|
8
|
+
* Creates a package with:
|
|
9
|
+
* - Input: "value" (Integer, default 10)
|
|
10
|
+
* - Task: "compute" - multiplies input by 2
|
|
11
|
+
*
|
|
12
|
+
* @param tempDir - Directory to write the zip file
|
|
13
|
+
* @param name - Package name
|
|
14
|
+
* @param version - Package version
|
|
15
|
+
* @returns Path to the created zip file
|
|
16
|
+
*/
|
|
17
|
+
export declare function createPackageZip(tempDir: string, name: string, version: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a package with multiple inputs for testing.
|
|
20
|
+
*
|
|
21
|
+
* Creates a package with:
|
|
22
|
+
* - Input: "a" (Integer, default 1)
|
|
23
|
+
* - Input: "b" (Integer, default 2)
|
|
24
|
+
* - Task: "add" - returns a + b
|
|
25
|
+
*
|
|
26
|
+
* @param tempDir - Directory to write the zip file
|
|
27
|
+
* @param name - Package name
|
|
28
|
+
* @param version - Package version
|
|
29
|
+
* @returns Path to the created zip file
|
|
30
|
+
*/
|
|
31
|
+
export declare function createMultiInputPackageZip(tempDir: string, name: string, version: string): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a package with string input for testing.
|
|
34
|
+
*
|
|
35
|
+
* Creates a package with:
|
|
36
|
+
* - Input: "config" (String, default "default")
|
|
37
|
+
* - Task: "echo" - returns input unchanged
|
|
38
|
+
*
|
|
39
|
+
* @param tempDir - Directory to write the zip file
|
|
40
|
+
* @param name - Package name
|
|
41
|
+
* @param version - Package version
|
|
42
|
+
* @returns Path to the created zip file
|
|
43
|
+
*/
|
|
44
|
+
export declare function createStringPackageZip(tempDir: string, name: string, version: string): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Create a package with diamond dependencies for testing dataflow.
|
|
47
|
+
*
|
|
48
|
+
* Creates a package with:
|
|
49
|
+
* - Input: "a" (Integer, default 10)
|
|
50
|
+
* - Input: "b" (Integer, default 5)
|
|
51
|
+
* - Task: "left" - returns a + b
|
|
52
|
+
* - Task: "right" - returns a * b
|
|
53
|
+
* - Task: "merge" - returns left + right
|
|
54
|
+
*
|
|
55
|
+
* @param tempDir - Directory to write the zip file
|
|
56
|
+
* @param name - Package name
|
|
57
|
+
* @param version - Package version
|
|
58
|
+
* @returns Path to the created zip file
|
|
59
|
+
*/
|
|
60
|
+
export declare function createDiamondPackageZip(tempDir: string, name: string, version: string): Promise<string>;
|
|
61
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/fixtures.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Test fixture creation utilities.
|
|
7
|
+
*
|
|
8
|
+
* Creates test packages using the @elaraai/e3 SDK to ensure
|
|
9
|
+
* fixtures stay in sync with the SDK.
|
|
10
|
+
*/
|
|
11
|
+
import { mkdirSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import e3 from '@elaraai/e3';
|
|
14
|
+
import { IntegerType, StringType, East } from '@elaraai/east';
|
|
15
|
+
/**
|
|
16
|
+
* Create a simple compute package for testing.
|
|
17
|
+
*
|
|
18
|
+
* Creates a package with:
|
|
19
|
+
* - Input: "value" (Integer, default 10)
|
|
20
|
+
* - Task: "compute" - multiplies input by 2
|
|
21
|
+
*
|
|
22
|
+
* @param tempDir - Directory to write the zip file
|
|
23
|
+
* @param name - Package name
|
|
24
|
+
* @param version - Package version
|
|
25
|
+
* @returns Path to the created zip file
|
|
26
|
+
*/
|
|
27
|
+
export async function createPackageZip(tempDir, name, version) {
|
|
28
|
+
mkdirSync(tempDir, { recursive: true });
|
|
29
|
+
const input = e3.input('value', IntegerType, 10n);
|
|
30
|
+
const task = e3.task('compute', [input], East.function([IntegerType], IntegerType, ($, x) => x.multiply(2n)));
|
|
31
|
+
const pkg = e3.package(name, version, task);
|
|
32
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
33
|
+
await e3.export(pkg, zipPath);
|
|
34
|
+
return zipPath;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a package with multiple inputs for testing.
|
|
38
|
+
*
|
|
39
|
+
* Creates a package with:
|
|
40
|
+
* - Input: "a" (Integer, default 1)
|
|
41
|
+
* - Input: "b" (Integer, default 2)
|
|
42
|
+
* - Task: "add" - returns a + b
|
|
43
|
+
*
|
|
44
|
+
* @param tempDir - Directory to write the zip file
|
|
45
|
+
* @param name - Package name
|
|
46
|
+
* @param version - Package version
|
|
47
|
+
* @returns Path to the created zip file
|
|
48
|
+
*/
|
|
49
|
+
export async function createMultiInputPackageZip(tempDir, name, version) {
|
|
50
|
+
mkdirSync(tempDir, { recursive: true });
|
|
51
|
+
const inputA = e3.input('a', IntegerType, 1n);
|
|
52
|
+
const inputB = e3.input('b', IntegerType, 2n);
|
|
53
|
+
const task = e3.task('add', [inputA, inputB], East.function([IntegerType, IntegerType], IntegerType, ($, a, b) => a.add(b)));
|
|
54
|
+
const pkg = e3.package(name, version, task);
|
|
55
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
56
|
+
await e3.export(pkg, zipPath);
|
|
57
|
+
return zipPath;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a package with string input for testing.
|
|
61
|
+
*
|
|
62
|
+
* Creates a package with:
|
|
63
|
+
* - Input: "config" (String, default "default")
|
|
64
|
+
* - Task: "echo" - returns input unchanged
|
|
65
|
+
*
|
|
66
|
+
* @param tempDir - Directory to write the zip file
|
|
67
|
+
* @param name - Package name
|
|
68
|
+
* @param version - Package version
|
|
69
|
+
* @returns Path to the created zip file
|
|
70
|
+
*/
|
|
71
|
+
export async function createStringPackageZip(tempDir, name, version) {
|
|
72
|
+
mkdirSync(tempDir, { recursive: true });
|
|
73
|
+
const input = e3.input('config', StringType, 'default');
|
|
74
|
+
const task = e3.task('echo', [input], East.function([StringType], StringType, ($, x) => x));
|
|
75
|
+
const pkg = e3.package(name, version, task);
|
|
76
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
77
|
+
await e3.export(pkg, zipPath);
|
|
78
|
+
return zipPath;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create a package with diamond dependencies for testing dataflow.
|
|
82
|
+
*
|
|
83
|
+
* Creates a package with:
|
|
84
|
+
* - Input: "a" (Integer, default 10)
|
|
85
|
+
* - Input: "b" (Integer, default 5)
|
|
86
|
+
* - Task: "left" - returns a + b
|
|
87
|
+
* - Task: "right" - returns a * b
|
|
88
|
+
* - Task: "merge" - returns left + right
|
|
89
|
+
*
|
|
90
|
+
* @param tempDir - Directory to write the zip file
|
|
91
|
+
* @param name - Package name
|
|
92
|
+
* @param version - Package version
|
|
93
|
+
* @returns Path to the created zip file
|
|
94
|
+
*/
|
|
95
|
+
export async function createDiamondPackageZip(tempDir, name, version) {
|
|
96
|
+
mkdirSync(tempDir, { recursive: true });
|
|
97
|
+
const inputA = e3.input('a', IntegerType, 10n);
|
|
98
|
+
const inputB = e3.input('b', IntegerType, 5n);
|
|
99
|
+
const leftTask = e3.task('left', [inputA, inputB], East.function([IntegerType, IntegerType], IntegerType, ($, a, b) => a.add(b)));
|
|
100
|
+
const rightTask = e3.task('right', [inputA, inputB], East.function([IntegerType, IntegerType], IntegerType, ($, a, b) => a.multiply(b)));
|
|
101
|
+
const mergeTask = e3.task('merge', [leftTask.output, rightTask.output], East.function([IntegerType, IntegerType], IntegerType, ($, a, b) => a.add(b)));
|
|
102
|
+
const pkg = e3.package(name, version, mergeTask);
|
|
103
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
104
|
+
await e3.export(pkg, zipPath);
|
|
105
|
+
return zipPath;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/fixtures.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,IAAY,EACZ,OAAe;IAEf,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAExC,MAAM,KA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AAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAE9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* e3 API Compliance Tests
|
|
7
|
+
*
|
|
8
|
+
* Shared test suites for verifying e3 API implementations.
|
|
9
|
+
* Works with both local (e3-api-server) and cloud (e3-aws) deployments.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { describe, before, after } from 'node:test';
|
|
14
|
+
* import { createServer } from '@elaraai/e3-api-server';
|
|
15
|
+
* import { allTests, createTestContext } from '@elaraai/e3-api-tests';
|
|
16
|
+
*
|
|
17
|
+
* describe('API compliance', () => {
|
|
18
|
+
* let server: Server;
|
|
19
|
+
* let context: TestContext;
|
|
20
|
+
*
|
|
21
|
+
* before(async () => {
|
|
22
|
+
* server = await createServer({ reposDir: tempDir, port: 0 });
|
|
23
|
+
* await server.start();
|
|
24
|
+
* context = await createTestContext({
|
|
25
|
+
* baseUrl: `http://localhost:${server.port}`,
|
|
26
|
+
* getToken: async () => 'test-token',
|
|
27
|
+
* });
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* after(async () => {
|
|
31
|
+
* await context.cleanup();
|
|
32
|
+
* await server.stop();
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* allTests(() => context);
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export { createTestContext, type TestConfig, type TestContext } from './context.js';
|
|
40
|
+
export { createPackageZip, createMultiInputPackageZip, createStringPackageZip, createDiamondPackageZip, } from './fixtures.js';
|
|
41
|
+
export { runE3Command, spawnE3Command, getE3CliPath, waitFor, type CliResult, type RunE3Options, type RunningCliProcess, } from './cli.js';
|
|
42
|
+
export { repositoryTests } from './suites/repository.js';
|
|
43
|
+
export { packageTests } from './suites/packages.js';
|
|
44
|
+
export { workspaceTests } from './suites/workspaces.js';
|
|
45
|
+
export { datasetTests } from './suites/datasets.js';
|
|
46
|
+
export { dataflowTests } from './suites/dataflow.js';
|
|
47
|
+
export { platformTests } from './suites/platform.js';
|
|
48
|
+
export { cliTests } from './suites/cli.js';
|
|
49
|
+
import type { TestContext } from './context.js';
|
|
50
|
+
/**
|
|
51
|
+
* Register all API test suites (excluding CLI tests).
|
|
52
|
+
*
|
|
53
|
+
* CLI tests require additional credentials setup and are registered separately.
|
|
54
|
+
*
|
|
55
|
+
* @param getContext - Function that returns the current test context
|
|
56
|
+
*/
|
|
57
|
+
export declare function allApiTests(getContext: () => TestContext): void;
|
|
58
|
+
/**
|
|
59
|
+
* Register all test suites including CLI tests.
|
|
60
|
+
*
|
|
61
|
+
* @param getContext - Function that returns the current test context
|
|
62
|
+
* @param getCredentialsEnv - Function that returns env vars for CLI auth
|
|
63
|
+
*/
|
|
64
|
+
export declare function allTests(getContext: () => TestContext, getCredentialsEnv: () => Record<string, string>): void;
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGpF,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,OAAO,EACP,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAShD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,WAAW,GAAG,IAAI,CAO/D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,WAAW,EAC7B,iBAAiB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9C,IAAI,CAGN"}
|