From ef9cb417df4a7931131c308917a56934fea08a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Thu, 16 Mar 2023 12:56:00 +0000 Subject: [PATCH] [web] Fix tests --- web/src/client/storage.test.js | 34 +++++++++++++------ .../overview/StorageSection.test.jsx | 3 +- .../storage/ProposalTargetSection.test.jsx | 8 ++++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/web/src/client/storage.test.js b/web/src/client/storage.test.js index 15b15dafd8..d65fc6d1d1 100644 --- a/web/src/client/storage.test.js +++ b/web/src/client/storage.test.js @@ -168,9 +168,10 @@ describe("#proposal", () => { }; describe("#getData", () => { - beforeEach(() => { + beforeEach(async () => { contexts.withAvailableDevices(); contexts.withProposal(); + await client.setUp(); }); it("returns the available devices and the proposal result", async () => { @@ -181,8 +182,9 @@ describe("#proposal", () => { }); describe("#getAvailableDevices", () => { - beforeEach(() => { + beforeEach(async () => { contexts.withAvailableDevices(); + await client.setUp(); }); it("returns the list of available devices", async () => { @@ -193,8 +195,9 @@ describe("#proposal", () => { describe("#getResult", () => { describe("if there is no proposal yet", () => { - beforeEach(() => { + beforeEach(async () => { contexts.withoutProposal(); + await client.setUp(); }); it("returns undefined", async () => { @@ -204,8 +207,10 @@ describe("#proposal", () => { }); describe("if there is a proposal", () => { - beforeEach(() => { + beforeEach(async () => { contexts.withProposal(); + await client.setUp(); + }); it("returns the proposal settings and actions", async () => { @@ -216,10 +221,11 @@ describe("#proposal", () => { }); describe("#calculate", () => { - beforeEach(() => { + beforeEach(async () => { cockpitProxies.proposalCalculator = { Calculate: jest.fn() }; + await client.setUp(); }); it("calculates a default proposal when no settings are given", async () => { @@ -278,10 +284,11 @@ describe("#proposal", () => { describe("#iscsi", () => { describe("#getInitiatorName", () => { - beforeEach(() => { + beforeEach(async () => { cockpitProxies.iscsiInitiator = { InitiatorName: "iqn.1996-04.com.suse:01:351e6d6249" }; + await client.setUp(); }); it("returns the current initiator name", async () => { @@ -291,10 +298,11 @@ describe("#iscsi", () => { }); describe("#setInitiatorName", () => { - beforeEach(() => { + beforeEach(async () => { cockpitProxies.iscsiInitiator = { InitiatorName: "iqn.1996-04.com.suse:01:351e6d6249" }; + await client.setUp(); }); it("sets the given initiator name", async () => { @@ -306,8 +314,9 @@ describe("#iscsi", () => { describe("#getNodes", () => { describe("if there is no exported iSCSI nodes yet", () => { - beforeEach(() => { + beforeEach(async () => { contexts.withoutISCSINodes(); + await client.setUp(); }); it("returns an empty list", async () => { @@ -317,8 +326,9 @@ describe("#iscsi", () => { }); describe("if there are exported iSCSI nodes", () => { - beforeEach(() => { + beforeEach(async () => { contexts.withISCSINodes(); + await client.setUp(); }); it("returns a list with the exported iSCSI nodes", async () => { @@ -349,10 +359,11 @@ describe("#iscsi", () => { }); describe("#discover", () => { - beforeEach(() => { + beforeEach(async () => { cockpitProxies.iscsiInitiator = { Discover: jest.fn() }; + await client.setUp(); }); it("performs an iSCSI discovery with the given options", async () => { @@ -373,10 +384,11 @@ describe("#iscsi", () => { }); describe("#Delete", () => { - beforeEach(() => { + beforeEach(async () => { cockpitProxies.iscsiInitiator = { Delete: jest.fn() }; + await client.setUp(); }); it("deletes the given iSCSI node", async () => { diff --git a/web/src/components/overview/StorageSection.test.jsx b/web/src/components/overview/StorageSection.test.jsx index b66d7c738b..bd7c387c83 100644 --- a/web/src/components/overview/StorageSection.test.jsx +++ b/web/src/components/overview/StorageSection.test.jsx @@ -50,7 +50,8 @@ beforeEach(() => { proposal: { getData: jest.fn().mockResolvedValue(proposal) }, getStatus: jest.fn().mockResolvedValue(status), getValidationErrors: jest.fn().mockResolvedValue(errors), - onStatusChange: onStatusChangeFn + onStatusChange: onStatusChangeFn, + setUp: jest.fn().mockResolvedValue(null) }, }; }); diff --git a/web/src/components/storage/ProposalTargetSection.test.jsx b/web/src/components/storage/ProposalTargetSection.test.jsx index c48ad4c29b..88c21cc0c7 100644 --- a/web/src/components/storage/ProposalTargetSection.test.jsx +++ b/web/src/components/storage/ProposalTargetSection.test.jsx @@ -109,7 +109,13 @@ describe("when there are no candidate devices available", () => { it("renders an informative message", () => { installerRender(); - screen.getByText("No available devices"); + screen.getByText("No devices found"); + }); + + it("allows configuring iSCSI devices", () => { + installerRender(); + + screen.getByRole("button", { name: "Configure iSCSI" }); }); it("does not allow configuring the candidate devices", () => {