Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(e2e): Fix tests after FastEndpoints casing change #1432

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

oskogstad
Copy link
Collaborator

@oskogstad oskogstad commented Nov 10, 2024

Summary by CodeRabbit

  • Bug Fixes
    • Corrected case sensitivity in error handling for process filter and GUI actions in test cases, ensuring accurate validation against the API response.
  • Chores
    • Removed unnecessary blank lines for cleaner code in the test scripts.

@oskogstad oskogstad requested a review from a team as a code owner November 10, 2024 19:03
Copy link
Contributor

coderabbitai bot commented Nov 10, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces modifications to error handling in two test files. In dialogSearch.js, the property name in the error response is changed from "Process" to "process" to ensure case sensitivity in assertions. Additionally, a test case for "List with org filter" is commented out. In dialogCreateInvalidActionCount.js, the property name checked in the error response is updated from GuiActions to guiActions, and unnecessary blank lines are removed. These changes aim to align the tests with the expected API response structure.

Changes

File Path Change Summary
tests/k6/tests/enduser/dialogSearch.js Changed error response property from "Process" to "process"; commented out "List with org filter" test case.
tests/k6/tests/serviceowner/dialogCreateInvalidActionCount.js Updated error response property from GuiActions to guiActions; removed unnecessary blank lines.

Possibly related PRs

Suggested reviewers

  • arealmaas
  • MagnusSandgren

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (3)
tests/k6/tests/serviceowner/dialogCreateInvalidActionCount.js (2)

8-9: Fix typo in error message.

There's a typo in the error message: 'reponse' should be 'response'.

-expect(r.json(), 'reponse').to.have.property('errors');
+expect(r.json(), 'response').to.have.property('errors');

Line range hint 14-24: Consider improving code maintainability.

The helper function could be improved in the following ways:

  1. Use a for loop instead of a while loop for better readability
  2. Consider using an enum or constants for action types
 let createDialogWithGuiActions = function(numActions, actionType) {
     let dialog = dialogToInsert();
     dialog.guiActions = [];
-    while (numActions--) {
-        let id = `foo${numActions}`;
+    for (let i = 0; i < numActions; i++) {
+        let id = `foo${i}`;
         dialog.guiActions.push(
             { action: id, title: [{ languageCode: "nb", value: id }], url: `foo:${id}`, priority: actionType }
         )
     }
     return dialog;
 };

Consider adding action type constants at the top of the file:

const ACTION_TYPES = {
    PRIMARY: 'primary',
    SECONDARY: 'secondary',
    TERTIARY: 'tertiary'
};
tests/k6/tests/enduser/dialogSearch.js (1)

Line range hint 264-274: Track the disabled test case.

The test for org filter functionality is commented out due to incomplete TTD handling. While the comment provides context, it would be beneficial to track this technical debt to ensure it's not forgotten.

Would you like me to help create a GitHub issue to track the re-enabling of this test case once TTD handling is properly implemented?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 647816c and 3c53b8c.

📒 Files selected for processing (2)
  • tests/k6/tests/enduser/dialogSearch.js (1 hunks)
  • tests/k6/tests/serviceowner/dialogCreateInvalidActionCount.js (1 hunks)
🔇 Additional comments (4)
tests/k6/tests/serviceowner/dialogCreateInvalidActionCount.js (2)

11-11: LGTM: Property casing update aligns with FastEndpoints changes.

The change from GuiActions to guiActions in the error response check correctly aligns with the FastEndpoints casing changes mentioned in the PR title.


Line range hint 31-39: LGTM: Test cases are well-structured and comprehensive.

The test cases effectively cover validation scenarios for different action types and counts, ensuring the API correctly rejects invalid combinations.

tests/k6/tests/enduser/dialogSearch.js (2)

207-207: LGTM: Error property case change aligns with FastEndpoints conventions.

The change from "Process" to "process" in the error property access correctly aligns with the FastEndpoints casing conventions.


207-207: Verify consistent error property casing across test files.

Let's ensure other test files are consistently using the new lowercase casing for error properties.

✅ Verification successful

Property casing is consistent across test files

Based on the comprehensive search results, all error property assertions in the test files are using consistent lowercase casing for error properties. The reviewed line is consistent with the rest of the codebase where:

  • Error property checks use lowercase: .property('errors')
  • Nested error properties like process and guiActions also use lowercase
  • No instances of uppercase error property names were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find potential inconsistent error property casing in test files
# Look for error property access patterns that might need updating

# Search for uppercase error property access
rg -g '*.js' '"[A-Z][a-zA-Z]*".*errors'

# Search for specific process error property with potential wrong casing
rg -g '*.js' 'errors.*Process'

Length of output: 74


Script:

#!/bin/bash
# Let's try a more comprehensive search for error property patterns in test files

# Search for any error property access patterns
rg -g '*.js' 'errors.*property|expect.*errors' -B 1 -A 1

# Search for any error-related assertions
rg -g '*.js' 'expect.*json\(\)\.errors' -B 1 -A 1

# Look specifically in the test directory
rg -g '*.js' 'errors' tests/ -B 1 -A 1

Length of output: 10851

@oskogstad oskogstad changed the title chore(e2e): Fix e2e test after FastEndpoints casing change chore(e2e): Fix tests after FastEndpoints casing change Nov 10, 2024
Copy link

@oskogstad oskogstad merged commit 3bac598 into main Nov 11, 2024
4 checks passed
@oskogstad oskogstad deleted the chore/fix-e2e-fastendpoints-casing-change branch November 11, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants