Skip to content

Commit

Permalink
fix(web): remove isBusy from InstallationProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jan 24, 2025
1 parent 56eadf1 commit d26394a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
18 changes: 2 additions & 16 deletions web/src/components/core/InstallationProgress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ import { InstallationPhase } from "~/types/status";
import InstallationProgress from "./InstallationProgress";
import { ROOT } from "~/routes/paths";

let isBusy = false;
let phase = InstallationPhase.Install;
const mockInstallerStatusChanges = jest.fn();

jest.mock("~/components/core/ProgressReport", () => () => <div>ProgressReport Mock</div>);

jest.mock("~/queries/status", () => ({
...jest.requireActual("~/queries/status"),
useInstallerStatus: () => ({ isBusy, phase }),
useInstallerStatus: () => ({ phase }),
useInstallerStatusChanges: () => mockInstallerStatusChanges(),
}));

Expand All @@ -56,27 +55,14 @@ describe("InstallationProgress", () => {
});
});

describe("when installer in the installation phase and busy", () => {
describe("when installer in the installation phase", () => {
beforeEach(() => {
phase = InstallationPhase.Install;
isBusy = true;
});

it("renders progress report", () => {
installerRender(<InstallationProgress />);
screen.getByText("ProgressReport Mock");
});
});

describe("when installer in the installation phase but not busy", () => {
beforeEach(() => {
phase = InstallationPhase.Install;
isBusy = false;
});

it("redirect to installation finished path", async () => {
installerRender(<InstallationProgress />);
await screen.findByText(`Navigating to ${ROOT.installationFinished}`);
});
});
});
6 changes: 1 addition & 5 deletions web/src/components/core/InstallationProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@ import { Navigate } from "react-router-dom";
import { useInstallerStatus, useInstallerStatusChanges } from "~/queries/status";

function InstallationProgress() {
const { isBusy, phase } = useInstallerStatus({ suspense: true });
const { phase } = useInstallerStatus({ suspense: true });
useInstallerStatusChanges();

if (phase !== InstallationPhase.Install) {
return <Navigate to={PATHS.root} replace />;
}

if (!isBusy) {
return <Navigate to={PATHS.installationFinished} replace />;
}

return <ProgressReport title={_("Installing the system, please wait...")} />;
}

Expand Down

0 comments on commit d26394a

Please sign in to comment.