@autobe/agent 0.9.0 → 0.9.1

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.
Files changed (46) hide show
  1. package/lib/AutoBeAgent.js +3 -1
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +2 -2
  4. package/lib/index.mjs +883 -865
  5. package/lib/index.mjs.map +1 -1
  6. package/lib/orchestrate/test/compileTestScenario.d.ts +5 -0
  7. package/lib/orchestrate/test/compileTestScenario.js +56 -0
  8. package/lib/orchestrate/test/compileTestScenario.js.map +1 -0
  9. package/lib/orchestrate/test/filterTestFileName.d.ts +1 -0
  10. package/lib/orchestrate/test/filterTestFileName.js +13 -0
  11. package/lib/orchestrate/test/filterTestFileName.js.map +1 -0
  12. package/lib/orchestrate/test/orchestrateTest.js +6 -3
  13. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  14. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +2 -2
  15. package/lib/orchestrate/test/orchestrateTestCorrect.js +46 -60
  16. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  17. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  18. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -0
  19. package/lib/orchestrate/test/{orchestrateTestProgress.js → orchestrateTestWrite.js} +10 -51
  20. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -0
  21. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +5 -0
  22. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.js +3 -0
  23. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.js.map +1 -0
  24. package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +2 -2
  25. package/lib/orchestrate/test/transformTestCorrectHistories.js +9 -13
  26. package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
  27. package/lib/orchestrate/test/transformTestWriteHistories.d.ts +7 -0
  28. package/lib/orchestrate/test/transformTestWriteHistories.js +47 -0
  29. package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -0
  30. package/package.json +4 -4
  31. package/src/AutoBeAgent.ts +5 -1
  32. package/src/constants/AutoBeSystemPromptConstant.ts +1 -1
  33. package/src/orchestrate/test/compileTestScenario.ts +63 -0
  34. package/src/orchestrate/test/filterTestFileName.ts +9 -0
  35. package/src/orchestrate/test/orchestrateTest.ts +6 -5
  36. package/src/orchestrate/test/orchestrateTestCorrect.ts +96 -97
  37. package/src/orchestrate/test/orchestrateTestScenario.ts +6 -3
  38. package/src/orchestrate/test/{orchestrateTestProgress.ts → orchestrateTestWrite.ts} +14 -73
  39. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +5 -0
  40. package/src/orchestrate/test/transformTestCorrectHistories.ts +10 -14
  41. package/src/orchestrate/test/{transformTestProgressHistories.ts → transformTestWriteHistories.ts} +9 -10
  42. package/lib/orchestrate/test/orchestrateTestProgress.d.ts +0 -5
  43. package/lib/orchestrate/test/orchestrateTestProgress.js.map +0 -1
  44. package/lib/orchestrate/test/transformTestProgressHistories.d.ts +0 -8
  45. package/lib/orchestrate/test/transformTestProgressHistories.js +0 -47
  46. package/lib/orchestrate/test/transformTestProgressHistories.js.map +0 -1
package/lib/index.mjs CHANGED
@@ -8952,57 +8952,198 @@ function isRetryError(error) {
8952
8952
  return false;
8953
8953
  }
8954
8954
 
