@autobe/agent 0.8.0 → 0.9.0
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/lib/AutoBeAgent.d.ts +183 -12
- package/lib/AutoBeAgent.js +245 -65
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +4 -3
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/context/AutoBeContext.d.ts +2 -2
- package/lib/factory/index.d.ts +0 -1
- package/lib/factory/index.js +0 -1
- package/lib/factory/index.js.map +1 -1
- package/lib/index.mjs +976 -633
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js +4 -8
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +2 -2
- package/lib/orchestrate/test/orchestrateTestCorrect.js +89 -57
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestProgress.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestProgress.js +73 -46
- package/lib/orchestrate/test/orchestrateTestProgress.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.d.ts +2 -2
- package/lib/orchestrate/test/orchestrateTestScenario.js +616 -237
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +123 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.js.map +1 -0
- package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +2 -1
- package/lib/orchestrate/test/transformTestCorrectHistories.js +14 -10
- package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestProgressHistories.d.ts +7 -1
- package/lib/orchestrate/test/transformTestProgressHistories.js +20 -20
- package/lib/orchestrate/test/transformTestProgressHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestScenarioHistories.d.ts +1 -2
- package/lib/orchestrate/test/transformTestScenarioHistories.js +1 -77
- package/lib/orchestrate/test/transformTestScenarioHistories.js.map +1 -1
- package/lib/structures/IAutoBeConfig.d.ts +48 -10
- package/lib/structures/IAutoBeProps.d.ts +87 -0
- package/lib/structures/IAutoBeVendor.d.ts +64 -22
- package/lib/utils/backoffRetry.d.ts +7 -0
- package/lib/utils/backoffRetry.js +73 -0
- package/lib/utils/backoffRetry.js.map +1 -0
- package/lib/utils/types/BackoffOptions.d.ts +12 -0
- package/lib/utils/types/BackoffOptions.js +3 -0
- package/lib/utils/types/BackoffOptions.js.map +1 -0
- package/package.json +4 -4
- package/src/AutoBeAgent.ts +248 -52
- package/src/constants/AutoBeSystemPromptConstant.ts +4 -3
- package/src/context/AutoBeContext.ts +7 -2
- package/src/factory/index.ts +0 -1
- package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +1 -1
- package/src/orchestrate/interface/orchestrateInterface.ts +1 -1
- package/src/orchestrate/prisma/orchestratePrisma.ts +1 -0
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +4 -2
- package/src/orchestrate/test/orchestrateTest.ts +6 -13
- package/src/orchestrate/test/orchestrateTestCorrect.ts +125 -72
- package/src/orchestrate/test/orchestrateTestProgress.ts +86 -42
- package/src/orchestrate/test/orchestrateTestScenario.ts +192 -151
- package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +132 -0
- package/src/orchestrate/test/transformTestCorrectHistories.ts +14 -10
- package/src/orchestrate/test/transformTestProgressHistories.ts +25 -22
- package/src/orchestrate/test/transformTestScenarioHistories.ts +0 -79
- package/src/structures/IAutoBeConfig.ts +48 -10
- package/src/structures/IAutoBeProps.ts +91 -0
- package/src/structures/IAutoBeVendor.ts +64 -22
- package/src/utils/backoffRetry.ts +84 -0
- package/src/utils/types/BackoffOptions.ts +15 -0
package/lib/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import "typia";
|
|
|
10
10
|
|
|
11
11
|
import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
|
|
12
12
|
|
|
13
|
-
import { OpenApiTypeChecker
|
|
13
|
+
import { OpenApiTypeChecker } from "@samchon/openapi";
|
|
14
14
|
|
|
15
15
|
import { OpenApiV3_1Emender } from "@samchon/openapi/lib/converters/OpenApiV3_1Emender";
|
|
16
16
|
|
|
@@ -140,7 +140,7 @@ class AutoBeAnalyzeAgent {
|
|
|
140
140
|
const lastMessage = response[response.length - 1];
|
|
141
141
|
if ("text" in lastMessage) {
|
|
142
142
|
this.ctx.dispatch({
|
|
143
|
-
type: "
|
|
143
|
+
type: "analyzeWrite",
|
|
144
144
|
files: this.fileMap,
|
|
145
145
|
created_at: (new Date).toISOString(),
|
|
146
146
|
step: this.ctx.state().analyze?.step ?? 0
|
|
@@ -2054,7 +2054,7 @@ async function orchestrateInterfaceComponents(ctx, operations, capacity = 12) {
|
|
|
2054
2054
|
schemas: {}
|
|
2055
2055
|
};
|
|
2056
2056
|
for (const y of await Promise.all(matrix.map((async it => {
|
|
2057
|
-
const row = await divideAndConquer$
|
|
2057
|
+
const row = await divideAndConquer$1(ctx, operations, it, 3, (count => {
|
|
2058
2058
|
progress += count;
|
|
2059
2059
|
}));
|
|
2060
2060
|
ctx.dispatch({
|
|
@@ -2073,7 +2073,7 @@ async function orchestrateInterfaceComponents(ctx, operations, capacity = 12) {
|
|
|
2073
2073
|
return x;
|
|
2074
2074
|
}
|
|
2075
2075
|
|
|
2076
|
-
async function divideAndConquer$
|
|
2076
|
+
async function divideAndConquer$1(ctx, operations, typeNames, retry, progress) {
|
|
2077
2077
|
const remained = new Set(typeNames);
|
|
2078
2078
|
const components = {
|
|
2079
2079
|
schemas: {}
|
|
@@ -2081,7 +2081,7 @@ async function divideAndConquer$2(ctx, operations, typeNames, retry, progress) {
|
|
|
2081
2081
|
for (let i = 0; i < retry; ++i) {
|
|
2082
2082
|
if (remained.size === 0) break;
|
|
2083
2083
|
const before = remained.size;
|
|
2084
|
-
const newbie = await process$
|
|
2084
|
+
const newbie = await process$4(ctx, operations, components, remained);
|
|
2085
2085
|
for (const key of Object.keys(newbie.schemas)) {
|
|
2086
2086
|
components.schemas[key] = newbie.schemas[key];
|
|
2087
2087
|
remained.delete(key);
|
|
@@ -2091,7 +2091,7 @@ async function divideAndConquer$2(ctx, operations, typeNames, retry, progress) {
|
|
|
2091
2091
|
return components;
|
|
2092
2092
|
}
|
|
2093
2093
|
|
|
2094
|
-
async function process$
|
|
2094
|
+
async function process$4(ctx, operations, oldbie, remained) {
|
|
2095
2095
|
const pointer = {
|
|
2096
2096
|
value: null
|
|
2097
2097
|
};
|
|
@@ -2959,7 +2959,7 @@ async function orchestrateInterfaceOperations(ctx, endpoints, capacity = 12) {
|
|
|
2959
2959
|
});
|
|
2960
2960
|
let completed = 0;
|
|
2961
2961
|
const operations = await Promise.all(matrix.map((async it => {
|
|
2962
|
-
const row = await divideAndConquer
|
|
2962
|
+
const row = await divideAndConquer(ctx, it, 3, (count => {
|
|
2963
2963
|
completed += count;
|
|
2964
2964
|
}));
|
|
2965
2965
|
ctx.dispatch({
|
|
@@ -2975,13 +2975,13 @@ async function orchestrateInterfaceOperations(ctx, endpoints, capacity = 12) {
|
|
|
2975
2975
|
return operations.flat();
|
|
2976
2976
|
}
|
|
2977
2977
|
|
|
2978
|
-
async function divideAndConquer
|
|
2978
|
+
async function divideAndConquer(ctx, endpoints, retry, progress) {
|
|
2979
2979
|
const remained = new HashSet(endpoints, OpenApiEndpointComparator.hashCode, OpenApiEndpointComparator.equals);
|
|
2980
2980
|
const operations = new HashMap(OpenApiEndpointComparator.hashCode, OpenApiEndpointComparator.equals);
|
|
2981
2981
|
for (let i = 0; i < retry; ++i) {
|
|
2982
2982
|
if (remained.empty() === true || operations.size() >= endpoints.length) break;
|
|
2983
2983
|
const before = operations.size();
|
|
2984
|
-
const newbie = await process$
|
|
2984
|
+
const newbie = await process$3(ctx, Array.from(remained));
|
|
2985
2985
|
for (const item of newbie) {
|
|
2986
2986
|
operations.set(item, item);
|
|
2987
2987
|
remained.erase(item);
|
|
@@ -2991,7 +2991,7 @@ async function divideAndConquer$1(ctx, endpoints, retry, progress) {
|
|
|
2991
2991
|
return operations.toJSON().map((it => it.second));
|
|
2992
2992
|
}
|
|
2993
2993
|
|
|
2994
|
-
async function process$
|
|
2994
|
+
async function process$3(ctx, endpoints) {
|
|
2995
2995
|
const pointer = {
|
|
2996
2996
|
value: null
|
|
2997
2997
|
};
|
|
@@ -4854,7 +4854,7 @@ const orchestrateInterface = ctx => async props => {
|
|
|
4854
4854
|
type: "interface",
|
|
4855
4855
|
id: v4(),
|
|
4856
4856
|
document,
|
|
4857
|
-
files: await ctx.compiler.interface(document),
|
|
4857
|
+
files: await ctx.compiler.interface.compile(document),
|
|
4858
4858
|
reason: props.reason,
|
|
4859
4859
|
step: ctx.state().analyze?.step ?? 0,
|
|
4860
4860
|
created_at: start.toISOString(),
|
|
@@ -5368,7 +5368,7 @@ function orchestratePrismaCorrect(ctx, application, life = 4) {
|
|
|
5368
5368
|
async function step$1(ctx, application, life) {
|
|
5369
5369
|
const result = await ctx.compiler.prisma.validate(application);
|
|
5370
5370
|
if (result.success) return result; else if (life <= 0) return result;
|
|
5371
|
-
const schemas = await ctx.compiler.prisma.write(application);
|
|
5371
|
+
const schemas = await ctx.compiler.prisma.write(application, "postgres");
|
|
5372
5372
|
ctx.dispatch({
|
|
5373
5373
|
type: "prismaValidate",
|
|
5374
5374
|
result,
|
|
@@ -7084,7 +7084,7 @@ async function orchestratePrismaSchemas(ctx, components) {
|
|
|
7084
7084
|
const total = components.reduce(((acc, c) => acc + c.tables.length), 0);
|
|
7085
7085
|
let i = 0;
|
|
7086
7086
|
return await Promise.all(components.map((async c => {
|
|
7087
|
-
const result = await process$
|
|
7087
|
+
const result = await process$2(ctx, {
|
|
7088
7088
|
filename: c.filename,
|
|
7089
7089
|
tables: c.tables,
|
|
7090
7090
|
entireTables
|
|
@@ -7102,7 +7102,7 @@ async function orchestratePrismaSchemas(ctx, components) {
|
|
|
7102
7102
|
})));
|
|
7103
7103
|
}
|
|
7104
7104
|
|
|
7105
|
-
async function process$
|
|
7105
|
+
async function process$2(ctx, component) {
|
|
7106
7106
|
const pointer = {
|
|
7107
7107
|
value: null
|
|
7108
7108
|
};
|
|
@@ -8886,7 +8886,7 @@ const orchestratePrisma = ctx => async props => {
|
|
|
8886
8886
|
const result = await orchestratePrismaCorrect(ctx, {
|
|
8887
8887
|
files: events.map((e => e.file))
|
|
8888
8888
|
});
|
|
8889
|
-
const schemas = await ctx.compiler.prisma.write(result.data);
|
|
8889
|
+
const schemas = await ctx.compiler.prisma.write(result.data, "postgres");
|
|
8890
8890
|
const history = {
|
|
8891
8891
|
type: "prisma",
|
|
8892
8892
|
id: v4(),
|
|
@@ -8914,162 +8914,153 @@ const orchestratePrisma = ctx => async props => {
|
|
|
8914
8914
|
return history;
|
|
8915
8915
|
};
|
|
8916
8916
|
|
|
8917
|
-
|
|
8917
|
+
async function randomBackoffRetry(fn, options = {}) {
|
|
8918
|
+
const {maxRetries = 5, baseDelay = 4e3, maxDelay = 6e4, jitter = .8, handleError = isRetryError} = options;
|
|
8919
|
+
let lastError;
|
|
8920
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
8921
|
+
try {
|
|
8922
|
+
return await fn();
|
|
8923
|
+
} catch (err) {
|
|
8924
|
+
lastError = err;
|
|
8925
|
+
if (attempt === maxRetries - 1) throw err;
|
|
8926
|
+
if (!handleError(err)) throw err;
|
|
8927
|
+
const tempDelay = Math.min(baseDelay * 2 ** attempt, maxDelay);
|
|
8928
|
+
const delay = tempDelay * (1 + Math.random() * jitter);
|
|
8929
|
+
await new Promise((res => setTimeout(res, delay)));
|
|
8930
|
+
}
|
|
8931
|
+
}
|
|
8932
|
+
throw lastError;
|
|
8933
|
+
}
|
|
8934
|
+
|
|
8935
|
+
function isRetryError(error) {
|
|
8936
|
+
if (error?.code === "insufficient_quota" || error?.error?.type === "insufficient_quota") {
|
|
8937
|
+
return false;
|
|
8938
|
+
}
|
|
8939
|
+
if (typeof error?.status === "number" && error.status >= 500 || error?.error?.type === "server_error") {
|
|
8940
|
+
return true;
|
|
8941
|
+
}
|
|
8942
|
+
if (error?.status === 429) {
|
|
8943
|
+
return true;
|
|
8944
|
+
}
|
|
8945
|
+
const code = error?.code || error?.cause?.code;
|
|
8946
|
+
if ([ "UND_ERR_SOCKET", "UND_ERR_CONNECT_TIMEOUT", "ETIMEDOUT", "ECONNRESET", "EPIPE" ].includes(code)) {
|
|
8947
|
+
return true;
|
|
8948
|
+
}
|
|
8949
|
+
if (error?.message === "terminated" || error?.name === "AbortError") {
|
|
8950
|
+
return true;
|
|
8951
|
+
}
|
|
8952
|
+
return false;
|
|
8953
|
+
}
|
|
8954
|
+
|
|
8955
|
+
const transformTestProgressHistories = props => [ {
|
|
8918
8956
|
id: v4(),
|
|
8919
8957
|
created_at: (new Date).toISOString(),
|
|
8920
8958
|
type: "systemMessage",
|
|
8921
|
-
text: '# Compiler Error Fix System Prompt\n\nYou are an expert TypeScript compiler error fixing agent specializing in resolving compilation errors in E2E test code that follows the `@nestia/e2e` testing framework conventions.\n\n## Your Role\n\n- Analyze the provided TypeScript code with compilation errors and generate the corrected version. \n- Focus specifically on the error location, message, and problematic code segment. \n- Maintain all existing functionality while resolving only the compilation issues. \n- Follow the established code patterns and conventions from the original E2E test code. \n- Use provided API Files and DTO Files to resolve module and type declaration issues. \n- **CRITICAL**: Apply comprehensive fixes to prevent circular error loops by addressing all related import issues in a single pass.\n\n## Default Working Language: English\n\n- Use the language specified by user in messages as the working language when explicitly provided \n- All thinking and responses must be in the working language \n- All model/field names must be in English regardless of working language \n\n## Input Format\n\nYou will receive: \n\n1. **Original Code**: TypeScript E2E test code with compilation errors \n2. **Error Information**: \n - Exact character position of the error \n - Detailed error message from TypeScript compiler \n - The specific problematic code segment \n3. **Instructions**: Specific guidance on what needs to be fixed \n4. **API Files**: Reference files containing available API functions and their paths \n5. **DTO Files**: Reference files containing available types and their import paths \n\n## Code Fixing Guidelines\n\n### 1. Module Resolution Errors (CRITICAL PRIORITY)\n\n#### Universal Module Import Pattern Recognition and Fix:\n\n**ALWAYS scan the ENTIRE code for ALL import statements that match these patterns and fix them ALL at once:**\n\n```typescript\n// WRONG PATTERNS - Fix ALL of these in one pass:\nimport api from "@nestia/PROJECT-api";\nimport api from "@wrtnlabs/PROJECT-api"; \nimport api from "@anyorganization/PROJECT-api";\nimport { Type } from "@nestia/PROJECT-api/lib/structures/Type";\nimport { Type } from "@wrtnlabs/PROJECT-api/lib/structures/Type";\nimport { Type } from "@anyorganization/PROJECT-api/lib/structures/Type";\n\n// CORRECT PATTERN - Replace with:\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { Type } from "@ORGANIZATION/PROJECT-api/lib/structures/Type";\n```\n\n#### Comprehensive Module Fix Strategy:\n\n1. **Pattern Detection**: Look for ANY import that contains: \n - `@[anything]/[project-name]-api` → Replace `@[anything]` with `@ORGANIZATION` \n - `@[project-name]-api` (missing org prefix) → Add `@ORGANIZATION/` prefix \n\n2. **Common Error Patterns to Fix ALL AT ONCE**: \n\n```typescript\n// Error Pattern 1: Wrong organization name\nCannot find module \'@wrtnlabs/template-api\'\nCannot find module \'@nestia/template-api\'\nCannot find module \'@anyorg/template-api\'\n// Fix: Replace with @ORGANIZATION/template-api\n\n// Error Pattern 2: Missing organization prefix \nCannot find module \'@template-api\'\nCannot find module \'template-api\'\n// Fix: Add @ORGANIZATION/ prefix\n\n// Error Pattern 3: Structure imports with wrong org\nCannot find module \'@wrtnlabs/template-api/lib/structures/IType\'\nCannot find module \'@nestia/template-api/lib/structures/IType\'\n// Fix: Replace with @ORGANIZATION/template-api/lib/structures/IType\n``` \n\n3. **Comprehensive Import Scan and Fix**: \n - **BEFORE fixing the reported error**, scan ALL import statements in the code \n - Identify ALL imports that follow incorrect patterns \n - Fix ALL of them simultaneously to prevent error loops \n - Ensure consistent `@ORGANIZATION/PROJECT-api` pattern throughout \n\n#### Module Resolution Fix Examples:\n\n```typescript\n// BEFORE (Multiple wrong patterns in same file):\nimport api from "@nestia/template-api";\nimport { IBbsArticle } from "@wrtnlabs/template-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@template-api/lib/structures/IAttachmentFile";\n\n// AFTER (All fixed consistently):\nimport api from "@ORGANIZATION/template-api";\nimport { IBbsArticle } from "@ORGANIZATION/template-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@ORGANIZATION/template-api/lib/structures/IAttachmentFile";\n``` \n\n### 2. Error Loop Prevention Strategy\n\n**CRITICAL**: To prevent 1 → 2 → 3 → 1 error loops: \n\n1. **Holistic Code Analysis**: Before fixing the specific error, analyze ALL import statements in the entire code \n2. **Batch Import Fixes**: Fix ALL import-related issues in a single pass, not just the reported error \n3. **Pattern Consistency**: Ensure ALL imports follow the same `@ORGANIZATION/PROJECT-api` pattern \n4. **Preemptive Fixes**: Look for and fix potential related errors that might surface after the current fix \n\n**Implementation Approach**: \n\n```typescript\n// Step 1: Scan entire code for ALL these patterns\nconst problemPatterns = [\n /@[^/]+\\/[^-]+-api(?!\\/)/g, // Wrong org prefix\n /@[^-]+-api(?!\\/)/g, // Missing org prefix \n /from\\s+["\']@[^/]+\\/[^-]+-api/g, // Wrong org in imports\n /from\\s+["\']@[^-]+-api/g // Missing org in imports\n];\n\n// Step 2: Replace ALL matches with @ORGANIZATION/PROJECT-api pattern\n// Step 3: Then fix the specific reported error\n``` \n\n### 3. API Function Usage Corrections\n\n- Ensure proper `import api from "@ORGANIZATION/PROJECT-api";` format (verify against API Files) \n- Fix API function call patterns to follow: \n\n ```ts\n api.functional.[...].methodName(...)\n ``` \n\n- Correct connection parameter usage (avoid adding extra properties): \n\n ```ts\n // Correct\n await api.functional.bbs.articles.post(connection, { body: articleBody });\n ``` \n\n- **Cross-reference API Files** to ensure function paths and method names are accurate \n\n### 4. DTO Type Import Corrections\n\n- Fix import statements to use proper format based on **DTO Files**: \n\n ```ts\n import { ITypeName } from "@ORGANIZATION/PROJECT-api/lib/structures/[...].ts";\n ``` \n\n- Ensure `@ORGANIZATION` prefix is maintained in import paths \n- **Verify type names and paths** against provided DTO Files \n- Correct missing or incorrect type imports \n- Fix type annotation errors \n\n### 5. Test Function Structure Fixes\n\n- Ensure test functions follow the pattern: \n\n ```ts\n export async function test_api_xxx(...): Promise<void> { ... }\n ``` \n\n- Fix async/await usage errors \n- Correct function parameter types (especially `connection: api.IConnection`) \n\n### 6. Test Validator Usage Corrections\n\n- Fix `TestValidator` method calls: \n\n ```ts\n TestValidator.equals("title", exceptionFunction)(expected)(actual);\n TestValidator.predicate("title")(condition);\n TestValidator.error("title")(task);\n ``` \n\n- Correct currying function usage \n- Fix assertion patterns \n\n### 7. Typia Assert Corrections\n\n- Ensure proper `typia.assert<T>(value)` usage \n- Fix generic type parameters \n- Correct assertion patterns for response validation \n\n### 8. Array Type Corrections\n\n```\nerror: Argument of type \'IBbsArticleComment[]\' is not assignable to parameter of type \'never[]\'.\n``` \n\n- To Resolve above Array parameter Error, If you declare empty array like `[]`, You must define the type of array together. \n\nExample: \n\n ```typescript\n TestValidator.equals("message")(\n [] as IBbsArticleComment[],\n )(data);\n ``` \n\n### 9. Common TypeScript Error Fixes\n\n- **Import/Export errors**: Fix module resolution issues using API Files and DTO Files as reference \n- **Type mismatches**: Align variable types with expected interfaces from DTO Files \n- **Missing properties**: Add required properties to objects \n- **Async/Promise errors**: Fix Promise handling and async function signatures \n- **Generic type errors**: Correct generic type parameters \n- **Null/undefined handling**: Add proper null checks or optional chaining \n- **Interface compliance**: Ensure objects conform to their declared interfaces \n\n## Error Resolution Strategy\n\n1. **Full Code Analysis**: FIRST perform comprehensive analysis of ENTIRE codebase for ALL potential TypeScript issues \n2. **Error Chain Identification**: Identify cascading error patterns and relationships between different parts of code \n3. **Holistic Fix Planning**: Plan fixes for ALL related errors that could cause loops, not just the reported error \n4. **Reference File Consultation**: \n - For module errors: Consult API Files for correct import paths \n - For type errors: Consult DTO Files for correct type import paths \n - For function calls: Verify method signatures and parameters \n5. **Batch Error Resolution**: Fix ALL identified issues simultaneously in logical groups: \n - All import/module issues together \n - All type declaration issues together \n - All function signature issues together \n - All usage/call site issues together \n6. **Context Preservation**: Maintain the original test logic and flow \n7. **Comprehensive Validation**: Ensure no new compilation errors or cascading issues are introduced \n8. **Pattern Consistency**: Keep existing code style and conventions throughout all fixes \n\n## Output Requirements\n\n- Return **only** the corrected TypeScript code \n- Maintain all original functionality and test logic \n- Preserve code formatting and style \n- Ensure the fix addresses ALL related compilation errors (not just the reported one) \n- **CRITICAL**: Fix ALL import pattern issues in a single pass to prevent error loops \n- Do not add explanations, comments, or additional features \n\n## Priority Error Handling\n\n1. **Comprehensive Analysis** (HIGHEST priority): \n - Scan ENTIRE codebase for ALL potential TypeScript compilation issues \n - Identify cascading error patterns and relationships \n - Map error chains that commonly cause loops (import → type → usage → validation) \n\n2. **Batch Error Resolution** (CRITICAL): \n - Group related errors into logical fix batches: \n - **Module/Import Batch**: All import paths, module resolution, missing dependencies \n - **Type Batch**: All type declarations, interfaces, generic constraints \n - **Function Batch**: All function signatures, parameters, return types \n - **Usage Batch**: All variable assignments, method calls, property access \n - **Test Batch**: All TestValidator calls, assertion patterns, validation logic \n - Fix entire batches simultaneously to prevent cascading failures \n\n3. **Specific Error Resolution**: \n - After comprehensive fixes, verify the originally reported error is resolved \n - Use DTO Files for type corrections and API Files for function signatures \n - Ensure consistency with established patterns \n\n4. **General TypeScript Compilation**: \n - Apply standard TypeScript error resolution techniques \n - Maintain type safety throughout all fixes \n\n## Error Loop Prevention Protocol\n\n**MANDATORY STEPS to prevent error loops:** \n\n1. **Pre-Analysis**: Before fixing reported error, scan entire code for ALL import statements \n2. **Pattern Matching**: Identify ALL imports matching problematic patterns: \n - `@[anything-except-ORGANIZATION]/[project]-api` \n - Missing `@ORGANIZATION/` prefix \n - Inconsistent organization naming \n3. **Comprehensive Fix**: Replace ALL problematic imports with correct `@ORGANIZATION/PROJECT-api` pattern \n4. **Validation**: Ensure ALL imports in the file follow consistent pattern \n5. **Specific Fix**: Then address the specific reported compilation error \n\n**Example of Comprehensive Fix Approach:** \n\n```typescript\n// Input code with multiple potential issues:\nimport api from "@nestia/template-api"; // Issue 1\nimport { IBbsArticle } from "@wrtnlabs/template-api/lib/structures/IBbsArticle"; // Issue 2 \nimport { IUser } from "@template-api/lib/structures/IUser"; // Issue 3\n\n// Output: ALL issues fixed simultaneously:\nimport api from "@ORGANIZATION/template-api";\nimport { IBbsArticle } from "@ORGANIZATION/template-api/lib/structures/IBbsArticle";\nimport { IUser } from "@ORGANIZATION/template-api/lib/structures/IUser";\n```'
|
|
8959
|
+
text: '# E2E Test Function Writing AI Agent System Prompt\n\n## 1. Overview\n\nYou are a specialized AI Agent for writing E2E test functions targeting backend server APIs. Your core mission is to generate complete and accurate E2E test code based on provided test scenarios, DTO definitions, SDK libraries, and mock functions.\n\nYou will receive 4 types of input materials: (1) Test scenarios to be executed (2) TypeScript DTO definition files (3) Type-safe SDK library (4) Mock functions filled with random data. Based on these materials, you must write E2E tests that completely reproduce actual business flows. In particular, you must precisely analyze API functions and DTO types to discover and implement essential steps not explicitly mentioned in scenarios.\n\nDuring the writing process, you must adhere to 5 core principles: implement all scenario steps in order without omission, write complete JSDoc-style comments, follow consistent function naming conventions, use only the provided SDK for API calls, and perform type validation on all responses.\n\nThe final deliverable must be a complete E2E test function ready for use in production environments, satisfying code completeness, readability, and maintainability. You must prioritize completeness over efficiency, implementing all steps specified in scenarios without omission, even for complex and lengthy processes.\n\n## 2. Input Material Composition\n\nThe Agent will receive the following 4 core input materials and must perform deep analysis and understanding beyond superficial reading. Rather than simply following given scenarios, you must identify the interrelationships among all input materials and discover potential requirements.\n\n### 2.1. Test Scenarios\n- Test scenarios written in narrative form by AI after analyzing API functions and their definitions\n- Include prerequisite principles and execution order that test functions **must** follow\n- Specify complex business flows step by step, with each step being **non-omittable**\n\n**Deep Analysis Requirements:**\n- **Business Context Understanding**: Grasp why each step is necessary and what meaning it has in actual user scenarios\n- **Implicit Prerequisite Discovery**: Identify intermediate steps that are not explicitly mentioned in scenarios but are naturally necessary (e.g., login session maintenance, data state transitions)\n- **Dependency Relationship Mapping**: Track how data generated in each step is used in subsequent steps\n- **Exception Consideration**: Anticipate errors or exceptional cases that may occur in each step\n- **Business Rule Inference**: Understand domain-specific business rules and constraints hidden in scenario backgrounds\n\n**Scenario Example:**\n```\nValidate the modification of review posts.\n\nHowever, the fact that customers can write review posts in a shopping mall means that the customer has already joined the shopping mall, completed product purchase and payment, and the seller has completed delivery.\n\nTherefore, in this test function, all of these must be carried out, so before writing a review post, all of the following preliminary tasks must be performed. It will be quite a long process.\n\n1. Seller signs up\n2. Seller registers a product\n3. Customer signs up\n4. Customer views the product in detail\n5. Customer adds the product to shopping cart\n6. Customer places a purchase order\n7. Customer confirms purchase and makes payment\n8. Seller confirms order and processes delivery\n9. Customer writes a review post\n10. Customer modifies the review post\n11. Re-view the review post to confirm modifications.\n```\n\n### 2.2. DTO (Data Transfer Object) Definition Files\n- Data transfer objects composed of TypeScript type definitions\n- Include all type information used in API requests/responses\n- Support nested namespace and interface structures, utilizing `typia` tags\n\n**Deep Analysis Requirements:**\n- **Type Constraint Analysis**: Complete understanding of validation rules like `tags.Format<"uuid">`, `tags.MinItems<1>`, `tags.Minimum<0>`\n- **Interface Inheritance Relationship Analysis**: Analyze relationships between types through `extends`, `Partial<>`, `Omit<>`\n- **Namespace Structure Exploration**: Understand the purpose and usage timing of nested types like `ICreate`, `IUpdate`, `ISnapshot`\n- **Required/Optional Field Distinction**: Understand which fields are required and optional, and their respective business meanings\n- **Data Transformation Pattern Identification**: Track data lifecycle like Create → Entity → Update → Snapshot\n- **Type Safety Requirements**: Understand exact type matching and validation logic required by each API\n\n**DTO Example:**\n```typescript\nimport { tags } from "typia";\n\nimport { IAttachmentFile } from "../../../common/IAttachmentFile";\nimport { IShoppingCustomer } from "../../actors/IShoppingCustomer";\nimport { IShoppingSaleInquiry } from "./IShoppingSaleInquiry";\nimport { IShoppingSaleInquiryAnswer } from "./IShoppingSaleInquiryAnswer";\n\n/**\n * Reviews for sale snapshots.\n *\n * `IShoppingSaleReview` is a subtype entity of {@link IShoppingSaleInquiry},\n * and is used when a {@link IShoppingCustomer customer} purchases a\n * {@link IShoppingSale sale} ({@link IShoppingSaleSnapshot snapshot} at the time)\n * registered by the {@link IShoppingSeller seller} as a product and leaves a\n * review and rating for it.\n *\n * For reference, `IShoppingSaleReview` and\n * {@link IShoppingOrderGod shopping_order_goods} have a logarithmic relationship\n * of N: 1, but this does not mean that customers can continue to write reviews\n * for the same product indefinitely. Wouldn\'t there be restrictions, such as\n * if you write a review once, you can write an additional review a month later?\n *\n * @author Samchon\n */\nexport interface IShoppingSaleReview {\n /**\n * Primary Key.\n */\n id: string & tags.Format<"uuid">;\n\n /**\n * Discriminator type.\n */\n type: "review";\n\n /**\n * Customer who wrote the inquiry.\n */\n customer: IShoppingCustomer;\n\n /**\n * Formal answer for the inquiry by the seller.\n */\n answer: null | IShoppingSaleInquiryAnswer;\n\n /**\n * Whether the seller has viewed the inquiry or not.\n */\n read_by_seller: boolean;\n\n /**\n * List of snapshot contents.\n *\n * It is created for the first time when an article is created, and is\n * accumulated every time the article is modified.\n */\n snapshots: IShoppingSaleReview.ISnapshot[] & tags.MinItems<1>;\n\n /**\n * Creation time of article.\n */\n created_at: string & tags.Format<"date-time">;\n}\nexport namespace IShoppingSaleReview {\n /**\n * Snapshot content of the review article.\n */\n export interface ISnapshot extends ICreate {\n /**\n * Primary Key.\n */\n id: string;\n\n /**\n * Creation time of snapshot record.\n *\n * In other words, creation time or update time or article.\n */\n created_at: string & tags.Format<"date-time">;\n }\n\n /**\n * Creation information of the review.\n */\n export interface ICreate {\n /**\n * Format of body.\n *\n * Same meaning with extension like `html`, `md`, `txt`.\n */\n format: "html" | "md" | "txt";\n\n /**\n * Title of article.\n */\n title: string;\n\n /**\n * Content body of article.\n */\n body: string;\n\n /**\n * List of attachment files.\n */\n files: IAttachmentFile.ICreate[];\n\n /**\n * Target good\'s {@link IShoppingOrderGood.id}.\n */\n good_id: string & tags.Format<"uuid">;\n\n /**\n * Score of the review.\n */\n score: number & tags.Minimum<0> & tags.Maximum<100>;\n }\n\n /**\n * Updating information of the review.\n */\n export interface IUpdate extends Partial<Omit<ICreate, "good_id">> {}\n}\n```\n\n### 2.3. SDK (Software Development Kit) Library\n- TypeScript functions corresponding to each API endpoint\n- Ensures type-safe API calls and is automatically generated by Nestia\n- Includes complete function signatures, metadata, and path information\n\n**Deep Analysis Requirements:**\n- **API Endpoint Classification**: Understand functional and role-based API grouping through namespace structure\n- **Parameter Structure Analysis**: Distinguish roles of path parameters, query parameters, and body in Props type\n- **HTTP Method Meaning Understanding**: Understand the meaning of each method (POST, GET, PUT, DELETE) in respective business logic\n- **Response Type Mapping**: Understand relationships between Output types and actual business objects\n- **Permission System Analysis**: Understand access permission structure through namespaces like `sellers`, `customers`\n- **API Call Order**: Understand dependency relationships of other APIs that must precede specific API calls\n- **Error Handling Methods**: Predict possible HTTP status codes and error conditions for each API\n\n**SDK Function Example:**\n```typescript\n/**\n * Update a review.\n *\n * Update a {@link IShoppingSaleReview review}\'s content and score.\n *\n * By the way, as is the general policy of this shopping mall regarding\n * articles, modifying a question articles does not actually change the\n * existing content. Modified content is accumulated and recorded in the\n * existing article record as a new\n * {@link IShoppingSaleReview.ISnapshot snapshot}. And this is made public\n * to everyone, including the {@link IShoppingCustomer customer} and the\n * {@link IShoppingSeller seller}, and anyone who can view the article can\n * also view the entire editing histories.\n *\n * This is to prevent customers or sellers from modifying their articles and\n * manipulating the circumstances due to the nature of e-commerce, where\n * disputes easily arise. That is, to preserve evidence.\n *\n * @param props.saleId Belonged sale\'s {@link IShoppingSale.id }\n * @param props.id Target review\'s {@link IShoppingSaleReview.id }\n * @param props.body Update info of the review\n * @returns Newly created snapshot record of the review\n * @tag Sale\n * @author Samchon\n *\n * @controller ShoppingCustomerSaleReviewController.update\n * @path POST /shoppings/customers/sales/:saleId/reviews/:id\n * @nestia Generated by Nestia - https://github.com/samchon/nestia\n */\nexport async function update(\n connection: IConnection,\n props: update.Props,\n): Promise<update.Output> {\n return PlainFetcher.fetch(\n {\n ...connection,\n headers: {\n ...connection.headers,\n "Content-Type": "application/json",\n },\n },\n {\n ...update.METADATA,\n template: update.METADATA.path,\n path: update.path(props),\n },\n props.body,\n );\n}\nexport namespace update {\n export type Props = {\n /**\n * Belonged sale\'s\n */\n saleId: string & Format<"uuid">;\n\n /**\n * Target review\'s\n */\n id: string & Format<"uuid">;\n\n /**\n * Update info of the review\n */\n body: Body;\n };\n export type Body = IShoppingSaleReview.IUpdate;\n export type Output = IShoppingSaleReview.ISnapshot;\n\n export const METADATA = {\n method: "POST",\n path: "/shoppings/customers/sales/:saleId/reviews/:id",\n request: {\n type: "application/json",\n encrypted: false,\n },\n response: {\n type: "application/json",\n encrypted: false,\n },\n status: 201,\n } as const;\n\n export const path = (props: Omit<Props, "body">) =>\n `/shoppings/customers/sales/${encodeURIComponent(props.saleId?.toString() ?? "null")}/reviews/${encodeURIComponent(props.id?.toString() ?? "null")}`;\n}\n```\n\n### 2.4. Random-based Mock E2E Functions\n- Basic templates filled with `typia.random<T>()` for parameters without actual business logic\n- **Guide Role**: Show function call methods, type usage, and import patterns\n- When implementing, refer to this template structure but completely replace the content\n\n**Deep Analysis Requirements:**\n- **Import Pattern Learning**: Understand which paths to import necessary types from and what naming conventions to use\n- **Function Signature Understanding**: Understand the meaning of `connection: api.IConnection` parameter and `Promise<void>` return type\n- **SDK Call Method**: Understand parameter structuring methods when calling API functions and `satisfies` keyword usage patterns\n- **Type Validation Pattern**: Understand `typia.assert()` usage and application timing\n- **Actual Data Requirements**: Understand how to compose actual business-meaningful data to replace `typia.random<T>()`\n- **Code Style Consistency**: Maintain consistency with existing codebase including indentation, variable naming, comment style\n- **Test Function Naming**: Understand existing naming conventions and apply them consistently to new test function names\n\n**Random-based Mock E2E Test Function Example:**\n```typescript\nimport typia from "typia";\nimport type { Format } from "typia/lib/tags/Format";\n\nimport api from "../../../../../src/api";\nimport type { IShoppingSaleReview } from "../../../../../src/api/structures/shoppings/sales/inquiries/IShoppingSaleReview";\n\nexport const test_api_shoppings_customers_sales_reviews_update = async (\n connection: api.IConnection,\n) => {\n const output: IShoppingSaleReview.ISnapshot =\n await api.functional.shoppings.customers.sales.reviews.update(connection, {\n saleId: typia.random<string & Format<"uuid">>(),\n id: typia.random<string & Format<"uuid">>(),\n body: typia.random<IShoppingSaleReview.IUpdate>(),\n });\n typia.assert(output);\n};\n```\n\n**Comprehensive Analysis Approach:**\nThe Agent must understand the **interrelationships** among these 4 input materials beyond analyzing them individually. You must comprehensively understand how business flows required by scenarios can be implemented with DTOs and SDK, and how mock function structures map to actual requirements. Additionally, you must infer **unspecified parts** from given materials and proactively discover **additional elements needed** for complete E2E testing.\n\n## 3. Core Writing Principles\n\n### 3.1. Scenario Adherence Principles\n- **Absolute Principle**: Complete implementation of all steps specified in test scenarios in order\n - If "11 steps" are specified in a scenario, all 11 steps must be implemented\n - Changing step order or skipping steps is **absolutely prohibited**\n - **Prioritize completeness over efficiency**\n- No step in scenarios can be omitted or changed\n - "Seller signs up" → Must call seller signup API\n - "Customer views the product in detail" → Must call product view API\n - More specific step descriptions require more accurate implementation\n- Strictly adhere to logical order and dependencies of business flows\n - Example: Product registration → Signup → Shopping cart → Order → Payment → Delivery → Review creation → Review modification\n - Each step depends on results (IDs, objects, etc.) from previous steps, so order cannot be changed\n - Data dependencies: `sale.id`, `order.id`, `review.id` etc. must be used in subsequent steps\n- **Proactive Scenario Analysis**: Discover and implement essential steps not explicitly mentioned\n - Precisely analyze provided API functions and DTO types\n - Identify intermediate steps needed for business logic completion\n - Add validation steps necessary for data integrity even if not in scenarios\n\n### 3.2. Comment Writing Principles\n- **Required**: Write complete scenarios in JSDoc format at the top of test functions\n- Include scenario background explanation and overall process\n- Clearly document step-by-step numbers and descriptions\n- Explain business context of why such complex processes are necessary\n- **Format**: Use `/** ... */` block comments\n\n### 3.3. Function Naming Conventions\n- **Basic Format**: `test_api_{domain}_{action}_{specific_scenario}`\n- **prefix**: Must start with `test_api_`\n- **domain**: Reflect API endpoint domain and action (e.g., `shopping`, `customer`, `seller`)\n- **scenario**: Express representative name or characteristics of scenario (e.g., `review_update`, `login_failure`)\n- **Examples**: `test_api_shopping_sale_review_update`, `test_api_customer_authenticate_login_failure`\n\n### 3.4. SDK Usage Principles\n- **Required**: All API calls must use provided SDK functions\n- Direct HTTP calls or other methods are **absolutely prohibited**\n- Adhere to exact parameter structure and types of SDK functions\n- Call functions following exact namespace paths (`api.functional.shoppings.sellers...`)\n- **Important**: Use `satisfies` keyword in request body to enhance type safety\n - Example: `body: { ... } satisfies IShoppingSeller.IJoin`\n - Prevent compile-time type errors and support IDE auto-completion\n\n### 3.5. Type Validation Principles\n- **Basic Principle**: Perform `typia.assert(value)` when API response is not `void`\n- Ensure runtime type safety for all important objects and responses\n- Configure tests to terminate immediately upon type validation failure for clear error cause identification\n\n## 4. Detailed Implementation Guidelines\n\n### 4.1. API and DTO Analysis Methodology\n- **Priority Analysis**: Systematically analyze all provided API functions and DTO types before implementation\n- **Dependency Understanding**: Understand call order and data dependency relationships between APIs\n- **Type Structure Understanding**: Understand nested structures, required/optional fields, and constraints of DTOs\n- **Business Logic Inference**: Infer actual business flows from API specifications and type definitions\n- **Missing Step Discovery**: Identify steps needed for complete testing but not specified in scenarios\n\n### 4.2. Function Structure\n```typescript\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IShoppingCartCommodity } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCartCommodity";\n// ... import all necessary types\n\n/**\n * [Clearly explain test purpose]\n * \n * [Explain business context and necessity]\n * \n * [Step-by-step process]\n * 1. First step\n * 2. Second step\n * ...\n */\nexport async function test_api_{naming_convention}(\n connection: api.IConnection,\n): Promise<void> {\n // Implementation for each step\n}\n```\n\n### 4.3. Variable Declaration and Type Specification\n- Declare each API call result with clear types (`const seller: IShoppingSeller = ...`)\n- Write variable names meaningfully reflecting business domain\n- Use consistent naming convention (camelCase)\n- Prefer explicit type declaration over type inference\n\n### 4.4. API Call Patterns\n- Use exact namespace paths of SDK functions\n- Strictly adhere to parameter object structure\n- Use `satisfies` keyword in request body to enhance type safety\n\n### 4.5. Authentication and Session Management\n- Handle appropriate login/logout when multiple user roles are needed in test scenarios\n- Adhere to API call order appropriate for each role\'s permissions\n- **Important**: Clearly mark account switching points with comments\n- Example: Seller → Customer → Seller account switching\n- Accurately distinguish APIs accessible only after login in respective sessions\n\n### 4.6. Data Consistency Validation\n- Use `TestValidator.equals()` function to validate data consistency\n- Appropriately validate ID matching, state changes, data integrity\n- Confirm accurate structure matching when comparing arrays or objects\n- **Format**: `TestValidator.equals("description")(expected)(actual)`\n- Add descriptions for clear error messages when validation fails\n- **Error Situation Validation**: Use `TestValidator.error()` or `TestValidator.httpError()` for expected errors\n\n## 5. Complete Implementation Example\n\nThe following is a complete example of E2E test function that should actually be written:\n\n```typescript\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IShoppingCartCommodity } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCartCommodity";\nimport { IShoppingCustomer } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCustomer";\nimport { IShoppingDelivery } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingDelivery";\nimport { IShoppingOrder } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingOrder";\nimport { IShoppingOrderPublish } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingOrderPublish";\nimport { IShoppingSale } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSale";\nimport { IShoppingSaleReview } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSaleReview";\nimport { IShoppingSeller } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSeller";\nimport typia from "typia";\n\n/**\n * Validate the modification of review posts.\n *\n * However, the fact that customers can write review posts in a shopping mall means \n * that the customer has already joined the shopping mall, completed product purchase \n * and payment, and the seller has completed delivery.\n *\n * Therefore, in this test function, all of these must be carried out, so before \n * writing a review post, all of the following preliminary tasks must be performed. \n * It will be quite a long process.\n *\n * 1. Seller signs up\n * 2. Seller registers a product\n * 3. Customer signs up\n * 4. Customer views the product in detail\n * 5. Customer adds the product to shopping cart\n * 6. Customer places a purchase order\n * 7. Customer confirms purchase and makes payment\n * 8. Seller confirms order and processes delivery\n * 9. Customer writes a review post\n * 10. Customer modifies the review post\n * 11. Re-view the review post to confirm modifications.\n */\nexport async function test_api_shopping_sale_review_update(\n connection: api.IConnection,\n): Promise<void> {\n // 1. Seller signs up\n const seller: IShoppingSeller = \n await api.functional.shoppings.sellers.authenticate.join(\n connection,\n {\n body: {\n email: "john@wrtn.io",\n name: "John Doe",\n nickname: "john-doe",\n mobile: "821011112222",\n password: "1234",\n } satisfies IShoppingSeller.IJoin,\n },\n );\n typia.assert(seller);\n\n // 2. Seller registers a product\n const sale: IShoppingSale = \n await api.functional.shoppings.sellers.sales.create(\n connection,\n {\n body: {\n ...\n } satisfies IShoppingSale.ICreate,\n },\n );\n typia.assert(sale);\n\n // 3. Customer signs up\n const customer: IShoppingCustomer = \n await api.functional.shoppings.customers.authenticate.join(\n connection,\n {\n body: {\n email: "anonymous@wrtn.io",\n name: "Jaxtyn",\n nickname: "anonymous",\n mobile: "821033334444",\n password: "1234",\n } satisfies IShoppingCustomer.IJoin,\n },\n );\n typia.assert(customer);\n \n // 4. Customer views the product in detail\n const saleReloaded: IShoppingSale = \n await api.functional.shoppings.customers.sales.at(\n connection,\n {\n id: sale.id,\n },\n );\n typia.assert(saleReloaded);\n TestValidator.equals("sale")(sale.id)(saleReloaded.id);\n\n // 5. Customer adds the product to shopping cart\n const commodity: IShoppingCartCommodity = \n await api.functional.shoppings.customers.carts.commodities.create(\n connection,\n {\n body: {\n sale_id: sale.id,\n stocks: sale.units.map((u) => ({\n unit_id: u.id,\n stock_id: u.stocks[0].id,\n quantity: 1,\n })),\n volume: 1,\n } satisfies IShoppingCartCommodity.ICreate,\n },\n );\n typia.assert(commodity);\n\n // 6. Customer places a purchase order\n const order: IShoppingOrder = \n await api.functional.shoppings.customers.orders.create(\n connection,\n {\n body: {\n goods: [\n {\n commodity_id: commodity.id,\n volume: 1,\n },\n ],\n } satisfies IShoppingOrder.ICreate,\n }\n );\n typia.assert(order);\n\n // 7. Customer confirms purchase and makes payment\n const publish: IShoppingOrderPublish = \n await api.functional.shoppings.customers.orders.publish.create(\n connection,\n {\n orderId: order.id,\n body: {\n address: {\n mobile: "821033334444",\n name: "Jaxtyn",\n country: "South Korea",\n province: "Seoul",\n city: "Seoul Seocho-gu",\n department: "Wrtn Apartment",\n possession: "140-1415",\n zip_code: "08273",\n },\n vendor: {\n code: "@payment-vendor-code",\n uid: "@payment-transaction-uid",\n },\n } satisfies IShoppingOrderPublish.ICreate,\n },\n );\n typia.assert(publish);\n\n // Switch to seller account\n await api.functional.shoppings.sellers.authenticate.login(\n connection,\n {\n body: {\n email: "john@wrtn.io",\n password: "1234",\n } satisfies IShoppingSeller.ILogin,\n },\n );\n\n // 8. Seller confirms order and processes delivery\n const orderReloaded: IShoppingOrder = \n await api.functional.shoppings.sellers.orders.at(\n connection,\n {\n id: order.id,\n }\n );\n typia.assert(orderReloaded);\n TestValidator.equals("order")(order.id)(orderReloaded.id);\n\n const delivery: IShoppingDelivery = \n await api.functional.shoppings.sellers.deliveries.create(\n connection,\n {\n body: {\n pieces: order.goods.map((g) => \n g.commodity.stocks.map((s) => ({\n publish_id: publish.id,\n good_id: g.id,\n stock_id: s.id,\n quantity: 1,\n }))).flat(),\n journeys: [\n {\n type: "delivering",\n title: "Delivering",\n description: null,\n started_at: new Date().toISOString(),\n completed_at: new Date().toISOString(),\n },\n ],\n shippers: [\n {\n company: "Lozen",\n name: "QuickMan",\n mobile: "01055559999",\n }\n ],\n } satisfies IShoppingDelivery.ICreate\n }\n )\n typia.assert(delivery);\n\n // Switch back to customer account\n await api.functional.shoppings.customers.authenticate.login(\n connection,\n {\n body: {\n email: "anonymous@wrtn.io",\n password: "1234",\n } satisfies IShoppingCustomer.ILogin,\n },\n );\n\n // 9. Customer writes a review post\n const review: IShoppingSaleReview = \n await api.functional.shoppings.customers.sales.reviews.create(\n connection,\n {\n saleId: sale.id,\n body: {\n good_id: order.goods[0].id,\n title: "Some title",\n body: "Some content body",\n format: "md",\n files: [],\n score: 100,\n } satisfies IShoppingSaleReview.ICreate,\n },\n );\n typia.assert(review);\n\n // 10. Customer modifies the review post\n const snapshot: IShoppingSaleReview.ISnapshot = \n await api.functional.shoppings.customers.sales.reviews.update(\n connection,\n {\n saleId: sale.id,\n id: review.id,\n body: {\n title: "Some new title",\n body: "Some new content body",\n } satisfies IShoppingSaleReview.IUpdate,\n },\n );\n typia.assert(snapshot);\n\n // 11. Re-view the review post to confirm modifications\n const read: IShoppingSaleReview = \n await api.functional.shoppings.customers.sales.reviews.at(\n connection,\n {\n saleId: sale.id,\n id: review.id,\n },\n );\n typia.assert(read);\n TestValidator.equals("snapshots")(read.snapshots)([\n ...review.snapshots,\n snapshot,\n ]);\n}\n```\n\n### 5.1. Implementation Example Commentary\n\n**1. Import Statements**: Explicitly import all necessary types and utilities, accurately referencing package paths in `@ORGANIZATION/PROJECT-api` format and type definitions under `lib/structures/`.\n\n**2. Comment Structure**: JSDoc comments at the top of functions explain the background and necessity of entire scenarios, specifying detailed 11-step processes with numbers.\n\n**3. Function Name**: `test_api_shopping_sale_review_update` follows naming conventions expressing domain (shopping), entity (sale), function (review), and action (update) in order.\n\n**4. Variable Type Declaration**: Declare each API call result with clear types (`IShoppingSeller`, `IShoppingSale`, etc.) to ensure type safety.\n\n**5. SDK Function Calls**: Use exact namespace paths like `api.functional.shoppings.sellers.authenticate.join` and structure parameters according to SDK definitions.\n\n**6. satisfies Usage**: Use `satisfies` keyword in request body to enhance type safety (`satisfies IShoppingSeller.IJoin`, etc.).\n\n**7. Type Validation**: Apply `typia.assert()` to all API responses to ensure runtime type safety.\n\n**8. Account Switching**: Call login functions at appropriate times for role switching between sellers and customers.\n\n**9. Data Validation**: Use `TestValidator.equals()` to validate ID matching, array state changes, etc.\n\n**10. Complex Data Structures**: Appropriately structure complex nested objects like delivery information and shopping cart products to reflect actual business logic.\n\n## 6. Error Prevention Guidelines\n\n### 6.1. Common Mistake Prevention\n- **Typo Prevention**: Verify accuracy of SDK function paths, type names, property names\n- **Type Consistency**: Ensure consistency between variable type declarations and actual usage\n- **Missing Required Validation**: Verify application of `typia.assert()`\n- **Missing Imports**: Verify import of all necessary types and utilities\n- **Code Style**: Maintain consistent indentation, naming conventions, comment style\n\n### 6.2. Business Logic Validation\n- Adhere to logical order of scenarios\n- Verify fulfillment of essential prerequisites\n- Consider data dependency relationships\n- **State Transition**: Verify proper data state changes in each step\n- **Permission Check**: Verify only appropriate APIs are called for each user role\n\n### 6.3. Type Safety Assurance\n- Perform appropriate type validation on all API responses\n- Use `satisfies` keyword in request body\n- Verify consistency between DTO interfaces and actual data structures\n- **Compile Time**: Utilize TypeScript compiler\'s type checking\n- **Runtime**: Actual data validation through `typia.assert`\n\n## 7. Quality Standards\n\n### 7.1. Completeness\n- All scenario steps implemented without omission\n- Appropriate validation performed for each step\n- Consideration of exceptional situations included\n- **Test Coverage**: Include all major API endpoints\n- **Edge Cases**: Handle possible error situations\n\n### 7.2. Readability\n- Use clear and meaningful variable names\n- Include appropriate comments and explanations\n- Maintain logical code structure and consistent indentation\n- **Step-by-step Comments**: Clearly separate each business step\n- **Code Formatting**: Maintain consistent style and readability\n\n### 7.3. Maintainability\n- Utilize reusable patterns\n- Minimize hardcoded values\n- Design with extensible structure\n- **Modularization**: Implement repetitive logic with clear patterns\n- **Extensibility**: Structure that allows easy addition of new test cases\n\n## 8. Error Scenario Testing (Appendix)\n\n### 8.1. Purpose and Importance of Error Testing\nE2E testing must verify that systems operate correctly not only in normal business flows but also in expected error situations. It\'s important to confirm that appropriate HTTP status codes and error messages are returned in situations like incorrect input, unauthorized access, requests for non-existent resources.\n\n### 8.2. Error Validation Function Usage\n- **TestValidator.error()**: For general error situations where HTTP status code cannot be determined with certainty\n- **TestValidator.httpError()**: When specific HTTP status code can be determined with confidence\n- **Format**: `TestValidator.httpError("description")(statusCode)(() => APICall)`\n\n### 8.3. Error Test Writing Principles\n- **Clear Failure Conditions**: Clearly set conditions that should intentionally fail\n- **Appropriate Test Data**: Simulate realistic error situations like non-existent emails, incorrect passwords\n- **Concise Structure**: Unlike normal flows, compose error tests with minimal steps\n- **Function Naming Convention**: `test_api_{domain}_{action}_failure` or `test_api_{domain}_{action}_{specific_error}`\n\n### 8.4. Error Test Example\n\n```typescript\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IShoppingCustomer } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCustomer";\n\n/**\n * Validate customer login failure.\n * \n * Verify that appropriate error response is returned when attempting \n * to login with a non-existent email address.\n */\nexport async function test_api_customer_authenticate_login_failure(\n connection: api.IConnection,\n): Promise<void> {\n await TestValidator.httpError("login failure")(403)(() =>\n api.functional.shoppings.customers.authenticate.login(\n connection,\n {\n body: {\n email: "never-existing-email@sadfasdfasdf.com",\n password: "1234",\n } satisfies IShoppingCustomer.ILogin,\n },\n ),\n );\n}\n```\n\n### 8.5. Common Error Test Scenarios\n- **Authentication Failure**: Incorrect login information, expired tokens\n- **Permission Error**: Requests for resources without access rights\n- **Resource Not Found**: Attempts to query with non-existent IDs\n- **Validation Failure**: Input of incorrectly formatted data\n- **Duplicate Data**: Signup attempts with already existing emails\n\n### 8.6. Precautions When Writing Error Tests\n- Write error tests as separate independent functions\n- Do not mix with normal flow tests\n- Accurately specify expected HTTP status codes\n- Focus on status codes rather than error message content\n\n## 9. Final Checklist\n\nE2E test function writing completion requires verification of the following items:\n\n### 9.1. Essential Element Verification\n- [ ] Are all scenario steps implemented in order?\n- [ ] Are complete JSDoc-style comments written?\n- [ ] Does the function name follow naming conventions (`test_api_{domain}_{action}_{scenario}`)?\n- [ ] Are SDK used for all API calls?\n- [ ] Is the `satisfies` keyword used in request body?\n- [ ] Is `typia.assert` applied where necessary?\n- [ ] Are all necessary types imported with correct paths?\n\n### 9.2. Quality Element Verification\n- [ ] Are variable names meaningful and consistent?\n- [ ] Are account switches performed at appropriate times?\n- [ ] Is data validation performed correctly?\n- [ ] Is code structure logical with good readability?\n- [ ] Are error scenarios handled appropriately when needed?\n- [ ] Is business logic completeness guaranteed?\n\nPlease adhere to all these principles and guidelines to write complete and accurate E2E test functions. Your mission is not simply to write code, but to build a robust test system that perfectly reproduces and validates actual business scenarios.'
|
|
8922
8960
|
}, {
|
|
8923
8961
|
id: v4(),
|
|
8924
8962
|
created_at: (new Date).toISOString(),
|
|
8925
8963
|
type: "assistantMessage",
|
|
8926
|
-
text: [ "
|
|
8964
|
+
text: [ "Here is the list of input material composition.", "", "Make e2e test functions based on the following information.", "", "## Secnario Plan", "```json", JSON.stringify(props.scenario), "```", "", "## DTO Definitions", "```json", JSON.stringify(props.dto), "```", "", "## API (SDK) Functions", "```json", JSON.stringify(props.sdk), "```", "", "## E2E Mockup Functions", "```json", JSON.stringify(props.e2e), "```", "" ].join("\n")
|
|
8927
8965
|
} ];
|
|
8928
8966
|
|
|
8929
|
-
async function
|
|
8930
|
-
const
|
|
8931
|
-
|
|
8932
|
-
const
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
files: {
|
|
8942
|
-
...mergedFiles,
|
|
8943
|
-
...response.files
|
|
8944
|
-
}
|
|
8945
|
-
};
|
|
8946
|
-
return event;
|
|
8947
|
-
}
|
|
8948
|
-
|
|
8949
|
-
async function step(ctx, files, life) {
|
|
8950
|
-
const result = await ctx.compiler.typescript({
|
|
8951
|
-
files
|
|
8952
|
-
});
|
|
8953
|
-
if (result.type === "success") {
|
|
8954
|
-
return {
|
|
8955
|
-
type: "testValidate",
|
|
8956
|
-
created_at: (new Date).toISOString(),
|
|
8957
|
-
files,
|
|
8958
|
-
result,
|
|
8959
|
-
step: ctx.state().interface?.step ?? 0
|
|
8960
|
-
};
|
|
8961
|
-
}
|
|
8962
|
-
if (result.type === "exception") {
|
|
8963
|
-
ctx.dispatch({
|
|
8964
|
-
type: "testValidate",
|
|
8965
|
-
created_at: (new Date).toISOString(),
|
|
8966
|
-
files,
|
|
8967
|
-
result,
|
|
8968
|
-
step: ctx.state().interface?.step ?? 0
|
|
8969
|
-
});
|
|
8970
|
-
throw new Error(JSON.stringify(result.error, null, 2));
|
|
8971
|
-
}
|
|
8972
|
-
const diagnostics = {};
|
|
8973
|
-
result.diagnostics.forEach((d => {
|
|
8974
|
-
if (d.file === null) return;
|
|
8975
|
-
diagnostics[d.file] = diagnostics[d.file] ?? [];
|
|
8976
|
-
diagnostics[d.file].push(d);
|
|
8977
|
-
}));
|
|
8978
|
-
if (Object.keys(diagnostics).length === 0) {
|
|
8979
|
-
return {
|
|
8980
|
-
type: "testValidate",
|
|
8981
|
-
created_at: (new Date).toISOString(),
|
|
8982
|
-
files,
|
|
8983
|
-
result: {
|
|
8984
|
-
...result,
|
|
8985
|
-
type: "success"
|
|
8986
|
-
},
|
|
8967
|
+
async function orchestrateTestProgress(ctx, scenarios) {
|
|
8968
|
+
const start = new Date;
|
|
8969
|
+
let complete = 0;
|
|
8970
|
+
const events = await Promise.all(scenarios.map((async scenario => {
|
|
8971
|
+
const code = await process$1(ctx, scenario);
|
|
8972
|
+
const event = {
|
|
8973
|
+
type: "testWrite",
|
|
8974
|
+
created_at: start.toISOString(),
|
|
8975
|
+
filename: `${code.domain}/${scenario.functionName}.ts`,
|
|
8976
|
+
content: code.content,
|
|
8977
|
+
completed: ++complete,
|
|
8978
|
+
total: scenarios.length,
|
|
8987
8979
|
step: ctx.state().interface?.step ?? 0
|
|
8988
8980
|
};
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
type: "testValidate",
|
|
8992
|
-
created_at: (new Date).toISOString(),
|
|
8993
|
-
files,
|
|
8994
|
-
result,
|
|
8995
|
-
step: ctx.state().interface?.step ?? 0
|
|
8996
|
-
});
|
|
8997
|
-
if (life <= 0) return {
|
|
8998
|
-
type: "testValidate",
|
|
8999
|
-
created_at: (new Date).toISOString(),
|
|
9000
|
-
files,
|
|
9001
|
-
result,
|
|
9002
|
-
step: ctx.state().interface?.step ?? 0
|
|
9003
|
-
};
|
|
9004
|
-
const validate = await Promise.all(Object.entries(diagnostics).map((async ([filename, d]) => {
|
|
9005
|
-
const code = files[filename];
|
|
9006
|
-
const response = await process$2(ctx, d, code);
|
|
9007
|
-
ctx.dispatch({
|
|
9008
|
-
type: "testCorrect",
|
|
9009
|
-
created_at: (new Date).toISOString(),
|
|
9010
|
-
files: {
|
|
9011
|
-
...files,
|
|
9012
|
-
[filename]: response.content
|
|
9013
|
-
},
|
|
9014
|
-
result,
|
|
9015
|
-
solution: response.solution,
|
|
9016
|
-
think_without_compile_error: response.think_without_compile_error,
|
|
9017
|
-
think_again_with_compile_error: response.think_again_with_compile_error,
|
|
9018
|
-
step: ctx.state().interface?.step ?? 0
|
|
9019
|
-
});
|
|
9020
|
-
return [ filename, response.content ];
|
|
8981
|
+
ctx.dispatch(event);
|
|
8982
|
+
return event;
|
|
9021
8983
|
})));
|
|
9022
|
-
|
|
9023
|
-
...files,
|
|
9024
|
-
...Object.fromEntries(validate)
|
|
9025
|
-
};
|
|
9026
|
-
return step(ctx, newFiles, life - 1);
|
|
8984
|
+
return events;
|
|
9027
8985
|
}
|
|
9028
8986
|
|
|
9029
|
-
async function process$
|
|
8987
|
+
async function process$1(ctx, scenario) {
|
|
9030
8988
|
const pointer = {
|
|
9031
8989
|
value: null
|
|
9032
8990
|
};
|
|
9033
|
-
const
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
const dtoFiles = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => filename.startsWith("src/api/structures/"))).reduce(((acc, [filename, content]) => Object.assign(acc, {
|
|
9037
|
-
[filename]: content
|
|
9038
|
-
})), {});
|
|
8991
|
+
const document = filterDocument(scenario, ctx.state().interface.document);
|
|
8992
|
+
const files = Object.entries(await ctx.compiler.interface.compile(document));
|
|
8993
|
+
const filter = prefix => Object.fromEntries(files.filter((([key]) => key.startsWith(prefix))));
|
|
9039
8994
|
const agentica = new MicroAgentica({
|
|
9040
8995
|
model: ctx.model,
|
|
9041
|
-
vendor:
|
|
9042
|
-
...ctx.vendor
|
|
9043
|
-
},
|
|
8996
|
+
vendor: ctx.vendor,
|
|
9044
8997
|
config: {
|
|
9045
8998
|
...ctx.config ?? {}
|
|
9046
8999
|
},
|
|
9047
|
-
histories:
|
|
9000
|
+
histories: transformTestProgressHistories({
|
|
9001
|
+
scenario,
|
|
9002
|
+
dto: filter("src/api/structures"),
|
|
9003
|
+
sdk: filter("src/api/functional"),
|
|
9004
|
+
e2e: filter("test/features")
|
|
9005
|
+
}),
|
|
9048
9006
|
controllers: [ createApplication$2({
|
|
9049
9007
|
model: ctx.model,
|
|
9050
9008
|
build: next => {
|
|
9051
9009
|
pointer.value = next;
|
|
9052
9010
|
}
|
|
9053
|
-
}) ]
|
|
9011
|
+
}) ],
|
|
9012
|
+
tokenUsage: ctx.usage()
|
|
9054
9013
|
});
|
|
9055
9014
|
enforceToolCall(agentica);
|
|
9056
|
-
await agentica.conversate(
|
|
9057
|
-
|
|
9058
|
-
return [ "## Error Information", `- Position: Characters ${diagnostic.start} to ${diagnostic.start + diagnostic.length}`, `- Error Message: ${diagnostic.messageText}`, `- Problematic Code: \`${code.substring(diagnostic.start, diagnostic.start + diagnostic.length)}\``, "" ].join("\n");
|
|
9059
|
-
})), "## Instructions", "1. Focus on the specific error location and message", "2. Provide the corrected TypeScript code", "3. Ensure the fix resolves the compilation error", "", "Return only the fixed code without explanations." ].join("\n"));
|
|
9060
|
-
if (pointer.value === null) throw new Error("Failed to modify test code.");
|
|
9015
|
+
await agentica.conversate("Create e2e test functions.");
|
|
9016
|
+
if (pointer.value === null) throw new Error("Failed to create test code.");
|
|
9061
9017
|
return pointer.value;
|
|
9062
9018
|
}
|
|
9063
9019
|
|
|
9020
|
+
function filterDocument(scenario, document) {
|
|
9021
|
+
const operations = document.operations.filter((op => {
|
|
9022
|
+
if (scenario.endpoint.method === op.method && scenario.endpoint.path === op.path) {
|
|
9023
|
+
return true;
|
|
9024
|
+
} else if (scenario.dependencies.some((dp => dp.endpoint.method === op.method && dp.endpoint.path === op.path))) {
|
|
9025
|
+
return true;
|
|
9026
|
+
}
|
|
9027
|
+
}));
|
|
9028
|
+
const components = {
|
|
9029
|
+
schemas: {}
|
|
9030
|
+
};
|
|
9031
|
+
const visit = typeName => {
|
|
9032
|
+
OpenApiTypeChecker.visit({
|
|
9033
|
+
components: document.components,
|
|
9034
|
+
schema: {
|
|
9035
|
+
$ref: `#/components/schemas/${typeName}`
|
|
9036
|
+
},
|
|
9037
|
+
closure: s => {
|
|
9038
|
+
if (OpenApiTypeChecker.isReference(s)) {
|
|
9039
|
+
const key = s.$ref.split("/").pop();
|
|
9040
|
+
components.schemas[key] = document.components.schemas[key];
|
|
9041
|
+
}
|
|
9042
|
+
}
|
|
9043
|
+
});
|
|
9044
|
+
};
|
|
9045
|
+
for (const op of operations) {
|
|
9046
|
+
if (op.requestBody) visit(op.requestBody.typeName);
|
|
9047
|
+
if (op.responseBody) visit(op.responseBody.typeName);
|
|
9048
|
+
}
|
|
9049
|
+
return {
|
|
9050
|
+
operations,
|
|
9051
|
+
components
|
|
9052
|
+
};
|
|
9053
|
+
}
|
|
9054
|
+
|
|
9064
9055
|
function createApplication$2(props) {
|
|
9065
9056
|
assertSchemaModel(props.model);
|
|
9066
9057
|
const application = collection$3[props.model];
|
|
9067
9058
|
return {
|
|
9068
9059
|
protocol: "class",
|
|
9069
|
-
name: "
|
|
9060
|
+
name: "Create Test Code",
|
|
9070
9061
|
application,
|
|
9071
9062
|
execute: {
|
|
9072
|
-
|
|
9063
|
+
createTestCode: next => {
|
|
9073
9064
|
props.build(next);
|
|
9074
9065
|
}
|
|
9075
9066
|
}
|
|
@@ -9083,48 +9074,41 @@ const claude$3 = {
|
|
|
9083
9074
|
separate: null
|
|
9084
9075
|
},
|
|
9085
9076
|
functions: [ {
|
|
9086
|
-
name: "
|
|
9077
|
+
name: "createTestCode",
|
|
9087
9078
|
parameters: {
|
|
9088
|
-
description: "Current Type: {@link
|
|
9079
|
+
description: "Current Type: {@link ICreateTestCodeProps}",
|
|
9089
9080
|
type: "object",
|
|
9090
9081
|
properties: {
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
type: "
|
|
9094
|
-
},
|
|
9095
|
-
think_again_with_compile_error: {
|
|
9096
|
-
description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
|
|
9082
|
+
scenario: {
|
|
9083
|
+
title: "Strategic approach for test implementation",
|
|
9084
|
+
description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception plans\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error plans (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the scenario if it doesn't follow the Test Generation\n Guildelines.",
|
|
9097
9085
|
type: "string"
|
|
9098
9086
|
},
|
|
9099
|
-
|
|
9100
|
-
title: "
|
|
9101
|
-
description:
|
|
9087
|
+
domain: {
|
|
9088
|
+
title: "Functional domain classification for test organization",
|
|
9089
|
+
description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` → Article management operations\n- `comment` → Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` → User management operations\n- `payment` → Payment processing\n- `notification` → Notification system',
|
|
9102
9090
|
type: "string"
|
|
9103
9091
|
},
|
|
9104
9092
|
content: {
|
|
9105
|
-
title: "
|
|
9106
|
-
description: "
|
|
9093
|
+
title: "Complete TypeScript E2E test implementation",
|
|
9094
|
+
description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
|
|
9107
9095
|
type: "string"
|
|
9108
9096
|
}
|
|
9109
9097
|
},
|
|
9110
|
-
required: [ "
|
|
9098
|
+
required: [ "scenario", "domain", "content" ],
|
|
9111
9099
|
additionalProperties: false,
|
|
9112
9100
|
$defs: {}
|
|
9113
9101
|
},
|
|
9114
9102
|
validate: (() => {
|
|
9115
|
-
const _io0 = input => "string" === typeof input.
|
|
9116
|
-
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
9117
|
-
path: _path + ".
|
|
9118
|
-
expected: "string",
|
|
9119
|
-
value: input.think_without_compile_error
|
|
9120
|
-
}), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
|
|
9121
|
-
path: _path + ".think_again_with_compile_error",
|
|
9103
|
+
const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
|
|
9104
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
|
|
9105
|
+
path: _path + ".scenario",
|
|
9122
9106
|
expected: "string",
|
|
9123
|
-
value: input.
|
|
9124
|
-
}), "string" === typeof input.
|
|
9125
|
-
path: _path + ".
|
|
9107
|
+
value: input.scenario
|
|
9108
|
+
}), "string" === typeof input.domain || _report(_exceptionable, {
|
|
9109
|
+
path: _path + ".domain",
|
|
9126
9110
|
expected: "string",
|
|
9127
|
-
value: input.
|
|
9111
|
+
value: input.domain
|
|
9128
9112
|
}), "string" === typeof input.content || _report(_exceptionable, {
|
|
9129
9113
|
path: _path + ".content",
|
|
9130
9114
|
expected: "string",
|
|
@@ -9139,11 +9123,11 @@ const claude$3 = {
|
|
|
9139
9123
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
9140
9124
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
9141
9125
|
path: _path + "",
|
|
9142
|
-
expected: "
|
|
9126
|
+
expected: "ICreateTestCodeProps",
|
|
9143
9127
|
value: input
|
|
9144
9128
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
9145
9129
|
path: _path + "",
|
|
9146
|
-
expected: "
|
|
9130
|
+
expected: "ICreateTestCodeProps",
|
|
9147
9131
|
value: input
|
|
9148
9132
|
}))(input, "$input", true);
|
|
9149
9133
|
const success = 0 === errors.length;
|
|
@@ -9174,48 +9158,41 @@ const collection$3 = {
|
|
|
9174
9158
|
separate: null
|
|
9175
9159
|
},
|
|
9176
9160
|
functions: [ {
|
|
9177
|
-
name: "
|
|
9161
|
+
name: "createTestCode",
|
|
9178
9162
|
parameters: {
|
|
9179
|
-
description: "Current Type: {@link
|
|
9163
|
+
description: "Current Type: {@link ICreateTestCodeProps}",
|
|
9180
9164
|
type: "object",
|
|
9181
9165
|
properties: {
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
type: "
|
|
9185
|
-
},
|
|
9186
|
-
think_again_with_compile_error: {
|
|
9187
|
-
description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
|
|
9166
|
+
scenario: {
|
|
9167
|
+
title: "Strategic approach for test implementation",
|
|
9168
|
+
description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception plans\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error plans (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the scenario if it doesn't follow the Test Generation\n Guildelines.",
|
|
9188
9169
|
type: "string"
|
|
9189
9170
|
},
|
|
9190
|
-
|
|
9191
|
-
title: "
|
|
9192
|
-
description:
|
|
9171
|
+
domain: {
|
|
9172
|
+
title: "Functional domain classification for test organization",
|
|
9173
|
+
description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` → Article management operations\n- `comment` → Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` → User management operations\n- `payment` → Payment processing\n- `notification` → Notification system',
|
|
9193
9174
|
type: "string"
|
|
9194
9175
|
},
|
|
9195
9176
|
content: {
|
|
9196
|
-
title: "
|
|
9197
|
-
description: "
|
|
9177
|
+
title: "Complete TypeScript E2E test implementation",
|
|
9178
|
+
description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
|
|
9198
9179
|
type: "string"
|
|
9199
9180
|
}
|
|
9200
9181
|
},
|
|
9201
|
-
required: [ "
|
|
9182
|
+
required: [ "scenario", "domain", "content" ],
|
|
9202
9183
|
additionalProperties: false,
|
|
9203
9184
|
$defs: {}
|
|
9204
9185
|
},
|
|
9205
9186
|
validate: (() => {
|
|
9206
|
-
const _io0 = input => "string" === typeof input.
|
|
9207
|
-
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
9208
|
-
path: _path + ".
|
|
9209
|
-
expected: "string",
|
|
9210
|
-
value: input.think_without_compile_error
|
|
9211
|
-
}), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
|
|
9212
|
-
path: _path + ".think_again_with_compile_error",
|
|
9187
|
+
const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
|
|
9188
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
|
|
9189
|
+
path: _path + ".scenario",
|
|
9213
9190
|
expected: "string",
|
|
9214
|
-
value: input.
|
|
9215
|
-
}), "string" === typeof input.
|
|
9216
|
-
path: _path + ".
|
|
9191
|
+
value: input.scenario
|
|
9192
|
+
}), "string" === typeof input.domain || _report(_exceptionable, {
|
|
9193
|
+
path: _path + ".domain",
|
|
9217
9194
|
expected: "string",
|
|
9218
|
-
value: input.
|
|
9195
|
+
value: input.domain
|
|
9219
9196
|
}), "string" === typeof input.content || _report(_exceptionable, {
|
|
9220
9197
|
path: _path + ".content",
|
|
9221
9198
|
expected: "string",
|
|
@@ -9230,11 +9207,11 @@ const collection$3 = {
|
|
|
9230
9207
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
9231
9208
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
9232
9209
|
path: _path + "",
|
|
9233
|
-
expected: "
|
|
9210
|
+
expected: "ICreateTestCodeProps",
|
|
9234
9211
|
value: input
|
|
9235
9212
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
9236
9213
|
path: _path + "",
|
|
9237
|
-
expected: "
|
|
9214
|
+
expected: "ICreateTestCodeProps",
|
|
9238
9215
|
value: input
|
|
9239
9216
|
}))(input, "$input", true);
|
|
9240
9217
|
const success = 0 === errors.length;
|
|
@@ -9267,47 +9244,40 @@ const collection$3 = {
|
|
|
9267
9244
|
separate: null
|
|
9268
9245
|
},
|
|
9269
9246
|
functions: [ {
|
|
9270
|
-
name: "
|
|
9247
|
+
name: "createTestCode",
|
|
9271
9248
|
parameters: {
|
|
9272
9249
|
type: "object",
|
|
9273
9250
|
properties: {
|
|
9274
|
-
|
|
9275
|
-
type: "string",
|
|
9276
|
-
description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages."
|
|
9277
|
-
},
|
|
9278
|
-
think_again_with_compile_error: {
|
|
9251
|
+
scenario: {
|
|
9279
9252
|
type: "string",
|
|
9280
|
-
|
|
9253
|
+
title: "Strategic approach for test implementation",
|
|
9254
|
+
description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception plans\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error plans (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the scenario if it doesn't follow the Test Generation\n Guildelines."
|
|
9281
9255
|
},
|
|
9282
|
-
|
|
9256
|
+
domain: {
|
|
9283
9257
|
type: "string",
|
|
9284
|
-
title: "
|
|
9285
|
-
description:
|
|
9258
|
+
title: "Functional domain classification for test organization",
|
|
9259
|
+
description: 'Functional domain classification for test organization.\n\nDetermines file structure and test categorization based on API\nfunctionality. Used for organizing tests into logical groups and directory\nhierarchies.\n\n### Naming Rules:\n\n- Lowercase English words only\n- Singular nouns (e.g., "article", "user", "comment")\n- Kebab-case for compound words (e.g., "user-profile", "payment-method")\n- Match primary API resource being tested\n- Domain Name must be named only one word.\n\n### Domain Examples:\n\n- `article` → Article management operations\n- `comment` → Comment-related functionality\n- `auth` → Authentication and authorization\n- `user` → User management operations\n- `payment` → Payment processing\n- `notification` → Notification system'
|
|
9286
9260
|
},
|
|
9287
9261
|
content: {
|
|
9288
9262
|
type: "string",
|
|
9289
|
-
title: "
|
|
9290
|
-
description: "
|
|
9263
|
+
title: "Complete TypeScript E2E test implementation",
|
|
9264
|
+
description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following"
|
|
9291
9265
|
}
|
|
9292
9266
|
},
|
|
9293
|
-
required: [ "
|
|
9294
|
-
description: "Current Type: {@link
|
|
9267
|
+
required: [ "scenario", "domain", "content" ],
|
|
9268
|
+
description: "Current Type: {@link ICreateTestCodeProps}",
|
|
9295
9269
|
additionalProperties: false
|
|
9296
9270
|
},
|
|
9297
9271
|
validate: (() => {
|
|
9298
|
-
const _io0 = input => "string" === typeof input.
|
|
9299
|
-
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
9300
|
-
path: _path + ".
|
|
9301
|
-
expected: "string",
|
|
9302
|
-
value: input.think_without_compile_error
|
|
9303
|
-
}), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
|
|
9304
|
-
path: _path + ".think_again_with_compile_error",
|
|
9272
|
+
const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
|
|
9273
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
|
|
9274
|
+
path: _path + ".scenario",
|
|
9305
9275
|
expected: "string",
|
|
9306
|
-
value: input.
|
|
9307
|
-
}), "string" === typeof input.
|
|
9308
|
-
path: _path + ".
|
|
9276
|
+
value: input.scenario
|
|
9277
|
+
}), "string" === typeof input.domain || _report(_exceptionable, {
|
|
9278
|
+
path: _path + ".domain",
|
|
9309
9279
|
expected: "string",
|
|
9310
|
-
value: input.
|
|
9280
|
+
value: input.domain
|
|
9311
9281
|
}), "string" === typeof input.content || _report(_exceptionable, {
|
|
9312
9282
|
path: _path + ".content",
|
|
9313
9283
|
expected: "string",
|
|
@@ -9322,11 +9292,11 @@ const collection$3 = {
|
|
|
9322
9292
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
9323
9293
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
9324
9294
|
path: _path + "",
|
|
9325
|
-
expected: "
|
|
9295
|
+
expected: "ICreateTestCodeProps",
|
|
9326
9296
|
value: input
|
|
9327
9297
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
9328
9298
|
path: _path + "",
|
|
9329
|
-
expected: "
|
|
9299
|
+
expected: "ICreateTestCodeProps",
|
|
9330
9300
|
value: input
|
|
9331
9301
|
}))(input, "$input", true);
|
|
9332
9302
|
const success = 0 === errors.length;
|
|
@@ -9349,65 +9319,163 @@ const collection$3 = {
|
|
|
9349
9319
|
}
|
|
9350
9320
|
};
|
|
9351
9321
|
|
|
9352
|
-
const
|
|
9322
|
+
const transformTestCorrectHistories = document => [ {
|
|
9353
9323
|
id: v4(),
|
|
9354
9324
|
created_at: (new Date).toISOString(),
|
|
9355
9325
|
type: "systemMessage",
|
|
9356
|
-
text: '# E2E Test Code Generator System Prompt\n\nYou are an expert E2E (End-to-End) test automation engineer specializing in generating test code directly from user scenarios using API functions and TypeScript DTO types.\n\n## Your Role\n\n- Analyze the given user scenario and generate complete E2E test code (max 300 lines). \n- Use only the **provided API functions and DTO types** to implement realistic, maintainable, and deterministic test flows. \n- Write tests in **TypeScript** using the `@nestia/e2e` testing style — do **not** use other test frameworks (e.g., Jest, Mocha). \n- **Focus on simplicity and correctness** - avoid complex type manipulations and ensure all imports match the provided API structure. \n- When generating E2E test code, you must perform extremely strict type checking. \n\n## Default Working Language: English\n\n- Use the language specified by user in messages as the working language when explicitly provided \n- All thinking and responses must be in the working language \n- All model/field names must be in English regardless of working language \n\n\n## Input Format\n\nYou will receive:\n\n1. **User Scenario**: A textual description of a business use-case or user flow \n2. **Filename**: The desired filename for the test file \n3. **API Files**: A collection of functions exposed by the system under test \n4. **DTO Files**: TypeScript types used in request/response payloads of API functions \n\n## Test Generation Guidelines\n\n### 1. API Function Usage\n\n- Must use `import api from "@ORGANIZATION/PROJECT-api";` to import api functions. \n - Never use other import statement like `import api from "@PROJECT/api"` \n- **Only use API functions that are explicitly listed in the provided API Files** - do not assume functions exist. \n- **Carefully match function names and paths** from the provided API structure. \n- Connection parameter should be used as-is without modification: \n\n ```ts\n // Correct Usage\n await api.functional.bbs.articles.post(connection, { body: articleBody });\n\n // Incorrect - Don\'t modify connection\n const slowConnection = { ...connection, simulate: { delay: 4000 } };\n ``` \n\n- API functions follow this pattern: `api.functional.[...].methodName(...)` \n- For example, if file path is `src/api/functional/bbs/articles/comments/index.ts` and function is `postByArticleId`, use `api.functional.bbs.articles.comments.postByArticleId(...)` \n\n### 2. DTO Type Usage\n\n- **Import DTO types exactly as provided** in the DTO Files section. \n- Use the exact import path: `import { ITypeName } from "@ORGANIZATION/PROJECT-api/lib/structures/[exact-path]";` \n- **Do not assume property names or structures** - only use properties that are explicitly defined in the provided DTO types. \n- **Ensure all required properties are included** when creating request objects. \n\nExample: \n\n ```ts\n import { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/IBbsArticle";\n ``` \n\n### 3. Type Safety and Error Prevention\n\n- **Always verify that functions and types exist** in the provided files before using them. \n- **Use simple, direct type assertions** - avoid complex type manipulations. \n- **Check for required vs optional properties** in DTO types before creating objects. \n- **Use only documented API methods** - don\'t assume method existence. \n\n### 4. Scenario Coverage\n\n- Fully implement the test scenario by chaining relevant API calls. \n- If the scenario involves data creation, create prerequisite data using corresponding APIs. \n- Include positive test cases (happy paths) and negative test cases when appropriate. \n- **Keep test logic simple and straightforward** - avoid overly complex flows. \n\n## Code Structure & Style\n\n### Test Function Structure\n\n```ts\nexport async function test_api_xxx(connection: api.IConnection): Promise<void> {\n // Simple, clear test implementation\n}\n```\n\n### Validation Guidelines\n\n- Use `TestValidator` for validations as defined below \n- Use `typia.assert` for type validations as defined below \n- **Ensure proper function signatures** when using TestValidator methods \n- **Verify all required properties** are included when creating test objects \n\n### Test Validator Definition\n\n```ts\n/**\n * Test validator.\n *\n * `TestValidator` is a collection gathering E2E validation functions.\n *\n */\nexport declare namespace TestValidator {\n /**\n * Test whether condition is satisfied.\n *\n * @param title Title of error message when condition is not satisfied\n * @return Currying function\n */\n const predicate: (title: string) => <T extends boolean | (() => boolean) | (() => Promise<boolean>)>(condition: T) => T extends () => Promise<boolean> ? Promise<void> : void;\n /**\n * Test whether two values are equal.\n *\n * If you want to validate `covers` relationship,\n * call smaller first and then larger.\n *\n * Otherwise you wanna non equals validator, combine with {@link error}.\n *\n * @param title Title of error message when different\n * @param exception Exception filter for ignoring some keys\n * @returns Currying function\n */\n const equals: (title: string, exception?: (key: string) => boolean) => <T>(x: T) => (y: T) => void;\n /**\n * Test whether error occurs.\n *\n * If error occurs, nothing would be happened.\n *\n * However, no error exists, then exception would be thrown.\n *\n * @param title Title of exception because of no error exists\n */\n const error: (title: string) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;\n const httpError: (title: string) => (...statuses: number[]) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;\n function proceed(task: () => Promise<any>): Promise<Error | null>;\n function proceed(task: () => any): Error | null;\n /**\n * Validate index API.\n *\n * Test whether two indexed values are equal.\n *\n * If two values are different, then exception would be thrown.\n *\n * @param title Title of error message when different\n * @return Currying function\n *\n * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts\n */\n const index: (title: string) => <Solution extends IEntity<any>>(expected: Solution[]) => <Summary extends IEntity<any>>(gotten: Summary[], trace?: boolean) => void;\n /**\n * Valiate search options.\n *\n * Test a pagination API supporting search options.\n *\n * @param title Title of error message when searching is invalid\n * @returns Currying function\n *\n * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts\n */\n const search: (title: string) => <Entity extends IEntity<any>, Request>(getter: (input: Request) => Promise<Entity[]>) => (total: Entity[], sampleCount?: number) => <Values extends any[]>(props: ISearchProps<Entity, Values, Request>) => Promise<void>;\n interface ISearchProps<Entity extends IEntity<any>, Values extends any[], Request> {\n fields: string[];\n values(entity: Entity): Values;\n filter(entity: Entity, values: Values): boolean;\n request(values: Values): Request;\n }\n /**\n * Validate sorting options.\n *\n * Test a pagination API supporting sorting options.\n *\n * You can validate detailed sorting options both ascending and descending orders\n * with multiple fields. However, as it forms a complicate currying function,\n * I recommend you to see below example code before using.\n *\n * @param title Title of error message when sorting is invalid\n * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts\n */\n const sort: (title: string) => <T extends object, Fields extends string, Sortable extends Array<`-${Fields}` | `+${Fields}`> = Array<`-${Fields}` | `+${Fields}`>>(getter: (sortable: Sortable) => Promise<T[]>) => (...fields: Fields[]) => (comp: (x: T, y: T) => number, filter?: (elem: T) => boolean) => (direction: "+" | "-", trace?: boolean) => Promise<void>;\n type Sortable<Literal extends string> = Array<`-${Literal}` | `+${Fields}`>;\n}\ninterface IEntity<Type extends string | number | bigint> {\n id: Type;\n}\nexport {};\n```\n\n### Typia Assert Definition\n\n```ts\n/**\n * Asserts a value type.\n *\n * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed\n * reason, if the parametric value is not following the type `T`. Otherwise, the\n * value is following the type `T`, just input parameter would be returned.\n *\n * If what you want is not asserting but just knowing whether the parametric value is\n * following the type `T` or not, you can choose the {@link is} function instead.\n * Otherwise you want to know all the errors, {@link validate} is the way to go.\n * Also, if you want to automatically cast the parametric value to the type `T`\n * when no problem (perform the assertion guard of type).\n *\n * On the other and, if you don\'t want to allow any superfluous property that is not\n * enrolled to the type `T`, you can use {@link assertEquals} function instead.\n *\n * @template T Type of the input value\n * @param input A value to be asserted\n * @param errorFactory Custom error factory. Default is `TypeGuardError`\n * @returns Parametric input value\n * @throws A {@link TypeGuardError} instance with detailed reason\n *\n */\nexport declare function assert<T>(input: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;\n/**\n * Asserts a value type.\n *\n * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed\n * reason, if the parametric value is not following the type `T`. Otherwise, the\n * value is following the type `T`, just input parameter would be returned.\n *\n * If what you want is not asserting but just knowing whether the parametric value is\n * following the type `T` or not, you can choose the {@link is} function instead.\n * Otherwise, you want to know all the errors, {@link validate} is the way to go.\n *\n * On the other and, if you don\'t want to allow any superfluous property that is not\n * enrolled to the type `T`, you can use {@link assertEquals} function instead.\n *\n * @template T Type of the input value\n * @param input A value to be asserted\n * @param errorFactory Custom error factory. Default is `TypeGuardError`\n * @returns Parametric input value casted as `T`\n * @throws A {@link TypeGuardError} instance with detailed reason\n *\n */\nexport declare function assert<T>(input: unknown, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;\n/**\n * Assertion guard of a value type.\n *\n * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed\n * reason, if the parametric value is not following the type `T`. Otherwise, the\n * value is following the type `T`, nothing would be returned, but the input value\n * would be automatically casted to the type `T`. This is the concept of\n * "Assertion Guard" of a value type.\n *\n * If what you want is not asserting but just knowing whether the parametric value is\n * following the type `T` or not, you can choose the {@link is} function instead.\n * Otherwise you want to know all the errors, {@link validate} is the way to go.\n * Also, if you want to returns the parametric value when no problem, you can use\n * {@link assert} function instead.\n *\n * On the other and, if you don\'t want to allow any superfluous property that is not\n * enrolled to the type `T`, you can use {@link assertGuardEquals} function instead.\n *\n * @template T Type of the input value\n * @param input A value to be asserted\n * @param errorFactory Custom error factory. Default is `TypeGuardError`\n * @throws A {@link TypeGuardError} instance with detailed reason\n *\n */\n```\n\n### Example Format:\n\n```ts\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IExampleDto } from "@ORGANIZATION/PROJECT-api/lib/structures/IExampleDto";\nimport typia from "typia";\n\nexport async function test_api_example_flow(connection: api.IConnection): Promise<void> {\n const input: IExampleDto = { ... }; // construct valid input\n\n const result = await api.functional.example.post(connection, input);\n\n typia.assert(result); // ensure response matches expected type\n TestValidator.equals("result", exceptFunction)(result.someField);\n}\n\n``` \n\n```ts\nexport async function test_api_hub_cart_commodity_at(\n connection: api.IConnection,\n): Promise<void> {\n await test_api_hub_admin_login(pool);\n await test_api_hub_seller_join(pool);\n await test_api_hub_customer_create(pool);\n\n const sale: IHubSale = await generate_random_sale(pool, "approved");\n const commodity: IHubCartCommodity = await generate_random_cart_commodity(\n pool,\n sale,\n );\n\n const read: IHubCartCommodity =\n await HubApi.functional.hub.customers.carts.commodities.at(\n pool.customer,\n null,\n commodity.id,\n );\n TestValidator.equals("at", exceptSaleKeys)(commodity)(read);\n}\n\nexport const exceptSaleKeys = (key: string): boolean =>\n key === "aggregate" || key === "swagger" || key.endsWith("_at");\n\n``` \n\n### Import Guidelines\n\n- **Only import what you actually use** \n- **Verify all imports exist** in the provided API and DTO files \n- **Use exact import paths** as specified in the file structure \n\n```ts\nimport { TestValidator } from "@nestia/e2e";\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { ISimpleDto } from "@ORGANIZATION/PROJECT-api/lib/structures/ISimpleDto";\nimport typia from "typia";\n``` \n\n### Data Construction\n\n- **Create simple, valid test data** that matches the DTO structure exactly \n- **Include all required properties** as defined in the DTO \n- **Use literal values** rather than complex data generation \n\n```ts\n// Simple, clear data construction\nconst articleInput: IBbsArticleInput = {\n title: "Test Article",\n body: "Test article content",\n // Include all required properties from the DTO\n};\n``` \n\n## Error Prevention Rules\n\n### 1. Type Matching\n\n- Always ensure function parameters match the expected types from API definitions \n- Verify that all required properties are included in request objects \n- Don\'t use properties that aren\'t defined in the DTO types \n\n### 2. Import Validation\n\n- Only import functions and types that exist in the provided files \n- Use exact import paths without assumptions \n- **Follow the exact TestValidator and typia.assert usage patterns** as defined in their type definitions \n\n### 3. Simple Logic\n\n- Avoid complex type manipulations and filtering functions \n- Use straightforward validation patterns \n- Don\'t use TypeScript directives like `@ts-expect-error` or `@ts-ignore` \n\n### 4. Null Safety\n\n- Check for null/undefined values before using them \n- Use optional chaining when appropriate \n- Handle potential null returns from API calls \n\n```ts\n// Safe null handling\nif (result && result.data) {\n typia.assert<IExpectedType>(result.data);\n}\n``` \n\n### 5. Type Safety\n\n- If you declare empty array like `[]`, You must define the type of array together. \n\nExample: \n\n ```typescript\n const emptyArray: IBbsArticle[] = [];\n\n TestValidator.equals("message")(\n [] as IBbsArticleComment[],\n )(data);\n ```\n\n\n## Output Format\n\nReturn the following: \n\n1. **Filename**: Suggested filename for the test (from input) \n2. **Full Test Code**: A TypeScript file (max 300 lines) containing the E2E test \n3. **Test Explanation**: Brief paragraph explaining what the test does and how it maps to the scenario \n4. **Execution Notes**: Any setup steps or dependencies required to run the test \n\n## Best Practices\n\n- **Keep tests simple and readable** - prioritize clarity over cleverness \n- **Use only provided API functions and DTO types** - no assumptions \n- **Create minimal but meaningful tests** that cover the core scenario \n- **Make tests deterministic** with predictable data and flows \n- **Include clear comments** for complex business logic only \n- **Follow naming conventions** (`test_api_[feature]_[action]`) \n- **Validate inputs and outputs** with simple, direct assertions \n\n## Error Handling\n\n- If the scenario lacks sufficient detail, ask for clarification \n- If no matching API function is found for a step, mention it and suggest alternatives from the provided API list \n- If a required DTO property is missing or unclear, request the complete DTO definition \n- **Always verify that all used functions and types exist** in the provided files before generating code'
|
|
9326
|
+
text: '# Compiler Error Fix System Prompt\n\nYou are an expert TypeScript compiler error fixing agent specializing in resolving compilation errors in E2E test code that follows the `@nestia/e2e` testing framework conventions.\n\n## Your Role\n\n- Analyze the provided TypeScript code with compilation errors and generate the corrected version. \n- Focus specifically on the error location, message, and problematic code segment. \n- Maintain all existing functionality while resolving only the compilation issues. \n- Follow the established code patterns and conventions from the original E2E test code. \n- Use provided API Files and DTO Files to resolve module and type declaration issues. \n- **CRITICAL**: Apply comprehensive fixes to prevent circular error loops by addressing all related import issues in a single pass.\n\n## Default Working Language: English\n\n- Use the language specified by user in messages as the working language when explicitly provided \n- All thinking and responses must be in the working language \n- All model/field names must be in English regardless of working language \n\n## Input Format\n\nYou will receive: \n\n1. **Original Code**: TypeScript E2E test code with compilation errors \n2. **Error Information**: \n - Exact character position of the error \n - Detailed error message from TypeScript compiler \n - The specific problematic code segment \n3. **Instructions**: Specific guidance on what needs to be fixed \n4. **API Files**: Reference files containing available API functions and their paths \n5. **DTO Files**: Reference files containing available types and their import paths \n\n## Code Fixing Guidelines\n\n### 1. Module Resolution Errors (CRITICAL PRIORITY)\n\n#### Universal Module Import Pattern Recognition and Fix:\n\n**ALWAYS scan the ENTIRE code for ALL import statements that match these patterns and fix them ALL at once:**\n\n```typescript\n// WRONG PATTERNS - Fix ALL of these in one pass:\nimport api from "@nestia/PROJECT-api";\nimport api from "@wrtnlabs/PROJECT-api"; \nimport api from "@anyorganization/PROJECT-api";\nimport { Type } from "@nestia/PROJECT-api/lib/structures/Type";\nimport { Type } from "@wrtnlabs/PROJECT-api/lib/structures/Type";\nimport { Type } from "@anyorganization/PROJECT-api/lib/structures/Type";\n\n// CORRECT PATTERN - Replace with:\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { Type } from "@ORGANIZATION/PROJECT-api/lib/structures/Type";\n```\n\n#### Importing namespace rule\n\n```ts\n// ❌ Incorrect usage: importing inner types directly from a namespaced type\nimport {\n IShoppingSaleInquiryComment,\n IShoppingSaleInquiryComment_ICreate,\n IShoppingSaleInquiryComment_IRequest,\n} from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSaleInquiryComment";\n\n```\n\n```ts\n// ✅ Correct usage: import only the namespace and access inner types via dot notation\nimport {\n IShoppingSaleInquiryComment,\n} from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSaleInquiryComment";\n\ntype A = IShoppingSaleInquiryComment.ICreate // correct!\ntype B = IShoppingSaleInquiryComment.IRequest // correct!\n```\n\n- 💡 Rule: When working with types defined inside a namespace, import only the namespace and access inner types using dot notation (e.g., Namespace.InnerType).\nAvoid importing inner types directly, as it breaks encapsulation and may cause naming conflicts or improper typings.\n\n\n#### Comprehensive Module Fix Strategy:\n\n1. **Pattern Detection**: Look for ANY import that contains: \n - `@[anything]/[project-name]-api` → Replace `@[anything]` with `@ORGANIZATION` \n - `@[project-name]-api` (missing org prefix) → Add `@ORGANIZATION/` prefix \n\n2. **Common Error Patterns to Fix ALL AT ONCE**: \n\n```typescript\n// Error Pattern 1: Wrong organization name\nCannot find module \'@wrtnlabs/PROJECT-api\'\nCannot find module \'@nestia/PROJECT-api\'\nCannot find module \'@anyorg/PROJECT-api\'\n// Fix: Replace with @ORGANIZATION/PROJECT-api\n\n// Error Pattern 2: Missing organization prefix \nCannot find module \'@PROJECT-api\'\nCannot find module \'PROJECT-api\'\n// Fix: Add @ORGANIZATION/ prefix\n\n// Error Pattern 3: Structure imports with wrong org\nCannot find module \'@wrtnlabs/PROJECT-api/lib/structures/IType\'\nCannot find module \'@nestia/PROJECT-api/lib/structures/IType\'\n// Fix: Replace with @ORGANIZATION/PROJECT-api/lib/structures/IType\n``` \n\n3. **Comprehensive Import Scan and Fix**: \n - **BEFORE fixing the reported error**, scan ALL import statements in the code \n - Identify ALL imports that follow incorrect patterns \n - Fix ALL of them simultaneously to prevent error loops \n - Ensure consistent `@ORGANIZATION/PROJECT-api` pattern throughout \n\n#### Module Resolution Fix Examples:\n\n```typescript\n// BEFORE (Multiple wrong patterns in same file):\nimport api from "@nestia/PROJECT-api";\nimport { IBbsArticle } from "@wrtnlabs/PROJECT-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@PROJECT-api/lib/structures/IAttachmentFile";\n\n// AFTER (All fixed consistently):\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/IBbsArticle";\nimport { IAttachmentFile } from "@ORGANIZATION/PROJECT-api/lib/structures/IAttachmentFile";\n``` \n\n### 2. Error Loop Prevention Strategy\n\n**CRITICAL**: To prevent 1 → 2 → 3 → 1 error loops: \n\n1. **Holistic Code Analysis**: Before fixing the specific error, analyze ALL import statements in the entire code \n2. **Batch Import Fixes**: Fix ALL import-related issues in a single pass, not just the reported error \n3. **Pattern Consistency**: Ensure ALL imports follow the same `@ORGANIZATION/PROJECT-api` pattern \n4. **Preemptive Fixes**: Look for and fix potential related errors that might surface after the current fix \n\n**Implementation Approach**: \n\n```typescript\n// Step 1: Scan entire code for ALL these patterns\nconst problemPatterns = [\n /@[^/]+\\/[^-]+-api(?!\\/)/g, // Wrong org prefix\n /@[^-]+-api(?!\\/)/g, // Missing org prefix \n /from\\s+["\']@[^/]+\\/[^-]+-api/g, // Wrong org in imports\n /from\\s+["\']@[^-]+-api/g // Missing org in imports\n];\n\n// Step 2: Replace ALL matches with @ORGANIZATION/PROJECT-api pattern\n// Step 3: Then fix the specific reported error\n``` \n\n### 3. API Function Usage Corrections\n\n- Ensure proper `import api from "@ORGANIZATION/PROJECT-api";` format (verify against API Files) \n- Fix API function call patterns to follow: \n\n ```ts\n api.functional.[...].methodName(...)\n ``` \n\n- Correct connection parameter usage (avoid adding extra properties): \n\n ```ts\n // Correct\n await api.functional.bbs.articles.post(connection, { body: articleBody });\n ``` \n\n- **Cross-reference API Files** to ensure function paths and method names are accurate \n\n### 4. DTO Type Import Corrections\n\n- Fix import statements to use proper format based on **DTO Files**: \n\n ```ts\n import { ITypeName } from "@ORGANIZATION/PROJECT-api/lib/structures/[...].ts";\n ``` \n\n- Ensure `@ORGANIZATION` prefix is maintained in import paths \n- **Verify type names and paths** against provided DTO Files \n- Correct missing or incorrect type imports \n- Fix type annotation errors \n\n### 5. Test Function Structure Fixes\n\n- Ensure test functions follow the pattern: \n\n ```ts\n export async function test_api_xxx(...): Promise<void> { ... }\n ``` \n\n- Fix async/await usage errors \n- Correct function parameter types (especially `connection: api.IConnection`) \n\n### 6. Test Validator Usage Corrections\n\n- Fix `TestValidator` method calls: \n\n ```ts\n TestValidator.equals("title", exceptionFunction)(expected)(actual);\n TestValidator.predicate("title")(condition);\n TestValidator.error("title")(task);\n ``` \n\n- Correct currying function usage \n- Fix assertion patterns \n\n### 7. Typia Assert Corrections\n\n- Ensure proper `typia.assert<T>(value)` usage \n- Fix generic type parameters \n- Correct assertion patterns for response validation \n\n### 8. Array Type Corrections\n\n```\nerror: Argument of type \'IBbsArticleComment[]\' is not assignable to parameter of type \'never[]\'.\n``` \n\n- To Resolve above Array parameter Error, If you declare empty array like `[]`, You must define the type of array together. \n\nExample: \n\n ```typescript\n TestValidator.equals("message")(\n [] as IBbsArticleComment[],\n )(data);\n ``` \n\n### 9. Common TypeScript Error Fixes\n\n- **Import/Export errors**: Fix module resolution issues using API Files and DTO Files as reference \n- **Type mismatches**: Align variable types with expected interfaces from DTO Files \n- **Missing properties**: Add required properties to objects \n- **Async/Promise errors**: Fix Promise handling and async function signatures \n- **Generic type errors**: Correct generic type parameters \n- **Null/undefined handling**: Add proper null checks or optional chaining \n- **Interface compliance**: Ensure objects conform to their declared interfaces \n\n## Error Resolution Strategy\n\n1. **Full Code Analysis**: FIRST perform comprehensive analysis of ENTIRE codebase for ALL potential TypeScript issues \n2. **Error Chain Identification**: Identify cascading error patterns and relationships between different parts of code \n3. **Holistic Fix Planning**: Plan fixes for ALL related errors that could cause loops, not just the reported error \n4. **Reference File Consultation**: \n - For module errors: Consult API Files for correct import paths \n - For type errors: Consult DTO Files for correct type import paths \n - For function calls: Verify method signatures and parameters \n5. **Batch Error Resolution**: Fix ALL identified issues simultaneously in logical groups: \n - All import/module issues together \n - All type declaration issues together \n - All function signature issues together \n - All usage/call site issues together \n6. **Context Preservation**: Maintain the original test logic and flow \n7. **Comprehensive Validation**: Ensure no new compilation errors or cascading issues are introduced \n8. **Pattern Consistency**: Keep existing code style and conventions throughout all fixes \n\n## Output Requirements\n\n- Return **only** the corrected TypeScript code \n- Maintain all original functionality and test logic \n- Preserve code formatting and style \n- Ensure the fix addresses ALL related compilation errors (not just the reported one) \n- **CRITICAL**: Fix ALL import pattern issues in a single pass to prevent error loops \n- Do not add explanations, comments, or additional features \n\n## Priority Error Handling\n\n1. **Comprehensive Analysis** (HIGHEST priority): \n - Scan ENTIRE codebase for ALL potential TypeScript compilation issues \n - Identify cascading error patterns and relationships \n - Map error chains that commonly cause loops (import → type → usage → validation) \n\n2. **Batch Error Resolution** (CRITICAL): \n - Group related errors into logical fix batches: \n - **Module/Import Batch**: All import paths, module resolution, missing dependencies \n - **Type Batch**: All type declarations, interfaces, generic constraints \n - **Function Batch**: All function signatures, parameters, return types \n - **Usage Batch**: All variable assignments, method calls, property access \n - **Test Batch**: All TestValidator calls, assertion patterns, validation logic \n - Fix entire batches simultaneously to prevent cascading failures \n\n3. **Specific Error Resolution**: \n - After comprehensive fixes, verify the originally reported error is resolved \n - Use DTO Files for type corrections and API Files for function signatures \n - Ensure consistency with established patterns \n\n4. **General TypeScript Compilation**: \n - Apply standard TypeScript error resolution techniques \n - Maintain type safety throughout all fixes \n\n## Error Loop Prevention Protocol\n\n**MANDATORY STEPS to prevent error loops:** \n\n1. **Pre-Analysis**: Before fixing reported error, scan entire code for ALL import statements \n2. **Pattern Matching**: Identify ALL imports matching problematic patterns: \n - `@[anything-except-ORGANIZATION]/[project]-api` \n - Missing `@ORGANIZATION/` prefix \n - Inconsistent organization naming \n3. **Comprehensive Fix**: Replace ALL problematic imports with correct `@ORGANIZATION/PROJECT-api` pattern \n4. **Validation**: Ensure ALL imports in the file follow consistent pattern \n5. **Specific Fix**: Then address the specific reported compilation error \n\n**Example of Comprehensive Fix Approach:** \n\n```typescript\n// Input code with multiple potential issues:\nimport api from "@nestia/PROJECT-api"; // Issue 1\nimport { IBbsArticle } from "@wrtnlabs/PROJECT-api/lib/structures/IBbsArticle"; // Issue 2 \nimport { IUser } from "@PROJECT-api/lib/structures/IUser"; // Issue 3\n\n// Output: ALL issues fixed simultaneously:\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/IBbsArticle";\nimport { IUser } from "@ORGANIZATION/PROJECT-api/lib/structures/IUser";\n```'
|
|
9357
9327
|
}, {
|
|
9358
9328
|
id: v4(),
|
|
9359
9329
|
created_at: (new Date).toISOString(),
|
|
9360
9330
|
type: "assistantMessage",
|
|
9361
|
-
text: [ "You are the world's best
|
|
9331
|
+
text: [ "You are the world's best TypeScript compiler error fixer.", "You will be given a **TypeScript code** with compilation errors, and your job is to fix the errors.", "", "## Rules", "- Follow the base E2E test style strictly. Never use other frameworks like Jest or Mocha.", "- Use `TestValidator.equals(...)` and `typia.assert(...)` to verify results.", "- Use `api.functional.XXX` for all API calls. These are defined in API Files.", "- Use helper functions like `generate_random_xxx(...)` **only if** they already exist in the base test imports.", "- Do not invent new helpers or use utilities that are not explicitly shown.", "- Keep all tests deterministic and reliable.", "", "## File References", "### OpenAPI Like Document", "```json", JSON.stringify(document), "```", "", "Now Fix the E2E test function based on the given error information.", "Only output a single `async function` named `test_api_{...}`. No explanation, no commentary." ].join("\n")
|
|
9362
9332
|
} ];
|
|
9363
9333
|
|
|
9364
|
-
async function
|
|
9365
|
-
const
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9334
|
+
async function orchestrateTestCorrect(ctx, codes, scenarios, life = 4) {
|
|
9335
|
+
const scenarioMap = new Map;
|
|
9336
|
+
codes.forEach((({filename}, index) => {
|
|
9337
|
+
scenarioMap.set(filename, scenarios[index]);
|
|
9338
|
+
}));
|
|
9339
|
+
const testFiles = codes.map((({filename, content}) => ({
|
|
9340
|
+
[`test/features/api/${filename}`]: content
|
|
9341
|
+
}))).reduce(((acc, cur) => Object.assign(acc, cur)), {});
|
|
9342
|
+
const retainedFiles = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => !filename.startsWith("test/features/api"))).map((([filename, content]) => ({
|
|
9343
|
+
[filename]: content
|
|
9344
|
+
}))).reduce(((acc, cur) => Object.assign(acc, cur)), {});
|
|
9345
|
+
const mergedFiles = {
|
|
9346
|
+
...retainedFiles,
|
|
9347
|
+
...testFiles
|
|
9348
|
+
};
|
|
9349
|
+
const files = Object.fromEntries(Object.entries(mergedFiles).filter((([filename]) => filename.endsWith(".ts") && !filename.startsWith("test/benchmark/") || filename.endsWith(".json"))));
|
|
9350
|
+
const response = await step(ctx, files, scenarioMap, life);
|
|
9351
|
+
const event = {
|
|
9352
|
+
...response,
|
|
9353
|
+
type: "testValidate",
|
|
9354
|
+
files: {
|
|
9355
|
+
...mergedFiles,
|
|
9356
|
+
...response.files
|
|
9357
|
+
}
|
|
9358
|
+
};
|
|
9359
|
+
return event;
|
|
9360
|
+
}
|
|
9361
|
+
|
|
9362
|
+
async function step(ctx, files, scenarioMap, life) {
|
|
9363
|
+
const result = await ctx.compiler.typescript.compile({
|
|
9364
|
+
files
|
|
9365
|
+
});
|
|
9366
|
+
if (result.type === "success") {
|
|
9367
|
+
return {
|
|
9368
|
+
type: "testValidate",
|
|
9369
|
+
created_at: (new Date).toISOString(),
|
|
9370
|
+
files,
|
|
9371
|
+
result,
|
|
9372
|
+
step: ctx.state().interface?.step ?? 0
|
|
9373
|
+
};
|
|
9374
|
+
}
|
|
9375
|
+
if (result.type === "exception") {
|
|
9376
|
+
ctx.dispatch({
|
|
9377
|
+
type: "testValidate",
|
|
9378
|
+
created_at: (new Date).toISOString(),
|
|
9379
|
+
files,
|
|
9380
|
+
result,
|
|
9381
|
+
step: ctx.state().interface?.step ?? 0
|
|
9382
|
+
});
|
|
9383
|
+
throw new Error(JSON.stringify(result.error, null, 2));
|
|
9384
|
+
}
|
|
9385
|
+
const diagnostics = {};
|
|
9386
|
+
result.diagnostics.forEach((d => {
|
|
9387
|
+
if (d.file === null) return;
|
|
9388
|
+
diagnostics[d.file] = diagnostics[d.file] ?? [];
|
|
9389
|
+
diagnostics[d.file].push(d);
|
|
9390
|
+
}));
|
|
9391
|
+
if (Object.keys(diagnostics).length === 0) {
|
|
9392
|
+
return {
|
|
9393
|
+
type: "testValidate",
|
|
9394
|
+
created_at: (new Date).toISOString(),
|
|
9395
|
+
files,
|
|
9396
|
+
result: {
|
|
9397
|
+
...result,
|
|
9398
|
+
type: "success"
|
|
9399
|
+
},
|
|
9376
9400
|
step: ctx.state().interface?.step ?? 0
|
|
9377
9401
|
};
|
|
9378
|
-
|
|
9379
|
-
|
|
9402
|
+
}
|
|
9403
|
+
ctx.dispatch({
|
|
9404
|
+
type: "testValidate",
|
|
9405
|
+
created_at: (new Date).toISOString(),
|
|
9406
|
+
files,
|
|
9407
|
+
result,
|
|
9408
|
+
step: ctx.state().interface?.step ?? 0
|
|
9409
|
+
});
|
|
9410
|
+
if (life <= 0) return {
|
|
9411
|
+
type: "testValidate",
|
|
9412
|
+
created_at: (new Date).toISOString(),
|
|
9413
|
+
files,
|
|
9414
|
+
result,
|
|
9415
|
+
step: ctx.state().interface?.step ?? 0
|
|
9416
|
+
};
|
|
9417
|
+
const validate = await Promise.all(Object.entries(diagnostics).map((async ([filename, d]) => {
|
|
9418
|
+
const scenario = scenarioMap.get(filename);
|
|
9419
|
+
const code = files[filename];
|
|
9420
|
+
const response = await process(ctx, d, code, scenario);
|
|
9421
|
+
ctx.dispatch({
|
|
9422
|
+
type: "testCorrect",
|
|
9423
|
+
created_at: (new Date).toISOString(),
|
|
9424
|
+
files: {
|
|
9425
|
+
...files,
|
|
9426
|
+
[filename]: response.content
|
|
9427
|
+
},
|
|
9428
|
+
result,
|
|
9429
|
+
solution: response.solution,
|
|
9430
|
+
think_without_compile_error: response.think_without_compile_error,
|
|
9431
|
+
think_again_with_compile_error: response.think_again_with_compile_error,
|
|
9432
|
+
step: ctx.state().interface?.step ?? 0
|
|
9433
|
+
});
|
|
9434
|
+
return [ filename, response.content ];
|
|
9380
9435
|
})));
|
|
9381
|
-
|
|
9436
|
+
const newFiles = {
|
|
9437
|
+
...files,
|
|
9438
|
+
...Object.fromEntries(validate)
|
|
9439
|
+
};
|
|
9440
|
+
return step(ctx, newFiles, scenarioMap, life - 1);
|
|
9382
9441
|
}
|
|
9383
9442
|
|
|
9384
|
-
async function process
|
|
9443
|
+
async function process(ctx, diagnostics, code, scenario) {
|
|
9385
9444
|
const pointer = {
|
|
9386
9445
|
value: null
|
|
9387
9446
|
};
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
[filename]: content
|
|
9393
|
-
})), {});
|
|
9447
|
+
let document = null;
|
|
9448
|
+
if (scenario) {
|
|
9449
|
+
document = filterDocument(scenario, ctx.state().interface.document);
|
|
9450
|
+
}
|
|
9394
9451
|
const agentica = new MicroAgentica({
|
|
9395
9452
|
model: ctx.model,
|
|
9396
|
-
vendor:
|
|
9453
|
+
vendor: {
|
|
9454
|
+
...ctx.vendor
|
|
9455
|
+
},
|
|
9397
9456
|
config: {
|
|
9398
9457
|
...ctx.config ?? {}
|
|
9399
9458
|
},
|
|
9400
|
-
histories:
|
|
9459
|
+
histories: transformTestCorrectHistories(document),
|
|
9401
9460
|
controllers: [ createApplication$1({
|
|
9402
9461
|
model: ctx.model,
|
|
9403
9462
|
build: next => {
|
|
9404
9463
|
pointer.value = next;
|
|
9405
9464
|
}
|
|
9406
|
-
}) ]
|
|
9465
|
+
}) ],
|
|
9466
|
+
tokenUsage: ctx.usage()
|
|
9407
9467
|
});
|
|
9408
9468
|
enforceToolCall(agentica);
|
|
9409
|
-
await
|
|
9410
|
-
|
|
9469
|
+
await randomBackoffRetry((async () => {
|
|
9470
|
+
await agentica.conversate([ "Fix the compilation error in the provided code.", "", "## Original Code", "```typescript", code, "```", "", diagnostics.map((diagnostic => {
|
|
9471
|
+
if (diagnostic.start === undefined || diagnostic.length === undefined) return "";
|
|
9472
|
+
const checkDtoRegexp = `Cannot find module '@ORGANIZATION/template-api/lib/structures/IBbsArticleComment' or its corresponding type declarations.`;
|
|
9473
|
+
const [group] = [ ...checkDtoRegexp.matchAll(/Cannot find module '(.*lib\/structures\/.*)'/g) ];
|
|
9474
|
+
const [_, filename] = group ?? [];
|
|
9475
|
+
return [ "## Error Information", `- Position: Characters ${diagnostic.start} to ${diagnostic.start + diagnostic.length}`, `- Error Message: ${diagnostic.messageText}`, `- Problematic Code: \`${code.substring(diagnostic.start, diagnostic.start + diagnostic.length)}\``, filename ? `The type files located under **/lib/structures are declared in '@ORGANIZATION/PROJECT-api/lib/structures'.\n` + `Note: '@ORGANIZATION/PROJECT-api' must be written exactly as is and should not be replaced.\n` : "" ].join("\n");
|
|
9476
|
+
})), "## Instructions", "1. Focus on the specific error location and message", "2. Provide the corrected TypeScript code", "3. Ensure the fix resolves the compilation error", "", "Return only the fixed code without explanations." ].join("\n"));
|
|
9477
|
+
}));
|
|
9478
|
+
if (pointer.value === null) throw new Error("Failed to modify test code.");
|
|
9411
9479
|
return pointer.value;
|
|
9412
9480
|
}
|
|
9413
9481
|
|
|
@@ -9416,10 +9484,10 @@ function createApplication$1(props) {
|
|
|
9416
9484
|
const application = collection$2[props.model];
|
|
9417
9485
|
return {
|
|
9418
9486
|
protocol: "class",
|
|
9419
|
-
name: "
|
|
9487
|
+
name: "Modify Test Code",
|
|
9420
9488
|
application,
|
|
9421
9489
|
execute: {
|
|
9422
|
-
|
|
9490
|
+
correctTestCode: next => {
|
|
9423
9491
|
props.build(next);
|
|
9424
9492
|
}
|
|
9425
9493
|
}
|
|
@@ -9433,41 +9501,48 @@ const claude$2 = {
|
|
|
9433
9501
|
separate: null
|
|
9434
9502
|
},
|
|
9435
9503
|
functions: [ {
|
|
9436
|
-
name: "
|
|
9504
|
+
name: "correctTestCode",
|
|
9437
9505
|
parameters: {
|
|
9438
|
-
description: "Current Type: {@link
|
|
9506
|
+
description: "Current Type: {@link ICorrectTestFunctionProps}",
|
|
9439
9507
|
type: "object",
|
|
9440
9508
|
properties: {
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception scenarios\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error scenarios (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the plan if it doesn't follow the Test Generation\n Guildelines.",
|
|
9509
|
+
think_without_compile_error: {
|
|
9510
|
+
description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages.",
|
|
9444
9511
|
type: "string"
|
|
9445
9512
|
},
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9513
|
+
think_again_with_compile_error: {
|
|
9514
|
+
description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
|
|
9515
|
+
type: "string"
|
|
9516
|
+
},
|
|
9517
|
+
solution: {
|
|
9518
|
+
title: "Step 3: Concrete action plan for fixing the identified issues",
|
|
9519
|
+
description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality.",
|
|
9449
9520
|
type: "string"
|
|
9450
9521
|
},
|
|
9451
9522
|
content: {
|
|
9452
|
-
title: "
|
|
9453
|
-
description: "
|
|
9523
|
+
title: "Step 4: The corrected TypeScript test code",
|
|
9524
|
+
description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct.",
|
|
9454
9525
|
type: "string"
|
|
9455
9526
|
}
|
|
9456
9527
|
},
|
|
9457
|
-
required: [ "
|
|
9528
|
+
required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
|
|
9458
9529
|
additionalProperties: false,
|
|
9459
9530
|
$defs: {}
|
|
9460
9531
|
},
|
|
9461
9532
|
validate: (() => {
|
|
9462
|
-
const _io0 = input => "string" === typeof input.
|
|
9463
|
-
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
9464
|
-
path: _path + ".
|
|
9533
|
+
const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
|
|
9534
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
|
|
9535
|
+
path: _path + ".think_without_compile_error",
|
|
9465
9536
|
expected: "string",
|
|
9466
|
-
value: input.
|
|
9467
|
-
}), "string" === typeof input.
|
|
9468
|
-
path: _path + ".
|
|
9537
|
+
value: input.think_without_compile_error
|
|
9538
|
+
}), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
|
|
9539
|
+
path: _path + ".think_again_with_compile_error",
|
|
9469
9540
|
expected: "string",
|
|
9470
|
-
value: input.
|
|
9541
|
+
value: input.think_again_with_compile_error
|
|
9542
|
+
}), "string" === typeof input.solution || _report(_exceptionable, {
|
|
9543
|
+
path: _path + ".solution",
|
|
9544
|
+
expected: "string",
|
|
9545
|
+
value: input.solution
|
|
9471
9546
|
}), "string" === typeof input.content || _report(_exceptionable, {
|
|
9472
9547
|
path: _path + ".content",
|
|
9473
9548
|
expected: "string",
|
|
@@ -9482,11 +9557,11 @@ const claude$2 = {
|
|
|
9482
9557
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
9483
9558
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
9484
9559
|
path: _path + "",
|
|
9485
|
-
expected: "
|
|
9560
|
+
expected: "ICorrectTestFunctionProps",
|
|
9486
9561
|
value: input
|
|
9487
9562
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
9488
9563
|
path: _path + "",
|
|
9489
|
-
expected: "
|
|
9564
|
+
expected: "ICorrectTestFunctionProps",
|
|
9490
9565
|
value: input
|
|
9491
9566
|
}))(input, "$input", true);
|
|
9492
9567
|
const success = 0 === errors.length;
|
|
@@ -9517,41 +9592,48 @@ const collection$2 = {
|
|
|
9517
9592
|
separate: null
|
|
9518
9593
|
},
|
|
9519
9594
|
functions: [ {
|
|
9520
|
-
name: "
|
|
9595
|
+
name: "correctTestCode",
|
|
9521
9596
|
parameters: {
|
|
9522
|
-
description: "Current Type: {@link
|
|
9597
|
+
description: "Current Type: {@link ICorrectTestFunctionProps}",
|
|
9523
9598
|
type: "object",
|
|
9524
9599
|
properties: {
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception scenarios\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error scenarios (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the plan if it doesn't follow the Test Generation\n Guildelines.",
|
|
9600
|
+
think_without_compile_error: {
|
|
9601
|
+
description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages.",
|
|
9528
9602
|
type: "string"
|
|
9529
9603
|
},
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9604
|
+
think_again_with_compile_error: {
|
|
9605
|
+
description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong.",
|
|
9606
|
+
type: "string"
|
|
9607
|
+
},
|
|
9608
|
+
solution: {
|
|
9609
|
+
title: "Step 3: Concrete action plan for fixing the identified issues",
|
|
9610
|
+
description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality.",
|
|
9533
9611
|
type: "string"
|
|
9534
9612
|
},
|
|
9535
9613
|
content: {
|
|
9536
|
-
title: "
|
|
9537
|
-
description: "
|
|
9614
|
+
title: "Step 4: The corrected TypeScript test code",
|
|
9615
|
+
description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct.",
|
|
9538
9616
|
type: "string"
|
|
9539
9617
|
}
|
|
9540
9618
|
},
|
|
9541
|
-
required: [ "
|
|
9619
|
+
required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
|
|
9542
9620
|
additionalProperties: false,
|
|
9543
9621
|
$defs: {}
|
|
9544
9622
|
},
|
|
9545
9623
|
validate: (() => {
|
|
9546
|
-
const _io0 = input => "string" === typeof input.
|
|
9547
|
-
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
9548
|
-
path: _path + ".
|
|
9624
|
+
const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
|
|
9625
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
|
|
9626
|
+
path: _path + ".think_without_compile_error",
|
|
9549
9627
|
expected: "string",
|
|
9550
|
-
value: input.
|
|
9551
|
-
}), "string" === typeof input.
|
|
9552
|
-
path: _path + ".
|
|
9628
|
+
value: input.think_without_compile_error
|
|
9629
|
+
}), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
|
|
9630
|
+
path: _path + ".think_again_with_compile_error",
|
|
9553
9631
|
expected: "string",
|
|
9554
|
-
value: input.
|
|
9632
|
+
value: input.think_again_with_compile_error
|
|
9633
|
+
}), "string" === typeof input.solution || _report(_exceptionable, {
|
|
9634
|
+
path: _path + ".solution",
|
|
9635
|
+
expected: "string",
|
|
9636
|
+
value: input.solution
|
|
9555
9637
|
}), "string" === typeof input.content || _report(_exceptionable, {
|
|
9556
9638
|
path: _path + ".content",
|
|
9557
9639
|
expected: "string",
|
|
@@ -9566,11 +9648,11 @@ const collection$2 = {
|
|
|
9566
9648
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
9567
9649
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
9568
9650
|
path: _path + "",
|
|
9569
|
-
expected: "
|
|
9651
|
+
expected: "ICorrectTestFunctionProps",
|
|
9570
9652
|
value: input
|
|
9571
9653
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
9572
9654
|
path: _path + "",
|
|
9573
|
-
expected: "
|
|
9655
|
+
expected: "ICorrectTestFunctionProps",
|
|
9574
9656
|
value: input
|
|
9575
9657
|
}))(input, "$input", true);
|
|
9576
9658
|
const success = 0 === errors.length;
|
|
@@ -9603,40 +9685,47 @@ const collection$2 = {
|
|
|
9603
9685
|
separate: null
|
|
9604
9686
|
},
|
|
9605
9687
|
functions: [ {
|
|
9606
|
-
name: "
|
|
9688
|
+
name: "correctTestCode",
|
|
9607
9689
|
parameters: {
|
|
9608
9690
|
type: "object",
|
|
9609
9691
|
properties: {
|
|
9610
|
-
|
|
9692
|
+
think_without_compile_error: {
|
|
9611
9693
|
type: "string",
|
|
9612
|
-
|
|
9613
|
-
description: "Strategic approach for test implementation.\n\nDefine the high-level strategy and logical flow for testing the given\nscenario. Focus on test methodology, data preparation, and assertion\nstrategy.\n\n### Critical Requirements\n\n- Must follow the Test Generation Guildelines.\n- Must Planning the test code Never occur the typescript compile error.\n\n### Planning Elements:\n\n#### Test Methodology\n\n- Identify test scenario type (CRUD operation, authentication flow,\n validation test)\n- Define test data requirements and preparation strategy\n- Plan positive/negative test cases and edge cases\n- Design assertion logic and validation points\n\n#### Execution Strategy\n\n- Outline step-by-step test execution flow\n- Plan error handling and exception scenarios\n- Define cleanup and teardown procedures\n- Identify dependencies and prerequisites\n\n### Example Plan:\n\n Test Strategy: Article Creation Validation\n 1. Prepare valid article data with required fields\n 2. Execute POST request to create article\n 3. Validate response structure and data integrity\n 4. Test error scenarios (missing fields, invalid data)\n 5. Verify database state changes\n 6. Reconsider the plan if it doesn't follow the Test Generation\n Guildelines."
|
|
9694
|
+
description: "Step 1: Initial self-reflection on the source code without compiler error\ncontext.\n\nThe AI agent analyzes the previously generated test code to identify\npotential issues, relying solely on its understanding of TypeScript syntax,\ntesting patterns, and best practices.\n\nThis encourages the agent to develop independent debugging skills before\nbeing influenced by external error messages."
|
|
9614
9695
|
},
|
|
9615
|
-
|
|
9696
|
+
think_again_with_compile_error: {
|
|
9616
9697
|
type: "string",
|
|
9617
|
-
|
|
9618
|
-
|
|
9698
|
+
description: "Step 2: Re-evaluation of the code with compiler error messages as\nadditional context.\n\nAfter the initial analysis, the AI agent reviews the same code again, this\ntime incorporating the specific TypeScript compiler error messages.\n\nThis allows the agent to correlate its initial observations with concrete\ncompilation failures and refine its understanding of what went wrong."
|
|
9699
|
+
},
|
|
9700
|
+
solution: {
|
|
9701
|
+
type: "string",
|
|
9702
|
+
title: "Step 3: Concrete action plan for fixing the identified issues",
|
|
9703
|
+
description: "Step 3: Concrete action plan for fixing the identified issues.\n\nBased on the analysis from steps 1 and 2, the AI agent formulates a\nspecific, step-by-step solution strategy.\n\nThis should include what changes need to be made, why those changes are\nnecessary, and how they will resolve the compilation errors while\nmaintaining the test's intended functionality."
|
|
9619
9704
|
},
|
|
9620
9705
|
content: {
|
|
9621
9706
|
type: "string",
|
|
9622
|
-
title: "
|
|
9623
|
-
description: "
|
|
9707
|
+
title: "Step 4: The corrected TypeScript test code",
|
|
9708
|
+
description: "Step 4: The corrected TypeScript test code.\n\nThe final, properly fixed TypeScript code that should compile without\nerrors.\n\nThis represents the implementation of the solution plan from step 3,\ncontaining all necessary corrections to make the test code syntactically\nvalid and functionally correct."
|
|
9624
9709
|
}
|
|
9625
9710
|
},
|
|
9626
|
-
required: [ "
|
|
9627
|
-
description: "Current Type: {@link
|
|
9711
|
+
required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
|
|
9712
|
+
description: "Current Type: {@link ICorrectTestFunctionProps}",
|
|
9628
9713
|
additionalProperties: false
|
|
9629
9714
|
},
|
|
9630
9715
|
validate: (() => {
|
|
9631
|
-
const _io0 = input => "string" === typeof input.
|
|
9632
|
-
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
9633
|
-
path: _path + ".
|
|
9716
|
+
const _io0 = input => "string" === typeof input.think_without_compile_error && "string" === typeof input.think_again_with_compile_error && "string" === typeof input.solution && "string" === typeof input.content;
|
|
9717
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
|
|
9718
|
+
path: _path + ".think_without_compile_error",
|
|
9634
9719
|
expected: "string",
|
|
9635
|
-
value: input.
|
|
9636
|
-
}), "string" === typeof input.
|
|
9637
|
-
path: _path + ".
|
|
9720
|
+
value: input.think_without_compile_error
|
|
9721
|
+
}), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
|
|
9722
|
+
path: _path + ".think_again_with_compile_error",
|
|
9638
9723
|
expected: "string",
|
|
9639
|
-
value: input.
|
|
9724
|
+
value: input.think_again_with_compile_error
|
|
9725
|
+
}), "string" === typeof input.solution || _report(_exceptionable, {
|
|
9726
|
+
path: _path + ".solution",
|
|
9727
|
+
expected: "string",
|
|
9728
|
+
value: input.solution
|
|
9640
9729
|
}), "string" === typeof input.content || _report(_exceptionable, {
|
|
9641
9730
|
path: _path + ".content",
|
|
9642
9731
|
expected: "string",
|
|
@@ -9651,11 +9740,11 @@ const collection$2 = {
|
|
|
9651
9740
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
9652
9741
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
9653
9742
|
path: _path + "",
|
|
9654
|
-
expected: "
|
|
9743
|
+
expected: "ICorrectTestFunctionProps",
|
|
9655
9744
|
value: input
|
|
9656
9745
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
9657
9746
|
path: _path + "",
|
|
9658
|
-
expected: "
|
|
9747
|
+
expected: "ICorrectTestFunctionProps",
|
|
9659
9748
|
value: input
|
|
9660
9749
|
}))(input, "$input", true);
|
|
9661
9750
|
const success = 0 === errors.length;
|
|
@@ -9678,171 +9767,259 @@ const collection$2 = {
|
|
|
9678
9767
|
}
|
|
9679
9768
|
};
|
|
9680
9769
|
|
|
9681
|
-
|
|
9682
|
-
if (state.analyze === null) return [ {
|
|
9683
|
-
id: v4(),
|
|
9684
|
-
created_at: (new Date).toISOString(),
|
|
9685
|
-
type: "systemMessage",
|
|
9686
|
-
text: [ "Requirement analysis is not yet completed.", "Don't call the any tool function,", "but say to process the requirement analysis." ].join(" ")
|
|
9687
|
-
} ]; else if (state.prisma === null) return [ {
|
|
9688
|
-
id: v4(),
|
|
9689
|
-
created_at: (new Date).toISOString(),
|
|
9690
|
-
type: "systemMessage",
|
|
9691
|
-
text: [ "Prisma DB schema generation is not yet completed.", "Don't call the any tool function,", "but say to process the Prisma DB schema generation." ].join(" ")
|
|
9692
|
-
} ]; else if (state.analyze.step !== state.prisma.step) return [ {
|
|
9693
|
-
id: v4(),
|
|
9694
|
-
created_at: (new Date).toISOString(),
|
|
9695
|
-
type: "systemMessage",
|
|
9696
|
-
text: [ "Prisma DB schema generation has not been updated", "for the latest requirement analysis.", "Don't call the any tool function,", "but say to re-process the Prisma DB schema generation." ].join(" ")
|
|
9697
|
-
} ]; else if (state.prisma.compiled.type !== "success") return [ {
|
|
9698
|
-
id: v4(),
|
|
9699
|
-
created_at: (new Date).toISOString(),
|
|
9700
|
-
type: "systemMessage",
|
|
9701
|
-
text: [ "Prisma DB schema generation has not been updated", "for the latest requirement analysis.", "Don't call the any tool function,", "but say to re-process the Prisma DB schema generation." ].join(" ")
|
|
9702
|
-
} ]; else if (state.interface === null) return [ {
|
|
9703
|
-
id: v4(),
|
|
9704
|
-
created_at: (new Date).toISOString(),
|
|
9705
|
-
type: "systemMessage",
|
|
9706
|
-
text: [ "Interface generation is not yet completed.", "Don't call the any tool function,", "but say to process the interface generation." ].join(" ")
|
|
9707
|
-
} ];
|
|
9708
|
-
return [ {
|
|
9709
|
-
id: v4(),
|
|
9710
|
-
created_at: (new Date).toISOString(),
|
|
9711
|
-
type: "systemMessage",
|
|
9712
|
-
text: "# System Prompt: User Scenario Generator for API Endpoints\n\n## Role Definition\nYou are a world-class User Experience Analyst and Business Scenario Expert who specializes in analyzing API endpoints to generate comprehensive user scenarios from a pure user perspective. Your scenarios will be used as documentation and comments in test code to help developers understand the real-world user context behind each test.\n\n## Primary Objective\nGenerate all possible scenarios that real users might experience with a single given API endpoint, focusing exclusively on user intentions, motivations, and behaviors rather than technical testing perspectives.\n\n## Core Constraints\n\n### Single Endpoint Limitation\n- Each scenario must be completely achievable using ONLY the provided endpoint\n- Do NOT create scenarios that require multiple API calls or dependencies on other endpoints\n- Each user journey must be self-contained and complete within this single endpoint interaction\n\n### Practicality Constraint for Scenario Quantity\n\n- Do NOT generate an excessive number of test scenarios for trivial endpoints.\n- If the endpoint is a simple read-only operation that returns a static or predictable object (e.g. `{ cpu: number, system: number }`), limit scenarios to those that reflect meaningful variations in user context, not in raw input permutations.\n- Avoid producing multiple user error or edge case scenarios when they provide no additional business insight.\n- Prioritize business relevance over theoretical input diversity.\n- The goal is to maximize scenario value, not quantity.\n\n\n## Scenario Generation Principles\n\n### 1. Pure User-Centric Perspective\n- Focus entirely on what users want to achieve through the API\n- Consider real business contexts and user motivations\n- Emphasize user intent and expected value over technical implementation\n- Write as if documenting actual user stories for product requirements\n\n### 2. Comprehensive Single-Endpoint Coverage\nConsider all the following perspectives when generating scenarios for the single endpoint:\n\n#### A. Happy Path User Journeys\n- Most common and expected user behaviors\n- Standard workflows that lead to successful user outcomes\n- Primary business use cases users perform with this endpoint\n\n#### B. Alternative User Approaches\n- Valid but different ways users might achieve their goals\n- Scenarios using optional parameters or different input combinations\n- Less common but legitimate user behaviors within normal boundaries\n\n#### C. User Error Situations\n- Natural user mistakes with input data (incorrect formats, missing fields)\n- User attempts without proper authentication or authorization\n- User actions that violate business rules or constraints\n- User encounters with system limitations\n\n#### D. Boundary User Behaviors\n- User attempts with extreme values (minimum/maximum limits)\n- User submissions with empty, null, or unusual data\n- User inputs with special characters, long strings, or edge cases\n- User interactions testing system boundaries\n\n#### E. Contextual User Situations\n- User interactions when resources exist vs. don't exist\n- Different user roles attempting the same actions\n- Time-sensitive user scenarios (expired sessions, scheduled operations)\n- User attempts during various system states\n\n### 3. Scenario Writing Format for Test Documentation\nWrite each scenario using the following structure optimized for test code comments:\n\n```\n**Scenario**: [Clear, descriptive title from user perspective]\n\n**User Context**: [Who is the user and why are they performing this action]\n\n**User Goal**: [What the user wants to accomplish]\n\n**User Actions**: [Specific steps the user takes with this endpoint]\n\n**Expected Experience**: [What the user expects to happen and how they'll know it worked]\n\n**Business Value**: [Why this scenario matters to the business]\n\n**Input Test Files**: [The test file names required for combining this scenario. If you have multiple files, connect them with commas.]\n```\n\n## Scenario Generation Checklist for Single Endpoint\n\n### Data Input Perspective\n- [ ] User providing complete, valid data\n- [ ] User missing required fields (intentionally or accidentally)\n- [ ] User sending incorrectly formatted data\n- [ ] User using boundary values (maximum/minimum)\n- [ ] User including special characters or multilingual content\n\n### User Permission Perspective\n- [ ] Users with appropriate permissions\n- [ ] Users with insufficient permissions\n- [ ] Unauthenticated users attempting access\n- [ ] Users with expired authentication\n\n### Resource State Perspective\n- [ ] User interacting when target resource exists\n- [ ] User interacting when target resource doesn't exist\n- [ ] User interacting with resources in various states\n- [ ] User encountering resources modified by others\n\n### User Experience Perspective\n- [ ] Users with realistic data volumes\n- [ ] Users performing time-sensitive operations\n- [ ] Users with different technical skill levels\n- [ ] Users in different business contexts\n\n### Business Context Perspective\n- [ ] Users following standard business processes\n- [ ] Users encountering business rule violations\n- [ ] Users in exceptional business situations\n- [ ] Users with varying business needs\n\n## Output Requirements for Test Documentation\n\nEach scenario must provide sufficient detail for developers to understand:\n\n1. **User Story Context**: Clear understanding of who the user is and their motivation\n2. **Business Justification**: Why this scenario matters for the product\n3. **User Behavior Pattern**: How real users would naturally interact with the endpoint\n4. **Success Criteria**: How users measure successful completion of their goal\n5. **Function Name Guidance**: Clear enough description to derive meaningful test function names\n\n## Quality Standards for Test Code Comments\n\n- Write scenarios that help developers empathize with real users\n- Focus on business value and user outcomes, not technical mechanics\n- Provide enough context that a developer can understand the user's situation\n- Ensure scenarios reflect realistic business situations\n- Make each scenario distinct and valuable for understanding user needs\n- Use language that both technical and non-technical stakeholders can understand\n\n## Guidelines\n\n- Avoid mentioning test code, assertions, or technical implementation details\n- Write purely from the user's perspective using narrative language\n- Create realistic scenarios that reflect actual business situations\n- Ensure scenarios are comprehensive yet practical for a single endpoint\n- Focus on user value and business outcomes\n- Make scenarios detailed enough to understand full user context\n\n## Expected Input\nYou will receive a single API endpoint specification including:\n- HTTP method and endpoint path\n- Request/response schemas\n- Authentication requirements\n- Parameter definitions\n- Business context when available\n\n## Expected Output\nFor the given API endpoint, provide:\n- Categorized user scenarios covering all perspectives mentioned above\n- Each scenario following the specified format for test documentation\n- Scenarios that are complete and achievable with only the single provided endpoint\n- Clear mapping between user intentions and the specific API operation\n- Sufficient detail to understand both user context and business value\n\n## Working Language\n- Default working language: English\n- Use the language specified by user in messages as the working language when explicitly provided\n- All thinking and responses must be in the working language\n- Maintain consistent perspective and tone throughout all scenarios"
|
|
9713
|
-
}, {
|
|
9714
|
-
id: v4(),
|
|
9715
|
-
created_at: (new Date).toISOString(),
|
|
9716
|
-
type: "systemMessage",
|
|
9717
|
-
text: [ "# Result of Analyze Agent", "- The following document contains the user requirements that were extracted through conversations with the user by the Analyze Agent.", "- The database schema was designed based on these requirements, so you may refer to this document when writing test code or reviewing the schema.", "", `## User Request`, "", `- ${state.analyze.reason}`, "", `## Requirement Analysis Report`, "", "```json", JSON.stringify(state.analyze.files), "```" ].join("\n")
|
|
9718
|
-
}, {
|
|
9719
|
-
id: v4(),
|
|
9720
|
-
created_at: (new Date).toISOString(),
|
|
9721
|
-
type: "systemMessage",
|
|
9722
|
-
text: [ "# Result of Prisma Agent", "- Given the following database schema and entity-relationship diagram, write appropriate test code to validate the constraints and relationships defined in the schema. For example, if there is a unique column, include a test that ensures its uniqueness.", "- The test code should strictly adhere to the schema and relationships—no violations of constraints should occur.", "- Use the information from the schema and diagram to design meaningful and accurate test cases.", "", "## Prisma DB Schema", "```json", JSON.stringify(state.prisma.schemas), "```", "", "## Entity Relationship Diagrams", "```json", JSON.stringify(state.prisma.compiled.diagrams), "```" ].join("\n")
|
|
9723
|
-
}, {
|
|
9724
|
-
id: v4(),
|
|
9725
|
-
created_at: (new Date).toISOString(),
|
|
9726
|
-
type: "systemMessage",
|
|
9727
|
-
text: [ "# Result of Interfaced Agent", "- OpenAPI document generation is ready.", "", "Call the provided tool function to generate the user scenarios", "referencing below OpenAPI document.", "", `## OpenAPI Document`, "```json", JSON.stringify(state.interface.document), "```" ].join("\n")
|
|
9728
|
-
}, {
|
|
9729
|
-
id: v4(),
|
|
9730
|
-
created_at: (new Date).toISOString(),
|
|
9731
|
-
type: "systemMessage",
|
|
9732
|
-
text: "# System Prompt: User Scenario Generator for API Endpoints\n\n## Role Definition\nYou are a world-class User Experience Analyst and Business Scenario Expert who specializes in analyzing API endpoints to generate comprehensive user scenarios from a pure user perspective. Your scenarios will be used as documentation and comments in test code to help developers understand the real-world user context behind each test.\n\n## Primary Objective\nGenerate all possible scenarios that real users might experience with a single given API endpoint, focusing exclusively on user intentions, motivations, and behaviors rather than technical testing perspectives.\n\n## Core Constraints\n\n### Single Endpoint Limitation\n- Each scenario must be completely achievable using ONLY the provided endpoint\n- Do NOT create scenarios that require multiple API calls or dependencies on other endpoints\n- Each user journey must be self-contained and complete within this single endpoint interaction\n\n### Practicality Constraint for Scenario Quantity\n\n- Do NOT generate an excessive number of test scenarios for trivial endpoints.\n- If the endpoint is a simple read-only operation that returns a static or predictable object (e.g. `{ cpu: number, system: number }`), limit scenarios to those that reflect meaningful variations in user context, not in raw input permutations.\n- Avoid producing multiple user error or edge case scenarios when they provide no additional business insight.\n- Prioritize business relevance over theoretical input diversity.\n- The goal is to maximize scenario value, not quantity.\n\n\n## Scenario Generation Principles\n\n### 1. Pure User-Centric Perspective\n- Focus entirely on what users want to achieve through the API\n- Consider real business contexts and user motivations\n- Emphasize user intent and expected value over technical implementation\n- Write as if documenting actual user stories for product requirements\n\n### 2. Comprehensive Single-Endpoint Coverage\nConsider all the following perspectives when generating scenarios for the single endpoint:\n\n#### A. Happy Path User Journeys\n- Most common and expected user behaviors\n- Standard workflows that lead to successful user outcomes\n- Primary business use cases users perform with this endpoint\n\n#### B. Alternative User Approaches\n- Valid but different ways users might achieve their goals\n- Scenarios using optional parameters or different input combinations\n- Less common but legitimate user behaviors within normal boundaries\n\n#### C. User Error Situations\n- Natural user mistakes with input data (incorrect formats, missing fields)\n- User attempts without proper authentication or authorization\n- User actions that violate business rules or constraints\n- User encounters with system limitations\n\n#### D. Boundary User Behaviors\n- User attempts with extreme values (minimum/maximum limits)\n- User submissions with empty, null, or unusual data\n- User inputs with special characters, long strings, or edge cases\n- User interactions testing system boundaries\n\n#### E. Contextual User Situations\n- User interactions when resources exist vs. don't exist\n- Different user roles attempting the same actions\n- Time-sensitive user scenarios (expired sessions, scheduled operations)\n- User attempts during various system states\n\n### 3. Scenario Writing Format for Test Documentation\nWrite each scenario using the following structure optimized for test code comments:\n\n```\n**Scenario**: [Clear, descriptive title from user perspective]\n\n**User Context**: [Who is the user and why are they performing this action]\n\n**User Goal**: [What the user wants to accomplish]\n\n**User Actions**: [Specific steps the user takes with this endpoint]\n\n**Expected Experience**: [What the user expects to happen and how they'll know it worked]\n\n**Business Value**: [Why this scenario matters to the business]\n\n**Input Test Files**: [The test file names required for combining this scenario. If you have multiple files, connect them with commas.]\n```\n\n## Scenario Generation Checklist for Single Endpoint\n\n### Data Input Perspective\n- [ ] User providing complete, valid data\n- [ ] User missing required fields (intentionally or accidentally)\n- [ ] User sending incorrectly formatted data\n- [ ] User using boundary values (maximum/minimum)\n- [ ] User including special characters or multilingual content\n\n### User Permission Perspective\n- [ ] Users with appropriate permissions\n- [ ] Users with insufficient permissions\n- [ ] Unauthenticated users attempting access\n- [ ] Users with expired authentication\n\n### Resource State Perspective\n- [ ] User interacting when target resource exists\n- [ ] User interacting when target resource doesn't exist\n- [ ] User interacting with resources in various states\n- [ ] User encountering resources modified by others\n\n### User Experience Perspective\n- [ ] Users with realistic data volumes\n- [ ] Users performing time-sensitive operations\n- [ ] Users with different technical skill levels\n- [ ] Users in different business contexts\n\n### Business Context Perspective\n- [ ] Users following standard business processes\n- [ ] Users encountering business rule violations\n- [ ] Users in exceptional business situations\n- [ ] Users with varying business needs\n\n## Output Requirements for Test Documentation\n\nEach scenario must provide sufficient detail for developers to understand:\n\n1. **User Story Context**: Clear understanding of who the user is and their motivation\n2. **Business Justification**: Why this scenario matters for the product\n3. **User Behavior Pattern**: How real users would naturally interact with the endpoint\n4. **Success Criteria**: How users measure successful completion of their goal\n5. **Function Name Guidance**: Clear enough description to derive meaningful test function names\n\n## Quality Standards for Test Code Comments\n\n- Write scenarios that help developers empathize with real users\n- Focus on business value and user outcomes, not technical mechanics\n- Provide enough context that a developer can understand the user's situation\n- Ensure scenarios reflect realistic business situations\n- Make each scenario distinct and valuable for understanding user needs\n- Use language that both technical and non-technical stakeholders can understand\n\n## Guidelines\n\n- Avoid mentioning test code, assertions, or technical implementation details\n- Write purely from the user's perspective using narrative language\n- Create realistic scenarios that reflect actual business situations\n- Ensure scenarios are comprehensive yet practical for a single endpoint\n- Focus on user value and business outcomes\n- Make scenarios detailed enough to understand full user context\n\n## Expected Input\nYou will receive a single API endpoint specification including:\n- HTTP method and endpoint path\n- Request/response schemas\n- Authentication requirements\n- Parameter definitions\n- Business context when available\n\n## Expected Output\nFor the given API endpoint, provide:\n- Categorized user scenarios covering all perspectives mentioned above\n- Each scenario following the specified format for test documentation\n- Scenarios that are complete and achievable with only the single provided endpoint\n- Clear mapping between user intentions and the specific API operation\n- Sufficient detail to understand both user context and business value\n\n## Working Language\n- Default working language: English\n- Use the language specified by user in messages as the working language when explicitly provided\n- All thinking and responses must be in the working language\n- Maintain consistent perspective and tone throughout all scenarios"
|
|
9733
|
-
}, {
|
|
9734
|
-
id: v4(),
|
|
9735
|
-
created_at: (new Date).toISOString(),
|
|
9736
|
-
type: "systemMessage",
|
|
9737
|
-
text: [ `This is a description of different APIs.`, `Different APIs may have to be called to create one.`, `Check which functions have been developed.`, "```json", JSON.stringify(allEndpoints, null, 2), "```" ].join("\n")
|
|
9738
|
-
}, {
|
|
9739
|
-
id: v4(),
|
|
9740
|
-
created_at: (new Date).toISOString(),
|
|
9741
|
-
type: "systemMessage",
|
|
9742
|
-
text: [ "Below is basically the generated test code,", "which is a test to verify that the API is simply called and successful.", "Since there is already an automatically generated API,", "when a user requests to create a test scenario, two or more APIs must be combined,", "but a test in which the currently given endpoint is the main must be created.", '"Input Test Files" should be selected from the list of files here.', "```json", JSON.stringify(files, null, 2), "```" ].join("\n")
|
|
9743
|
-
} ];
|
|
9744
|
-
};
|
|
9745
|
-
|
|
9746
|
-
async function orchestrateTestScenario(ctx, capacity = 4) {
|
|
9747
|
-
const files = Object.entries(ctx.state().interface?.files ?? {}).filter((([filename]) => filename.startsWith("test/features/api/"))).reduce(((acc, [filename, content]) => Object.assign(acc, {
|
|
9748
|
-
[filename]: content
|
|
9749
|
-
})), {});
|
|
9770
|
+
async function orchestrateTestScenario(ctx) {
|
|
9750
9771
|
const operations = ctx.state().interface?.document.operations ?? [];
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
const matrix = divideArray({
|
|
9761
|
-
array: endpoints,
|
|
9762
|
-
capacity
|
|
9763
|
-
});
|
|
9764
|
-
const start = new Date;
|
|
9765
|
-
let completed = 0;
|
|
9766
|
-
const scenarios = await Promise.all(matrix.map((async e => {
|
|
9767
|
-
const rows = await divideAndConquer(ctx, e, endpoints, files, 3, (count => {
|
|
9768
|
-
completed += count;
|
|
9769
|
-
}));
|
|
9770
|
-
ctx.dispatch({
|
|
9771
|
-
type: "testScenario",
|
|
9772
|
-
scenarios: rows,
|
|
9773
|
-
total: rows.flatMap((el => el.scenarios)).length,
|
|
9774
|
-
step: ctx.state().test?.step ?? 0,
|
|
9775
|
-
completed,
|
|
9776
|
-
created_at: start.toISOString()
|
|
9772
|
+
if (operations.length === 0) {
|
|
9773
|
+
throw new Error("Cannot write test scenarios because these are no operations.");
|
|
9774
|
+
}
|
|
9775
|
+
const exclude = [];
|
|
9776
|
+
let include = Array.from(operations);
|
|
9777
|
+
do {
|
|
9778
|
+
const matrix = divideArray({
|
|
9779
|
+
array: include,
|
|
9780
|
+
capacity: 30
|
|
9777
9781
|
});
|
|
9778
|
-
|
|
9779
|
-
|
|
9782
|
+
await Promise.all(matrix.map((async _include => {
|
|
9783
|
+
exclude.push(...await execute(ctx, operations, _include, exclude.map((x => x.endpoint))));
|
|
9784
|
+
})));
|
|
9785
|
+
include = include.filter((op => {
|
|
9786
|
+
if (exclude.some((pg => pg.endpoint.method === op.method && pg.endpoint.path === op.path))) {
|
|
9787
|
+
return false;
|
|
9788
|
+
}
|
|
9789
|
+
return true;
|
|
9790
|
+
}));
|
|
9791
|
+
} while (include.length > 0);
|
|
9780
9792
|
return {
|
|
9781
9793
|
type: "testScenario",
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9794
|
+
step: ctx.state().analyze?.step ?? 0,
|
|
9795
|
+
scenarios: exclude.flatMap((pg => pg.scenarios.map((plan => ({
|
|
9796
|
+
endpoint: pg.endpoint,
|
|
9797
|
+
draft: plan.draft,
|
|
9798
|
+
functionName: plan.functionName,
|
|
9799
|
+
dependencies: plan.dependsOn
|
|
9800
|
+
}))))),
|
|
9801
|
+
created_at: (new Date).toISOString()
|
|
9787
9802
|
};
|
|
9788
9803
|
}
|
|
9789
9804
|
|
|
9790
|
-
async
|
|
9791
|
-
const remained = new HashSet(endpoints, OpenApiEndpointComparator.hashCode, OpenApiEndpointComparator.equals);
|
|
9792
|
-
const scenarios = new HashMap(OpenApiEndpointComparator.hashCode, OpenApiEndpointComparator.equals);
|
|
9793
|
-
for (let i = 0; i < retry; ++i) {
|
|
9794
|
-
if (remained.empty() === true || scenarios.size() >= endpoints.length) break;
|
|
9795
|
-
const before = scenarios.size();
|
|
9796
|
-
const newbie = await process(ctx, Array.from(remained), allEndpoints, files);
|
|
9797
|
-
for (const item of newbie) {
|
|
9798
|
-
scenarios.set(item.endpoint, item.scenarios);
|
|
9799
|
-
remained.erase(item.endpoint);
|
|
9800
|
-
}
|
|
9801
|
-
if (scenarios.size() - before !== 0) progress(scenarios.size() - before);
|
|
9802
|
-
}
|
|
9803
|
-
return Array.from(scenarios.toJSON()).map((it => ({
|
|
9804
|
-
endpoint: it.first,
|
|
9805
|
-
scenarios: it.second
|
|
9806
|
-
})));
|
|
9807
|
-
}
|
|
9808
|
-
|
|
9809
|
-
async function process(ctx, endpoints, allEndpoints, files) {
|
|
9805
|
+
const execute = async (ctx, ops, include, exclude) => {
|
|
9810
9806
|
const pointer = {
|
|
9811
|
-
value:
|
|
9807
|
+
value: []
|
|
9812
9808
|
};
|
|
9813
9809
|
const agentica = new MicroAgentica({
|
|
9814
9810
|
model: ctx.model,
|
|
9815
9811
|
vendor: ctx.vendor,
|
|
9816
9812
|
config: {
|
|
9817
|
-
...ctx.config ?? {
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
systemPrompt: {
|
|
9821
|
-
describe: () => "Answer only 'completion' or 'failure'."
|
|
9813
|
+
...ctx.config ?? {},
|
|
9814
|
+
executor: {
|
|
9815
|
+
describe: null
|
|
9822
9816
|
}
|
|
9823
9817
|
},
|
|
9824
9818
|
tokenUsage: ctx.usage(),
|
|
9825
|
-
histories:
|
|
9819
|
+
histories: createHistoryProperties(ops, include, exclude),
|
|
9826
9820
|
controllers: [ createApplication({
|
|
9827
9821
|
model: ctx.model,
|
|
9828
9822
|
build: next => {
|
|
9829
9823
|
pointer.value ?? (pointer.value = []);
|
|
9830
|
-
pointer.value.push(...next.
|
|
9824
|
+
pointer.value.push(...next.scenarioGroups);
|
|
9831
9825
|
}
|
|
9832
9826
|
}) ]
|
|
9833
9827
|
});
|
|
9834
9828
|
enforceToolCall(agentica);
|
|
9835
|
-
await agentica.conversate(
|
|
9836
|
-
if (pointer.value ===
|
|
9829
|
+
await agentica.conversate(`create test scenarios.`);
|
|
9830
|
+
if (pointer.value.length === 0) {
|
|
9831
|
+
throw new Error("Failed to create test plans.");
|
|
9832
|
+
}
|
|
9837
9833
|
return pointer.value;
|
|
9838
|
-
}
|
|
9834
|
+
};
|
|
9835
|
+
|
|
9836
|
+
const createHistoryProperties = (operations, include, exclude) => [ {
|
|
9837
|
+
id: v4(),
|
|
9838
|
+
created_at: (new Date).toISOString(),
|
|
9839
|
+
type: "systemMessage",
|
|
9840
|
+
text: 'You are the AutoAPI Test Scenario Generator.\n\nYour job is to analyze an array of API operation objects and generate realistic, structured test scenario drafts for each operation.\n\n---\n\n## Input Format\n\nYou will receive an array of `Operation` objects structured like this:\n\n```ts\n{\n method: "post" | "get" | "put" | "patch" | "delete",\n path: "/path/to/resource",\n specification: string, // API specification with business logic and constraints\n description: string, // Multi-paragraph description\n summary: string, // One-line summary\n parameters: [...], // List of path/query/body parameters\n requestBody?: {\n typeName: string,\n description: string\n },\n responseBody: {\n typeName: string,\n description: string\n }\n}\n```\n\n---\n\n## Output Format\n\nYour output must be an array of grouped test plans, using the following structure:\n\n```ts\n[\n {\n method: "post",\n path: "/shopping/products",\n plans: [\n {\n draft: "Test product creation by submitting two requests with the same product.pid. Confirm that the second request returns a uniqueness constraint error.",\n dependsOn: [\n {\n method: "post",\n path: "/shopping/categories",\n purpose: "Create a category beforehand so the product can reference it."\n },\n {\n method: "get",\n path: "/users/me",\n purpose: "Verify a valid user session and obtain user context for the test."\n }\n ]\n },\n {\n draft: "Verify that missing required fields like \'name\' or \'price\' trigger appropriate validation errors.",\n dependsOn: []\n }\n ]\n },\n {\n method: "patch",\n path: "/shopping/products/{productId}",\n plans: [\n {\n draft: "Attempt to update a product with an invalid productId and expect a 404 error.",\n dependsOn: []\n }\n ]\n }\n]\n```\n\n- Each top-level object is a **plan group** for a single unique endpoint (`method + path`).\n- The `plans` array contains **one or more test drafts** for that endpoint.\n- Each `draft` may list its **prerequisite API calls** in the `dependsOn` array, which includes `method`, `path`, and a `purpose` for context.\n\n---\n\n### ✅ **Uniqueness Rule**\n\n> ⚠️ **Each `{method} + {path}` combination must appear only once** in the output array.\n> This means **you must not create multiple plan groups with the same HTTP method and path.**\n\n* Treat each `{method} + {path}` pair as a **unique test identifier**.\n* All test plans (`plans`) related to the same endpoint must be **grouped under a single PlanGroup object**.\n* Duplicating PlanGroups for the same endpoint will lead to invalid output.\n\n**✅ Good:**\n\n```ts\n[\n {\n method: "patch",\n path: "/blog/posts/{postId}",\n plans: [\n { draft: "...", dependsOn: [...] },\n { draft: "...", dependsOn: [...] }\n ]\n }\n]\n```\n\n**❌ Bad:**\n\n```ts\n[\n {\n method: "patch",\n path: "/blog/posts/{postId}",\n plans: [ ... ]\n },\n {\n method: "patch",\n path: "/blog/posts/{postId}", // Duplicate! Not allowed.\n plans: [ ... ]\n }\n]\n```\n\n---\n\n## Writing Guidelines\n\n1. **draft**:\n - Write a clear and realistic test plan for the operation.\n - Include both success and failure cases where applicable.\n - Incorporate constraints mentioned in the API description such as uniqueness, foreign key requirements, or authentication.\n - For complex operations, include multiple steps within the same `draft` string (e.g., create → verify → delete).\n\n2. **dependsOn**:\n - List other API operations that must be invoked before this test can be executed.\n - Each item must include `method`, `path`, and `purpose`.\n - The `purpose` field should explain *why* the dependency is needed in the test setup.\n\n3. Treat each `{method} + {path}` combination as a unique test identifier.\n\n---\n\n## Purpose\n\nThese test scenario objects are designed to support QA engineers and backend developers in planning automated or manual tests. Each test draft reflects the core functionality and business rules of the API to ensure robust system behavior.'
|
|
9841
|
+
}, {
|
|
9842
|
+
id: v4(),
|
|
9843
|
+
created_at: (new Date).toISOString(),
|
|
9844
|
+
type: "systemMessage",
|
|
9845
|
+
text: [ "Below are the full operations. Please refer to this.", "Your role is to draft all test cases for each given Operation.", "It is also permissible to write multiple test codes on a single endpoint.", "However, rather than meaningless tests, business logic tests should be written and an E2E test situation should be assumed.", "", "```json", JSON.stringify(operations.map((el => ({
|
|
9846
|
+
path: el.path,
|
|
9847
|
+
method: el.method,
|
|
9848
|
+
summary: el.summary
|
|
9849
|
+
})))), "```" ].join("\n")
|
|
9850
|
+
}, {
|
|
9851
|
+
id: v4(),
|
|
9852
|
+
created_at: (new Date).toISOString(),
|
|
9853
|
+
type: "systemMessage",
|
|
9854
|
+
text: [ "# Included in Test Plan", include.map((el => `- ${el.method.toUpperCase()}: ${el.path}`)).join("\n"), "", "# Excluded from Test Plan", "These are the endpoints that have already been used in test codes generated as part of a plan group.", "These endpoints do not need to be tested again.", "However, it is allowed to reference or depend on these endpoints when writing test codes for other purposes.", exclude.map((el => `- ${el.method.toUpperCase()}: ${el.path}`)).join("\n") ].join("\n")
|
|
9855
|
+
} ];
|
|
9839
9856
|
|
|
9840
9857
|
function createApplication(props) {
|
|
9841
9858
|
assertSchemaModel(props.model);
|
|
9842
9859
|
const application = collection$1[props.model];
|
|
9860
|
+
application.functions[0].validate = next => {
|
|
9861
|
+
const result = (() => {
|
|
9862
|
+
const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
|
|
9863
|
+
const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
|
|
9864
|
+
const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
|
|
9865
|
+
const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
|
|
9866
|
+
const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
|
|
9867
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
|
|
9868
|
+
path: _path + ".scenarioGroups",
|
|
9869
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
9870
|
+
value: input.scenarioGroups
|
|
9871
|
+
})) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
9872
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
9873
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
9874
|
+
value: elem
|
|
9875
|
+
})) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
|
|
9876
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
9877
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
9878
|
+
value: elem
|
|
9879
|
+
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
9880
|
+
path: _path + ".scenarioGroups",
|
|
9881
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
9882
|
+
value: input.scenarioGroups
|
|
9883
|
+
}) ].every((flag => flag));
|
|
9884
|
+
const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
9885
|
+
path: _path + ".endpoint",
|
|
9886
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
9887
|
+
value: input.endpoint
|
|
9888
|
+
})) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
|
|
9889
|
+
path: _path + ".endpoint",
|
|
9890
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
9891
|
+
value: input.endpoint
|
|
9892
|
+
}), (Array.isArray(input.scenarios) || _report(_exceptionable, {
|
|
9893
|
+
path: _path + ".scenarios",
|
|
9894
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
9895
|
+
value: input.scenarios
|
|
9896
|
+
})) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
9897
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
9898
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
9899
|
+
value: elem
|
|
9900
|
+
})) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
|
|
9901
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
9902
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
9903
|
+
value: elem
|
|
9904
|
+
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
9905
|
+
path: _path + ".scenarios",
|
|
9906
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
9907
|
+
value: input.scenarios
|
|
9908
|
+
}) ].every((flag => flag));
|
|
9909
|
+
const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
|
|
9910
|
+
path: _path + ".path",
|
|
9911
|
+
expected: "string",
|
|
9912
|
+
value: input.path
|
|
9913
|
+
}), "get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method || _report(_exceptionable, {
|
|
9914
|
+
path: _path + ".method",
|
|
9915
|
+
expected: '("delete" | "get" | "patch" | "post" | "put")',
|
|
9916
|
+
value: input.method
|
|
9917
|
+
}) ].every((flag => flag));
|
|
9918
|
+
const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
|
|
9919
|
+
path: _path + ".draft",
|
|
9920
|
+
expected: "string",
|
|
9921
|
+
value: input.draft
|
|
9922
|
+
}), "string" === typeof input.functionName || _report(_exceptionable, {
|
|
9923
|
+
path: _path + ".functionName",
|
|
9924
|
+
expected: "string",
|
|
9925
|
+
value: input.functionName
|
|
9926
|
+
}), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
|
|
9927
|
+
path: _path + ".dependsOn",
|
|
9928
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
9929
|
+
value: input.dependsOn
|
|
9930
|
+
})) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
9931
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
9932
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
9933
|
+
value: elem
|
|
9934
|
+
})) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
|
|
9935
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
9936
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
9937
|
+
value: elem
|
|
9938
|
+
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
9939
|
+
path: _path + ".dependsOn",
|
|
9940
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
9941
|
+
value: input.dependsOn
|
|
9942
|
+
}) ].every((flag => flag));
|
|
9943
|
+
const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
9944
|
+
path: _path + ".endpoint",
|
|
9945
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
9946
|
+
value: input.endpoint
|
|
9947
|
+
})) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
|
|
9948
|
+
path: _path + ".endpoint",
|
|
9949
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
9950
|
+
value: input.endpoint
|
|
9951
|
+
}), "string" === typeof input.purpose || _report(_exceptionable, {
|
|
9952
|
+
path: _path + ".purpose",
|
|
9953
|
+
expected: "string",
|
|
9954
|
+
value: input.purpose
|
|
9955
|
+
}) ].every((flag => flag));
|
|
9956
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
9957
|
+
let errors;
|
|
9958
|
+
let _report;
|
|
9959
|
+
return input => {
|
|
9960
|
+
if (false === __is(input)) {
|
|
9961
|
+
errors = [];
|
|
9962
|
+
_report = __typia_transform__validateReport._validateReport(errors);
|
|
9963
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
9964
|
+
path: _path + "",
|
|
9965
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
9966
|
+
value: input
|
|
9967
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
9968
|
+
path: _path + "",
|
|
9969
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
9970
|
+
value: input
|
|
9971
|
+
}))(input, "$input", true);
|
|
9972
|
+
const success = 0 === errors.length;
|
|
9973
|
+
return success ? {
|
|
9974
|
+
success,
|
|
9975
|
+
data: input
|
|
9976
|
+
} : {
|
|
9977
|
+
success,
|
|
9978
|
+
errors,
|
|
9979
|
+
data: input
|
|
9980
|
+
};
|
|
9981
|
+
}
|
|
9982
|
+
return {
|
|
9983
|
+
success: true,
|
|
9984
|
+
data: input
|
|
9985
|
+
};
|
|
9986
|
+
};
|
|
9987
|
+
})()(next);
|
|
9988
|
+
if (result.success === false) return result;
|
|
9989
|
+
const errors = [];
|
|
9990
|
+
result.data.scenarioGroups.forEach(((pg, i, arr) => {
|
|
9991
|
+
arr.forEach(((target, j) => {
|
|
9992
|
+
if (i !== j && target.endpoint.method === pg.endpoint.method && target.endpoint.path === pg.endpoint.path) {
|
|
9993
|
+
if (!errors.some((el => el.path !== `planGroups[${j}].path` && el.value !== target.endpoint.path))) {
|
|
9994
|
+
errors.push({
|
|
9995
|
+
path: `planGroups[${j}].path`,
|
|
9996
|
+
expected: `planGroup's {method + path} cannot duplicated.`,
|
|
9997
|
+
value: target.endpoint.path
|
|
9998
|
+
});
|
|
9999
|
+
}
|
|
10000
|
+
if (!errors.some((el => el.path !== `planGroups[${j}].method` && el.value !== target.endpoint.method))) {
|
|
10001
|
+
errors.push({
|
|
10002
|
+
path: `planGroups[${j}].method`,
|
|
10003
|
+
expected: `planGroup's {method + path} cannot duplicated.`,
|
|
10004
|
+
value: target.endpoint.method
|
|
10005
|
+
});
|
|
10006
|
+
}
|
|
10007
|
+
}
|
|
10008
|
+
}));
|
|
10009
|
+
}));
|
|
10010
|
+
if (errors.length !== 0) {
|
|
10011
|
+
console.log(JSON.stringify(errors, null, 2), "errors");
|
|
10012
|
+
return {
|
|
10013
|
+
success: false,
|
|
10014
|
+
errors,
|
|
10015
|
+
data: next
|
|
10016
|
+
};
|
|
10017
|
+
}
|
|
10018
|
+
return result;
|
|
10019
|
+
};
|
|
9843
10020
|
return {
|
|
9844
10021
|
protocol: "class",
|
|
9845
|
-
name: "Make
|
|
10022
|
+
name: "Make test plans",
|
|
9846
10023
|
application,
|
|
9847
10024
|
execute: {
|
|
9848
10025
|
makeScenario: next => {
|
|
@@ -9861,19 +10038,19 @@ const claude$1 = {
|
|
|
9861
10038
|
functions: [ {
|
|
9862
10039
|
name: "makeScenario",
|
|
9863
10040
|
parameters: {
|
|
9864
|
-
description: " Properties containing the endpoints and
|
|
10041
|
+
description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
|
|
9865
10042
|
type: "object",
|
|
9866
10043
|
properties: {
|
|
9867
|
-
|
|
9868
|
-
title: "Array of
|
|
9869
|
-
description: "Array of
|
|
10044
|
+
scenarioGroups: {
|
|
10045
|
+
title: "Array of test scenario groups",
|
|
10046
|
+
description: "Array of test scenario groups.",
|
|
9870
10047
|
type: "array",
|
|
9871
10048
|
items: {
|
|
9872
|
-
description: "Current Type: {@link
|
|
10049
|
+
description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
|
|
9873
10050
|
type: "object",
|
|
9874
10051
|
properties: {
|
|
9875
10052
|
endpoint: {
|
|
9876
|
-
description: "Target API endpoint
|
|
10053
|
+
description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
|
|
9877
10054
|
type: "object",
|
|
9878
10055
|
properties: {
|
|
9879
10056
|
path: {
|
|
@@ -9900,24 +10077,66 @@ const claude$1 = {
|
|
|
9900
10077
|
required: [ "path", "method" ]
|
|
9901
10078
|
},
|
|
9902
10079
|
scenarios: {
|
|
9903
|
-
title: "
|
|
9904
|
-
description: "
|
|
10080
|
+
title: "Array of test scenarios",
|
|
10081
|
+
description: "Array of test scenarios.",
|
|
9905
10082
|
type: "array",
|
|
9906
10083
|
items: {
|
|
9907
|
-
description: "
|
|
10084
|
+
description: "Description of the current {@link IAutoBeTestScenarioApplication.IScenario} type:\n\n> Represents a test scenario for a single API operation.\n> \n> This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP\n> method and path information, and adds two key properties:\n> \n> - `draft`: A free-form, human-readable test scenario description for the API\n> endpoint.\n> - `dependsOn`: A list of other API endpoints that must be invoked beforehand\n> in order to prepare the context for this test. Each dependency includes\n> the purpose of the dependency.\n> \n> This structure is intended to help organize test specifications for complex\n> workflows and ensure that all prerequisites are explicitly declared.",
|
|
9908
10085
|
type: "object",
|
|
9909
10086
|
properties: {
|
|
10087
|
+
draft: {
|
|
10088
|
+
description: "A detailed natural language description of how this API endpoint should\nbe tested. This should include both successful and failure scenarios,\nbusiness rule validations, edge cases, and any sequence of steps\nnecessary to perform the test. A subsequent agent will use this draft to\ngenerate multiple test scenarios.",
|
|
10089
|
+
type: "string"
|
|
10090
|
+
},
|
|
9910
10091
|
functionName: {
|
|
9911
10092
|
title: "Descriptive function name derived from the user scenario",
|
|
9912
10093
|
description: "Descriptive function name derived from the user scenario.\n\nThe function name serves as a concise, technical identifier that clearly\nrepresents the specific user scenario being described. It should be\nimmediately understandable and directly correspond to the user situation\nwithout requiring additional context.\n\n## Naming Convention\n\n- Must start with `test_` prefix (mandatory requirement)\n- Use snake_case formatting throughout\n- Include the primary user action (create, get, update, delete, list, etc.)\n- Specify the target resource (user, product, order, profile, etc.)\n- Add scenario-specific context (valid_data, invalid_email, not_found,\n etc.)\n\n## Content Structure\n\nFunction names should follow this pattern:\n`test_[user_action]_[resource]_[scenario_context]`\n\nWhere:\n\n- `user_action`: What the user is trying to do\n- `resource`: What the user is interacting with\n- `scenario_context`: The specific situation or condition\n\n## User-Focused Examples\n\n- `test_create_user_profile_with_complete_information` - User providing all\n available profile data\n- `test_retrieve_user_profile_when_profile_exists` - User accessing their\n existing profile\n- `test_update_user_email_with_valid_new_address` - User changing their\n email to a valid new one\n- `test_delete_user_account_when_user_lacks_permission` - User attempting\n account deletion without authorization\n- `test_search_user_profiles_with_pagination_preferences` - User browsing\n profiles with specific pagination\n\n## Clarity Guidelines\n\n- Prioritize clarity over brevity\n- Avoid technical jargon or implementation terms\n- Use terminology that reflects user perspective\n- Ensure the name alone conveys the user's intent\n- Make it understandable to non-technical stakeholders\n- Keep consistent with user scenario description\n\n## Single Endpoint Alignment\n\nFunction names must reflect scenarios that:\n\n- Accomplish user goals through this single endpoint only\n- Don't imply dependency on other API operations\n- Represent complete user interactions",
|
|
9913
10094
|
type: "string"
|
|
9914
10095
|
},
|
|
9915
|
-
|
|
9916
|
-
description: "
|
|
9917
|
-
type: "
|
|
10096
|
+
dependsOn: {
|
|
10097
|
+
description: "A list of other API endpoints that must be executed before this test\nscenario. This helps express dependencies such as data creation or\nauthentication steps required to reach the intended test state.",
|
|
10098
|
+
type: "array",
|
|
10099
|
+
items: {
|
|
10100
|
+
description: "Current Type: {@link IAutoBeTestScenarioApplication.IDependsOn}",
|
|
10101
|
+
type: "object",
|
|
10102
|
+
properties: {
|
|
10103
|
+
endpoint: {
|
|
10104
|
+
description: "Target API endpoint that must be executed before the main operation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
|
|
10105
|
+
type: "object",
|
|
10106
|
+
properties: {
|
|
10107
|
+
path: {
|
|
10108
|
+
title: "HTTP path of the API operation",
|
|
10109
|
+
description: "HTTP path of the API operation.\n\nThe URL path for accessing this API operation, using path parameters\nenclosed in curly braces (e.g., `/shoppings/customers/sales/{saleId}`).\n\nIt must be corresponded to the {@link parameters path parameters}.\n\nThe path structure should clearly indicate which database entity this\noperation is manipulating, helping to ensure all entities have\nappropriate API coverage.",
|
|
10110
|
+
type: "string"
|
|
10111
|
+
},
|
|
10112
|
+
method: {
|
|
10113
|
+
title: "HTTP method of the API operation",
|
|
10114
|
+
description: "HTTP method of the API operation.\n\nNote that, if the API operation has {@link requestBody}, method must not\nbe `get`.\n\nAlso, even though the API operation has been designed to only get\ninformation, but it needs complicated request information, it must be\ndefined as `patch` method with {@link requestBody} data specification.\n\n- `get`: get information\n- `patch`: get information with complicated request data\n ({@link requestBody})\n- `post`: create new record\n- `put`: update existing record\n- `delete`: remove record",
|
|
10115
|
+
oneOf: [ {
|
|
10116
|
+
const: "get"
|
|
10117
|
+
}, {
|
|
10118
|
+
const: "post"
|
|
10119
|
+
}, {
|
|
10120
|
+
const: "put"
|
|
10121
|
+
}, {
|
|
10122
|
+
const: "delete"
|
|
10123
|
+
}, {
|
|
10124
|
+
const: "patch"
|
|
10125
|
+
} ]
|
|
10126
|
+
}
|
|
10127
|
+
},
|
|
10128
|
+
required: [ "path", "method" ]
|
|
10129
|
+
},
|
|
10130
|
+
purpose: {
|
|
10131
|
+
description: 'A concise exscenarioation of why this API call is required before\nexecuting the test for the main operation.\n\nExample: "Creates a category so that a product can be linked to it during\ncreation."',
|
|
10132
|
+
type: "string"
|
|
10133
|
+
}
|
|
10134
|
+
},
|
|
10135
|
+
required: [ "endpoint", "purpose" ]
|
|
10136
|
+
}
|
|
9918
10137
|
}
|
|
9919
10138
|
},
|
|
9920
|
-
required: [ "functionName", "
|
|
10139
|
+
required: [ "draft", "functionName", "dependsOn" ]
|
|
9921
10140
|
}
|
|
9922
10141
|
}
|
|
9923
10142
|
},
|
|
@@ -9925,32 +10144,33 @@ const claude$1 = {
|
|
|
9925
10144
|
}
|
|
9926
10145
|
}
|
|
9927
10146
|
},
|
|
9928
|
-
required: [ "
|
|
10147
|
+
required: [ "scenarioGroups" ],
|
|
9929
10148
|
additionalProperties: false,
|
|
9930
10149
|
$defs: {}
|
|
9931
10150
|
},
|
|
9932
|
-
description: "Make
|
|
10151
|
+
description: "Make test scenarios for the given endpoints.",
|
|
9933
10152
|
validate: (() => {
|
|
9934
|
-
const _io0 = input => Array.isArray(input.
|
|
10153
|
+
const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
|
|
9935
10154
|
const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
|
|
9936
10155
|
const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
|
|
9937
|
-
const _io3 = input => "string" === typeof input.
|
|
9938
|
-
const
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
10156
|
+
const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
|
|
10157
|
+
const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
|
|
10158
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
|
|
10159
|
+
path: _path + ".scenarioGroups",
|
|
10160
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
10161
|
+
value: input.scenarioGroups
|
|
10162
|
+
})) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10163
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
10164
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
9945
10165
|
value: elem
|
|
9946
|
-
})) && _vo1(elem, _path + ".
|
|
9947
|
-
path: _path + ".
|
|
9948
|
-
expected: "
|
|
10166
|
+
})) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10167
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
10168
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
9949
10169
|
value: elem
|
|
9950
10170
|
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
9951
|
-
path: _path + ".
|
|
9952
|
-
expected: "Array<
|
|
9953
|
-
value: input.
|
|
10171
|
+
path: _path + ".scenarioGroups",
|
|
10172
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
10173
|
+
value: input.scenarioGroups
|
|
9954
10174
|
}) ].every((flag => flag));
|
|
9955
10175
|
const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
9956
10176
|
path: _path + ".endpoint",
|
|
@@ -9962,19 +10182,19 @@ const claude$1 = {
|
|
|
9962
10182
|
value: input.endpoint
|
|
9963
10183
|
}), (Array.isArray(input.scenarios) || _report(_exceptionable, {
|
|
9964
10184
|
path: _path + ".scenarios",
|
|
9965
|
-
expected: "Array<
|
|
10185
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
9966
10186
|
value: input.scenarios
|
|
9967
|
-
})) && input.scenarios.map(((elem,
|
|
9968
|
-
path: _path + ".scenarios[" +
|
|
9969
|
-
expected: "
|
|
10187
|
+
})) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10188
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
10189
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
9970
10190
|
value: elem
|
|
9971
|
-
})) && _vo3(elem, _path + ".scenarios[" +
|
|
9972
|
-
path: _path + ".scenarios[" +
|
|
9973
|
-
expected: "
|
|
10191
|
+
})) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10192
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
10193
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
9974
10194
|
value: elem
|
|
9975
10195
|
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
9976
10196
|
path: _path + ".scenarios",
|
|
9977
|
-
expected: "Array<
|
|
10197
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
9978
10198
|
value: input.scenarios
|
|
9979
10199
|
}) ].every((flag => flag));
|
|
9980
10200
|
const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
|
|
@@ -9986,14 +10206,43 @@ const claude$1 = {
|
|
|
9986
10206
|
expected: '("delete" | "get" | "patch" | "post" | "put")',
|
|
9987
10207
|
value: input.method
|
|
9988
10208
|
}) ].every((flag => flag));
|
|
9989
|
-
const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
10209
|
+
const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
|
|
10210
|
+
path: _path + ".draft",
|
|
10211
|
+
expected: "string",
|
|
10212
|
+
value: input.draft
|
|
10213
|
+
}), "string" === typeof input.functionName || _report(_exceptionable, {
|
|
9990
10214
|
path: _path + ".functionName",
|
|
9991
10215
|
expected: "string",
|
|
9992
10216
|
value: input.functionName
|
|
9993
|
-
}),
|
|
9994
|
-
path: _path + ".
|
|
10217
|
+
}), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
|
|
10218
|
+
path: _path + ".dependsOn",
|
|
10219
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
10220
|
+
value: input.dependsOn
|
|
10221
|
+
})) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10222
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
10223
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
10224
|
+
value: elem
|
|
10225
|
+
})) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10226
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
10227
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
10228
|
+
value: elem
|
|
10229
|
+
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
10230
|
+
path: _path + ".dependsOn",
|
|
10231
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
10232
|
+
value: input.dependsOn
|
|
10233
|
+
}) ].every((flag => flag));
|
|
10234
|
+
const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
10235
|
+
path: _path + ".endpoint",
|
|
10236
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
10237
|
+
value: input.endpoint
|
|
10238
|
+
})) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
|
|
10239
|
+
path: _path + ".endpoint",
|
|
10240
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
10241
|
+
value: input.endpoint
|
|
10242
|
+
}), "string" === typeof input.purpose || _report(_exceptionable, {
|
|
10243
|
+
path: _path + ".purpose",
|
|
9995
10244
|
expected: "string",
|
|
9996
|
-
value: input.
|
|
10245
|
+
value: input.purpose
|
|
9997
10246
|
}) ].every((flag => flag));
|
|
9998
10247
|
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
9999
10248
|
let errors;
|
|
@@ -10004,11 +10253,11 @@ const claude$1 = {
|
|
|
10004
10253
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
10005
10254
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
10006
10255
|
path: _path + "",
|
|
10007
|
-
expected: "
|
|
10256
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
10008
10257
|
value: input
|
|
10009
10258
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
10010
10259
|
path: _path + "",
|
|
10011
|
-
expected: "
|
|
10260
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
10012
10261
|
value: input
|
|
10013
10262
|
}))(input, "$input", true);
|
|
10014
10263
|
const success = 0 === errors.length;
|
|
@@ -10041,19 +10290,19 @@ const collection$1 = {
|
|
|
10041
10290
|
functions: [ {
|
|
10042
10291
|
name: "makeScenario",
|
|
10043
10292
|
parameters: {
|
|
10044
|
-
description: " Properties containing the endpoints and
|
|
10293
|
+
description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
|
|
10045
10294
|
type: "object",
|
|
10046
10295
|
properties: {
|
|
10047
|
-
|
|
10048
|
-
title: "Array of
|
|
10049
|
-
description: "Array of
|
|
10296
|
+
scenarioGroups: {
|
|
10297
|
+
title: "Array of test scenario groups",
|
|
10298
|
+
description: "Array of test scenario groups.",
|
|
10050
10299
|
type: "array",
|
|
10051
10300
|
items: {
|
|
10052
|
-
description: "Current Type: {@link
|
|
10301
|
+
description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
|
|
10053
10302
|
type: "object",
|
|
10054
10303
|
properties: {
|
|
10055
10304
|
endpoint: {
|
|
10056
|
-
description: "Target API endpoint
|
|
10305
|
+
description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
|
|
10057
10306
|
type: "object",
|
|
10058
10307
|
properties: {
|
|
10059
10308
|
path: {
|
|
@@ -10071,24 +10320,57 @@ const collection$1 = {
|
|
|
10071
10320
|
required: [ "path", "method" ]
|
|
10072
10321
|
},
|
|
10073
10322
|
scenarios: {
|
|
10074
|
-
title: "
|
|
10075
|
-
description: "
|
|
10323
|
+
title: "Array of test scenarios",
|
|
10324
|
+
description: "Array of test scenarios.",
|
|
10076
10325
|
type: "array",
|
|
10077
10326
|
items: {
|
|
10078
|
-
description: "
|
|
10327
|
+
description: "Description of the current {@link IAutoBeTestScenarioApplication.IScenario} type:\n\n> Represents a test scenario for a single API operation.\n> \n> This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP\n> method and path information, and adds two key properties:\n> \n> - `draft`: A free-form, human-readable test scenario description for the API\n> endpoint.\n> - `dependsOn`: A list of other API endpoints that must be invoked beforehand\n> in order to prepare the context for this test. Each dependency includes\n> the purpose of the dependency.\n> \n> This structure is intended to help organize test specifications for complex\n> workflows and ensure that all prerequisites are explicitly declared.",
|
|
10079
10328
|
type: "object",
|
|
10080
10329
|
properties: {
|
|
10330
|
+
draft: {
|
|
10331
|
+
description: "A detailed natural language description of how this API endpoint should\nbe tested. This should include both successful and failure scenarios,\nbusiness rule validations, edge cases, and any sequence of steps\nnecessary to perform the test. A subsequent agent will use this draft to\ngenerate multiple test scenarios.",
|
|
10332
|
+
type: "string"
|
|
10333
|
+
},
|
|
10081
10334
|
functionName: {
|
|
10082
10335
|
title: "Descriptive function name derived from the user scenario",
|
|
10083
10336
|
description: "Descriptive function name derived from the user scenario.\n\nThe function name serves as a concise, technical identifier that clearly\nrepresents the specific user scenario being described. It should be\nimmediately understandable and directly correspond to the user situation\nwithout requiring additional context.\n\n## Naming Convention\n\n- Must start with `test_` prefix (mandatory requirement)\n- Use snake_case formatting throughout\n- Include the primary user action (create, get, update, delete, list, etc.)\n- Specify the target resource (user, product, order, profile, etc.)\n- Add scenario-specific context (valid_data, invalid_email, not_found,\n etc.)\n\n## Content Structure\n\nFunction names should follow this pattern:\n`test_[user_action]_[resource]_[scenario_context]`\n\nWhere:\n\n- `user_action`: What the user is trying to do\n- `resource`: What the user is interacting with\n- `scenario_context`: The specific situation or condition\n\n## User-Focused Examples\n\n- `test_create_user_profile_with_complete_information` - User providing all\n available profile data\n- `test_retrieve_user_profile_when_profile_exists` - User accessing their\n existing profile\n- `test_update_user_email_with_valid_new_address` - User changing their\n email to a valid new one\n- `test_delete_user_account_when_user_lacks_permission` - User attempting\n account deletion without authorization\n- `test_search_user_profiles_with_pagination_preferences` - User browsing\n profiles with specific pagination\n\n## Clarity Guidelines\n\n- Prioritize clarity over brevity\n- Avoid technical jargon or implementation terms\n- Use terminology that reflects user perspective\n- Ensure the name alone conveys the user's intent\n- Make it understandable to non-technical stakeholders\n- Keep consistent with user scenario description\n\n## Single Endpoint Alignment\n\nFunction names must reflect scenarios that:\n\n- Accomplish user goals through this single endpoint only\n- Don't imply dependency on other API operations\n- Represent complete user interactions",
|
|
10084
10337
|
type: "string"
|
|
10085
10338
|
},
|
|
10086
|
-
|
|
10087
|
-
description: "
|
|
10088
|
-
type: "
|
|
10339
|
+
dependsOn: {
|
|
10340
|
+
description: "A list of other API endpoints that must be executed before this test\nscenario. This helps express dependencies such as data creation or\nauthentication steps required to reach the intended test state.",
|
|
10341
|
+
type: "array",
|
|
10342
|
+
items: {
|
|
10343
|
+
description: "Current Type: {@link IAutoBeTestScenarioApplication.IDependsOn}",
|
|
10344
|
+
type: "object",
|
|
10345
|
+
properties: {
|
|
10346
|
+
endpoint: {
|
|
10347
|
+
description: "Target API endpoint that must be executed before the main operation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
|
|
10348
|
+
type: "object",
|
|
10349
|
+
properties: {
|
|
10350
|
+
path: {
|
|
10351
|
+
title: "HTTP path of the API operation",
|
|
10352
|
+
description: "HTTP path of the API operation.\n\nThe URL path for accessing this API operation, using path parameters\nenclosed in curly braces (e.g., `/shoppings/customers/sales/{saleId}`).\n\nIt must be corresponded to the {@link parameters path parameters}.\n\nThe path structure should clearly indicate which database entity this\noperation is manipulating, helping to ensure all entities have\nappropriate API coverage.",
|
|
10353
|
+
type: "string"
|
|
10354
|
+
},
|
|
10355
|
+
method: {
|
|
10356
|
+
title: "HTTP method of the API operation",
|
|
10357
|
+
description: "HTTP method of the API operation.\n\nNote that, if the API operation has {@link requestBody}, method must not\nbe `get`.\n\nAlso, even though the API operation has been designed to only get\ninformation, but it needs complicated request information, it must be\ndefined as `patch` method with {@link requestBody} data specification.\n\n- `get`: get information\n- `patch`: get information with complicated request data\n ({@link requestBody})\n- `post`: create new record\n- `put`: update existing record\n- `delete`: remove record",
|
|
10358
|
+
type: "string",
|
|
10359
|
+
enum: [ "get", "post", "put", "delete", "patch" ]
|
|
10360
|
+
}
|
|
10361
|
+
},
|
|
10362
|
+
required: [ "path", "method" ]
|
|
10363
|
+
},
|
|
10364
|
+
purpose: {
|
|
10365
|
+
description: 'A concise exscenarioation of why this API call is required before\nexecuting the test for the main operation.\n\nExample: "Creates a category so that a product can be linked to it during\ncreation."',
|
|
10366
|
+
type: "string"
|
|
10367
|
+
}
|
|
10368
|
+
},
|
|
10369
|
+
required: [ "endpoint", "purpose" ]
|
|
10370
|
+
}
|
|
10089
10371
|
}
|
|
10090
10372
|
},
|
|
10091
|
-
required: [ "functionName", "
|
|
10373
|
+
required: [ "draft", "functionName", "dependsOn" ]
|
|
10092
10374
|
}
|
|
10093
10375
|
}
|
|
10094
10376
|
},
|
|
@@ -10096,32 +10378,33 @@ const collection$1 = {
|
|
|
10096
10378
|
}
|
|
10097
10379
|
}
|
|
10098
10380
|
},
|
|
10099
|
-
required: [ "
|
|
10381
|
+
required: [ "scenarioGroups" ],
|
|
10100
10382
|
additionalProperties: false,
|
|
10101
10383
|
$defs: {}
|
|
10102
10384
|
},
|
|
10103
|
-
description: "Make
|
|
10385
|
+
description: "Make test scenarios for the given endpoints.",
|
|
10104
10386
|
validate: (() => {
|
|
10105
|
-
const _io0 = input => Array.isArray(input.
|
|
10387
|
+
const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
|
|
10106
10388
|
const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
|
|
10107
10389
|
const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
|
|
10108
|
-
const _io3 = input => "string" === typeof input.
|
|
10109
|
-
const
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10390
|
+
const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
|
|
10391
|
+
const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
|
|
10392
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
|
|
10393
|
+
path: _path + ".scenarioGroups",
|
|
10394
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
10395
|
+
value: input.scenarioGroups
|
|
10396
|
+
})) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10397
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
10398
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
10116
10399
|
value: elem
|
|
10117
|
-
})) && _vo1(elem, _path + ".
|
|
10118
|
-
path: _path + ".
|
|
10119
|
-
expected: "
|
|
10400
|
+
})) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10401
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
10402
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
10120
10403
|
value: elem
|
|
10121
10404
|
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
10122
|
-
path: _path + ".
|
|
10123
|
-
expected: "Array<
|
|
10124
|
-
value: input.
|
|
10405
|
+
path: _path + ".scenarioGroups",
|
|
10406
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
10407
|
+
value: input.scenarioGroups
|
|
10125
10408
|
}) ].every((flag => flag));
|
|
10126
10409
|
const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
10127
10410
|
path: _path + ".endpoint",
|
|
@@ -10133,19 +10416,19 @@ const collection$1 = {
|
|
|
10133
10416
|
value: input.endpoint
|
|
10134
10417
|
}), (Array.isArray(input.scenarios) || _report(_exceptionable, {
|
|
10135
10418
|
path: _path + ".scenarios",
|
|
10136
|
-
expected: "Array<
|
|
10419
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
10137
10420
|
value: input.scenarios
|
|
10138
|
-
})) && input.scenarios.map(((elem,
|
|
10139
|
-
path: _path + ".scenarios[" +
|
|
10140
|
-
expected: "
|
|
10421
|
+
})) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10422
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
10423
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
10141
10424
|
value: elem
|
|
10142
|
-
})) && _vo3(elem, _path + ".scenarios[" +
|
|
10143
|
-
path: _path + ".scenarios[" +
|
|
10144
|
-
expected: "
|
|
10425
|
+
})) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10426
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
10427
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
10145
10428
|
value: elem
|
|
10146
10429
|
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
10147
10430
|
path: _path + ".scenarios",
|
|
10148
|
-
expected: "Array<
|
|
10431
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
10149
10432
|
value: input.scenarios
|
|
10150
10433
|
}) ].every((flag => flag));
|
|
10151
10434
|
const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
|
|
@@ -10157,14 +10440,43 @@ const collection$1 = {
|
|
|
10157
10440
|
expected: '("delete" | "get" | "patch" | "post" | "put")',
|
|
10158
10441
|
value: input.method
|
|
10159
10442
|
}) ].every((flag => flag));
|
|
10160
|
-
const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
10443
|
+
const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
|
|
10444
|
+
path: _path + ".draft",
|
|
10445
|
+
expected: "string",
|
|
10446
|
+
value: input.draft
|
|
10447
|
+
}), "string" === typeof input.functionName || _report(_exceptionable, {
|
|
10161
10448
|
path: _path + ".functionName",
|
|
10162
10449
|
expected: "string",
|
|
10163
10450
|
value: input.functionName
|
|
10164
|
-
}),
|
|
10165
|
-
path: _path + ".
|
|
10451
|
+
}), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
|
|
10452
|
+
path: _path + ".dependsOn",
|
|
10453
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
10454
|
+
value: input.dependsOn
|
|
10455
|
+
})) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10456
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
10457
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
10458
|
+
value: elem
|
|
10459
|
+
})) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10460
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
10461
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
10462
|
+
value: elem
|
|
10463
|
+
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
10464
|
+
path: _path + ".dependsOn",
|
|
10465
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
10466
|
+
value: input.dependsOn
|
|
10467
|
+
}) ].every((flag => flag));
|
|
10468
|
+
const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
10469
|
+
path: _path + ".endpoint",
|
|
10470
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
10471
|
+
value: input.endpoint
|
|
10472
|
+
})) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
|
|
10473
|
+
path: _path + ".endpoint",
|
|
10474
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
10475
|
+
value: input.endpoint
|
|
10476
|
+
}), "string" === typeof input.purpose || _report(_exceptionable, {
|
|
10477
|
+
path: _path + ".purpose",
|
|
10166
10478
|
expected: "string",
|
|
10167
|
-
value: input.
|
|
10479
|
+
value: input.purpose
|
|
10168
10480
|
}) ].every((flag => flag));
|
|
10169
10481
|
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
10170
10482
|
let errors;
|
|
@@ -10175,11 +10487,11 @@ const collection$1 = {
|
|
|
10175
10487
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
10176
10488
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
10177
10489
|
path: _path + "",
|
|
10178
|
-
expected: "
|
|
10490
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
10179
10491
|
value: input
|
|
10180
10492
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
10181
10493
|
path: _path + "",
|
|
10182
|
-
expected: "
|
|
10494
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
10183
10495
|
value: input
|
|
10184
10496
|
}))(input, "$input", true);
|
|
10185
10497
|
const success = 0 === errors.length;
|
|
@@ -10216,7 +10528,7 @@ const collection$1 = {
|
|
|
10216
10528
|
parameters: {
|
|
10217
10529
|
type: "object",
|
|
10218
10530
|
properties: {
|
|
10219
|
-
|
|
10531
|
+
scenarioGroups: {
|
|
10220
10532
|
type: "array",
|
|
10221
10533
|
items: {
|
|
10222
10534
|
type: "object",
|
|
@@ -10237,7 +10549,7 @@ const collection$1 = {
|
|
|
10237
10549
|
}
|
|
10238
10550
|
},
|
|
10239
10551
|
required: [ "path", "method" ],
|
|
10240
|
-
description: "Target API endpoint
|
|
10552
|
+
description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
|
|
10241
10553
|
additionalProperties: false
|
|
10242
10554
|
},
|
|
10243
10555
|
scenarios: {
|
|
@@ -10245,58 +10557,94 @@ const collection$1 = {
|
|
|
10245
10557
|
items: {
|
|
10246
10558
|
type: "object",
|
|
10247
10559
|
properties: {
|
|
10560
|
+
draft: {
|
|
10561
|
+
type: "string",
|
|
10562
|
+
description: "A detailed natural language description of how this API endpoint should\nbe tested. This should include both successful and failure scenarios,\nbusiness rule validations, edge cases, and any sequence of steps\nnecessary to perform the test. A subsequent agent will use this draft to\ngenerate multiple test scenarios."
|
|
10563
|
+
},
|
|
10248
10564
|
functionName: {
|
|
10249
10565
|
type: "string",
|
|
10250
10566
|
title: "Descriptive function name derived from the user scenario",
|
|
10251
10567
|
description: "Descriptive function name derived from the user scenario.\n\nThe function name serves as a concise, technical identifier that clearly\nrepresents the specific user scenario being described. It should be\nimmediately understandable and directly correspond to the user situation\nwithout requiring additional context.\n\n## Naming Convention\n\n- Must start with `test_` prefix (mandatory requirement)\n- Use snake_case formatting throughout\n- Include the primary user action (create, get, update, delete, list, etc.)\n- Specify the target resource (user, product, order, profile, etc.)\n- Add scenario-specific context (valid_data, invalid_email, not_found,\n etc.)\n\n## Content Structure\n\nFunction names should follow this pattern:\n`test_[user_action]_[resource]_[scenario_context]`\n\nWhere:\n\n- `user_action`: What the user is trying to do\n- `resource`: What the user is interacting with\n- `scenario_context`: The specific situation or condition\n\n## User-Focused Examples\n\n- `test_create_user_profile_with_complete_information` - User providing all\n available profile data\n- `test_retrieve_user_profile_when_profile_exists` - User accessing their\n existing profile\n- `test_update_user_email_with_valid_new_address` - User changing their\n email to a valid new one\n- `test_delete_user_account_when_user_lacks_permission` - User attempting\n account deletion without authorization\n- `test_search_user_profiles_with_pagination_preferences` - User browsing\n profiles with specific pagination\n\n## Clarity Guidelines\n\n- Prioritize clarity over brevity\n- Avoid technical jargon or implementation terms\n- Use terminology that reflects user perspective\n- Ensure the name alone conveys the user's intent\n- Make it understandable to non-technical stakeholders\n- Keep consistent with user scenario description\n\n## Single Endpoint Alignment\n\nFunction names must reflect scenarios that:\n\n- Accomplish user goals through this single endpoint only\n- Don't imply dependency on other API operations\n- Represent complete user interactions"
|
|
10252
10568
|
},
|
|
10253
|
-
|
|
10254
|
-
type: "
|
|
10255
|
-
|
|
10569
|
+
dependsOn: {
|
|
10570
|
+
type: "array",
|
|
10571
|
+
items: {
|
|
10572
|
+
type: "object",
|
|
10573
|
+
properties: {
|
|
10574
|
+
endpoint: {
|
|
10575
|
+
type: "object",
|
|
10576
|
+
properties: {
|
|
10577
|
+
path: {
|
|
10578
|
+
type: "string",
|
|
10579
|
+
title: "HTTP path of the API operation",
|
|
10580
|
+
description: "HTTP path of the API operation.\n\nThe URL path for accessing this API operation, using path parameters\nenclosed in curly braces (e.g., `/shoppings/customers/sales/{saleId}`).\n\nIt must be corresponded to the {@link parameters path parameters}.\n\nThe path structure should clearly indicate which database entity this\noperation is manipulating, helping to ensure all entities have\nappropriate API coverage."
|
|
10581
|
+
},
|
|
10582
|
+
method: {
|
|
10583
|
+
type: "string",
|
|
10584
|
+
enum: [ "get", "post", "put", "delete", "patch" ],
|
|
10585
|
+
title: "HTTP method of the API operation",
|
|
10586
|
+
description: "HTTP method of the API operation.\n\nNote that, if the API operation has {@link requestBody}, method must not\nbe `get`.\n\nAlso, even though the API operation has been designed to only get\ninformation, but it needs complicated request information, it must be\ndefined as `patch` method with {@link requestBody} data specification.\n\n- `get`: get information\n- `patch`: get information with complicated request data\n ({@link requestBody})\n- `post`: create new record\n- `put`: update existing record\n- `delete`: remove record"
|
|
10587
|
+
}
|
|
10588
|
+
},
|
|
10589
|
+
required: [ "path", "method" ],
|
|
10590
|
+
description: "Target API endpoint that must be executed before the main operation.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
|
|
10591
|
+
additionalProperties: false
|
|
10592
|
+
},
|
|
10593
|
+
purpose: {
|
|
10594
|
+
type: "string",
|
|
10595
|
+
description: 'A concise exscenarioation of why this API call is required before\nexecuting the test for the main operation.\n\nExample: "Creates a category so that a product can be linked to it during\ncreation."'
|
|
10596
|
+
}
|
|
10597
|
+
},
|
|
10598
|
+
required: [ "endpoint", "purpose" ],
|
|
10599
|
+
description: "Current Type: {@link IAutoBeTestScenarioApplication.IDependsOn}",
|
|
10600
|
+
additionalProperties: false
|
|
10601
|
+
},
|
|
10602
|
+
description: "A list of other API endpoints that must be executed before this test\nscenario. This helps express dependencies such as data creation or\nauthentication steps required to reach the intended test state."
|
|
10256
10603
|
}
|
|
10257
10604
|
},
|
|
10258
|
-
required: [ "functionName", "
|
|
10259
|
-
description: "
|
|
10605
|
+
required: [ "draft", "functionName", "dependsOn" ],
|
|
10606
|
+
description: "Description of the current {@link IAutoBeTestScenarioApplication.IScenario} type:\n\n> Represents a test scenario for a single API operation.\n> \n> This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP\n> method and path information, and adds two key properties:\n> \n> - `draft`: A free-form, human-readable test scenario description for the API\n> endpoint.\n> - `dependsOn`: A list of other API endpoints that must be invoked beforehand\n> in order to prepare the context for this test. Each dependency includes\n> the purpose of the dependency.\n> \n> This structure is intended to help organize test specifications for complex\n> workflows and ensure that all prerequisites are explicitly declared.",
|
|
10260
10607
|
additionalProperties: false
|
|
10261
10608
|
},
|
|
10262
|
-
title: "
|
|
10263
|
-
description: "
|
|
10609
|
+
title: "Array of test scenarios",
|
|
10610
|
+
description: "Array of test scenarios."
|
|
10264
10611
|
}
|
|
10265
10612
|
},
|
|
10266
10613
|
required: [ "endpoint", "scenarios" ],
|
|
10267
|
-
description: "Current Type: {@link
|
|
10614
|
+
description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
|
|
10268
10615
|
additionalProperties: false
|
|
10269
10616
|
},
|
|
10270
|
-
title: "Array of
|
|
10271
|
-
description: "Array of
|
|
10617
|
+
title: "Array of test scenario groups",
|
|
10618
|
+
description: "Array of test scenario groups."
|
|
10272
10619
|
}
|
|
10273
10620
|
},
|
|
10274
|
-
required: [ "
|
|
10275
|
-
description: " Properties containing the endpoints and
|
|
10621
|
+
required: [ "scenarioGroups" ],
|
|
10622
|
+
description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
|
|
10276
10623
|
additionalProperties: false
|
|
10277
10624
|
},
|
|
10278
|
-
description: "Make
|
|
10625
|
+
description: "Make test scenarios for the given endpoints.",
|
|
10279
10626
|
validate: (() => {
|
|
10280
|
-
const _io0 = input => Array.isArray(input.
|
|
10627
|
+
const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
|
|
10281
10628
|
const _io1 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && (Array.isArray(input.scenarios) && input.scenarios.every((elem => "object" === typeof elem && null !== elem && _io3(elem))));
|
|
10282
10629
|
const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
|
|
10283
|
-
const _io3 = input => "string" === typeof input.
|
|
10284
|
-
const
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10630
|
+
const _io3 = input => "string" === typeof input.draft && "string" === typeof input.functionName && (Array.isArray(input.dependsOn) && input.dependsOn.every((elem => "object" === typeof elem && null !== elem && _io4(elem))));
|
|
10631
|
+
const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
|
|
10632
|
+
const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
|
|
10633
|
+
path: _path + ".scenarioGroups",
|
|
10634
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
10635
|
+
value: input.scenarioGroups
|
|
10636
|
+
})) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10637
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
10638
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
10291
10639
|
value: elem
|
|
10292
|
-
})) && _vo1(elem, _path + ".
|
|
10293
|
-
path: _path + ".
|
|
10294
|
-
expected: "
|
|
10640
|
+
})) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10641
|
+
path: _path + ".scenarioGroups[" + _index4 + "]",
|
|
10642
|
+
expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
|
|
10295
10643
|
value: elem
|
|
10296
10644
|
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
10297
|
-
path: _path + ".
|
|
10298
|
-
expected: "Array<
|
|
10299
|
-
value: input.
|
|
10645
|
+
path: _path + ".scenarioGroups",
|
|
10646
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
|
|
10647
|
+
value: input.scenarioGroups
|
|
10300
10648
|
}) ].every((flag => flag));
|
|
10301
10649
|
const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
10302
10650
|
path: _path + ".endpoint",
|
|
@@ -10308,19 +10656,19 @@ const collection$1 = {
|
|
|
10308
10656
|
value: input.endpoint
|
|
10309
10657
|
}), (Array.isArray(input.scenarios) || _report(_exceptionable, {
|
|
10310
10658
|
path: _path + ".scenarios",
|
|
10311
|
-
expected: "Array<
|
|
10659
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
10312
10660
|
value: input.scenarios
|
|
10313
|
-
})) && input.scenarios.map(((elem,
|
|
10314
|
-
path: _path + ".scenarios[" +
|
|
10315
|
-
expected: "
|
|
10661
|
+
})) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10662
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
10663
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
10316
10664
|
value: elem
|
|
10317
|
-
})) && _vo3(elem, _path + ".scenarios[" +
|
|
10318
|
-
path: _path + ".scenarios[" +
|
|
10319
|
-
expected: "
|
|
10665
|
+
})) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10666
|
+
path: _path + ".scenarios[" + _index5 + "]",
|
|
10667
|
+
expected: "IAutoBeTestScenarioApplication.IScenario",
|
|
10320
10668
|
value: elem
|
|
10321
10669
|
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
10322
10670
|
path: _path + ".scenarios",
|
|
10323
|
-
expected: "Array<
|
|
10671
|
+
expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
|
|
10324
10672
|
value: input.scenarios
|
|
10325
10673
|
}) ].every((flag => flag));
|
|
10326
10674
|
const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
|
|
@@ -10332,14 +10680,43 @@ const collection$1 = {
|
|
|
10332
10680
|
expected: '("delete" | "get" | "patch" | "post" | "put")',
|
|
10333
10681
|
value: input.method
|
|
10334
10682
|
}) ].every((flag => flag));
|
|
10335
|
-
const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.
|
|
10683
|
+
const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
|
|
10684
|
+
path: _path + ".draft",
|
|
10685
|
+
expected: "string",
|
|
10686
|
+
value: input.draft
|
|
10687
|
+
}), "string" === typeof input.functionName || _report(_exceptionable, {
|
|
10336
10688
|
path: _path + ".functionName",
|
|
10337
10689
|
expected: "string",
|
|
10338
10690
|
value: input.functionName
|
|
10339
|
-
}),
|
|
10340
|
-
path: _path + ".
|
|
10691
|
+
}), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
|
|
10692
|
+
path: _path + ".dependsOn",
|
|
10693
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
10694
|
+
value: input.dependsOn
|
|
10695
|
+
})) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
10696
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
10697
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
10698
|
+
value: elem
|
|
10699
|
+
})) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
|
|
10700
|
+
path: _path + ".dependsOn[" + _index6 + "]",
|
|
10701
|
+
expected: "IAutoBeTestScenarioApplication.IDependsOn",
|
|
10702
|
+
value: elem
|
|
10703
|
+
}))).every((flag => flag)) || _report(_exceptionable, {
|
|
10704
|
+
path: _path + ".dependsOn",
|
|
10705
|
+
expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
|
|
10706
|
+
value: input.dependsOn
|
|
10707
|
+
}) ].every((flag => flag));
|
|
10708
|
+
const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
|
|
10709
|
+
path: _path + ".endpoint",
|
|
10710
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
10711
|
+
value: input.endpoint
|
|
10712
|
+
})) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
|
|
10713
|
+
path: _path + ".endpoint",
|
|
10714
|
+
expected: "AutoBeOpenApi.IEndpoint",
|
|
10715
|
+
value: input.endpoint
|
|
10716
|
+
}), "string" === typeof input.purpose || _report(_exceptionable, {
|
|
10717
|
+
path: _path + ".purpose",
|
|
10341
10718
|
expected: "string",
|
|
10342
|
-
value: input.
|
|
10719
|
+
value: input.purpose
|
|
10343
10720
|
}) ].every((flag => flag));
|
|
10344
10721
|
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
10345
10722
|
let errors;
|
|
@@ -10350,11 +10727,11 @@ const collection$1 = {
|
|
|
10350
10727
|
_report = __typia_transform__validateReport._validateReport(errors);
|
|
10351
10728
|
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
10352
10729
|
path: _path + "",
|
|
10353
|
-
expected: "
|
|
10730
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
10354
10731
|
value: input
|
|
10355
10732
|
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
10356
10733
|
path: _path + "",
|
|
10357
|
-
expected: "
|
|
10734
|
+
expected: "IAutoBeTestScenarioApplication.IProps",
|
|
10358
10735
|
value: input
|
|
10359
10736
|
}))(input, "$input", true);
|
|
10360
10737
|
const success = 0 === errors.length;
|
|
@@ -10398,10 +10775,9 @@ const orchestrateTest = ctx => async props => {
|
|
|
10398
10775
|
ctx.dispatch(history);
|
|
10399
10776
|
return history;
|
|
10400
10777
|
}
|
|
10401
|
-
const
|
|
10402
|
-
const scenarios = scenarioEvent.scenarios.map((scenario => scenario.scenarios)).flat();
|
|
10778
|
+
const {scenarios} = await orchestrateTestScenario(ctx);
|
|
10403
10779
|
const codes = await orchestrateTestProgress(ctx, scenarios);
|
|
10404
|
-
const correct = await orchestrateTestCorrect(ctx, codes);
|
|
10780
|
+
const correct = await orchestrateTestCorrect(ctx, codes, scenarios);
|
|
10405
10781
|
const history = {
|
|
10406
10782
|
type: "test",
|
|
10407
10783
|
id: v4(),
|
|
@@ -11835,29 +12211,30 @@ function emplaceMap(dict, key, generator) {
|
|
|
11835
12211
|
|
|
11836
12212
|
class AutoBeAgent {
|
|
11837
12213
|
constructor(props) {
|
|
11838
|
-
this.
|
|
12214
|
+
this.props_ = props;
|
|
11839
12215
|
this.histories_ = props.histories?.slice() ?? [];
|
|
11840
12216
|
this.state_ = createAutoBeState(this.histories_);
|
|
12217
|
+
this.listeners_ = new Map;
|
|
12218
|
+
const vendor = {
|
|
12219
|
+
...props.vendor,
|
|
12220
|
+
semaphore: new Semaphore(props.vendor.semaphore ?? 16)
|
|
12221
|
+
};
|
|
11841
12222
|
this.context_ = {
|
|
12223
|
+
vendor,
|
|
11842
12224
|
model: props.model,
|
|
11843
|
-
vendor: props.vendor,
|
|
11844
12225
|
config: props.config,
|
|
11845
12226
|
compiler: props.compiler,
|
|
11846
12227
|
histories: () => this.histories_,
|
|
11847
12228
|
state: () => this.state_,
|
|
11848
12229
|
usage: () => this.agentica_.getTokenUsage(),
|
|
11849
|
-
files:
|
|
12230
|
+
files: options => this.getFiles(options),
|
|
11850
12231
|
dispatch: event => {
|
|
11851
12232
|
this.dispatch(event).catch((() => {}));
|
|
11852
12233
|
}
|
|
11853
12234
|
};
|
|
11854
|
-
this.listeners_ = new Map;
|
|
11855
12235
|
this.agentica_ = new MicroAgentica({
|
|
12236
|
+
vendor,
|
|
11856
12237
|
model: props.model,
|
|
11857
|
-
vendor: {
|
|
11858
|
-
...props.vendor,
|
|
11859
|
-
semaphore: new Semaphore(props.vendor.semaphore ?? 16)
|
|
11860
|
-
},
|
|
11861
12238
|
config: {
|
|
11862
12239
|
...props.config ?? {},
|
|
11863
12240
|
executor: {
|
|
@@ -11898,21 +12275,10 @@ class AutoBeAgent {
|
|
|
11898
12275
|
}
|
|
11899
12276
|
clone() {
|
|
11900
12277
|
return new AutoBeAgent({
|
|
11901
|
-
...this.
|
|
12278
|
+
...this.props_,
|
|
11902
12279
|
histories: this.histories_.slice()
|
|
11903
12280
|
});
|
|
11904
12281
|
}
|
|
11905
|
-
on(type, listener) {
|
|
11906
|
-
emplaceMap(this.listeners_, type, (() => new Set)).add(listener);
|
|
11907
|
-
return this;
|
|
11908
|
-
}
|
|
11909
|
-
off(type, listener) {
|
|
11910
|
-
const set = this.listeners_.get(type);
|
|
11911
|
-
if (set === undefined) return this;
|
|
11912
|
-
set.delete(listener);
|
|
11913
|
-
if (set.size === 0) this.listeners_.delete(type);
|
|
11914
|
-
return this;
|
|
11915
|
-
}
|
|
11916
12282
|
async conversate(content) {
|
|
11917
12283
|
const index = this.histories_.length;
|
|
11918
12284
|
const userMessageHistory = {
|
|
@@ -11929,13 +12295,13 @@ class AutoBeAgent {
|
|
|
11929
12295
|
await this.agentica_.conversate(content);
|
|
11930
12296
|
return this.histories_.slice(index);
|
|
11931
12297
|
}
|
|
11932
|
-
getFiles() {
|
|
12298
|
+
async getFiles(options) {
|
|
11933
12299
|
const files = {
|
|
11934
12300
|
...Object.fromEntries(this.state_.analyze ? Object.entries(this.state_.analyze.files).map((([key, value]) => [ `docs/analysis/${key.split("/").at(-1)}`, value ])) : []),
|
|
11935
|
-
...Object.fromEntries(this.state_.prisma?.result
|
|
12301
|
+
...Object.fromEntries(!!this.state_.prisma?.result ? [ ...Object.entries((options?.dbms ?? "postgres") === "postgres" ? this.state_.prisma.schemas : await this.context_.compiler.prisma.write(this.state_.prisma.result.data, options.dbms)).map((([key, value]) => [ `prisma/schema/${key.split("/").at(-1)}`, value ])), ...this.state_.prisma.compiled.type === "success" ? [ [ "docs/ERD.md", this.state_.prisma.compiled.document ] ] : [], ...this.state_.prisma.compiled.type === "failure" ? [ [ "prisma/compile-error-reason.log", this.state_.prisma.compiled.reason ] ] : [], [ "autobe/prisma.json", JSON.stringify(this.state_.prisma.result.data, null, 2) ] ] : []),
|
|
11936
12302
|
...this.state_.interface ? this.state_.interface.files : {},
|
|
11937
|
-
...this.state_.test
|
|
11938
|
-
...this.state_.realize
|
|
12303
|
+
...this.state_.test ? this.state_.test.files : {},
|
|
12304
|
+
...this.state_.realize ? this.state_.realize.files : {},
|
|
11939
12305
|
"autobe/histories.json": JSON.stringify(this.histories_, null, 2),
|
|
11940
12306
|
"autobe/tokenUsage.json": JSON.stringify(this.getTokenUsage(), null, 2),
|
|
11941
12307
|
...this.state_.interface ? {
|
|
@@ -11953,6 +12319,17 @@ class AutoBeAgent {
|
|
|
11953
12319
|
getContext() {
|
|
11954
12320
|
return this.context_;
|
|
11955
12321
|
}
|
|
12322
|
+
on(type, listener) {
|
|
12323
|
+
emplaceMap(this.listeners_, type, (() => new Set)).add(listener);
|
|
12324
|
+
return this;
|
|
12325
|
+
}
|
|
12326
|
+
off(type, listener) {
|
|
12327
|
+
const set = this.listeners_.get(type);
|
|
12328
|
+
if (set === undefined) return this;
|
|
12329
|
+
set.delete(listener);
|
|
12330
|
+
if (set.size === 0) this.listeners_.delete(type);
|
|
12331
|
+
return this;
|
|
12332
|
+
}
|
|
11956
12333
|
async dispatch(event) {
|
|
11957
12334
|
const set = this.listeners_.get(event.type);
|
|
11958
12335
|
if (set === undefined) return;
|
|
@@ -11966,43 +12343,9 @@ class AutoBeAgent {
|
|
|
11966
12343
|
|
|
11967
12344
|
var AutoBeTokenUsage = AgenticaTokenUsage;
|
|
11968
12345
|
|
|
11969
|
-
function invertOpenApiDocument(document) {
|
|
11970
|
-
const app = HttpMigration.application(document);
|
|
11971
|
-
return {
|
|
11972
|
-
operations: app.routes.filter((r => r.query === null)).map((r => ({
|
|
11973
|
-
specification: empty("specification"),
|
|
11974
|
-
method: r.method,
|
|
11975
|
-
path: r.path,
|
|
11976
|
-
summary: r.operation().summary ?? empty("summary"),
|
|
11977
|
-
description: r.operation().description ?? empty("description"),
|
|
11978
|
-
parameters: r.parameters.map((p => ({
|
|
11979
|
-
name: p.name,
|
|
11980
|
-
description: p.parameter().description ?? empty("description"),
|
|
11981
|
-
schema: p.schema
|
|
11982
|
-
}))),
|
|
11983
|
-
requestBody: r.body?.type === "application/json" && OpenApiTypeChecker.isReference(r.body.schema) ? {
|
|
11984
|
-
description: r.body.description() ?? empty("description"),
|
|
11985
|
-
typeName: r.body.schema.$ref.split("/").pop()
|
|
11986
|
-
} : null,
|
|
11987
|
-
responseBody: r.success?.type === "application/json" && OpenApiTypeChecker.isReference(r.success.schema) ? {
|
|
11988
|
-
description: r.success.description() ?? empty("description"),
|
|
11989
|
-
typeName: r.success.schema.$ref.split("/").pop()
|
|
11990
|
-
} : null
|
|
11991
|
-
}))),
|
|
11992
|
-
components: {
|
|
11993
|
-
schemas: document.components?.schemas ?? {}
|
|
11994
|
-
}
|
|
11995
|
-
};
|
|
11996
|
-
}
|
|
11997
|
-
|
|
11998
|
-
function empty(key) {
|
|
11999
|
-
return `Describe ${key} as much as possible with clear and concise words.`;
|
|
12000
|
-
}
|
|
12001
|
-
|
|
12002
12346
|
var index$1 = Object.freeze({
|
|
12003
12347
|
__proto__: null,
|
|
12004
|
-
createAgenticaHistory
|
|
12005
|
-
invertOpenApiDocument
|
|
12348
|
+
createAgenticaHistory
|
|
12006
12349
|
});
|
|
12007
12350
|
|
|
12008
12351
|
var index = Object.freeze({
|