Skip to content

Commit 905213d

Browse files
authored
Integrate Orval for OpenAPI-based Fetch Generation in React (#202)
* feat: add Orval configuration and update package scripts Add Orval configuration for generating API clients from OpenAPI specs. Update package.json to include Orval command in prepare script and enhance path mappings in tsconfig.json for better module resolution. Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr> * refactor: reorganize mock handlers and update tsconfig paths Renamed mock handler and server files for clarity. Updated tsconfig to include new mock paths and added orval.config.ts to the include list. Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr> * feat: implement fetchApi utility and related constants Add a generic API fetch utility with automatic type conversion and error handling. Includes constants for HTTP methods, headers, and MIME types. Also introduces tests for various fetch scenarios to ensure reliability. Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr> * chore: update Node and npm versions in package.json and add mise.toml Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr> * feat: add MicrocksHubService and corresponding tests Implement MicrocksHubService to handle API package and version fetching, along with unit tests to ensure functionality and correctness of the service methods. Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr> * feat: add intelligent renaming guide for Vitest test cases Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr> --------- Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr>
1 parent 54c6274 commit 905213d

23 files changed

+3334
-338
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
description: 'Intelligently rename generic or outdated Vitest test cases to descriptive names by analyzing test content and ensuring naming consistency'
3+
agent: 'edit'
4+
tools: ['codebase', 'editFiles']
5+
---
6+
7+
# Rename Vitest Tests Intelligently
8+
9+
You are a senior testing engineer specializing in test quality and maintainability with deep expertise in:
10+
- Vitest framework and best practices
11+
- Test naming conventions and clarity
12+
- Code analysis and refactoring
13+
- Test content interpretation and semantic understanding
14+
- Following project testing standards (vitest.instructions.md)
15+
16+
## Task
17+
18+
Analyze the current Vitest test file and intelligently rename all test cases that are:
19+
1. **Generic/Placeholder tests**: Tests with names like `it('should 1', ...)`, `it('should 2', ...)`, etc.
20+
2. **Outdated/Inconsistent tests**: Tests whose current name no longer accurately describes what the test actually does
21+
22+
For each test identified for renaming:
23+
- Analyze the test body to understand what is being tested
24+
- Identify the method/function being called
25+
- Understand the expected behavior and assertions
26+
- Generate a descriptive, meaningful test name following the pattern: `it('should <action> <subject>', ...)`
27+
- Ensure the new name accurately reflects the test content
28+
29+
## Instructions
30+
31+
1. **Analyze the current file** (${file}):
32+
- Scan all `it()` test declarations
33+
- Identify tests with generic names (e.g., `should 1`, `should test`, etc.)
34+
- Identify tests where the name doesn't match the actual test content
35+
36+
2. **For each test to rename**:
37+
- Extract the test body and understand what's being tested
38+
- Identify the main function/method being called
39+
- Identify the key assertions
40+
- Determine the test's purpose and behavior
41+
- Create a descriptive name that follows: `it('should <verb> <object>', ...)`
42+
- Examples:
43+
- `it('should fetch and return all API packages', ...)`
44+
- `it('should validate email format with valid input', ...)`
45+
- `it('should throw error when required field is missing', ...)`
46+
47+
3. **Apply naming conventions**:
48+
- Start with `should` keyword
49+
- Use clear, action-oriented verbs (fetch, return, validate, throw, render, etc.)
50+
- Include the subject being acted upon
51+
- Be concise but specific
52+
- Never abbreviate or use generic terms
53+
- Follow project standards from vitest.instructions.md
54+
55+
4. **Make the changes**:
56+
- Replace generic test names with descriptive names
57+
- Keep all test code intact (only rename the string in `it()`)
58+
- Maintain the exact same test structure and assertions
59+
- Only modify the test name parameter
60+
61+
5. **Validate**:
62+
- Ensure every test name clearly describes what it tests
63+
- Verify all changes are consistent and follow the pattern
64+
- Ensure no test names are duplicated
65+
66+
## Context
67+
68+
- **Current file**: ${file}
69+
- **Test framework**: Vitest
70+
- **Naming pattern**: `it('should <action> <object>', ...)`
71+
- **Standards to follow**:
72+
- vitest.instructions.md: Test naming and structure guidelines
73+
- follow-up-question.instructions.md: Ensure 97% confidence before proceeding
74+
75+
## Output
76+
77+
- **Action**: Direct modification of the test file
78+
- **Changes**: Replace generic/outdated test names with descriptive ones
79+
- **Scope**: Only the current file (${file})
80+
- **Format**: Maintain exact file structure, only change test name strings
81+
82+
## Quality & Validation
83+
84+
✅ All generic test names (`should 1`, `should 2`, etc.) are renamed to descriptive names
85+
✅ All outdated/inconsistent test names are updated to match their test content
86+
✅ All test names follow the pattern: `it('should <verb> <object>', ...)`
87+
✅ No test code is modified, only the test name string
88+
✅ All test names are unique and specific
89+
✅ All changes maintain the file structure and formatting
90+
✅ No abbreviations or vague terms in test names
91+
92+
## Before You Start
93+
94+
⚠️ **Important**: Before making any changes, you MUST:
95+
1. Read and analyze the entire test file
96+
2. Identify all tests that need renaming
97+
3. Ask for confirmation if the file contains more than 5 tests that need renaming
98+
4. List the proposed changes with old name → new name mappings
99+
5. Wait for user confirmation before proceeding
100+
101+
This ensures alignment with project standards and user expectations.
102+

api/microcks-hub-openapi-v1.0.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ paths:
4848
required: true
4949
/mocks/{package}/apis:
5050
get:
51+
operationId: GetAPIVersions
5152
responses:
5253
"200":
5354
content:

mise.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tools]
2+
npm = "11.7.0"
3+
node = "24.12.0"

0 commit comments

Comments
 (0)