8955
- const transformTestProgressHistories = props => [ {
8955
+ async function compileTestScenario(ctx, scenario) {
8956
+ const document = filterDocument(scenario, ctx.state().interface.document);
8957
+ const entries = Object.entries(await ctx.compiler.interface.compile(document));
8958
+ const filter = prefix => Object.fromEntries(entries.filter((([key]) => key.startsWith(prefix))));
8959
+ return {
8960
+ sdk: filter("src/api/functional"),
8961
+ dto: filter("src/api/structures"),
8962
+ e2e: filter("test/features")
8963
+ };
8964
+ }
8965
+
8966
+ function filterDocument(scenario, document) {
8967
+ const operations = document.operations.filter((op => scenario.endpoint.method === op.method && scenario.endpoint.path === op.path || scenario.dependencies.some((dp => dp.endpoint.method === op.method && dp.endpoint.path === op.path))));
8968
+ const components = {
8969
+ schemas: {}
8970
+ };
8971
+ const visit = typeName => {
8972
+ OpenApiTypeChecker.visit({
8973
+ components: document.components,
8974
+ schema: {
8975
+ $ref: `#/components/schemas/${typeName}`
8976
+ },
8977
+ closure: s => {
8978
+ if (OpenApiTypeChecker.isReference(s)) {
8979
+ const key = s.$ref.split("/").pop();
8980
+ components.schemas[key] = document.components.schemas[key];
8981
+ }
8982
+ }
8983
+ });
8984
+ };
8985
+ for (const op of operations) {
8986
+ if (op.requestBody) visit(op.requestBody.typeName);
8987
+ if (op.responseBody) visit(op.responseBody.typeName);
8988
+ }
8989
+ return {
8990
+ operations,
8991
+ components
8992
+ };
8993
+ }
8994
+
8995
+ function filterTestFileName(key) {
8996
+ if (key.endsWith(".ts") === false) return false; else if (key.startsWith("src/") === true) return true;
8997
+ return key.startsWith("test/") === true && key.startsWith("test/features/") === false && key.startsWith("test/benchmark/") === false;
8998
+ }
8999
+
9000
+ const transformTestCorrectHistories = artifacts => [ {
8956
9001
  id: v4(),
8957
9002
  created_at: (new Date).toISOString(),
8958
9003
  type: "systemMessage",
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.'
9004
+ 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```'
8960
9005
  }, {
8961
9006
  id: v4(),
8962
9007
  created_at: (new Date).toISOString(),
8963
9008
  type: "assistantMessage",
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")
9009
+ 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", "### API Files", "```typescript", JSON.stringify(artifacts.sdk), "```", "", "### DTO Files", "```typescript", JSON.stringify(artifacts.dto), "```", "", "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")
8965
9010
  } ];
8966
9011
 
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,
9012
+ async function orchestrateTestCorrect(ctx, codes, scenarios, life = 4) {
9013
+ const files = codes.map((({filename, content}, index) => {
9014
+ const scenario = scenarios[index];
9015
+ return {
9016
+ location: filename,
9017
+ content,
9018
+ scenario
9019
+ };
9020
+ }));
9021
+ const testFiles = Object.fromEntries(codes.map((c => [ c.filename, c.content ])));
9022
+ const retainedFiles = Object.fromEntries(Object.entries(ctx.state().interface?.files ?? {}).filter((([key]) => filterTestFileName(key))));
9023
+ const external = async location => {
9024
+ const content = await ctx.compiler.typescript.getExternal(location);
9025
+ if (content === undefined) throw new Error(`File not found: ${location}`);
9026
+ return {
9027
+ [location]: content
9028
+ };
9029
+ };
9030
+ const mergedFiles = {
9031
+ ...retainedFiles,
9032
+ ...testFiles,
9033
+ ...await external("node_modules/@nestia/e2e/lib/TestValidator.d.ts"),
9034
+ ...await external("node_modules/@nestia/fetcher/lib/IConnection.d.ts")
9035
+ };
9036
+ const response = await step(ctx, mergedFiles, files, life);
9037
+ const event = {
9038
+ ...response,
9039
+ type: "testValidate",
9040
+ files: [ ...Object.entries(mergedFiles).map((([filename, content]) => ({
9041
+ location: filename,
9042
+ content
9043
+ }))), ...response.files ]
9044
+ };
9045
+ return event;
9046
+ }
9047
+
9048
+ async function step(ctx, entireFiles, testFiles, life) {
9049
+ const result = await ctx.compiler.typescript.compile({
9050
+ files: entireFiles
9051
+ });
9052
+ if (result.type === "success") {
9053
+ return {
9054
+ type: "testValidate",
9055
+ created_at: (new Date).toISOString(),
9056
+ files: testFiles,
9057
+ result,
8979
9058
  step: ctx.state().interface?.step ?? 0
8980
9059
  };
8981
- ctx.dispatch(event);
8982
- return event;
9060
+ }
9061
+ if (result.type === "exception") {
9062
+ ctx.dispatch({
9063
+ type: "testValidate",
9064
+ created_at: (new Date).toISOString(),
9065
+ files: testFiles,
9066
+ result,
9067
+ step: ctx.state().interface?.step ?? 0
9068
+ });
9069
+ throw new Error(JSON.stringify(result.error, null, 2));
9070
+ }
9071
+ const diagnostics = {};
9072
+ result.diagnostics.forEach((d => {
9073
+ if (d.file === null) return;
9074
+ diagnostics[d.file] = diagnostics[d.file] ?? [];
9075
+ diagnostics[d.file].push(d);
9076
+ }));
9077
+ if (Object.keys(diagnostics).length === 0) {
9078
+ return {
9079
+ type: "testValidate",
9080
+ created_at: (new Date).toISOString(),
9081
+ files: testFiles,
9082
+ result: {
9083
+ ...result,
9084
+ type: "success"
9085
+ },
9086
+ step: ctx.state().interface?.step ?? 0
9087
+ };
9088
+ }
9089
+ ctx.dispatch({
9090
+ type: "testValidate",
9091
+ created_at: (new Date).toISOString(),
9092
+ files: testFiles,
9093
+ result,
9094
+ step: ctx.state().interface?.step ?? 0
9095
+ });
9096
+ if (life <= 0) return {
9097
+ type: "testValidate",
9098
+ created_at: (new Date).toISOString(),
9099
+ files: testFiles,
9100
+ result,
9101
+ step: ctx.state().interface?.step ?? 0
9102
+ };
9103
+ const validatedFiles = await Promise.all(Object.entries(diagnostics).map((async ([filename, d]) => {
9104
+ const file = testFiles.find((f => f.location === filename));
9105
+ const code = file?.content;
9106
+ const scenario = file?.scenario;
9107
+ const response = await process$1(ctx, d, code, scenario);
9108
+ ctx.dispatch({
9109
+ type: "testCorrect",
9110
+ created_at: (new Date).toISOString(),
9111
+ files: {
9112
+ ...testFiles,
9113
+ [filename]: response.content
9114
+ },
9115
+ result,
9116
+ solution: response.solution,
9117
+ think_without_compile_error: response.think_without_compile_error,
9118
+ think_again_with_compile_error: response.think_again_with_compile_error,
9119
+ step: ctx.state().interface?.step ?? 0
9120
+ });
9121
+ return {
9122
+ location: filename,
9123
+ content: code,
9124
+ scenario
9125
+ };
8983
9126
  })));
8984
- return events;
9127
+ return step(ctx, entireFiles, testFiles.map((f => {
9128
+ const validated = validatedFiles.find((v => v.location === f.location));
9129
+ return validated ? validated : f;
9130
+ })), life - 1);
8985
9131
  }
8986
9132
 
8987
- async function process$1(ctx, scenario) {
9133
+ async function process$1(ctx, diagnostics, code, scenario) {
8988
9134
  const pointer = {
8989
9135
  value: null
8990
9136
  };
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))));
9137
+ const artifacts = await compileTestScenario(ctx, scenario);
8994
9138
  const agentica = new MicroAgentica({
8995
9139
  model: ctx.model,
8996
- vendor: ctx.vendor,
9140
+ vendor: {
9141
+ ...ctx.vendor
9142
+ },
8997
9143
  config: {
8998
9144
  ...ctx.config ?? {}
8999
9145
  },
9000
- histories: transformTestProgressHistories({
9001
- scenario,
9002
- dto: filter("src/api/structures"),
9003
- sdk: filter("src/api/functional"),
9004
- e2e: filter("test/features")
9005
- }),
9146
+ histories: transformTestCorrectHistories(artifacts),
9006
9147
  controllers: [ createApplication$2({
9007
9148
  model: ctx.model,
9008
9149
  build: next => {
@@ -9012,44 +9153,17 @@ async function process$1(ctx, scenario) {
9012
9153
  tokenUsage: ctx.usage()
9013
9154
  });
9014
9155
  enforceToolCall(agentica);
9015
- await agentica.conversate("Create e2e test functions.");
9016
- if (pointer.value === null) throw new Error("Failed to create test code.");
9017
- return pointer.value;
9018
- }
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
- }
9156
+ await randomBackoffRetry((async () => {
9157
+ await agentica.conversate([ "Fix the compilation error in the provided code.", "", "## Original Code", "```typescript", code, "```", "", diagnostics.map((diagnostic => {
9158
+ if (diagnostic.start === undefined || diagnostic.length === undefined) return "";
9159
+ const checkDtoRegexp = `Cannot find module '@ORGANIZATION/template-api/lib/structures/IBbsArticleComment' or its corresponding type declarations.`;
9160
+ const [group] = [ ...checkDtoRegexp.matchAll(/Cannot find module '(.*lib\/structures\/.*)'/g) ];
9161
+ const [_, filename] = group ?? [];
9162
+ 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");
9163
+ })), "## 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"));
9027
9164
  }));
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
- };
9165
+ if (pointer.value === null) throw new Error("Failed to modify test code.");
9166
+ return pointer.value;
9053
9167
  }
9054
9168
 
9055
9169
  function createApplication$2(props) {
@@ -9057,10 +9171,10 @@ function createApplication$2(props) {
9057
9171
  const application = collection$3[props.model];
9058
9172
  return {
9059
9173
  protocol: "class",
9060
- name: "Create Test Code",
9174
+ name: "Modify Test Code",
9061
9175
  application,
9062
9176
  execute: {
9063
- createTestCode: next => {
9177
+ correctTestCode: next => {
9064
9178
  props.build(next);
9065
9179
  }
9066
9180
  }
@@ -9074,41 +9188,48 @@ const claude$3 = {
9074
9188
  separate: null
9075
9189
  },
9076
9190
  functions: [ {
9077
- name: "createTestCode",
9191
+ name: "correctTestCode",
9078
9192
  parameters: {
9079
- description: "Current Type: {@link ICreateTestCodeProps}",
9193
+ description: "Current Type: {@link ICorrectTestFunctionProps}",
9080
9194
  type: "object",
9081
9195
  properties: {
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.",
9196
+ think_without_compile_error: {
9197
+ 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.",
9085
9198
  type: "string"
9086
9199
  },
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',
9200
+ think_again_with_compile_error: {
9201
+ 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.",
9202
+ type: "string"
9203
+ },
9204
+ solution: {
9205
+ title: "Step 3: Concrete action plan for fixing the identified issues",
9206
+ 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.",
9090
9207
  type: "string"
9091
9208
  },
9092
9209
  content: {
9093
- title: "Complete TypeScript E2E test implementation",
9094
- description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
9210
+ title: "Step 4: The corrected TypeScript test code",
9211
+ 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.",
9095
9212
  type: "string"
9096
9213
  }
9097
9214
  },
9098
- required: [ "scenario", "domain", "content" ],
9215
+ required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9099
9216
  additionalProperties: false,
9100
9217
  $defs: {}
9101
9218
  },
9102
9219
  validate: (() => {
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",
9220
+ 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;
9221
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9222
+ path: _path + ".think_without_compile_error",
9106
9223
  expected: "string",
9107
- value: input.scenario
9108
- }), "string" === typeof input.domain || _report(_exceptionable, {
9109
- path: _path + ".domain",
9224
+ value: input.think_without_compile_error
9225
+ }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9226
+ path: _path + ".think_again_with_compile_error",
9110
9227
  expected: "string",
9111
- value: input.domain
9228
+ value: input.think_again_with_compile_error
9229
+ }), "string" === typeof input.solution || _report(_exceptionable, {
9230
+ path: _path + ".solution",
9231
+ expected: "string",
9232
+ value: input.solution
9112
9233
  }), "string" === typeof input.content || _report(_exceptionable, {
9113
9234
  path: _path + ".content",
9114
9235
  expected: "string",
@@ -9123,11 +9244,11 @@ const claude$3 = {
9123
9244
  _report = __typia_transform__validateReport._validateReport(errors);
9124
9245
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9125
9246
  path: _path + "",
9126
- expected: "ICreateTestCodeProps",
9247
+ expected: "ICorrectTestFunctionProps",
9127
9248
  value: input
9128
9249
  })) && _vo0(input, _path + "", true) || _report(true, {
9129
9250
  path: _path + "",
9130
- expected: "ICreateTestCodeProps",
9251
+ expected: "ICorrectTestFunctionProps",
9131
9252
  value: input
9132
9253
  }))(input, "$input", true);
9133
9254
  const success = 0 === errors.length;
@@ -9158,41 +9279,48 @@ const collection$3 = {
9158
9279
  separate: null
9159
9280
  },
9160
9281
  functions: [ {
9161
- name: "createTestCode",
9282
+ name: "correctTestCode",
9162
9283
  parameters: {
9163
- description: "Current Type: {@link ICreateTestCodeProps}",
9284
+ description: "Current Type: {@link ICorrectTestFunctionProps}",
9164
9285
  type: "object",
9165
9286
  properties: {
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.",
9287
+ think_without_compile_error: {
9288
+ 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.",
9169
9289
  type: "string"
9170
9290
  },
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',
9291
+ think_again_with_compile_error: {
9292
+ 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.",
9293
+ type: "string"
9294
+ },
9295
+ solution: {
9296
+ title: "Step 3: Concrete action plan for fixing the identified issues",
9297
+ 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.",
9174
9298
  type: "string"
9175
9299
  },
9176
9300
  content: {
9177
- title: "Complete TypeScript E2E test implementation",
9178
- description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
9301
+ title: "Step 4: The corrected TypeScript test code",
9302
+ 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.",
9179
9303
  type: "string"
9180
9304
  }
9181
9305
  },
9182
- required: [ "scenario", "domain", "content" ],
9306
+ required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9183
9307
  additionalProperties: false,
9184
9308
  $defs: {}
9185
9309
  },
9186
9310
  validate: (() => {
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",
9190
- expected: "string",
9191
- value: input.scenario
9192
- }), "string" === typeof input.domain || _report(_exceptionable, {
9193
- path: _path + ".domain",
9311
+ 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;
9312
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9313
+ path: _path + ".think_without_compile_error",
9194
9314
  expected: "string",
9195
- value: input.domain
9315
+ value: input.think_without_compile_error
9316
+ }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9317
+ path: _path + ".think_again_with_compile_error",
9318
+ expected: "string",
9319
+ value: input.think_again_with_compile_error
9320
+ }), "string" === typeof input.solution || _report(_exceptionable, {
9321
+ path: _path + ".solution",
9322
+ expected: "string",
9323
+ value: input.solution
9196
9324
  }), "string" === typeof input.content || _report(_exceptionable, {
9197
9325
  path: _path + ".content",
9198
9326
  expected: "string",
@@ -9207,11 +9335,11 @@ const collection$3 = {
9207
9335
  _report = __typia_transform__validateReport._validateReport(errors);
9208
9336
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9209
9337
  path: _path + "",
9210
- expected: "ICreateTestCodeProps",
9338
+ expected: "ICorrectTestFunctionProps",
9211
9339
  value: input
9212
9340
  })) && _vo0(input, _path + "", true) || _report(true, {
9213
9341
  path: _path + "",
9214
- expected: "ICreateTestCodeProps",
9342
+ expected: "ICorrectTestFunctionProps",
9215
9343
  value: input
9216
9344
  }))(input, "$input", true);
9217
9345
  const success = 0 === errors.length;
@@ -9244,40 +9372,47 @@ const collection$3 = {
9244
9372
  separate: null
9245
9373
  },
9246
9374
  functions: [ {
9247
- name: "createTestCode",
9375
+ name: "correctTestCode",
9248
9376
  parameters: {
9249
9377
  type: "object",
9250
9378
  properties: {
9251
- scenario: {
9379
+ think_without_compile_error: {
9252
9380
  type: "string",
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."
9381
+ 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."
9255
9382
  },
9256
- domain: {
9383
+ think_again_with_compile_error: {
9257
9384
  type: "string",
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'
9385
+ 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."
9386
+ },
9387
+ solution: {
9388
+ type: "string",
9389
+ title: "Step 3: Concrete action plan for fixing the identified issues",
9390
+ 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."
9260
9391
  },
9261
9392
  content: {
9262
9393
  type: "string",
9263
- title: "Complete TypeScript E2E test implementation",
9264
- description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following"
9394
+ title: "Step 4: The corrected TypeScript test code",
9395
+ 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."
9265
9396
  }
9266
9397
  },
9267
- required: [ "scenario", "domain", "content" ],
9268
- description: "Current Type: {@link ICreateTestCodeProps}",
9398
+ required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9399
+ description: "Current Type: {@link ICorrectTestFunctionProps}",
9269
9400
  additionalProperties: false
9270
9401
  },
9271
9402
  validate: (() => {
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",
9403
+ 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;
9404
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.think_without_compile_error || _report(_exceptionable, {
9405
+ path: _path + ".think_without_compile_error",
9275
9406
  expected: "string",
9276
- value: input.scenario
9277
- }), "string" === typeof input.domain || _report(_exceptionable, {
9278
- path: _path + ".domain",
9407
+ value: input.think_without_compile_error
9408
+ }), "string" === typeof input.think_again_with_compile_error || _report(_exceptionable, {
9409
+ path: _path + ".think_again_with_compile_error",
9279
9410
  expected: "string",
9280
- value: input.domain
9411
+ value: input.think_again_with_compile_error
9412
+ }), "string" === typeof input.solution || _report(_exceptionable, {
9413
+ path: _path + ".solution",
9414
+ expected: "string",
9415
+ value: input.solution
9281
9416
  }), "string" === typeof input.content || _report(_exceptionable, {
9282
9417
  path: _path + ".content",
9283
9418
  expected: "string",
@@ -9292,11 +9427,11 @@ const collection$3 = {
9292
9427
  _report = __typia_transform__validateReport._validateReport(errors);
9293
9428
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9294
9429
  path: _path + "",
9295
- expected: "ICreateTestCodeProps",
9430
+ expected: "ICorrectTestFunctionProps",
9296
9431
  value: input
9297
9432
  })) && _vo0(input, _path + "", true) || _report(true, {
9298
9433
  path: _path + "",
9299
- expected: "ICreateTestCodeProps",
9434
+ expected: "ICorrectTestFunctionProps",
9300
9435
  value: input
9301
9436
  }))(input, "$input", true);
9302
9437
  const success = 0 === errors.length;
@@ -9319,544 +9454,96 @@ const collection$3 = {
9319
9454
  }
9320
9455
  };
9321
9456
 
9322
- const transformTestCorrectHistories = document => [ {
9323
- id: v4(),
9324
- created_at: (new Date).toISOString(),
9325
- type: "systemMessage",
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```'
9327
- }, {
9328
- id: v4(),
9329
- created_at: (new Date).toISOString(),
9330
- type: "assistantMessage",
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")
9332
- } ];
9333
-
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
- },
9400
- step: ctx.state().interface?.step ?? 0
9401
- };
9457
+ async function orchestrateTestScenario(ctx) {
9458
+ const operations = ctx.state().interface?.document.operations ?? [];
9459
+ if (operations.length === 0) {
9460
+ throw new Error("Cannot write test scenarios because these are no operations.");
9402
9461
  }
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
9462
+ const exclude = [];
9463
+ let include = Array.from(operations);
9464
+ do {
9465
+ const matrix = divideArray({
9466
+ array: include,
9467
+ capacity: 30
9433
9468
  });
9434
- return [ filename, response.content ];
9435
- })));
9436
- const newFiles = {
9437
- ...files,
9438
- ...Object.fromEntries(validate)
9469
+ await Promise.all(matrix.map((async _include => {
9470
+ exclude.push(...await execute(ctx, operations, _include, exclude.map((x => x.endpoint))));
9471
+ })));
9472
+ include = include.filter((op => {
9473
+ if (exclude.some((pg => pg.endpoint.method === op.method && pg.endpoint.path === op.path))) {
9474
+ return false;
9475
+ }
9476
+ return true;
9477
+ }));
9478
+ } while (include.length > 0);
9479
+ return {
9480
+ type: "testScenario",
9481
+ step: ctx.state().analyze?.step ?? 0,
9482
+ scenarios: exclude.flatMap((pg => pg.scenarios.map((plan => ({
9483
+ endpoint: pg.endpoint,
9484
+ draft: plan.draft,
9485
+ functionName: plan.functionName,
9486
+ dependencies: plan.dependsOn
9487
+ }))))),
9488
+ created_at: (new Date).toISOString()
9439
9489
  };
