Skip to content

Update mock api#33

Open
spusala-sap wants to merge 1 commit intomainfrom
feature/update-mock-api
Open

Update mock api#33
spusala-sap wants to merge 1 commit intomainfrom
feature/update-mock-api

Conversation

@spusala-sap
Copy link
Copy Markdown
Contributor

@spusala-sap spusala-sap commented Mar 4, 2026

Resolves #32

Summary by CodeRabbit

  • Chores
    • Updated mock API endpoint structure for user information retrieval
    • Enhanced system operations with recovery action handling
    • Revised user data schema and field naming conventions

neilmcclelland
neilmcclelland previously approved these changes Mar 5, 2026
Ayurshi-Singh
Ayurshi-Singh previously approved these changes Mar 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 19, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3763afb-7b90-46b6-8fe0-f9e1a87087c7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Mock API endpoints and data structures are updated to align with actual API specifications. A user endpoint route is modified to remove optional parameters, response schemas are restructured with renamed fields, and new conditional handling is added for recovery actions.

Changes

Cohort / File(s) Summary
Route Handler Updates
mock.mjs
Replaced /user/:id? endpoint with /userInfo route; handler now invokes user() without parameters instead of extracting optional id path parameter.
Mock Data Schema Updates
mockServer/mockdata/user.mjs
Changed default export to remove test parameter and simplify to single user object return. Renamed fields: ididentifier, namegivenName/familyName, groupNamerole. Eliminated array-based user generation logic.
System Operations Logic
mockServer/mockdata/systems.mjs
Added conditional branch to handle recoveryActions operation when systemId is provided and keyConfigurationID is absent, returning { canCancel: true, canRetry: false }.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Twitching nose with glee so bright,
Mock endpoints realigned just right,
Fields renamed in harmonious sync,
No more parameter on the brink!
APIs dancing, now in tune,
Beneath the spring's forgiving moon. 🌙

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal (only 'Resolves #32') and does not follow the provided template with required sections like 'What this PR does', 'Special notes', and 'Release note'. Complete the PR description using the template: add 'What this PR does' section explaining the API endpoint changes, include 'Special notes', and provide a 'Release note' section.
Title check ❓ Inconclusive The title 'Update mock api' is vague and generic, lacking specifics about which endpoints were changed and how they now align with the actual API. Improve the title to be more specific, such as 'Update mock API endpoints to sync with actual API' or detail the key changes like 'Update user and recovery endpoints in mock API'.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully updates mock API endpoints (user endpoint, recovery actions, and user data shape) to sync with the actual API, addressing the core requirement to fix out-of-sync mock API issues.
Out of Scope Changes check ✅ Passed All changes are focused on updating mock API files (mock.mjs, systems.mjs, user.mjs) to align with the actual API, with no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
mock.mjs (1)

114-115: Stabilize /userInfo response across requests.

Line 115 regenerates a different user object on each call, which can cause flaky UI assertions and inconsistent state handling. Prefer returning a cached mock user for the server lifecycle.

♻️ Proposed change
+const mockedUserInfo = user();
+
 app.get("/cmk/v1/tenant1-id/userInfo", (req, res) => {
-    res.json(user());
+    res.json(mockedUserInfo);
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mock.mjs` around lines 114 - 115, The handler registered with
app.get("/cmk/v1/tenant1-id/userInfo") calls user() each request which returns a
new object and causes flaky tests; fix by creating a single cached mock user at
module scope (e.g., cachedUser) initialized once (via user() or a factory) and
have the route handler return that cachedUser instead of calling user() on every
request; update any tests that expect idempotent responses to rely on the stable
cachedUser and ensure any deliberate variations are produced by an explicit
endpoint or test helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mockServer/mockdata/user.mjs`:
- Around line 6-7: The givenName field in mockServer/mockdata/user.mjs is using
chance.name() which returns a full name and conflicts with the separate
familyName field; update the givenName assignment to use chance.first() instead
of chance.name() so givenName contains only the first/given name while
familyName remains chance.last().

---

Nitpick comments:
In `@mock.mjs`:
- Around line 114-115: The handler registered with
app.get("/cmk/v1/tenant1-id/userInfo") calls user() each request which returns a
new object and causes flaky tests; fix by creating a single cached mock user at
module scope (e.g., cachedUser) initialized once (via user() or a factory) and
have the route handler return that cachedUser instead of calling user() on every
request; update any tests that expect idempotent responses to rely on the stable
cachedUser and ensure any deliberate variations are produced by an explicit
endpoint or test helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f6f07055-9087-4047-8efe-4be387bc0c08

📥 Commits

Reviewing files that changed from the base of the PR and between f3528fe and f4c3a68.

📒 Files selected for processing (3)
  • mock.mjs
  • mockServer/mockdata/systems.mjs
  • mockServer/mockdata/user.mjs

Comment on lines +6 to +7
givenName: chance.name(),
familyName: chance.last(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In chance@1.1.13, what is the return format of chance.name() vs chance.first(), and which is appropriate for a "givenName" field?

💡 Result:

  • chance.name() returns a full name string (e.g., "Dafi Vatemi", optionally including middle/prefix/suffix). [1]
  • chance.first() returns a first/given name string only (e.g., "Leila"). [2]

For a "givenName" field, use chance.first(). [2]

Sources: [1] [2]


Use chance.first() for givenName instead of chance.name().

Line 6 uses chance.name(), which returns a full name string. This creates a schema mismatch since givenName should contain only the given/first name, not a full name that duplicates the separate familyName on line 7.

Proposed fix
 export default () => {
     return {
         identifier: chance.guid(),
-        givenName: chance.name(),
+        givenName: chance.first(),
         familyName: chance.last(),
         email: chance.email(),
         role: chance.pickone(['KEY_ADMINISTRATOR', 'TENANT_ADMINISTRATOR', 'TENANT_AUDITOR']),
     };
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
givenName: chance.name(),
familyName: chance.last(),
export default () => {
return {
identifier: chance.guid(),
givenName: chance.first(),
familyName: chance.last(),
email: chance.email(),
role: chance.pickone(['KEY_ADMINISTRATOR', 'TENANT_ADMINISTRATOR', 'TENANT_AUDITOR']),
};
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mockServer/mockdata/user.mjs` around lines 6 - 7, The givenName field in
mockServer/mockdata/user.mjs is using chance.name() which returns a full name
and conflicts with the separate familyName field; update the givenName
assignment to use chance.first() instead of chance.name() so givenName contains
only the first/given name while familyName remains chance.last().

@spusala-sap spusala-sap force-pushed the feature/update-mock-api branch from f4c3a68 to bb8418b Compare March 25, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Update mock api

3 participants