Skip to content

Commit

Permalink
fix(web): display the "finished" page (#1727)
Browse files Browse the repository at this point in the history
## Problem

The "Installation Finished" page is not shown when the installation
finishes. It seems to be related
to latest changes regarding the application layout. Now, the `App`
component is not always on top.

## Solution

Listen for status changes in the installation progress page.

## Testing

- Tested manually
  • Loading branch information
imobachgs authored Nov 5, 2024
2 parents 78a1faa + 9ec5543 commit 286b2b8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
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 <[email protected]>

- 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 <[email protected]>

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

0 comments on commit 286b2b8

Please sign in to comment.