9440
- return step(ctx, newFiles, scenarioMap, life - 1);
9441
9490
  }
9442
9491
 
9443
- async function process(ctx, diagnostics, code, scenario) {
9492
+ const execute = async (ctx, ops, include, exclude) => {
9444
9493
  const pointer = {
9445
- value: null
9494
+ value: []
9446
9495
  };
9447
- let document = null;
9448
- if (scenario) {
9449
- document = filterDocument(scenario, ctx.state().interface.document);
9450
- }
9451
9496
  const agentica = new MicroAgentica({
9452
9497
  model: ctx.model,
9453
- vendor: {
9454
- ...ctx.vendor
9455
- },
9498
+ vendor: ctx.vendor,
9456
9499
  config: {
9457
- ...ctx.config ?? {}
9500
+ ...ctx.config ?? {},
9501
+ executor: {
9502
+ describe: null
9503
+ }
9458
9504
  },
9459
- histories: transformTestCorrectHistories(document),
9505
+ tokenUsage: ctx.usage(),
9506
+ histories: createHistoryProperties(ops, include, exclude),
9460
9507
  controllers: [ createApplication$1({
9461
9508
  model: ctx.model,
9462
9509
  build: next => {
9463
- pointer.value = next;
9510
+ pointer.value ?? (pointer.value = []);
9511
+ pointer.value.push(...next.scenarioGroups);
9464
9512
  }
9465
- }) ],
9466
- tokenUsage: ctx.usage()
9513
+ }) ]
9467
9514
  });
