From 85bf5e1a2518f073ecbdce4e604b42aab1091635 Mon Sep 17 00:00:00 2001 From: Esa Kataja Date: Sun, 6 Sep 2026 00:04:32 +0300 Subject: [PATCH] test: make the smoke script use relative dates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script hardcoded 2026-09-05, so at the next midnight that became "some day in the past" and the assertions quietly changed meaning: today turned into an unlogged row, and a refute on "Ei merkintää" started matching it instead of the day under test. Dates are now computed at run time. That refute was wrong regardless. It denied the string across the whole page, but every unlogged day legitimately renders one. It now asserts positively that the entry is still shown while the delete is being confirmed. --- scripts/smoke.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/smoke.sh b/scripts/smoke.sh index 573b37d..de13d2d 100755 --- a/scripts/smoke.sh +++ b/scripts/smoke.sh @@ -11,6 +11,12 @@ cd "$(dirname "$0")/.." addr=127.0.0.1:8099 pass=smoke + +# Dates are relative, never literal. A hardcoded one turns into "some day in +# the past" at the next midnight, and the assertions quietly start meaning +# something else. +d0=$(date +%F) +d1=$(date -d yesterday +%F) tmp=$(mktemp -d) trap 'kill ${srv:-0} 2>/dev/null || true; rm -rf "$tmp"' EXIT @@ -134,51 +140,53 @@ check "picking a dish opens the sides step" \ check "saving redirects back to the day" \ "$(curl -s -o /dev/null -w '%{http_code}' -u ":$pass" \ - -d "pvm=2026-09-05&ruoka=$ruoka" "http://$addr/kirjaa")" "303" + -d "pvm=$d0&ruoka=$ruoka" "http://$addr/kirjaa")" "303" check "the saved day shows what was eaten" \ - "$(curl -s -u ":$pass" "http://$addr/?pvm=2026-09-05")" "kirjattu" + "$(curl -s -u ":$pass" "http://$addr/?pvm=$d0")" "kirjattu" # The selected day expands inside the list rather than in a panel above it, # so the rows below do not shift when one is tapped. -day=$(curl -s -u ":$pass" "http://$addr/?pvm=2026-09-05") +day=$(curl -s -u ":$pass" "http://$addr/?pvm=$d0") check "the selected day expands in place" "$day" 'class="open"' check "and stays in the list rather than being lifted out" "$day" "kirjattu" # ---- the day list patches in place instead of navigating ---------------- -dayp=$(curl -s -u ":$pass" -H 'Datastar-Request: true' "http://$addr/paiva?pvm=2026-09-05") +dayp=$(curl -s -u ":$pass" -H 'Datastar-Request: true' "http://$addr/paiva?pvm=$d0") check "opening a day patches the list" "$dayp" 'id="paivat"' refute "and returns a fragment, not a page" "$dayp" "