-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): ensure question are always rendered (#1825)
Rendering questions across the app no longer works as expected after #1690. Commit f10153b changed how the content outside the _installation settings context_ is handled, navigating to its own path instead of rendering as part of `App` component. _Mounting_ `Questions` component in `Layout` should restore the previous behavior and fix #1820.
- Loading branch information
Showing
10 changed files
with
253 additions
and
105 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
------------------------------------------------------------------- | ||
Tue Dec 10 14:43:08 UTC 2024 - David Diaz <[email protected]> | ||
|
||
- Restore the rendering of questions throughout the app | ||
(gh#agama-project/agama#1820) | ||
|
||
------------------------------------------------------------------- | ||
Mon Dec 9 14:10:44 UTC 2024 - David Diaz <[email protected]> | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) [2024] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React from "react"; | ||
import { screen } from "@testing-library/react"; | ||
import { plainRender } from "~/test-utils"; | ||
import Layout from "./Layout"; | ||
|
||
jest.mock("~/components/layout/Header", () => () => <div>Header Mock</div>); | ||
jest.mock("~/components/layout/Sidebar", () => () => <div>Sidebar Mock</div>); | ||
jest.mock("~/components/core/IssuesDrawer", () => () => <div>IssuesDrawer Mock</div>); | ||
jest.mock("~/components/questions/Questions", () => () => <div>Questions Mock</div>); | ||
|
||
describe("Layout", () => { | ||
it("renders a page with header and sidebar by default", () => { | ||
plainRender(<Layout />); | ||
screen.getByText("Header Mock"); | ||
screen.getByText("Sidebar Mock"); | ||
}); | ||
|
||
it("does not render the header when mountHeader=false", () => { | ||
plainRender(<Layout mountHeader={false} />); | ||
expect(screen.queryByText("Header Mock")).toBeNull(); | ||
}); | ||
|
||
it("does not render the sidebar when mountSidebar=false", () => { | ||
plainRender(<Layout mountSidebar={false} />); | ||
expect(screen.queryByText("Sidebar Mock")).toBeNull(); | ||
}); | ||
|
||
describe("when children are not given", () => { | ||
it("renders router <Outlet />", () => { | ||
plainRender(<Layout />); | ||
// NOTE: react-router-dom/Outlet is mock at src/test-utils | ||
screen.getByText("Outlet Content"); | ||
}); | ||
|
||
it("renders the questions component", () => { | ||
plainRender(<Layout />); | ||
screen.getByText("Questions Mock"); | ||
}); | ||
}); | ||
|
||
describe("when children are given", () => { | ||
it("renders children instead of router <Outlet />", () => { | ||
plainRender( | ||
<Layout> | ||
<button>Dummy testing button</button> | ||
</Layout>, | ||
); | ||
screen.getByRole("button", { name: "Dummy testing button" }); | ||
// NOTE: react-router-dom/Outlet is mock at src/test-utils | ||
expect(screen.queryByText("Outlet Content")).toBeNull(); | ||
}); | ||
|
||
it("renders the questions component", () => { | ||
plainRender(<Layout />); | ||
screen.getByText("Questions Mock"); | ||
}); | ||
}); | ||
}); |
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.