test: the lab restores real tabs across real launches, and follows real links

tools/lab/wonderink-workspace-check launches the installed command again
and again against a stand-in for WonderInk's start page whose sign-in is
Basic auth, as WonderInk's is: restored after 5 and 90 minutes; fresh
after two hours and a minute, a day and a week; reopened untouched until
it lapses; a click after a restore counts and the restore does not; a
busy page and an untouched print preview do not; Print does; closed,
reordered, worksheet and missing-worksheet tabs; killed outright; a
restore that crashes twice; corrupt, future-format and half-written
files; the file holding no credential; restored tabs printing. 59 checks.

The print check follows every kind of link on a signed-in page with one
click — new tab in front for links and window.open, nothing for buttons
and anchors, same-tab for no target, Back, closing — and prints a PDF and
a picture reached by a link, and a page after several tabs. 0.2.6.3's
scenarios are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ekklesia
2026-09-26 21:12:17 -05:00
co-authored by Claude Opus 5.5
parent b5d9535467
commit 78a844968c
5 changed files with 651 additions and 2 deletions
+47 -1
View File
@@ -186,6 +186,9 @@ PICTURES=(
# Black and white shown as it prints, and Color again (0.2.6.3).
COLOURS=(bw-web bw-pdf bw-colour-again bw-cancel)
# Links in a signed-in lesson, followed with one click (0.2.6.4).
LINKS=(links:follow links:pdf links:image links:image-rclick links:tabs-print)
# Right-click in a signed-in lesson (0.2.6.3):
# rclick-image:ELEMENT:SIZE:POSITION[:gray], the elements in
# wonderink-lesson-site.py.
@@ -209,7 +212,7 @@ RIGHT_CLICKS=(
scenarios=("$@")
[[ ${#scenarios[@]} -gt 0 ]] || scenarios=(web pdf pdf-options pdf-viewer-button inline
options bad-range broken cancel page-closes-itself close-window page-prints-again repeat
dark-page "${PICTURES[@]}" "${COLOURS[@]}" "${RIGHT_CLICKS[@]}")
dark-page "${PICTURES[@]}" "${COLOURS[@]}" "${RIGHT_CLICKS[@]}" "${LINKS[@]}")
# The inline scenario needs a PDF to serve; the worksheet scenario writes one.
lab 'test -f /opt/wonderink-check/www/ark.pdf' || { run pdf >/dev/null; lab 'cp "/home/teacher/Downloads/Wonder Ink/Colour the Ark.pdf" /opt/wonderink-check/www/ark.pdf; chmod a+r /opt/wonderink-check/www/ark.pdf'; }
@@ -340,6 +343,49 @@ for scenario in "${scenarios[@]}"; do
judge "CUPS was given exactly the page the preview showed" \
"lab 'cmp -s /tmp/rig-out/preview.pdf $(spool_file "$jobs")'"
judge "the teacher's clipboard is untouched" teacher_text_kept ;;
links:follow)
# link_is WHICH EXPECTED — the rig's line for that link contains EXPECTED.
link_is() { grep -o -- "LINK $1 .*" <<< "$out" | head -1 | grep -qF -- "$2"; }
judge "a text link to a picture opens it in a new tab, and Wonder Ink shows that tab" \
"link_is '#blank' \"tabs=2 current='/private/ark-wide.png' current_is_new=True\""
judge "another site's link: the same" \
"link_is '#external' \"tabs=3 current='http://localhost:8095/img/ark-tall.png' current_is_new=True\""
judge "a linked picture: the same" \
"link_is '#linked-picture' \"tabs=4 current='/private/ark-tall.png' current_is_new=True\""
judge "a worksheet PDF: a new tab, in the PDF viewer" \
"link_is '#pdf' \"tabs=5 current='/private/ark.pdf' current_is_new=True\""
judge "a lesson button that opens a window: a new tab, shown" \
"link_is '#popup' \"tabs=6 current='/private/ark-clear.png' current_is_new=True\""
judge "a lesson button that is not a link: no tab, no navigation" \
"link_is '#button' \"tabs=6 current='/links' current_is_new=False\""
judge "an in-page anchor: stays on the page, scrolled" \
"link_is '#anchor' \"tabs=6 current='/links#bottom' current_is_new=False\""
judge "a link with no target: followed in the same tab, as a browser does" \
"link_is '#same' \"tabs=6 current='/lesson' current_is_new=False\""
judge "and Back returns to the links" "link_is 'after Back' \"current='/links\""
judge "closing every tab the links opened leaves the lesson's own" \
"link_is 'after closing' \"tabs=1 current='/links\""
judge "every page and picture the links reached came through the signed-in session" \
"! lab \"grep '\\\"signed_in\\\": false' $SITE_LOG | grep -qE '\\\"path\\\": \\\"/(links|lesson|private)'\"" ;;
links:pdf)
judge "a worksheet reached by a link opens as a worksheet and prints" \
"said 'pages=2' && [[ \$(count) -eq 1 ]]"
judge "CUPS was given exactly the file the preview showed" \
"lab 'cmp -s /tmp/rig-out/preview.pdf $(spool_file "$jobs")'" ;;
links:image|links:image-rclick)
if [[ "$scenario" == links:image-rclick ]]; then
judge "right-click on the picture a link opened offers Print image" "said \"MENU .*'Print image…'\""
fi
judge "the picture a link opened gets the picture layout" "said 'PICTURE picture_box=True image=1600x1000'"
judge "one job" '[[ $(count) -eq 1 ]]'
judge "CUPS was given exactly the page the preview showed" \
"lab 'cmp -s /tmp/rig-out/preview.pdf $(spool_file "$jobs")'" ;;
links:tabs-print)
judge "three links opened and two closed again: two tabs left, back on the links" \
"said \"LINK before printing tabs=2 current='/links'\""
judge "the page they came from prints, one job" '[[ $(count) -eq 1 ]] && said "PREVIEW picture=False"'
judge "CUPS was given exactly the page the preview showed" \
"lab 'cmp -s /tmp/rig-out/preview.pdf $(spool_file "$jobs")'" ;;
rclick-page-gray)
judge "a lesson page full of pictures turns grey in the preview ($(lines 'GRAY PAGE' | grep -o 'took=[0-9.]*'))" \
"said 'GRAY PAGE .*shown_gray=True'"