9468
9515
  enforceToolCall(agentica);
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.");
9516
+ await agentica.conversate(`create test scenarios.`);
9517
+ if (pointer.value.length === 0) {
9518
+ throw new Error("Failed to create test plans.");
9519
+ }
9479
9520
  return pointer.value;
9480
- }
9521
+ };
9522
+
9523
+ const createHistoryProperties = (operations, include, exclude) => [ {
9524
+ id: v4(),
9525
+ created_at: (new Date).toISOString(),
9526
+ type: "systemMessage",
9527
+ 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.'
9528
+ }, {
9529
+ id: v4(),
9530
+ created_at: (new Date).toISOString(),
9531
+ type: "systemMessage",
9532
+ 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 => ({
9533
+ path: el.path,
9534
+ method: el.method,
9535
+ summary: el.summary
9536
+ })))), "```" ].join("\n")
9537
+ }, {
9538
+ id: v4(),
9539
+ created_at: (new Date).toISOString(),
9540
+ type: "systemMessage",
9541
+ 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")
9542
+ } ];
9481
9543
 
9482
9544
  function createApplication$1(props) {
9483
9545
  assertSchemaModel(props.model);
9484
9546
  const application = collection$2[props.model];
9485
- return {
9486
- protocol: "class",
9487
- name: "Modify Test Code",
9488
- application,
9489
- execute: {
9490
- correctTestCode: next => {
9491
- props.build(next);
9492
- }
9493
- }
9494
- };
9495
- }
9496
-
9497
- const claude$2 = {
9498
- model: "claude",
9499
- options: {
9500
- reference: true,
9501
- separate: null
9502
- },
9503
- functions: [ {
9504
- name: "correctTestCode",
9505
- parameters: {
9506
- description: "Current Type: {@link ICorrectTestFunctionProps}",
9507
- type: "object",
9508
- properties: {
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.",
9511
- type: "string"
9512
- },
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.",
9520
- type: "string"
9521
- },
9522
- content: {
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.",
9525
- type: "string"
9526
- }
9527
- },
9528
- required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9529
- additionalProperties: false,
9530
- $defs: {}
9531
- },
9532
- validate: (() => {
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",
9536
- expected: "string",
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",
9540
- expected: "string",
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
9546
- }), "string" === typeof input.content || _report(_exceptionable, {
9547
- path: _path + ".content",
9548
- expected: "string",
9549
- value: input.content
9550
- }) ].every((flag => flag));
9551
- const __is = input => "object" === typeof input && null !== input && _io0(input);
9552
- let errors;
9553
- let _report;
9554
- return input => {
9555
- if (false === __is(input)) {
9556
- errors = [];
9557
- _report = __typia_transform__validateReport._validateReport(errors);
9558
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9559
- path: _path + "",
9560
- expected: "ICorrectTestFunctionProps",
9561
- value: input
9562
- })) && _vo0(input, _path + "", true) || _report(true, {
9563
- path: _path + "",
9564
- expected: "ICorrectTestFunctionProps",
9565
- value: input
9566
- }))(input, "$input", true);
9567
- const success = 0 === errors.length;
9568
- return success ? {
9569
- success,
9570
- data: input
9571
- } : {
9572
- success,
9573
- errors,
9574
- data: input
9575
- };
9576
- }
9577
- return {
9578
- success: true,
9579
- data: input
9580
- };
9581
- };
9582
- })()
9583
- } ]
9584
- };
9585
-
9586
- const collection$2 = {
9587
- chatgpt: {
9588
- model: "chatgpt",
9589
- options: {
9590
- reference: true,
9591
- strict: false,
9592
- separate: null
9593
- },
9594
- functions: [ {
9595
- name: "correctTestCode",
9596
- parameters: {
9597
- description: "Current Type: {@link ICorrectTestFunctionProps}",
9598
- type: "object",
9599
- properties: {
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.",
9602
- type: "string"
9603
- },
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.",
9611
- type: "string"
9612
- },
9613
- content: {
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.",
9616
- type: "string"
9617
- }
9618
- },
9619
- required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9620
- additionalProperties: false,
9621
- $defs: {}
9622
- },
9623
- validate: (() => {
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",
9627
- expected: "string",
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",
9631
- expected: "string",
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
9637
- }), "string" === typeof input.content || _report(_exceptionable, {
9638
- path: _path + ".content",
9639
- expected: "string",
9640
- value: input.content
9641
- }) ].every((flag => flag));
9642
- const __is = input => "object" === typeof input && null !== input && _io0(input);
9643
- let errors;
9644
- let _report;
9645
- return input => {
9646
- if (false === __is(input)) {
9647
- errors = [];
9648
- _report = __typia_transform__validateReport._validateReport(errors);
9649
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9650
- path: _path + "",
9651
- expected: "ICorrectTestFunctionProps",
9652
- value: input
9653
- })) && _vo0(input, _path + "", true) || _report(true, {
9654
- path: _path + "",
9655
- expected: "ICorrectTestFunctionProps",
9656
- value: input
9657
- }))(input, "$input", true);
9658
- const success = 0 === errors.length;
9659
- return success ? {
9660
- success,
9661
- data: input
9662
- } : {
9663
- success,
9664
- errors,
9665
- data: input
9666
- };
9667
- }
9668
- return {
9669
- success: true,
9670
- data: input
9671
- };
9672
- };
9673
- })()
9674
- } ]
9675
- },
9676
- claude: claude$2,
9677
- llama: claude$2,
9678
- deepseek: claude$2,
9679
- 3.1: claude$2,
9680
- "3.0": {
9681
- model: "3.0",
9682
- options: {
9683
- constraint: true,
9684
- recursive: 3,
9685
- separate: null
9686
- },
9687
- functions: [ {
9688
- name: "correctTestCode",
9689
- parameters: {
9690
- type: "object",
9691
- properties: {
9692
- think_without_compile_error: {
9693
- type: "string",
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."
9695
- },
9696
- think_again_with_compile_error: {
9697
- type: "string",
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."
9704
- },
9705
- content: {
9706
- type: "string",
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."
9709
- }
9710
- },
9711
- required: [ "think_without_compile_error", "think_again_with_compile_error", "solution", "content" ],
9712
- description: "Current Type: {@link ICorrectTestFunctionProps}",
9713
- additionalProperties: false
9714
- },
9715
- validate: (() => {
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",
9719
- expected: "string",
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",
9723
- expected: "string",
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
9729
- }), "string" === typeof input.content || _report(_exceptionable, {
9730
- path: _path + ".content",
9731
- expected: "string",
9732
- value: input.content
9733
- }) ].every((flag => flag));
9734
- const __is = input => "object" === typeof input && null !== input && _io0(input);
9735
- let errors;
9736
- let _report;
9737
- return input => {
9738
- if (false === __is(input)) {
9739
- errors = [];
9740
- _report = __typia_transform__validateReport._validateReport(errors);
9741
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
9742
- path: _path + "",
9743
- expected: "ICorrectTestFunctionProps",
9744
- value: input
9745
- })) && _vo0(input, _path + "", true) || _report(true, {
9746
- path: _path + "",
9747
- expected: "ICorrectTestFunctionProps",
9748
- value: input
9749
- }))(input, "$input", true);
9750
- const success = 0 === errors.length;
9751
- return success ? {
9752
- success,
9753
- data: input
9754
- } : {
9755
- success,
9756
- errors,
9757
- data: input
9758
- };
9759
- }
9760
- return {
9761
- success: true,
9762
- data: input
9763
- };
9764
- };
9765
- })()
9766
- } ]
9767
- }
9768
- };
9769
-
9770
- async function orchestrateTestScenario(ctx) {
9771
- const operations = ctx.state().interface?.document.operations ?? [];
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
9781
- });
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);
9792
- return {
9793
- type: "testScenario",
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()
9802
- };
9803
- }
9804
-
9805
- const execute = async (ctx, ops, include, exclude) => {
9806
- const pointer = {
9807
- value: []
9808
- };
9809
- const agentica = new MicroAgentica({
9810
- model: ctx.model,
9811
- vendor: ctx.vendor,
9812
- config: {
9813
- ...ctx.config ?? {},
9814
- executor: {
9815
- describe: null
9816
- }
9817
- },
9818
- tokenUsage: ctx.usage(),
9819
- histories: createHistoryProperties(ops, include, exclude),
9820
- controllers: [ createApplication({
9821
- model: ctx.model,
9822
- build: next => {
9823
- pointer.value ?? (pointer.value = []);
9824
- pointer.value.push(...next.scenarioGroups);
9825
- }
9826
- }) ]
9827
- });
9828
- enforceToolCall(agentica);
9829
- await agentica.conversate(`create test scenarios.`);
9830
- if (pointer.value.length === 0) {
9831
- throw new Error("Failed to create test plans.");
9832
- }
9833
- return pointer.value;
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
- } ];
9856
-
9857
- function createApplication(props) {
9858
- assertSchemaModel(props.model);
9859
- const application = collection$1[props.model];
9860
9547
  application.functions[0].validate = next => {
9861
9548
  const result = (() => {
9862
9549
  const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
@@ -10029,7 +9716,7 @@ function createApplication(props) {
10029
9716
  };
10030
9717
  }
10031
9718
 
10032
- const claude$1 = {
9719
+ const claude$2 = {
10033
9720
  model: "claude",
10034
9721
  options: {
10035
9722
  reference: true,
@@ -10279,7 +9966,7 @@ const claude$1 = {
10279
9966
  } ]
10280
9967
  };
10281
9968
 
10282
- const collection$1 = {
9969
+ const collection$2 = {
10283
9970
  chatgpt: {
10284
9971
  model: "chatgpt",
10285
9972
  options: {
@@ -10447,36 +10134,519 @@ const collection$1 = {
10447
10134
  }), "string" === typeof input.functionName || _report(_exceptionable, {
10448
10135
  path: _path + ".functionName",
10449
10136
  expected: "string",
10450
- value: input.functionName
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",
10137
+ value: input.functionName
10138
+ }), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
10139
+ path: _path + ".dependsOn",
10140
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10141
+ value: input.dependsOn
10142
+ })) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10143
+ path: _path + ".dependsOn[" + _index6 + "]",
10144
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10145
+ value: elem
10146
+ })) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
10147
+ path: _path + ".dependsOn[" + _index6 + "]",
10148
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10149
+ value: elem
10150
+ }))).every((flag => flag)) || _report(_exceptionable, {
10151
+ path: _path + ".dependsOn",
10152
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10153
+ value: input.dependsOn
10154
+ }) ].every((flag => flag));
10155
+ const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10156
+ path: _path + ".endpoint",
10157
+ expected: "AutoBeOpenApi.IEndpoint",
10158
+ value: input.endpoint
10159
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
10160
+ path: _path + ".endpoint",
10161
+ expected: "AutoBeOpenApi.IEndpoint",
10162
+ value: input.endpoint
10163
+ }), "string" === typeof input.purpose || _report(_exceptionable, {
10164
+ path: _path + ".purpose",
10165
+ expected: "string",
10166
+ value: input.purpose
10167
+ }) ].every((flag => flag));
10168
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
10169
+ let errors;
10170
+ let _report;
10171
+ return input => {
10172
+ if (false === __is(input)) {
10173
+ errors = [];
10174
+ _report = __typia_transform__validateReport._validateReport(errors);
10175
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
10176
+ path: _path + "",
10177
+ expected: "IAutoBeTestScenarioApplication.IProps",
10178
+ value: input
10179
+ })) && _vo0(input, _path + "", true) || _report(true, {
10180
+ path: _path + "",
10181
+ expected: "IAutoBeTestScenarioApplication.IProps",
10182
+ value: input
10183
+ }))(input, "$input", true);
10184
+ const success = 0 === errors.length;
10185
+ return success ? {
10186
+ success,
10187
+ data: input
10188
+ } : {
10189
+ success,
10190
+ errors,
10191
+ data: input
10192
+ };
10193
+ }
10194
+ return {
10195
+ success: true,
10196
+ data: input
10197
+ };
10198
+ };
10199
+ })()
10200
+ } ]
10201
+ },
10202
+ claude: claude$2,
10203
+ llama: claude$2,
10204
+ deepseek: claude$2,
10205
+ 3.1: claude$2,
10206
+ "3.0": {
10207
+ model: "3.0",
10208
+ options: {
10209
+ constraint: true,
10210
+ recursive: 3,
10211
+ separate: null
10212
+ },
10213
+ functions: [ {
10214
+ name: "makeScenario",
10215
+ parameters: {
10216
+ type: "object",
10217
+ properties: {
10218
+ scenarioGroups: {
10219
+ type: "array",
10220
+ items: {
10221
+ type: "object",
10222
+ properties: {
10223
+ endpoint: {
10224
+ type: "object",
10225
+ properties: {
10226
+ path: {
10227
+ type: "string",
10228
+ title: "HTTP path of the API operation",
10229
+ 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."
10230
+ },
10231
+ method: {
10232
+ type: "string",
10233
+ enum: [ "get", "post", "put", "delete", "patch" ],
10234
+ title: "HTTP method of the API operation",
10235
+ 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"
10236
+ }
10237
+ },
10238
+ required: [ "path", "method" ],
10239
+ description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10240
+ additionalProperties: false
10241
+ },
10242
+ scenarios: {
10243
+ type: "array",
10244
+ items: {
10245
+ type: "object",
10246
+ properties: {
10247
+ draft: {
10248
+ type: "string",
10249
+ 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."
10250
+ },
10251
+ functionName: {
10252
+ type: "string",
10253
+ title: "Descriptive function name derived from the user scenario",
10254
+ 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"
10255
+ },
10256
+ dependsOn: {
10257
+ type: "array",
10258
+ items: {
10259
+ type: "object",
10260
+ properties: {
10261
+ endpoint: {
10262
+ type: "object",
10263
+ properties: {
10264
+ path: {
10265
+ type: "string",
10266
+ title: "HTTP path of the API operation",
10267
+ 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."
10268
+ },
10269
+ method: {
10270
+ type: "string",
10271
+ enum: [ "get", "post", "put", "delete", "patch" ],
10272
+ title: "HTTP method of the API operation",
10273
+ 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"
10274
+ }
10275
+ },
10276
+ required: [ "path", "method" ],
10277
+ 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.",
10278
+ additionalProperties: false
10279
+ },
10280
+ purpose: {
10281
+ type: "string",
10282
+ 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."'
10283
+ }
10284
+ },
10285
+ required: [ "endpoint", "purpose" ],
10286
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IDependsOn}",
10287
+ additionalProperties: false
10288
+ },
10289
+ 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."
10290
+ }
10291
+ },
10292
+ required: [ "draft", "functionName", "dependsOn" ],
10293
+ 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.",
10294
+ additionalProperties: false
10295
+ },
10296
+ title: "Array of test scenarios",
10297
+ description: "Array of test scenarios."
10298
+ }
10299
+ },
10300
+ required: [ "endpoint", "scenarios" ],
10301
+ description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
10302
+ additionalProperties: false
10303
+ },
10304
+ title: "Array of test scenario groups",
10305
+ description: "Array of test scenario groups."
10306
+ }
10307
+ },
10308
+ required: [ "scenarioGroups" ],
10309
+ description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
10310
+ additionalProperties: false
10311
+ },
10312
+ description: "Make test scenarios for the given endpoints.",
10313
+ validate: (() => {
10314
+ const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
10315
+ 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))));
10316
+ const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
10317
+ 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))));
10318
+ const _io4 = input => "object" === typeof input.endpoint && null !== input.endpoint && _io2(input.endpoint) && "string" === typeof input.purpose;
10319
+ const _vo0 = (input, _path, _exceptionable = true) => [ (Array.isArray(input.scenarioGroups) || _report(_exceptionable, {
10320
+ path: _path + ".scenarioGroups",
10321
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10322
+ value: input.scenarioGroups
10323
+ })) && input.scenarioGroups.map(((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10324
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10325
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
10326
+ value: elem
10327
+ })) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
10328
+ path: _path + ".scenarioGroups[" + _index4 + "]",
10329
+ expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
10330
+ value: elem
10331
+ }))).every((flag => flag)) || _report(_exceptionable, {
10332
+ path: _path + ".scenarioGroups",
10333
+ expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10334
+ value: input.scenarioGroups
10335
+ }) ].every((flag => flag));
10336
+ const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10337
+ path: _path + ".endpoint",
10338
+ expected: "AutoBeOpenApi.IEndpoint",
10339
+ value: input.endpoint
10340
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
10341
+ path: _path + ".endpoint",
10342
+ expected: "AutoBeOpenApi.IEndpoint",
10343
+ value: input.endpoint
10344
+ }), (Array.isArray(input.scenarios) || _report(_exceptionable, {
10345
+ path: _path + ".scenarios",
10346
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10347
+ value: input.scenarios
10348
+ })) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10349
+ path: _path + ".scenarios[" + _index5 + "]",
10350
+ expected: "IAutoBeTestScenarioApplication.IScenario",
10351
+ value: elem
10352
+ })) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
10353
+ path: _path + ".scenarios[" + _index5 + "]",
10354
+ expected: "IAutoBeTestScenarioApplication.IScenario",
10355
+ value: elem
10356
+ }))).every((flag => flag)) || _report(_exceptionable, {
10357
+ path: _path + ".scenarios",
10358
+ expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10359
+ value: input.scenarios
10360
+ }) ].every((flag => flag));
10361
+ const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
10362
+ path: _path + ".path",
10363
+ expected: "string",
10364
+ value: input.path
10365
+ }), "get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method || _report(_exceptionable, {
10366
+ path: _path + ".method",
10367
+ expected: '("delete" | "get" | "patch" | "post" | "put")',
10368
+ value: input.method
10369
+ }) ].every((flag => flag));
10370
+ const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
10371
+ path: _path + ".draft",
10372
+ expected: "string",
10373
+ value: input.draft
10374
+ }), "string" === typeof input.functionName || _report(_exceptionable, {
10375
+ path: _path + ".functionName",
10376
+ expected: "string",
10377
+ value: input.functionName
10378
+ }), (Array.isArray(input.dependsOn) || _report(_exceptionable, {
10379
+ path: _path + ".dependsOn",
10380
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10381
+ value: input.dependsOn
10382
+ })) && input.dependsOn.map(((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10383
+ path: _path + ".dependsOn[" + _index6 + "]",
10384
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10385
+ value: elem
10386
+ })) && _vo4(elem, _path + ".dependsOn[" + _index6 + "]", _exceptionable) || _report(_exceptionable, {
10387
+ path: _path + ".dependsOn[" + _index6 + "]",
10388
+ expected: "IAutoBeTestScenarioApplication.IDependsOn",
10389
+ value: elem
10390
+ }))).every((flag => flag)) || _report(_exceptionable, {
10391
+ path: _path + ".dependsOn",
10392
+ expected: "Array<IAutoBeTestScenarioApplication.IDependsOn>",
10393
+ value: input.dependsOn
10394
+ }) ].every((flag => flag));
10395
+ const _vo4 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10396
+ path: _path + ".endpoint",
10397
+ expected: "AutoBeOpenApi.IEndpoint",
10398
+ value: input.endpoint
10399
+ })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
10400
+ path: _path + ".endpoint",
10401
+ expected: "AutoBeOpenApi.IEndpoint",
10402
+ value: input.endpoint
10403
+ }), "string" === typeof input.purpose || _report(_exceptionable, {
10404
+ path: _path + ".purpose",
10405
+ expected: "string",
10406
+ value: input.purpose
10407
+ }) ].every((flag => flag));
10408
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
10409
+ let errors;
10410
+ let _report;
10411
+ return input => {
10412
+ if (false === __is(input)) {
10413
+ errors = [];
10414
+ _report = __typia_transform__validateReport._validateReport(errors);
10415
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
10416
+ path: _path + "",
10417
+ expected: "IAutoBeTestScenarioApplication.IProps",
10418
+ value: input
10419
+ })) && _vo0(input, _path + "", true) || _report(true, {
10420
+ path: _path + "",
10421
+ expected: "IAutoBeTestScenarioApplication.IProps",
10422
+ value: input
10423
+ }))(input, "$input", true);
10424
+ const success = 0 === errors.length;
10425
+ return success ? {
10426
+ success,
10427
+ data: input
10428
+ } : {
10429
+ success,
10430
+ errors,
10431
+ data: input
10432
+ };
10433
+ }
10434
+ return {
10435
+ success: true,
10436
+ data: input
10437
+ };
10438
+ };
10439
+ })()
10440
+ } ]
10441
+ }
10442
+ };
10443
+
10444
+ const transformTestWriteHistories = props => [ {
10445
+ id: v4(),
10446
+ created_at: (new Date).toISOString(),
10447
+ type: "systemMessage",
10448
+ 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### 3.6. Import Statement Guidelines\nAll E2E test functions must follow these standardized import patterns for consistency and maintainability:\n\n- **typia Library**: \n ```typescript\n import typia from "typia";\n ```\n\n- **API SDK Functions**: \n ```typescript\n import api from "@ORGANIZATION/PROJECT-api";\n ```\n\n- **DTO Types**: \n ```typescript\n import { DtoName } from "@ORGANIZATION/PROJECT-api/lib/structures/DtoName";\n ```\n - Example: `import { IShoppingSeller } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSeller";`\n - Import each DTO type individually with explicit naming\n - Follow the exact path structure: `@ORGANIZATION/PROJECT-api/lib/structures/`\n\n- **Test Validation Utilities**: \n ```typescript\n import { TestValidator } from "@nestia/e2e";\n ```\n\n**Import Organization Requirements:**\n- Group imports in the following order: typia, API SDK, DTO types, TestValidator\n- Maintain alphabetical ordering within each group\n- Use explicit imports rather than wildcard imports for better type safety\n- Ensure all necessary types are imported before function implementation\n- Verify import paths match exactly with the project structure\n\n**Import Example:**\n```typescript\nimport { TestValidator } from "@nestia/e2e";\nimport typia from "typia";\n\nimport api from "@ORGANIZATION/PROJECT-api";\nimport { IShoppingCustomer } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCustomer";\nimport { IShoppingSale } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSale";\nimport { IShoppingSeller } from "@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSeller";\n```\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 typia from "typia";\n\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 typia from "typia";\n\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";\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/`. Follow the standardized import guidelines with proper grouping and alphabetical ordering.\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- **CRITICAL**: Never use `// @ts-expect-error` comments when testing error cases. These functions test **runtime errors**, not compilation errors. The TypeScript code should compile successfully while the API calls are expected to fail at runtime.\n\n### 8.4. Error Test Example\n\n```typescript\nimport { TestValidator } from "@nestia/e2e";\n\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- **IMPORTANT**: Never add `// @ts-expect-error` comments - error validation functions handle runtime errors while maintaining TypeScript type safety\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- [ ] Do import statements follow the standardized guidelines (typia, API SDK, DTO types, TestValidator)?\n- [ ] Are error test cases written without `// @ts-expect-error` comments?\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 without TypeScript error suppression comments?\n- [ ] Is business logic completeness guaranteed?\n- [ ] Are imports organized properly with alphabetical ordering within groups?\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.'
10449
+ }, {
10450
+ id: v4(),
10451
+ created_at: (new Date).toISOString(),
10452
+ type: "assistantMessage",
10453
+ 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.artifacts.dto), "```", "", "## API (SDK) Functions", "```json", JSON.stringify(props.artifacts.sdk), "```", "", "## E2E Mockup Functions", "```json", JSON.stringify(props.artifacts.e2e), "```", "" ].join("\n")
10454
+ } ];
10455
+
10456
+ async function orchestrateTestWrite(ctx, scenarios) {
10457
+ const start = new Date;
10458
+ let complete = 0;
10459
+ const events = await Promise.all(scenarios.map((async scenario => {
10460
+ const code = await process(ctx, scenario);
10461
+ const event = {
10462
+ type: "testWrite",
10463
+ created_at: start.toISOString(),
10464
+ filename: `test/features/api/${code.domain}/${scenario.functionName}.ts`,
10465
+ content: code.content,
10466
+ completed: ++complete,
10467
+ total: scenarios.length,
10468
+ step: ctx.state().interface?.step ?? 0
10469
+ };
10470
+ ctx.dispatch(event);
10471
+ return event;
10472
+ })));
10473
+ return events;
10474
+ }
10475
+
10476
+ async function process(ctx, scenario) {
10477
+ const pointer = {
10478
+ value: null
10479
+ };
10480
+ const artifacts = await compileTestScenario(ctx, scenario);
10481
+ const agentica = new MicroAgentica({
10482
+ model: ctx.model,
10483
+ vendor: ctx.vendor,
10484
+ config: {
10485
+ ...ctx.config ?? {}
10486
+ },
10487
+ histories: transformTestWriteHistories({
10488
+ scenario,
10489
+ artifacts
10490
+ }),
10491
+ controllers: [ createApplication({
10492
+ model: ctx.model,
10493
+ build: next => {
10494
+ pointer.value = next;
10495
+ }
10496
+ }) ],
10497
+ tokenUsage: ctx.usage()
10498
+ });
10499
+ enforceToolCall(agentica);
10500
+ await agentica.conversate("Create e2e test functions.");
10501
+ if (pointer.value === null) throw new Error("Failed to create test code.");
10502
+ return pointer.value;
10503
+ }
10504
+
10505
+ function createApplication(props) {
10506
+ assertSchemaModel(props.model);
10507
+ const application = collection$1[props.model];
10508
+ return {
10509
+ protocol: "class",
10510
+ name: "Create Test Code",
10511
+ application,
10512
+ execute: {
10513
+ createTestCode: next => {
10514
+ props.build(next);
10515
+ }
10516
+ }
10517
+ };
10518
+ }
10519
+
10520
+ const claude$1 = {
10521
+ model: "claude",
10522
+ options: {
10523
+ reference: true,
10524
+ separate: null
10525
+ },
10526
+ functions: [ {
10527
+ name: "createTestCode",
10528
+ parameters: {
10529
+ description: "Current Type: {@link ICreateTestCodeProps}",
10530
+ type: "object",
10531
+ properties: {
10532
+ scenario: {
10533
+ title: "Strategic approach for test implementation",
10534
+ 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.",
10535
+ type: "string"
10536
+ },
10537
+ domain: {
10538
+ title: "Functional domain classification for test organization",
10539
+ 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',
10540
+ type: "string"
10541
+ },
10542
+ content: {
10543
+ title: "Complete TypeScript E2E test implementation",
10544
+ description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
10545
+ type: "string"
10546
+ }
10547
+ },
10548
+ required: [ "scenario", "domain", "content" ],
10549
+ additionalProperties: false,
10550
+ $defs: {}
10551
+ },
10552
+ validate: (() => {
10553
+ const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
10554
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
10555
+ path: _path + ".scenario",
10556
+ expected: "string",
10557
+ value: input.scenario
10558
+ }), "string" === typeof input.domain || _report(_exceptionable, {
10559
+ path: _path + ".domain",
10560
+ expected: "string",
10561
+ value: input.domain
10562
+ }), "string" === typeof input.content || _report(_exceptionable, {
10563
+ path: _path + ".content",
10564
+ expected: "string",
10565
+ value: input.content
10566
+ }) ].every((flag => flag));
10567
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
10568
+ let errors;
10569
+ let _report;
10570
+ return input => {
10571
+ if (false === __is(input)) {
10572
+ errors = [];
10573
+ _report = __typia_transform__validateReport._validateReport(errors);
10574
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
10575
+ path: _path + "",
10576
+ expected: "ICreateTestCodeProps",
10577
+ value: input
10578
+ })) && _vo0(input, _path + "", true) || _report(true, {
10579
+ path: _path + "",
10580
+ expected: "ICreateTestCodeProps",
10581
+ value: input
10582
+ }))(input, "$input", true);
10583
+ const success = 0 === errors.length;
10584
+ return success ? {
10585
+ success,
10586
+ data: input
10587
+ } : {
10588
+ success,
10589
+ errors,
10590
+ data: input
10591
+ };
10592
+ }
10593
+ return {
10594
+ success: true,
10595
+ data: input
10596
+ };
10597
+ };
10598
+ })()
10599
+ } ]
10600
+ };
10601
+
10602
+ const collection$1 = {
10603
+ chatgpt: {
10604
+ model: "chatgpt",
10605
+ options: {
10606
+ reference: true,
10607
+ strict: false,
10608
+ separate: null
10609
+ },
10610
+ functions: [ {
10611
+ name: "createTestCode",
10612
+ parameters: {
10613
+ description: "Current Type: {@link ICreateTestCodeProps}",
10614
+ type: "object",
10615
+ properties: {
10616
+ scenario: {
10617
+ title: "Strategic approach for test implementation",
10618
+ 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.",
10619
+ type: "string"
10620
+ },
10621
+ domain: {
10622
+ title: "Functional domain classification for test organization",
10623
+ 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',
10624
+ type: "string"
10625
+ },
10626
+ content: {
10627
+ title: "Complete TypeScript E2E test implementation",
10628
+ description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following",
10629
+ type: "string"
10630
+ }
10631
+ },
10632
+ required: [ "scenario", "domain", "content" ],
10633
+ additionalProperties: false,
10634
+ $defs: {}
10635
+ },
10636
+ validate: (() => {
10637
+ const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
10638
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
10639
+ path: _path + ".scenario",
10640
+ expected: "string",
10641
+ value: input.scenario
10642
+ }), "string" === typeof input.domain || _report(_exceptionable, {
10643
+ path: _path + ".domain",
10478
10644
  expected: "string",
10479
- value: input.purpose
10645
+ value: input.domain
10646
+ }), "string" === typeof input.content || _report(_exceptionable, {
10647
+ path: _path + ".content",
10648
+ expected: "string",
10649
+ value: input.content
10480
10650
  }) ].every((flag => flag));
10481
10651
  const __is = input => "object" === typeof input && null !== input && _io0(input);
10482
10652
  let errors;
@@ -10487,11 +10657,11 @@ const collection$1 = {
10487
10657
  _report = __typia_transform__validateReport._validateReport(errors);
10488
10658
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
10489
10659
  path: _path + "",
10490
- expected: "IAutoBeTestScenarioApplication.IProps",
10660
+ expected: "ICreateTestCodeProps",
10491
10661
  value: input
10492
10662
  })) && _vo0(input, _path + "", true) || _report(true, {
10493
10663
  path: _path + "",
10494
- expected: "IAutoBeTestScenarioApplication.IProps",
10664
+ expected: "ICreateTestCodeProps",
10495
10665
  value: input
10496
10666
  }))(input, "$input", true);
