Skip to content

Commit

Permalink
refactor(web): adapt ProposalSettingsSection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 5, 2024
1 parent 8358a94 commit cad7db7
Showing 1 changed file with 17 additions and 78 deletions.
95 changes: 17 additions & 78 deletions web/src/components/storage/ProposalSettingsSection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,12 @@
*/

import React from "react";
import { screen } from "@testing-library/react";
import { installerRender } from "~/test-utils";
import { screen, within } from "@testing-library/react";
import { plainRender } from "~/test-utils";
import { ProposalSettingsSection } from "~/components/storage";
import { ProposalTarget, StorageDevice } from "~/types/storage";
import { ProposalSettingsSectionProps } from "./ProposalSettingsSection";

jest.mock("@patternfly/react-core", () => {
const original = jest.requireActual("@patternfly/react-core");

return {
...original,
Skeleton: () => <div>PFSkeleton</div>,
};
});

const sda: StorageDevice = {
sid: 59,
isDrive: true,
type: "disk",
description: "",
vendor: "Micron",
model: "Micron 1100 SATA",
driver: ["ahci", "mmcblk"],
bus: "IDE",
busId: "",
transport: "usb",
dellBOSS: false,
sdCard: true,
active: true,
name: "/dev/sda",
size: 1024,
shrinking: { unsupported: ["Resizing is not supported"] },
systems: [],
udevIds: ["ata-Micron_1100_SATA_512GB_12563", "scsi-0ATA_Micron_1100_SATA_512GB"],
udevPaths: ["pci-0000:00-12", "pci-0000:00-12-ata"],
};

const sdb: StorageDevice = {
sid: 62,
isDrive: true,
type: "disk",
description: "",
vendor: "Samsung",
model: "Samsung Evo 8 Pro",
driver: ["ahci"],
bus: "IDE",
busId: "",
transport: "",
dellBOSS: false,
sdCard: false,
active: true,
name: "/dev/sdb",
size: 2048,
shrinking: { unsupported: ["Resizing is not supported"] },
systems: [],
udevIds: [],
udevPaths: ["pci-0000:00-19"],
};

let props: ProposalSettingsSectionProps;

beforeEach(() => {
Expand All @@ -95,7 +42,7 @@ beforeEach(() => {
spacePolicy: "delete",
spaceActions: [],
volumes: [],
installationDevices: [sda, sdb],
installationDevices: [],
},
availableDevices: [],
volumeDevices: [],
Expand All @@ -105,31 +52,23 @@ beforeEach(() => {
};
});

it.skip("allows changing the selected device", async () => {
const { user } = installerRender(<ProposalSettingsSection {...props} />);
const button = screen.getByRole("button", { name: /installation device/i });

await user.click(button);
await screen.findByRole("dialog", { name: /Device for installing/ });
it("allows changing the selected device", () => {
plainRender(<ProposalSettingsSection {...props} />);
const region = screen.getByRole("region", { name: "Installation device" });
const link: HTMLAnchorElement = within(region).getByRole("link", { name: "Change" });
expect(link.href).toMatch(/storage\/target-device/);
});

it.skip("allows changing the encryption settings", async () => {
const { user } = installerRender(<ProposalSettingsSection {...props} />);
const button = screen.getByRole("button", { name: /Encryption/ });

it("allows changing the encryption settings", async () => {
const { user } = plainRender(<ProposalSettingsSection {...props} />);
const region = screen.getByRole("region", { name: "Encryption" });
const button = within(region).getByRole("button", { name: "Enable" });
await user.click(button);
await screen.findByRole("dialog", { name: /Encryption/ });
});

it.skip("renders a section holding file systems related stuff", () => {
installerRender(<ProposalSettingsSection {...props} />);
screen.getByRole("button", { name: /Partitions and file systems/ });
await screen.findByRole("dialog", { name: "Encryption" });
});

it.skip("allows changing the space policy settings", async () => {
const { user } = installerRender(<ProposalSettingsSection {...props} />);
const button = screen.getByRole("button", { name: /Find space/ });

await user.click(button);
await screen.findByRole("dialog", { name: /Find space/ });
it("renders a section holding file systems related stuff", () => {
plainRender(<ProposalSettingsSection {...props} />);
const region = screen.getByRole("region", { name: "Partitions and file systems" });
expect(region).toBeInTheDocument();
});

0 comments on commit cad7db7

Please sign in to comment.