test: add e2e test for system time checkbox

This commit is contained in:
Loic Coenen
2026-06-24 23:01:10 +02:00
committed by Loic Coenen (aider)
parent d8348a64ea
commit d33c434fe9

View File

@@ -209,4 +209,30 @@ describe("Berlin Clock", () => {
assertFullClock("11:37:01", "ORROOROOOYYRYYRYOOOOYYOO"); assertFullClock("11:37:01", "ORROOROOOYYRYYRYOOOOYYOO");
}); });
}); });
describe("Use System Time", () => {
it("should show system time when checkbox is checked", () => {
// Start by entering a fixed time
cy.get('[data-testid="time-input"]').clear().type("12:00:00").type("{enter}");
cy.get('[data-testid="digital-clock"]').should("contain", "12:00:00");
// Check the "Use system time" checkbox
cy.get('[data-testid="use-system-time"]').check();
// Now the digital clock should reflect the real system time
cy.get('[data-testid="digital-clock"]').invoke("text").then((displayedTime) => {
// displayedTime is "HH:mm:ss"
const parts = displayedTime.split(":");
const displayedSeconds =
parseInt(parts[0]) * 3600 +
parseInt(parts[1]) * 60 +
parseInt(parts[2]);
const now = new Date();
const realSeconds =
now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
// Allow a 5-second tolerance
expect(Math.abs(displayedSeconds - realSeconds)).to.be.lessThan(5);
});
});
});
}); });