10497
10667
  const success = 0 === errors.length;
@@ -10524,199 +10694,44 @@ const collection$1 = {
10524
10694
  separate: null
10525
10695
  },
10526
10696
  functions: [ {
10527
- name: "makeScenario",
10697
+ name: "createTestCode",
10528
10698
  parameters: {
10529
10699
  type: "object",
10530
10700
  properties: {
10531
- scenarioGroups: {
10532
- type: "array",
10533
- items: {
10534
- type: "object",
10535
- properties: {
10536
- endpoint: {
10537
- type: "object",
10538
- properties: {
10539
- path: {
10540
- type: "string",
10541
- title: "HTTP path of the API operation",
10542
- 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."
10543
- },
10544
- method: {
10545
- type: "string",
10546
- enum: [ "get", "post", "put", "delete", "patch" ],
10547
- title: "HTTP method of the API operation",
10548
- 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"
10549
- }
10550
- },
10551
- required: [ "path", "method" ],
10552
- description: "Target API endpoint to test.\n\n------------------------------\n\nDescription of the current {@link AutoBeOpenApi.IEndpoint} type:\n\n> API endpoint information.",
10553
- additionalProperties: false
10554
- },
10555
- scenarios: {
10556
- type: "array",
10557
- items: {
10558
- type: "object",
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
- },
10564
- functionName: {
10565
- type: "string",
10566
- title: "Descriptive function name derived from the user scenario",
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"
10568
- },
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."
10603
- }
10604
- },
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.",
10607
- additionalProperties: false
10608
- },
10609
- title: "Array of test scenarios",
10610
- description: "Array of test scenarios."
10611
- }
10612
- },
10613
- required: [ "endpoint", "scenarios" ],
10614
- description: "Current Type: {@link IAutoBeTestScenarioApplication.IScenarioGroup}",
10615
- additionalProperties: false
10616
- },
10617
- title: "Array of test scenario groups",
10618
- description: "Array of test scenario groups."
10701
+ scenario: {
10702
+ type: "string",
10703
+ title: "Strategic approach for test implementation",
10704
+ 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."
10705
+ },
10706
+ domain: {
10707
+ type: "string",
10708
+ title: "Functional domain classification for test organization",
10709
+ 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'
10710
+ },
10711
+ content: {
10712
+ type: "string",
10713
+ title: "Complete TypeScript E2E test implementation",
10714
+ description: "Complete TypeScript E2E test implementation.\n\nGenerate fully functional, compilation-error-free test code following"
10619
10715
  }
10620
10716
  },
10621
- required: [ "scenarioGroups" ],
10622
- description: " Properties containing the endpoints and test scenarios.\n\n------------------------------\n\nCurrent Type: {@link IAutoBeTestScenarioApplication.IProps}",
10717
+ required: [ "scenario", "domain", "content" ],
10718
+ description: "Current Type: {@link ICreateTestCodeProps}",
10623
10719
  additionalProperties: false
10624
10720
  },
