- Automation rules propose suggestions instead of creating tasks; notify per rule config; corrected varroa measurements refresh or resolve their suggestion - Inspection values can be taken over into the colony card (occupiedFrames 0-40, strength deprecated); warning counts use the same visibility rule as the notification list - Biotech chains: swarm check after queen cells, queen acceptance check, split schedules (raise own, queen cell, queen) - Season autopilot core with A1 inspection due, A2 varroa measurement, A3 recheck after treatment; colony sync and daily step - Frontend: suggestions page with groups, bulk accept, undo, paging, focus management and permission gating - Frontend: varroa traffic light from seasonal bands, sample size, one range request for the colony chart - Notifications: mark-read answers 404 for rows the user may no longer see Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||
import { render, screen } from "@testing-library/react";
|
||
import { VarroaRateLight } from "./varroa-rate-light";
|
||
import type { VarroaBands } from "@/lib/varroa/bands";
|
||
|
||
const BANDS: VarroaBands = {
|
||
day: "2026-08-10",
|
||
bands: {
|
||
NATURAL_MITE_FALL: {
|
||
method: "NATURAL_MITE_FALL",
|
||
unit: "MITES_PER_DAY",
|
||
yellowFrom: 5,
|
||
redAbove: 10,
|
||
reason: "NATURAL_FALL_SEASON",
|
||
youngColony: false,
|
||
},
|
||
},
|
||
postTreatmentUntil: null,
|
||
active: true,
|
||
};
|
||
|
||
describe("VarroaRateLight", () => {
|
||
it("keeps one status element while the content changes", () => {
|
||
const { rerender } = render(<VarroaRateLight method="NATURAL_MITE_FALL" value={null} bands={BANDS} />);
|
||
const status = screen.getByRole("status");
|
||
expect(status).toHaveAttribute("aria-live", "polite");
|
||
expect(status).toBeEmptyDOMElement();
|
||
|
||
rerender(<VarroaRateLight method="NATURAL_MITE_FALL" value={12.4} bands={BANDS} />);
|
||
expect(screen.getByRole("status")).toBe(status);
|
||
expect(status).toHaveTextContent("12,4 Milben/Tag – Kritisch (Grenze 10, LWG)");
|
||
|
||
rerender(<VarroaRateLight method="NATURAL_MITE_FALL" value={3} bands={null} />);
|
||
expect(screen.getByRole("status")).toBe(status);
|
||
expect(status).toHaveTextContent(/^3,0 Milben\/Tag$/);
|
||
expect(screen.getAllByRole("status")).toHaveLength(1);
|
||
});
|
||
|
||
it("names every state in words, not by colour alone", () => {
|
||
const { rerender } = render(<VarroaRateLight method="NATURAL_MITE_FALL" value={1} bands={BANDS} />);
|
||
expect(screen.getByRole("status")).toHaveTextContent("Gut");
|
||
rerender(<VarroaRateLight method="NATURAL_MITE_FALL" value={6} bands={BANDS} />);
|
||
expect(screen.getByRole("status")).toHaveTextContent("Achtung");
|
||
rerender(
|
||
<VarroaRateLight method="NATURAL_MITE_FALL" value={6} bands={{ ...BANDS, postTreatmentUntil: "2026-08-16" }} />,
|
||
);
|
||
expect(screen.getByRole("status")).toHaveTextContent("Behandlungseffekt – Nachkontrolle ab 16.08.");
|
||
});
|
||
|
||
it("shows only the value for a method without a band", () => {
|
||
render(<VarroaRateLight method="POWDERED_SUGAR" value={2.4} bands={BANDS} />);
|
||
expect(screen.getByRole("status")).toHaveTextContent(/^2,4 %$/);
|
||
});
|
||
});
|