summaryrefslogtreecommitdiff
path: root/tools/copland/tests/smoke.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/copland/tests/smoke.sh')
-rwxr-xr-xtools/copland/tests/smoke.sh188
1 files changed, 188 insertions, 0 deletions
diff --git a/tools/copland/tests/smoke.sh b/tools/copland/tests/smoke.sh
new file mode 100755
index 0000000..bd54bab
--- /dev/null
+++ b/tools/copland/tests/smoke.sh
@@ -0,0 +1,188 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+root_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
+source "$root_dir/scripts/fossil-env.sh"
+test_dir=$(mktemp -d -t copland-smoke.XXXXXX)
+port=${COPLAND_TEST_PORT:-18081}
+server_pid=""
+
+finish() {
+ if [[ -n "$server_pid" ]]; then
+ kill "$server_pid" 2>/dev/null || true
+ wait "$server_pid" 2>/dev/null || true
+ fi
+}
+trap finish EXIT INT TERM
+
+require_org_fossil
+"$root_dir/scripts/create-demo.sh" "$test_dir"
+verify_org_mime "$test_dir/repositories/alpha.fossil"
+"$FOSSIL" sql -R "$test_dir/repositories/alpha.fossil" \
+ "REPLACE INTO config(name,value,mtime) VALUES('doc-glob','*.org',unixepoch());"
+"$FOSSIL" fts-config enable document -R "$test_dir/repositories/alpha.fossil" >/dev/null
+"$FOSSIL" fts-config enable wiki -R "$test_dir/repositories/alpha.fossil" >/dev/null
+"$FOSSIL" fts-config index on -R "$test_dir/repositories/alpha.fossil" >/dev/null
+"$FOSSIL" fts-config reindex -R "$test_dir/repositories/alpha.fossil" >/dev/null
+
+FOSSIL_REPOLIST_TITLE=Copland "$FOSSIL" server \
+ --localhost \
+ --localauth \
+ --port "$port" \
+ --repolist \
+ "$test_dir/repositories" >"$test_dir/server.log" 2>&1 &
+server_pid=$!
+
+base_url="http://127.0.0.1:$port"
+for attempt in $(seq 1 50); do
+ if curl --fail --location --silent "$base_url/" >/dev/null; then
+ break
+ fi
+ if [[ "$attempt" -eq 50 ]]; then
+ printf 'Fossil server did not start.\n' >&2
+ sed -n '1,120p' "$test_dir/server.log" >&2
+ exit 1
+ fi
+ sleep 0.1
+done
+
+paths=(
+ "/"
+ "/alpha/home"
+ "/alpha/timeline"
+ "/alpha/tree?ci=tip"
+ "/alpha/dir?ci=tip"
+ "/alpha/brlist"
+ "/alpha/taglist"
+ "/alpha/wiki"
+ "/alpha/wiki?name=Org%20Wiki"
+ "/alpha/wikiedit?name=New%20Org%20Page"
+ "/alpha/whistory?name=Org%20Wiki"
+ "/alpha/reportlist"
+ "/alpha/forum"
+ "/alpha/login"
+ "/alpha/sitemap"
+ "/alpha/doc/tip/docs/org-support.org"
+ "/alpha/file?name=docs/org-support.org&ci=tip"
+ "/alpha/file?name=docs/org-support.org&ci=tip&txt=1"
+ "/alpha/search?s=Native%20Org%20preview&y=d"
+ "/alpha/search?s=deployment%20guide&y=w"
+)
+
+for path in "${paths[@]}"; do
+ body=$(curl --fail --location --silent --show-error "$base_url$path")
+ if [[ "$body" != *"Copland"* ]]; then
+ printf 'Copland marker missing from %s\n' "$path" >&2
+ exit 1
+ fi
+ if [[ "$body" == *"thmainError"* ]]; then
+ printf 'TH1 template error on %s\n' "$path" >&2
+ exit 1
+ fi
+ if [[ "$path" == "/" && ("$body" != *"Alpha"* || "$body" != *"Beta"*) ]]; then
+ printf 'Demo repositories missing from repository list\n' >&2
+ exit 1
+ fi
+ if [[ "$path" == "/alpha/home" ]]; then
+ mainmenu=${body#*'<nav class="container mainmenu"'}
+ mainmenu=${mainmenu%%'</nav>'*}
+ for hidden_route in chat taglist forum reportlist sitemap ticket tkt; do
+ if [[ "$mainmenu" == *"/$hidden_route"* ]]; then
+ printf 'Hidden route /%s is still present in the main menu\n' "$hidden_route" >&2
+ exit 1
+ fi
+ done
+ fi
+ if [[ "$path" == "/alpha/wiki" ]]; then
+ if [[ "$body" != *"Available Wiki Pages"* || "$body" != *"Org Wiki"* ]]; then
+ printf 'Wiki landing page did not list available pages\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/tree?ci=tip" ]]; then
+ if [[ "$body" != *'class="org-document"'* || "$body" != *"A small repository"* ]]; then
+ printf 'README.org was not rendered below the repository tree\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/doc/tip/docs/org-support.org" ]]; then
+ if [[ "$body" != *'<title>Alpha: Native Org preview</title>'*
+ || "$body" != *'class="org-toc"'*
+ || "$body" != *'href="../README.org"'*
+ || "$body" != *'id="overview"'* ]]; then
+ printf 'Native Org /doc rendering is incomplete\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/wiki?name=Org%20Wiki" ]]; then
+ if [[ "$body" != *'<title>Alpha: Org Wiki</title>'*
+ || "$body" != *'class="org-document"'*
+ || "$body" == *'class="org-title"'*
+ || "$body" != *'href="wiki?name=Deployment+Guide"'*
+ || "$body" != *'href="doc/tip/docs/org-support.org"'* ]]; then
+ printf 'Native Org wiki rendering is incomplete\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/wikiedit?name=New%20Org%20Page" ]]; then
+ if [[ "$body" != *'value="text/x-org" selected'* ]]; then
+ printf 'Org is not the default format in the wiki editor\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/file?name=docs/org-support.org&ci=tip" ]]; then
+ if [[ "$body" != *'class="org-document"'* || "$body" != *'>Text</a>'* ]]; then
+ printf 'Native Org /file rendering or Text toggle is missing\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/file?name=docs/org-support.org&ci=tip&txt=1" ]]; then
+ if [[ "$body" == *'class="org-document"'* || "$body" != *'#+title: Native Org preview'* ]]; then
+ printf 'Org /file Text view did not show source\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/search?s=Native%20Org%20preview&y=d" ]]; then
+ if [[ "$body" != *"Native Org preview"* ]]; then
+ printf 'Org document was not found by full-text search\n' >&2
+ exit 1
+ fi
+ fi
+ if [[ "$path" == "/alpha/search?s=deployment%20guide&y=w" ]]; then
+ if [[ "$body" != *"Org Wiki"* ]]; then
+ printf 'Org wiki page was not found by full-text search\n' >&2
+ exit 1
+ fi
+ fi
+ printf 'ok %s\n' "$path"
+done
+
+default_skin_body=$(curl --fail --location --silent --show-error \
+ "$base_url/alpha/home?skin=default")
+if [[ "$default_skin_body" == *'class="site-brand"'* ]]; then
+ printf 'The original Fossil default skin is not selectable\n' >&2
+ exit 1
+fi
+copland_skin_body=$(curl --fail --location --silent --show-error \
+ "$base_url/alpha/home?skin=copland")
+if [[ "$copland_skin_body" != *'class="site-brand"'* ]]; then
+ printf 'The built-in Copland skin is not selectable\n' >&2
+ exit 1
+fi
+
+json_wiki=$(curl --fail --silent --show-error \
+ "$base_url/alpha/json/wiki/get?name=Org%20Wiki&format=html")
+if [[ "$json_wiki" != *'org-document'* || "$json_wiki" != *'contentFormat":"html'* ]]; then
+ printf 'JSON wiki output did not render Org\n' >&2
+ exit 1
+fi
+json_preview=$(curl --fail --silent --show-error \
+ --header 'Content-Type: application/json' \
+ --data '{"payload":{"body":"* JSON preview","mimetype":"text/x-org"}}' \
+ "$base_url/alpha/json/wiki/preview")
+if [[ "$json_preview" != *'org-document'* || "$json_preview" != *'JSON preview'* ]]; then
+ printf 'JSON wiki preview did not render Org\n' >&2
+ exit 1
+fi
+
+printf 'Smoke tests passed. Temporary fixtures: %s\n' "$test_dir"