-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(web): use queries for dealing with software (#1483)
Similar to #1439, #1452, and #1470, this set of changes aims to replace the client/software with Tanstack queries. Note that was not possible to fully drop the software client. It has to wait until migration of [`WithStatus`](https://github.com/openSUSE/agama/blob/bd2f35d0ead6d74931189f5619579f6c3ffa2770/web/src/client/mixins.js#L83) and [`WithProgress`](https://github.com/openSUSE/agama/blob/bd2f35d0ead6d74931189f5619579f6c3ffa2770/web/src/client/mixins.js#L147) mixins too.
- Loading branch information
Showing
23 changed files
with
916 additions
and
862 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,68 @@ | ||
/* | ||
* 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 version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* 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 { act, screen } from "@testing-library/react"; | ||
import { installerRender } from "~/test-utils"; | ||
import mockTestingPatterns from "~/components/software/patterns.test.json"; | ||
import testingProposal from "~/components/software/proposal.test.json"; | ||
import SoftwareSection from "~/components/overview/SoftwareSection"; | ||
import { SoftwareProposal } from "~/types/software"; | ||
|
||
let mockTestingProposal: SoftwareProposal; | ||
|
||
jest.mock("~/queries/software", () => ({ | ||
usePatterns: () => mockTestingPatterns, | ||
useProposal: () => mockTestingProposal, | ||
useProposalChanges: jest.fn(), | ||
})); | ||
|
||
describe("SoftwareSection", () => { | ||
describe("when the proposal does not have patterns to select", () => { | ||
beforeEach(() => { | ||
mockTestingProposal = { patterns: {}, size: "" }; | ||
}); | ||
|
||
it("renders nothing", () => { | ||
const { container } = installerRender(<SoftwareSection />); | ||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
}); | ||
|
||
describe("when the proposal has patterns to select", () => { | ||
beforeEach(() => { | ||
mockTestingProposal = testingProposal; | ||
}); | ||
|
||
it("renders the required space and the selected patterns", () => { | ||
installerRender(<SoftwareSection />); | ||
screen.getByText("4.6 GiB"); | ||
screen.getAllByText(/GNOME/); | ||
screen.getByText("YaST Base Utilities"); | ||
screen.getByText("YaST Desktop Utilities"); | ||
screen.getByText("Multimedia"); | ||
screen.getAllByText(/Office Software/); | ||
expect(screen.queryByText("KDE")).toBeNull(); | ||
expect(screen.queryByText("XFCE")).toBeNull(); | ||
expect(screen.queryByText("YaST Server Utilities")).toBeNull(); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.