Two real bugs found on the first production deploy: - /admin/ 404'd: file_server looked for /srv/homepage/admin/ (a dir), but the page is admin.html. Add '@admin rewrite * /admin.html' so the /admin/ path serves admin.html. - The pages used relative refs (style.css, app.js, services.json, status.json), which from /admin/ resolved to /admin/... (404). Add <base href="/"> so all refs resolve to the site root on both pages. - status.json was written 0600 (root); the checker now chmods it 0644 so Caddy can serve it regardless of its user.
51 lines
1.6 KiB
Bash
51 lines
1.6 KiB
Bash
#!/usr/bin/env bats
|
|
# Seam: the homepage pages (index.html, admin.html, app.js, style.css).
|
|
# A browser cannot run under bats, so the tests assert the public contract
|
|
# statically: the pages reference the data and the theme, the page does not
|
|
# auto-refresh (Q41), does not alter the user's cursor (Q28), offers the
|
|
# styling toggle (Q27), and shows the last master deployment datetime (Q43).
|
|
|
|
load helpers
|
|
|
|
setup() {
|
|
BASE="$REPO_ROOT/shared/homepage"
|
|
}
|
|
|
|
@test "pages exist and reference the data and the theme" {
|
|
[ -f "$BASE/index.html" ]
|
|
[ -f "$BASE/admin.html" ]
|
|
[ -f "$BASE/app.js" ]
|
|
[ -f "$BASE/style.css" ]
|
|
for f in app.js style.css; do
|
|
grep -q "$f" "$BASE/index.html"
|
|
grep -q "$f" "$BASE/admin.html"
|
|
done
|
|
grep -q "status.json" "$BASE/app.js"
|
|
grep -q "services.json" "$BASE/app.js"
|
|
}
|
|
|
|
@test "the page does not auto-refresh (Q41)" {
|
|
! grep -q "setInterval" "$BASE/app.js"
|
|
! grep -qi "poll" "$BASE/app.js"
|
|
}
|
|
|
|
@test "the page does not alter the user's cursor (Q28)" {
|
|
! grep -qE "cursor:[[:space:]]*(none|url\()" "$BASE/style.css"
|
|
}
|
|
|
|
@test "the styling toggle strips to bare HTML (Q27)" {
|
|
grep -q "data-bare" "$BASE/style.css"
|
|
grep -q "bare" "$BASE/app.js"
|
|
}
|
|
|
|
@test "the footer shows the last master deployment datetime (Q43)" {
|
|
grep -q "deployed-at" "$BASE/index.html"
|
|
grep -q "deployed-at" "$BASE/admin.html"
|
|
grep -q "deployed-at" "$BASE/app.js"
|
|
}
|
|
|
|
@test "the pages set a base so the /admin/ page resolves refs to the root" {
|
|
grep -q '<base href="/">' "$BASE/index.html"
|
|
grep -q '<base href="/">' "$BASE/admin.html"
|
|
}
|