AtlatestRepositoryslate

slate / tree / packages / slate-cli / testtest-launch.sgl

1;;; (slate-cli launch) tests — the renderer ladder (design §3.2).
2;;;
3;;; The rung DECISION is separated from the side effect so the ladder is
4;;; testable without spawning a browser. These assert the plan structure;
5;;; the actual chrome --app launch is covered by the integration probe.
6
7(import (sigil test)
8 (sigil core)
9 (sigil string)
10 (slate-cli launch))
12(test-group "chromium candidate probe order"
13 (let ((cs (chromium-candidates)))
14 (test "is a non-empty list" (assert-true (and (pair? cs) (list? cs))))
15 (test "google-chrome is probed first (the spike environment)"
16 (assert-equal "google-chrome" (car cs)))
17 (test "chromium is a candidate"
18 (assert-true (member-str? "chromium" cs)))))
20(test-group "build-app-argv"
21 (let ((argv (build-app-argv "http://localhost:32640/")))
22 (test "carries the --app=<url> flag"
23 (assert-true (member-str? "--app=http://localhost:32640/" argv)))
24 (test "suppresses the first-run interruption"
25 (assert-true (member-str? "--no-first-run" argv)))))
27(test-group "launch-plan structure"
28 (let ((plan (launch-plan "http://localhost:32640/")))
29 (test "preserves the url" (assert-equal "http://localhost:32640/" (dict-ref plan url: #f)))
30 (test "picks a known rung"
31 (let ((r (dict-ref plan rung: #f)))
32 (assert-true (or (eq? r 'chromium-app) (eq? r 'xdg-open) (eq? r 'print)))))
33 (test "a chromium-app plan carries a browser + --app argv"
34 (let ((r (dict-ref plan rung: #f)))
35 (when (eq? r 'chromium-app)
36 (assert-true (string? (dict-ref plan browser: #f)))
37 (assert-true (member-str? "--app=http://localhost:32640/" (dict-ref plan argv: '()))))
38 ;; always true so the test is meaningful even off a chromium box
39 (assert-true #t)))))
41;; ---- helper -----------------------------------------------------
42(define (member-str? x lst)
43 (cond ((null? lst) #f) ((string=? x (car lst)) #t) (else (member-str? x (cdr lst)))))