Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Feb 27 23:00:35 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Do not reset the configuration on product selection (bsc#1258032).

-------------------------------------------------------------------
Fri Feb 27 14:39:08 UTC 2026 - David Diaz <dgonzalez@suse.com>

Expand Down
14 changes: 13 additions & 1 deletion web/src/components/product/ProductSelectionPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useSystem as useSystemSoftware } from "~/hooks/model/system/software";
import { ROOT } from "~/routes/paths";
import ProductSelectionPage from "./ProductSelectionPage";
import { Product } from "~/model/system";
import { useConfig } from "~/hooks/model/config";

const tumbleweed: Product = {
id: "Tumbleweed",
Expand Down Expand Up @@ -60,7 +61,10 @@ const productWithModes: Product = {
],
};

const oldConfig = { hostname: { static: "agama" } };

const mockPutConfigFn = jest.fn();
const mockUseConfigFn: jest.Mock<ReturnType<typeof useConfig>> = jest.fn();
const mockUseSystemFn: jest.Mock<ReturnType<typeof useSystem>> = jest.fn();
const mockUseSystemSoftwareFn: jest.Mock<ReturnType<typeof useSystemSoftware>> = jest.fn();

Expand All @@ -76,6 +80,11 @@ jest.mock("~/api", () => ({
putConfig: (payload) => mockPutConfigFn(payload),
}));

jest.mock("~/hooks/model/config", () => ({
...jest.requireActual("~/hooks/model/config"),
useConfig: () => mockUseConfigFn(),
}));

jest.mock("~/hooks/model/system", () => ({
...jest.requireActual("~/hooks/model/system"),
useSystem: () => mockUseSystemFn(),
Expand All @@ -97,6 +106,8 @@ describe("ProductSelectionPage", () => {
patterns: [],
repositories: [],
});

mockUseConfigFn.mockReturnValue(oldConfig);
});

it("renders available products excluding the selected one unless it has modes", () => {
Expand Down Expand Up @@ -222,7 +233,7 @@ describe("ProductSelectionPage", () => {
const selectButton = screen.getByRole("button", { name: "Select" });
await user.click(productOption);
await user.click(selectButton);
expect(mockPutConfigFn).toHaveBeenCalledWith({ product: { id: tumbleweed.id } });
expect(mockPutConfigFn).toHaveBeenCalledWith({ ...oldConfig, product: { id: tumbleweed.id } });
});

it("does not trigger the product selection if user selects a product but clicks o cancel button", async () => {
Expand Down Expand Up @@ -316,6 +327,7 @@ describe("ProductSelectionPage", () => {
await user.click(selectButton);

expect(mockPutConfigFn).toHaveBeenCalledWith({
...oldConfig,
product: { id: productWithModes.id, mode: "standard" },
});
});
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/product/ProductSelectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { n_, _ } from "~/i18n";

import pfTextStyles from "@patternfly/react-styles/css/utilities/Text/text";
import { useInstallerL10n } from "~/context/installerL10n";
import { useConfig } from "~/hooks/model/config";

/**
* Props for ProductFormProductOption component
Expand Down Expand Up @@ -686,6 +687,7 @@ const ProductSelectionContent = () => {
const navigate = useNavigate();
const product = useProduct();
const { products } = useSystem();
const config = useConfig();
const currentProduct = useProductInfo();
const [submittedSelection, setSubmmitedSelection] = useState<Product>();
const [isSubmitted, setIsSubmmited] = useState(false);
Expand All @@ -702,7 +704,7 @@ const ProductSelectionContent = () => {
const onSubmit = async (selectedProduct: Product, selectedMode: string) => {
setIsSubmmited(true);
setSubmmitedSelection(selectedProduct);
putConfig({ product: { id: selectedProduct.id, mode: selectedMode } });
putConfig({ ...config, product: { id: selectedProduct.id, mode: selectedMode } });
};

return (
Expand Down
Loading