Skip to content

Commit

Permalink
fix(web): map product issues to registration path (#1878)
Browse files Browse the repository at this point in the history
Ensure proper navigation to the _Registration_ section when user clicks
on a registration issues from the drawer by restoring code that was
deleted by mistake when merging master into registration feature branch.
  • Loading branch information
dgdavid authored Jan 9, 2025
2 parents 95e8542 + b30e751 commit 46a4610
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 17 additions & 1 deletion web/src/components/core/IssuesDrawer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ describe("IssuesDrawer", () => {
describe("when there are installation issues", () => {
beforeEach(() => {
mockIssuesList = new IssuesList(
[],
[
{
description: "Registration Fake Issue",
source: 0,
severity: 0,
details: "Registration Fake Issue details",
},
],
[
{
description: "Software Fake Issue",
Expand Down Expand Up @@ -97,6 +104,7 @@ describe("IssuesDrawer", () => {
it("renders the drawer with categorized issues linking to their scope", async () => {
const { user } = installerRender(<IssuesDrawer onClose={onCloseFn} />);

const registrationIssues = screen.getByRole("region", { name: "Registration" });
const softwareIssues = screen.getByRole("region", { name: "Software" });
const storageIssues = screen.getByRole("region", { name: "Storage" });
const usersIssues = screen.getByRole("region", { name: "Users" });
Expand All @@ -114,6 +122,14 @@ describe("IssuesDrawer", () => {
expect(usersLink).toHaveAttribute("href", "/users");
within(usersIssues).getByText("Users Fake Issue");

// Regression test: right now, registration issues comes under product
// scope. Check that it links to registration section anyway.
const registrationLink = within(registrationIssues).getByRole("link", {
name: "Registration",
});
expect(registrationLink).toHaveAttribute("href", "/registration");
within(registrationIssues).getByText("Registration Fake Issue");

// onClose should be called when user clicks on a section too for ensuring
// drawer gets closed even when navigation is not needed.
await user.click(usersLink);
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/core/IssuesDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ const IssuesDrawer = forwardRef(({ onClose }: { onClose: () => void }, ref) => {
if (issues.length === 0) return null;
// FIXME: address this better or use the /product(s)? namespace instead of
// /registration.
const section = scope === "product" ? "registration" : scope;
const ariaLabelId = `${scope}-issues-section`;

return (
<section key={idx} aria-labelledby={ariaLabelId}>
<Stack hasGutter>
<h4 id={ariaLabelId}>
<Link variant="link" isInline onClick={onClose} to={`/${scope}`}>
<Link variant="link" isInline onClick={onClose} to={`/${section}`}>
{scopeHeaders[scope]}
</Link>
</h4>
Expand Down

0 comments on commit 46a4610

Please sign in to comment.