From d33c434fe92259cb284f7f6cb59c3f875e7249f1 Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Wed, 24 Jun 2026 23:01:10 +0200 Subject: [PATCH] test: add e2e test for system time checkbox --- cypress/e2e/clock.cy.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cypress/e2e/clock.cy.ts b/cypress/e2e/clock.cy.ts index 301fa55..a6d8eeb 100644 --- a/cypress/e2e/clock.cy.ts +++ b/cypress/e2e/clock.cy.ts @@ -209,4 +209,30 @@ describe("Berlin Clock", () => { 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); + }); + }); + }); });