10625
- description: "Make test scenarios for the given endpoints.",
10626
10721
  validate: (() => {
10627
- const _io0 = input => Array.isArray(input.scenarioGroups) && input.scenarioGroups.every((elem => "object" === typeof elem && null !== elem && _io1(elem)));
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))));
10629
- const _io2 = input => "string" === typeof input.path && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method);
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",
10639
- value: elem
10640
- })) && _vo1(elem, _path + ".scenarioGroups[" + _index4 + "]", _exceptionable) || _report(_exceptionable, {
10641
- path: _path + ".scenarioGroups[" + _index4 + "]",
10642
- expected: "IAutoBeTestScenarioApplication.IScenarioGroup",
10643
- value: elem
10644
- }))).every((flag => flag)) || _report(_exceptionable, {
10645
- path: _path + ".scenarioGroups",
10646
- expected: "Array<IAutoBeTestScenarioApplication.IScenarioGroup>",
10647
- value: input.scenarioGroups
10648
- }) ].every((flag => flag));
10649
- const _vo1 = (input, _path, _exceptionable = true) => [ ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
10650
- path: _path + ".endpoint",
10651
- expected: "AutoBeOpenApi.IEndpoint",
10652
- value: input.endpoint
10653
- })) && _vo2(input.endpoint, _path + ".endpoint", _exceptionable) || _report(_exceptionable, {
10654
- path: _path + ".endpoint",
10655
- expected: "AutoBeOpenApi.IEndpoint",
10656
- value: input.endpoint
10657
- }), (Array.isArray(input.scenarios) || _report(_exceptionable, {
10658
- path: _path + ".scenarios",
10659
- expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10660
- value: input.scenarios
10661
- })) && input.scenarios.map(((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
10662
- path: _path + ".scenarios[" + _index5 + "]",
10663
- expected: "IAutoBeTestScenarioApplication.IScenario",
10664
- value: elem
10665
- })) && _vo3(elem, _path + ".scenarios[" + _index5 + "]", _exceptionable) || _report(_exceptionable, {
10666
- path: _path + ".scenarios[" + _index5 + "]",
10667
- expected: "IAutoBeTestScenarioApplication.IScenario",
10668
- value: elem
10669
- }))).every((flag => flag)) || _report(_exceptionable, {
10670
- path: _path + ".scenarios",
10671
- expected: "Array<IAutoBeTestScenarioApplication.IScenario>",
10672
- value: input.scenarios
10673
- }) ].every((flag => flag));
10674
- const _vo2 = (input, _path, _exceptionable = true) => [ "string" === typeof input.path || _report(_exceptionable, {
10675
- path: _path + ".path",
10676
- expected: "string",
10677
- value: input.path
10678
- }), "get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method || _report(_exceptionable, {
10679
- path: _path + ".method",
10680
- expected: '("delete" | "get" | "patch" | "post" | "put")',
10681
- value: input.method
10682
- }) ].every((flag => flag));
10683
- const _vo3 = (input, _path, _exceptionable = true) => [ "string" === typeof input.draft || _report(_exceptionable, {
10684
- path: _path + ".draft",
10722
+ const _io0 = input => "string" === typeof input.scenario && "string" === typeof input.domain && "string" === typeof input.content;
10723
+ const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.scenario || _report(_exceptionable, {
10724
+ path: _path + ".scenario",
10685
10725
  expected: "string",
10686
- value: input.draft
10687
- }), "string" === typeof input.functionName || _report(_exceptionable, {
10688
- path: _path + ".functionName",
10726
+ value: input.scenario
10727
+ }), "string" === typeof input.domain || _report(_exceptionable, {
10728
+ path: _path + ".domain",
10689
10729
  expected: "string",
10690
- value: input.functionName
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",
10730
+ value: input.domain
10731
+ }), "string" === typeof input.content || _report(_exceptionable, {
10732
+ path: _path + ".content",
10718
10733
  expected: "string",
10719
- value: input.purpose
10734
+ value: input.content
10720
10735
  }) ].every((flag => flag));
10721
10736
  const __is = input => "object" === typeof input && null !== input && _io0(input);
10722
10737
  let errors;
@@ -10727,11 +10742,11 @@ const collection$1 = {
10727
10742
  _report = __typia_transform__validateReport._validateReport(errors);
10728
10743
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
10729
10744
  path: _path + "",
10730
- expected: "IAutoBeTestScenarioApplication.IProps",
10745
+ expected: "ICreateTestCodeProps",
10731
10746
  value: input
10732
10747
  })) && _vo0(input, _path + "", true) || _report(true, {
10733
10748
  path: _path + "",
10734
- expected: "IAutoBeTestScenarioApplication.IProps",
10749
+ expected: "ICreateTestCodeProps",
10735
10750
  value: input
10736
10751
  }))(input, "$input", true);
