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

fix: update getUidFilter to return 0 instead of undefined for All context #15098

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

espenhalsen
Copy link
Member

@espenhalsen espenhalsen commented Mar 28, 2025

Description

To fix the 400 undefined error in the Dashboard, a solution proposed is to change the return to 0; instead for having it as undefined;. The backend when proposed with 0; instead of undefined; gives an return which then is correct.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • Bug Fixes
    • Improved dashboard filtering behavior: when "All" is selected, the function now returns 0 to exclude specific user identifiers for a streamlined search experience.

Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

📝 Walkthrough

Walkthrough

The pull request updates the function getUidFilter in the dashboard’s filter utilities. The changes remove undefined from the function’s return type, now allowing only number or SelectedContextType. Additionally, when the selectedContext is SelectedContextType.All, the function now returns 0 instead of undefined, adjusting the logic for signaling the backend. Corresponding test cases have also been updated to reflect this change in expected behavior.

Changes

File(s) Change Summary
frontend/dashboard/utils/filterUtils/... Updated the getUidFilter signature by removing undefined from the return type and modified the return value for SelectedContextType.All to 0.
frontend/dashboard/utils/filterUtils/... Modified test case for getUidFilter to expect 0 instead of undefined when selectedContext is All.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added area/dashboard Area: Related to the dashboard application solution/studio/designer Issues related to the Altinn Studio Designer solution. frontend labels Mar 28, 2025
@espenhalsen espenhalsen linked an issue Mar 28, 2025 that may be closed by this pull request
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

🧹 Nitpick comments (1)
frontend/dashboard/utils/filterUtils/filterUtils.test.ts (1)

4-41: Consider adding a test comment to explain the reasoning behind the change.

While the test changes are correct, adding a comment explaining why 0 is used instead of undefined would help future developers understand the rationale behind this change (to prevent the 400 undefined error mentioned in the PR description).

 describe('getUidFilter', () => {
+  // Returns 0 instead of undefined for All context to prevent 400 undefined errors when querying the backend
   it('should return number zero when selectedContext is All', () => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f314420 and c187bb8.

📒 Files selected for processing (1)
  • frontend/dashboard/utils/filterUtils/filterUtils.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: CodeQL
  • GitHub Check: Testing
🔇 Additional comments (3)
frontend/dashboard/utils/filterUtils/filterUtils.test.ts (3)

5-5: Test description correctly updated to reflect new behavior.

The test description has been appropriately updated to match the new implementation where getUidFilter returns 0 instead of undefined when the selectedContext is All. This change aligns with the PR objectives to fix the 400 undefined error.


12-12: Assertion correctly changed to match updated implementation.

The assertion has been updated to expect 0 instead of undefined, which correctly verifies the new behavior of the getUidFilter function. This change is consistent with the PR objective of returning 0 instead of undefined for the All context.


1-41:

✅ Verification successful

Verify integration with the updated implementation file.

The test changes look good, but ensure they align with the corresponding implementation changes in filterUtils.ts. The PR mentions changing the return type to remove undefined and making the function return 0 instead of undefined for the All context.


🏁 Script executed:

#!/bin/bash
# Check the implementation of getUidFilter in filterUtils.ts
fd --type f filterUtils.ts --exec cat {} \; | grep -A 20 "export const getUidFilter"

Length of output: 506


Integration Verified – Tests align perfectly with the updated implementation.

  • The test for SelectedContextType.All now correctly expects a return value of 0, matching the new implementation.
  • The tests for Self and custom contexts return the expected userId and organization ID respectively.
  • All changes in behavior per the PR (removing undefined for the All context) have been effectively integrated.

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.87%. Comparing base (4613b77) to head (c187bb8).
Report is 35 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15098   +/-   ##
=======================================
  Coverage   95.87%   95.87%           
=======================================
  Files        1992     1992           
  Lines       25881    25881           
  Branches     2921     2921           
=======================================
  Hits        24814    24814           
  Misses        801      801           
  Partials      266      266           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dashboard Area: Related to the dashboard application frontend solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

400 Bad Request on dashboard
1 participant