diff --git a/test/dune b/test/dune index e64e037..426a7a0 100644 --- a/test/dune +++ b/test/dune @@ -48,6 +48,17 @@ (applies_to diagnostics) (deps %{bin:print-diagnostics})) +(cram + (applies_to + htmx-numbering + htmx-parent-handling + htmx-query + htmx-routing + server) + (locks /server-tests) + (deps + (package forester))) + (cram (deps (package forester))) diff --git a/test/htmx-numbering.t b/test/htmx-numbering.t index 8678609..1856fbe 100644 --- a/test/htmx-numbering.t +++ b/test/htmx-numbering.t @@ -19,19 +19,19 @@ classes are being set > \transclude{b} > EOF - $ forester start --no-browser --port 8082 & - Forester is running on http://localhost:8082 + $ forester start --no-browser & + Forester is running on http://localhost:8080 $ SERVER_PID=$! - $ curl -s --retry 5 --retry-connrefused -H "Hx-Request: true" http://localhost:8082/home > home.html + $ curl -s --retry 5 --retry-connrefused -H "Hx-Request: true" http://localhost:8080/home > home.html This is what the server would do via the headers encoded in the page: $ curl -s -H "Hx-Request: true" -H "Full: true" -H "Included-In-Toc: true" \ > -H "Header-Shown: true" -H "Metadata-Shown: false" \ > -H "Numbered-Effective: true" -H "Expanded: true" \ - > http://localhost:8082/preview/b/ | grep -oE '[^<]*()?[^<]*' + > http://localhost:8080/preview/b/ | grep -oE '[^<]*()?[^<]*' We can also disable numbering, via the Numbered-Effective flag: @@ -39,7 +39,8 @@ We can also disable numbering, via the Numbered-Effective flag: $ curl -s -H "Hx-Request: true" -H "Full: true" -H "Included-In-Toc: true" \ > -H "Header-Shown: true" -H "Metadata-Shown: false" \ > -H "Numbered-Effective: false" -H "Expanded: true" \ - > http://localhost:8082/preview/b/ | grep -oE '[^<]*()?[^<]*' + > http://localhost:8080/preview/b/ | grep -oE '[^<]*()?[^<]*' $ kill $SERVER_PID + $ wait $SERVER_PID 2>/dev/null || true diff --git a/test/htmx-parent-handling.t b/test/htmx-parent-handling.t index 682d872..e39f7d2 100644 --- a/test/htmx-parent-handling.t +++ b/test/htmx-parent-handling.t @@ -11,12 +11,12 @@ > \transclude{blog} > EOF - $ forester start --no-browser --port 8084 & - Forester is running on http://localhost:8084 + $ forester start --no-browser & + Forester is running on http://localhost:8080 $ SERVER_PID=$! - $ curl -s --retry 5 --retry-connrefused -H "Hx-Request: true" http://localhost:8084/home > /dev/null + $ curl -s --retry 5 --retry-connrefused -H "Hx-Request: true" http://localhost:8080/home > /dev/null When scope is set to parent, no caret is shown: @@ -24,12 +24,13 @@ When scope is set to parent, no caret is shown: > -H "Header-Shown: true" -H "Metadata-Shown: false" \ > -H "Numbered: true" -H "Expanded: true" -H "Number-Path: 1" \ > -H "Scope: https://www.my-great-forest.net/index/" \ - > http://localhost:8084/preview/blog/ | grep -oE 'Index › Blog' + > http://localhost:8080/preview/blog/ | grep -oE 'Index › Blog' [1] When viewing on its own, there is a caret - $ curl -s -H "Hx-Request: true" http://localhost:8084/preview/blog/ | grep -oE 'Index › Blog' + $ curl -s -H "Hx-Request: true" http://localhost:8080/preview/blog/ | grep -oE 'Index › Blog' Index › Blog $ kill $SERVER_PID + $ wait $SERVER_PID 2>/dev/null || true diff --git a/test/htmx-query.t b/test/htmx-query.t index abb5dbf..2edb6bf 100644 --- a/test/htmx-query.t +++ b/test/htmx-query.t @@ -35,18 +35,19 @@ > } > EOF - $ forester start --no-browser --port 8085 & - Forester is running on http://localhost:8085 + $ forester start --no-browser & + Forester is running on http://localhost:8080 $ SERVER_PID=$! - $ curl -s --retry 5 --retry-connrefused http://localhost:8085 > /dev/null + $ curl -s --retry 5 --retry-connrefused http://localhost:8080 > /dev/null - $ curl -s -H "Hx-Request: true" http://localhost:8085/home > home.html + $ curl -s -H "Hx-Request: true" http://localhost:8080/home > home.html $ grep -oE 'data-hx-get="/query"' home.html data-hx-get="/query" $ HEADERS_JSON=$(grep -oP "(?<=data-hx-headers=')[^']*" home.html) $ QUERY_HEADER=$(echo "$HEADERS_JSON" | jq -r '.Query') - $ curl -s -H "Hx-Request: true" -H "Query: $QUERY_HEADER" http://localhost:8085/query | grep -oE 'Some novel result' + $ curl -s -H "Hx-Request: true" -H "Query: $QUERY_HEADER" http://localhost:8080/query | grep -oE 'Some novel result' Some novel result $ kill $SERVER_PID + $ wait $SERVER_PID 2>/dev/null || true diff --git a/test/htmx-routing.t b/test/htmx-routing.t index 4d6dd78..ba90e1a 100644 --- a/test/htmx-routing.t +++ b/test/htmx-routing.t @@ -9,22 +9,23 @@ > \title{Foo} > EOF - $ forester start --no-browser --port 8081 & - Forester is running on http://localhost:8081 + $ forester start --no-browser & + Forester is running on http://localhost:8080 $ SERVER_PID=$! - $ curl -s --retry 5 --retry-connrefused http://localhost:8081 > /dev/null + $ curl -s --retry 5 --retry-connrefused http://localhost:8080 > /dev/null - $ curl -s http://localhost:8081/preview/index/ | grep -oE 'href="[^"]*foo[^"]*"' + $ curl -s http://localhost:8080/preview/index/ | grep -oE 'href="[^"]*foo[^"]*"' href="/preview/foo/" href="/preview/foo/" Full page has docs button: - $ curl -s http://localhost:8081/preview/index/ | grep -oE 'href="[^"]*forester-notes.org[^"]*"' + $ curl -s http://localhost:8080/preview/index/ | grep -oE 'href="[^"]*forester-notes.org[^"]*"' href="/preview/foreign/forester-notes.org/index/" - $ curl -s -H "Hx-Request: true" http://localhost:8081/preview/index/ | grep -oE 'href="[^"]*foo[^"]*"' + $ curl -s -H "Hx-Request: true" http://localhost:8080/preview/index/ | grep -oE 'href="[^"]*foo[^"]*"' href="/preview/foo/" href="/preview/foo/" $ kill $SERVER_PID + $ wait $SERVER_PID 2>/dev/null || true diff --git a/test/lsp/dune b/test/lsp/dune index 11145f0..099893a 100644 --- a/test/lsp/dune +++ b/test/lsp/dune @@ -4,6 +4,7 @@ (cram (deps harness.lua %{bin:forester}) + (locks /server-tests) (enabled_if %{bin-available:nvim})) (cram diff --git a/test/server.t b/test/server.t index 37b44a7..1bdc3a7 100644 --- a/test/server.t +++ b/test/server.t @@ -6,33 +6,34 @@ > \title{HTTP server test} > \[src]{\route-asset{assets/pic.png}}{} > EOF - $ forester start --no-browser --port=8083 & - Forester is running on http://localhost:8083 + $ forester start --no-browser & + Forester is running on http://localhost:8080 $ SERVER_PID=$! - $ curl -s --retry 5 --retry-connrefused http://localhost:8083 > response.html + $ curl -s --retry 5 --retry-connrefused http://localhost:8080 > response.html $ cat response.html | grep -Fo '
'
The json manifest is available: - $ curl -s http://localhost:8083/forest.json | grep -Fo '"title":"HTTP server test"' + $ curl -s http://localhost:8080/forest.json | grep -Fo '"title":"HTTP server test"' "title":"HTTP server test" Links in the manifest are routed to preview: - $ curl -s http://localhost:8083/forest.json | grep -Fo '/preview/index/' + $ curl -s http://localhost:8080/forest.json | grep -Fo '/preview/index/' /preview/index/ The docs are routed like any other foreign forest - $ curl -s --retry 5 --retry-connrefused http://localhost:8083/preview/foreign/forester-notes.org/index/ | grep -o "maintained by" + $ curl -s --retry 5 --retry-connrefused http://localhost:8080/preview/foreign/forester-notes.org/index/ | grep -o "maintained by" maintained by Assets are available: - $ curl -s -H "Hx-Request: true" http://localhost:8083/home > home.html + $ curl -s -H "Hx-Request: true" http://localhost:8080/home > home.html $ ASSET_SRC=$(grep -oE '/preview/[a-z0-9]+\.png' home.html) - $ curl -s http://localhost:8083$ASSET_SRC + $ curl -s http://localhost:8080$ASSET_SRC fake png - $ curl -s -o /dev/null -w '%{content_type}\n' http://localhost:8083$ASSET_SRC + $ curl -s -o /dev/null -w '%{content_type}\n' http://localhost:8080$ASSET_SRC image/png $ kill $SERVER_PID + $ wait $SERVER_PID 2>/dev/null || true