10737
10752
  const success = 0 === errors.length;
@@ -10776,7 +10791,7 @@ const orchestrateTest = ctx => async props => {
10776
10791
  return history;
10777
10792
  }
10778
10793
  const {scenarios} = await orchestrateTestScenario(ctx);
10779
- const codes = await orchestrateTestProgress(ctx, scenarios);
10794
+ const codes = await orchestrateTestWrite(ctx, scenarios);
10780
10795
  const correct = await orchestrateTestCorrect(ctx, codes, scenarios);
10781
10796
  const history = {
10782
10797
  type: "test",
@@ -10791,7 +10806,10 @@ const orchestrateTest = ctx => async props => {
10791
10806
  ctx.dispatch({
10792
10807
  type: "testComplete",
10793
10808
  created_at: start.toISOString(),
10794
- files: correct.files,
10809
+ files: correct.files.map((f => ({
10810
+ [f.location]: f.content
10811
+ }))).reduce(((acc, cur) => Object.assign(acc, cur)), {}),
10812
+ compiled: correct.result,
10795
10813
  step: ctx.state().interface?.step ?? 0
10796
10814
  });
10797
10815
  ctx.state().test = history;
@@ -12300,7 +12318,7 @@ class AutoBeAgent {
12300
12318
  ...Object.fromEntries(this.state_.analyze ? Object.entries(this.state_.analyze.files).map((([key, value]) => [ `docs/analysis/${key.split("/").at(-1)}`, value ])) : []),
12301
12319
  ...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) ] ] : []),
12302
12320
  ...this.state_.interface ? this.state_.interface.files : {},
12303
- ...this.state_.test ? this.state_.test.files : {},
12321
+ ...this.state_.test ? Object.fromEntries(this.state_.test.files.map((f => [ f.location, f.content ]))) : {},
12304
12322
  ...this.state_.realize ? this.state_.realize.files : {},
12305
12323
  "autobe/histories.json": JSON.stringify(this.histories_, null, 2),
12306
12324
  "autobe/tokenUsage.json": JSON.stringify(this.getTokenUsage(), null, 2),