-
Notifications
You must be signed in to change notification settings - Fork 29
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 Finished Announcement banner results link #6373
Conversation
@@ -23,7 +23,7 @@ function FinishedAnnouncementConnector() { | |||
|
|||
const announcement = t('Announcements.FinishedAnnouncement.announcement') | |||
const link = { | |||
href: `${baseUrl}/about/results`, | |||
href: `/projects${baseUrl}/about/results`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link should be using the Next router, which automatically adds the app base path.
If the link doesn’t use the client-side router, you lose all project state when you follow it, including classifier state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base path for internal routing, within the Next app, is set here:
basePath: '/projects', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#6374 fixes the underlying bug in the NavLink
component, which was causing this link to be rendered as an external link.
I've opened #6374 to fix the underlying bug in the Project navigation links pass a Here's an example of a working internal link, from the project introduction. This is the Learn More link. Lines 41 to 47 in 4062f39
|
const link = screen.findByLabelText('Announcements.FinishedAnnouncement.seeResults') | ||
expect(link).exists() | ||
const link = screen.getByRole('link') | ||
expect(link?.getAttribute('href')).to.equal('/projects/zookeeper/galaxy-zoo/about/results') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests don't use next.config.js
, which is why the app base path isn't included in these link URLs.
@@ -22,7 +22,7 @@ function NextRouterStory(Story) { | |||
|
|||
const mockStore = { | |||
project: { | |||
baseUrl: '/projects/zookeeper/galaxy-zoo', | |||
baseUrl: '/zookeeper/galaxy-zoo', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These links have /projects
prepended because the storybook doesn't get the app base path from next.config.js
, so it has to be added by hand.
@shaunanoordin I took a look at both this PR and #6374, and I'm going to merge the latter. It fixes the broken results link and future proofs any other internal links that might've left out StyledAnchor. Thank you for documenting the |
PR Overview
Package: app-project
Fixes #6370
This PR fixes the Finished Announcement banner's "See Results" link.
.exists()
.Testing
Test on app-project, on localhost
Status
Ready for review.
Note: if this gets approved while I'm on vacation, please go ahead and merge+deploy this.