Skip to content

Conversation

andypols
Copy link
Contributor

@andypols andypols commented Jul 26, 2025

Summary

This PR fixes a bug where the client silently ignored server-side errors when adding a new repository. As a result, users were led to believe the repository was added successfully, only to see it disappear upon refreshing the page.

Root Cause

The NewRepo.tsx component (src/ui/views/RepoList/Components/NewRepo.tsx) always closed the modal, regardless of whether the server request succeeded or failed.

Fix

Display server errors returned by addRepo in src/ui/services/repo.js.

Extended Cypress tests to:

  • Reproduce the bug.
  • Verify the fix.
  • Upgraded Cypress to version 14.5.2.
  • Added data-testid attributes to improve selector stability in Cypress tests (avoids coupling to CSS/JS changes). These are are also useful in the react unit tests (see note)
  • added a regular (non-admin) user for the cypress tests.
  • added cypress tests to ensure anonymous and regular users cannot add a repository.
  • added a cypress test to ensure an admin can successfully add and delete a repository.
  • added a cypress tests that displays an error if tries to add a duplicate repository.

Notes

Adding unit tests for the React components is desirable but considered out of scope for this PR.

Copy link

netlify bot commented Jul 26, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 33a5995
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/68b040e78158180008bcc3cb

@andypols andypols changed the title Fix display repo add errors fix: display errors when adding a new repo Jul 26, 2025
@github-actions github-actions bot added the fix label Jul 26, 2025
Copy link

codecov bot commented Jul 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.84%. Comparing base (4bf2276) to head (33a5995).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1120      +/-   ##
==========================================
+ Coverage   82.83%   82.84%   +0.01%     
==========================================
  Files          66       66              
  Lines        2784     2787       +3     
  Branches      334      334              
==========================================
+ Hits         2306     2309       +3     
  Misses        431      431              
  Partials       47       47              

☔ 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.

@andypols andypols requested a review from jescalada August 1, 2025 15:43
Copy link
Contributor

@jescalada jescalada left a comment

Choose a reason for hiding this comment

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

@andypols Looks great, thanks for the contribution! 🚀

Our E2E tests are pretty barebones so any improvements here are much appreciated! I just have some minor things to point out - will likely open a few issues for these!

Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

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

Needs a rebase, there are a handful of conflicting/similar changes in main.

I think there are some other cases where the errors aren't displayed that would benefit from similar changes, such as cancelling a push in the dashboard when you are not allowed. That's no doubt a separate issue ;-)

@andypols andypols requested a review from kriswest August 28, 2025 11:14
Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

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

LGTM - couple of minor comments.

The data-testid tags might be worth noting in the testing guide @jescalada is working on in #1147

Co-authored-by: Kris West <[email protected]>
Signed-off-by: Andy Pols <[email protected]>
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.

3 participants