Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): display the "finished" page #1727

Merged
merged 3 commits into from
Nov 5, 2024
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
7 changes: 7 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Nov 04 20:32:29 UTC 2024 - David Diaz <dgonzalez@suse.com>

- Add missing subscription to avoid Agama getting stuck at the installation
progress when the installation finishes
(gh#agama-project/agama#1726, gh#agama-project/agama#1727).

-------------------------------------------------------------------
Wed Oct 30 22:26:29 UTC 2024 - David Diaz <dgonzalez@suse.com>

Expand Down
48 changes: 43 additions & 5 deletions web/src/components/core/InstallationProgress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,58 @@ import { screen } from "@testing-library/react";
import { installerRender } from "~/test-utils";
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: true, phase: InstallationPhase.Install }),
useInstallerStatus: () => ({ isBusy, phase }),
useInstallerStatusChanges: () => mockInstallerStatusChanges(),
}));

describe("InstallationProgress", () => {
it("renders progress report", () => {
it("subscribes to installer status", () => {
installerRender(<InstallationProgress />);
screen.getByText("ProgressReport Mock");
expect(mockInstallerStatusChanges).toHaveBeenCalled();
});

it.todo("redirects to root path when not in an installation phase");
it.todo("redirects to installatino finished path if in an installation phase but not busy");
describe("when not in an installation phase", () => {
beforeEach(() => {
phase = InstallationPhase.Config;
});

it("redirects to the root path", async () => {
installerRender(<InstallationProgress />);
await screen.findByText(`Navigating to ${ROOT.root}`);
});
});

describe("when installer in the installation phase and busy", () => {
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}`);
});
});
});
3 changes: 2 additions & 1 deletion web/src/components/core/InstallationProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import ProgressReport from "./ProgressReport";
import { InstallationPhase } from "~/types/status";
import { ROOT as PATHS } from "~/routes/paths";
import { Navigate } from "react-router-dom";
import { useInstallerStatus } from "~/queries/status";
import { useInstallerStatus, useInstallerStatusChanges } from "~/queries/status";

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

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