mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
# Details This PR merges the feature branch for the scheduled scripts UI into main. This includes the following previously-approved PRs: * https://github.com/fleetdm/fleet/pull/31750 * https://github.com/fleetdm/fleet/pull/31604 * https://github.com/fleetdm/fleet/pull/31797 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [X] Added/updated automated tests - [X] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [X] QA'd all new/changed functionality manually --------- Co-authored-by: jacobshandling <61553566+jacobshandling@users.noreply.github.com> Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import React from "react";
|
|
|
|
import { render, screen } from "@testing-library/react";
|
|
|
|
import { COLORS } from "styles/var/colors";
|
|
|
|
import ProgressBar from "./ProgressBar";
|
|
|
|
describe("ProgressBar component", () => {
|
|
it("renders with the correct sections and colors", () => {
|
|
const sections = [
|
|
{ color: "green", portion: 0.7 },
|
|
{ color: "red", portion: 0.1 },
|
|
];
|
|
|
|
render(<ProgressBar sections={sections} />);
|
|
|
|
const progressBar = screen.getByRole("progressbar");
|
|
expect(progressBar).toBeInTheDocument();
|
|
expect(progressBar).toHaveStyle({
|
|
backgroundColor: COLORS["ui-fleet-black-10"],
|
|
});
|
|
|
|
const sectionElements = screen.getAllByTestId(/section-/);
|
|
expect(sectionElements.length).toBe(2);
|
|
|
|
// On CI, the rgb representation is used, while locally
|
|
// it seems to use the named color.
|
|
try {
|
|
expect(sectionElements[0]).toHaveStyle(
|
|
"background-color: rgb(0, 128, 0)"
|
|
);
|
|
} catch (error) {
|
|
expect(sectionElements[0]).toHaveStyle("background-color: green");
|
|
}
|
|
|
|
expect(sectionElements[0]).toHaveStyle("width: 70%");
|
|
|
|
// Check second section
|
|
try {
|
|
expect(sectionElements[1]).toHaveStyle(
|
|
"background-color: rgb(255, 0, 0)"
|
|
);
|
|
} catch (error) {
|
|
expect(sectionElements[1]).toHaveStyle("background-color: red");
|
|
}
|
|
expect(sectionElements[1]).toHaveStyle("width: 10%");
|
|
});
|
|
|
|
it("applies custom background color when provided", () => {
|
|
const sections = [{ color: "green", portion: 0.5 }];
|
|
const customBgColor = "blue";
|
|
|
|
render(<ProgressBar sections={sections} backgroundColor={customBgColor} />);
|
|
|
|
const progressBar = screen.getByRole("progressbar");
|
|
try {
|
|
expect(progressBar).toHaveStyle(`background-color: rgb(0, 0, 255)`);
|
|
} catch (error) {
|
|
expect(progressBar).toHaveStyle(`background-color: ${customBgColor}`);
|
|
}
|
|
});
|
|
});
|