Change: use byterate for beszel network field (#6402)

This commit is contained in:
shamoon 2026-03-06 23:20:38 -08:00 committed by GitHub
parent b676424d98
commit 597059045f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 1 deletions

View file

@ -54,7 +54,10 @@ export default function Component({ service }) {
<Block label="beszel.cpu" value={t("common.percent", { value: system.info.cpu, maximumFractionDigits: 2 })} />
<Block label="beszel.memory" value={t("common.percent", { value: system.info.mp, maximumFractionDigits: 2 })} />
<Block label="beszel.disk" value={t("common.percent", { value: system.info.dp, maximumFractionDigits: 2 })} />
<Block label="beszel.network" value={t("common.percent", { value: system.info.b, maximumFractionDigits: 2 })} />
<Block
label="beszel.network"
value={t("common.byterate", { value: system.info.bb, maximumFractionDigits: 2 })}
/>
</Container>
);
}

View file

@ -76,6 +76,35 @@ describe("widgets/beszel/component", () => {
expect(screen.queryByText("beszel.updated")).toBeNull();
});
it("renders optional fields", () => {
useWidgetAPI.mockReturnValue({
data: {
totalItems: 1,
items: [
{
id: "sys1",
name: "MySystem",
status: "up",
updated: 123,
info: { cpu: 10, mp: 20, dp: 30, b: 40, bb: 14.5 },
},
],
},
error: undefined,
});
const service = {
widget: { type: "beszel", systemId: "sys1", fields: ["name", "disk", "network"] },
};
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
expect(service.widget.fields).toEqual(["name", "disk", "network"]);
expect(container.querySelectorAll(".service-block")).toHaveLength(3);
expectBlockValue(container, "beszel.name", "MySystem");
expectBlockValue(container, "beszel.disk", 30);
expectBlockValue(container, "beszel.network", 14.5);
});
it("renders error when systemId is not found", () => {
useWidgetAPI.mockReturnValue({
data: { totalItems: 1, items: [{ id: "sys1", name: "MySystem", status: "up", info: {} }] },