add ui
CI / Test + coverage (push) Successful in 1m15s

This commit is contained in:
2026-09-19 06:49:28 -09:00
parent 0e3ea5a714
commit a46428a757
20 changed files with 529 additions and 30 deletions
+11 -3
View File
@@ -52,10 +52,18 @@ bb integration-test/integration_test.bb http://localhost:3000 --watch --interval
| # | Test | Checks |
|---|------|--------|
| 1 | `GET /` returns 200 | HTTP status code |
| 2 | `Content-Type` header | `text/plain` |
| 3 | Response body | Contains expected Clojure/Ring content |
| 4 | Not HTML | Confirms plain text response |
| 2 | `Content-Type` header | `text/html` |
| 3 | Response body | The HTML shell: mount point and `/js/main.js` script tag |
| 4 | `GET /js/main.js` | 200, JavaScript, non-empty, contains the UI's `/api/add` call |
| 5 | `HEAD /` works | HTTP 200 |
| 6 | `GET /api/ping` | 200, body `pong` |
| 7 | `GET /swagger.json` | 200, JSON, references `/api/ping` |
| 8 | `GET /api-docs` | 200, `text/html` |
| 9 | `GET /api/add?x=2&y=3` | 200, EDN `{:result 5}` |
| 10 | `GET /api/add` with bad params | 400 for a missing or non-numeric param |
Test 4 needs the compiled UI, which the Docker image includes (`script/integration-test`
builds it). Against a locally running server, run `script/ui-build` first.
## Line Coverage
+12 -13
View File
@@ -68,23 +68,22 @@
(assert-eq "HTTP status" 200 (:status (get* base-url)))
(println)
(println "Test 2: Content-Type is text/plain")
(assert-contains "Content-Type" "text/plain" (get (:headers (get* base-url)) "content-type" ""))
(println "Test 2: Content-Type is text/html")
(assert-contains "Content-Type" "text/html" (get (:headers (get* base-url)) "content-type" ""))
(println)
(println "Test 3: Root response points at the API docs")
(println "Test 3: Root serves the HTML shell for the UI")
(let [body (:body (get* base-url))]
(assert-contains "Body mentions /api-docs" "/api-docs" body)
(assert-not-empty "Body is non-empty" body)
(println)
(assert-contains "Body has the mount point" "<div id=\"app\"" body)
(assert-contains "Body loads the compiled UI" "<script src=\"/js/main.js\"" body))
(println)
(println "Test 4: Response is plain text, not HTML")
(if (and (not (str/includes? body "<!DOCTYPE"))
(not (str/includes? body "<html")))
(do (println " ✓ Response is not HTML") (swap! pass inc))
(do (println " ✗ Response appears to be HTML")
(swap! fail inc)
(swap! errors conj "Response was HTML, expected plain text"))))
(println "Test 4: GET /js/main.js serves the compiled UI")
(let [resp (get* (str base-url "/js/main.js"))]
(assert-eq "HTTP status" 200 (:status resp))
(assert-contains "Content-Type" "javascript" (get (:headers resp) "content-type" ""))
(assert-not-empty "Body is non-empty" (:body resp))
(assert-contains "Bundle calls the add API" "/api/add" (:body resp)))
(println)
(println "Test 5: HEAD / returns 200")