Skip to content

Commit

Permalink
[web] Add tests for InstallationFinished page
Browse files Browse the repository at this point in the history
For checking that conditional information is rendered when appropiate.
Even though that page will be reworked in a near future, keeping the
testsuite up-to-date worth more than its cost.
  • Loading branch information
dgdavid authored and ancorgs committed Jan 17, 2024
1 parent 3b6b17d commit 3de37a3
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions web/src/components/core/InstallationFinished.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@ jest.mock("~/client");
jest.mock("~/components/core/Sidebar", () => () => <div>Agama sidebar</div>);

const finishInstallationFn = jest.fn();

const storageSettings = { encryptionMethod: "luks2" };
let encryptionMethod;

describe("InstallationFinished", () => {
beforeEach(() => {
encryptionMethod = "luks2";
createClient.mockImplementation(() => {
return {
manager: {
finishInstallation: finishInstallationFn,
useIguana: () => Promise.resolve(false)
},
storage: { proposal: { getResult: jest.fn().mockResolvedValue({ settings: storageSettings }) } }
storage: {
proposal: {
getResult: jest.fn().mockResolvedValue({ settings: { encryptionMethod } })
},
}
};
});
});
Expand All @@ -63,4 +67,22 @@ describe("InstallationFinished", () => {
await user.click(rebootButton);
expect(finishInstallationFn).toHaveBeenCalled();
});

describe("when TPM was set to decrypt automatically on each boot", () => {
beforeEach(() => {
encryptionMethod = "tpm_fde";
});

it("shows the TPM reminder", async () => {
installerRender(<InstallationFinished />);
await screen.findAllByText(/TPM/);
});
});

describe("when TPM was not set to decrypt automatically on each boot", () => {
it("does not show the TPM reminder", () => {
installerRender(<InstallationFinished />);
expect(screen.queryByText(/TPM/)).toBeNull();
});
});
});

0 comments on commit 3de37a3

Please sign in to comment.