Add tests for shared components (FollowButton, PolicyActions, LabeledIcon, MessageBanner, TitledSectionCard, PaginatedItemsCard) - #2226
Open
olitreadwell wants to merge 3 commits into
Conversation
A logged-out visitor could click a Follow button (bill, profile, or ballot question) and nothing would happen. The button called the Firestore follow/unfollow write with an undefined uid, which fails silently for a signed-out user, so the click looked broken (codeforboston#2059). Following only makes sense for a signed-in user. This makes the button send a logged-out visitor to /login, with a redirect back to the current page, the same pattern the app already uses for other auth-only pages (see requireAuth in components/auth/service.tsx). - BaseFollowButton now checks for a uid before calling the follow or unfollow action. If there is no uid, it pushes to /login?redirect=<current path> instead. - Added a test that covers both cases: a logged-out click redirects to login without calling followAction, and a logged-in click still calls followAction as before. - Split the onClick assignment into two statements instead of a nested ternary, per an AI code review pass (open-code-review): the repo's rules disallow nested ternaries. Behaviour is unchanged.
…ny page The testimony detail page has its own separate Follow/Unfollow list item (PolicyActions), independent of BaseFollowButton. It had the same bug: a logged-out visitor clicking "Follow" called followBill or followBallotQuestion with an undefined uid, which writes to a Firestore path keyed on "undefined" and fails silently, so the click looked broken. Reproduced with a test that mocks a logged-out user and confirms the click called followBallotQuestion(undefined, ...) without any redirect. - handleClick now checks for a uid before calling FollowClick or UnfollowClick. If there is no uid, it pushes to /login?redirect=<current path>, the same pattern BaseFollowButton uses. - Added a test that covers the logged-out case: the click redirects to login and never calls followBallotQuestion or followBill.
olitreadwell
requested review from
Mephistic,
alexjball,
kiminkim724,
mertbagt,
mvictor55,
nesanders,
sashamaryl and
timblais
as code owners
August 26, 2026 15:10
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds unit tests for the shared components that back the testimony, bill, and committee pages:
FollowButton,PolicyActions,LabeledIcon,MessageBanner,TitledSectionCard, andPaginatedItemsCard. The tests lock in the logged-out Follow redirect, the follow/unfollow confirmation modals, and presentational rendering for the shared components.Checklist
firestore.indexes.json(Please do not only create indexes through the Firebase Web UI, even though the error messages may reccommend it - indexes created this way may be obliterated by subsequent deploys)Screenshots
N/A. Test-only change.
Known issues
N/A
Steps to test/reproduce
git fetch https://github.com/olitreadwell/maple.git test/shared-components-coveragegit checkout FETCH_HEADyarn install --frozen-lockfileyarn jest components/shared/ components/testimony/TestimonyDetailPage/PolicyActions.test.tsx --runInBandAI assistance
Drafted with AI assistance. The gap was found and verified against the current code, the change was verified before opening, and this diff was reviewed line by line.