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: machine status in the header lp#2044399 #5221

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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MachineHeader from "./MachineHeader";
import { actions as machineActions } from "app/store/machine";
import type { RootState } from "app/store/root/types";
import { PowerState } from "app/store/types/enum";
import { NodeActions, NodeStatusCode } from "app/store/types/node";
import { NodeActions, NodeStatus, NodeStatusCode } from "app/store/types/node";
import {
generalState as generalStateFactory,
machine as machineFactory,
Expand Down Expand Up @@ -84,15 +84,29 @@ describe("MachineHeader", () => {
);
});

it("displays power status", () => {
state.machine.items[0].power_state = PowerState.ON;
it("displays an icon when locked", () => {
state.machine.items[0].locked = true;

renderWithBrowserRouter(
<MachineHeader setSidePanelContent={jest.fn()} systemId="abc123" />,
{ state, route: "/machine/abc123" }
);

expect(screen.getByRole("button", { name: /locked/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /locked/i })).toHaveClass(
"has-icon"
);
});

it("displays machine status", () => {
state.machine.items[0].status = NodeStatus.DEPLOYED;

renderWithBrowserRouter(
<MachineHeader setSidePanelContent={jest.fn()} systemId="abc123" />,
{ state, route: "/machine/abc123" }
);

expect(screen.getByText(/power on/i)).toBeInTheDocument();
expect(screen.getByText(/deployed/i)).toBeInTheDocument();
});

it("displays power status when checking power", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const MachineHeader = ({
subtitle={
editingName ? null : (
<div className="u-flex--wrap u-flex--align-center">
<div className="u-nudge-left">
<div className="u-nudge-left u-nudge-right">
{machine.locked ? (
<TooltipButton
aria-label="locked"
Expand All @@ -102,6 +102,7 @@ const MachineHeader = ({
position="btm-left"
/>
) : null}
{machine.status}
</div>
<div>
<PowerIcon
Expand Down