Fix browser.cljs bug

Add automation for testing browser code.
This commit is contained in:
erik 2022-10-18 13:09:13 +02:00
parent 8a97900cda
commit 5ef80e7710
5 changed files with 51 additions and 21 deletions

22
copy-and-build-dda-io.sh Normal file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# set things
set -o nounset
set -o xtrace
set -o errexit
set -eo pipefail
# dirs
srcDir="/home/$USER/"
srcName="main.js"
targetDir="/home/$USER/"
targetName="c4k-website.js"
echo "build"
shadow-cljs compile frontend
echo "move and rename file"
cp $srcDir$srcName $targetDir$targetName
echo "build"
(cd $targetDir; lein ring server)

View file

@ -24,6 +24,19 @@
(def certificate? (s/keys :req-un [::fqdns ::cert-name]
:opt-un [::issuer]))
#?(:cljs
(defmethod yaml/load-resource :ingress [resource-name]
(case resource-name
"ingress/host-rule.yaml" (rc/inline "ingress/host-rule.yaml")
"ingress/certificate.yaml" (rc/inline "ingress/certificate.yaml")
"ingress/http-ingress.yaml" (rc/inline "ingress/http-ingress.yaml")
"ingress/https-ingress.yaml" (rc/inline "ingress/https-ingress.yaml")
(throw (js/Error. "Undefined Resource!")))))
#?(:cljs
(defmethod yaml/load-as-edn :ingress [resource-name]
(yaml/from-string (yaml/load-resource resource-name))))
(defn-spec generate-host-rule pred/map-or-seq?
[service-name ::service-name
service-port ::service-port

View file

@ -20,7 +20,7 @@
(s/def ::unique-name string?)
(s/def ::issuer pred/letsencrypt-issuer?)
(s/def ::authtoken pred/bash-env-string?)
(s/def ::fqdns fqdn-list?)
(s/def ::fqdns (s/coll-of pred/fqdn-string?))
(s/def ::gitea-host pred/fqdn-string?)
(s/def ::gitea-repo string?)
(s/def ::branchname string?)
@ -79,10 +79,7 @@
#?(:cljs
(defmethod yaml/load-resource :website [resource-name]
(case resource-name
"ingress/certificate.yaml" (rc/inline "ingress/certificate.yaml")
"ingress/http-ingress.yaml" (rc/inline "ingress/http-ingress.yaml")
"ingress/https-ingress.yaml" (rc/inline "ingress/https-ingress.yaml")
(case resource-name
"website/nginx-configmap.yaml" (rc/inline "website/nginx-configmap.yaml")
"website/nginx-deployment.yaml" (rc/inline "website/nginx-deployment.yaml")
"website/nginx-service.yaml" (rc/inline "website/nginx-service.yaml")

View file

@ -3,7 +3,7 @@
[clojure.string :as st]
[clojure.tools.reader.edn :as edn]
[dda.c4k-website.core :as core]
[dda.c4k-website.website :as website]
[dda.c4k-website.website :as website]
[dda.c4k-common.browser :as br]
[dda.c4k-common.common :as cm]))
@ -31,17 +31,18 @@
(cm/concat-vec
(br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" "")
(br/generate-text-area
"websites" "A map containing fqdns and repo infos for each website:"
"[{:unique-name \"test.io \",
:fqdns [\"test.de \" \"www.test.de \"],
:gitea-host \"githost.de \",
:gitea-repo \"repo \",
:branchname \"main \"}
"websites" "A collection containing fqdns and repo infos for each website:"
"{:websites
[{:unique-name \"test.io\",
:fqdns [\"test.de\" \"www.test.de\"],
:gitea-host \"githost.de\",
:gitea-repo \"repo\",
:branchname \"main\"}
{:unique-name \"example.io \",
:fqdns [\"example.org \" \"www.example.org \"],
:gitea-host \"githost.org \",
:gitea-repo \"repo \",
:branchname \"main \"}]"
:fqdns [\"example.org\" \"www.example.org\"],
:gitea-host \"githost.org\",
:gitea-repo \"repo\",
:branchname \"main\"}]}"
"10")))
(generate-group
"credentials"
@ -74,7 +75,7 @@
{:issuer issuer}))))
(defn validate-all! []
(br/validate! "websites" ::website/websites)
(br/validate! "websites" website/config? :deserializer edn/read-string)
(br/validate! "issuer" ::website/issuer :optional true)
(br/validate! "auth" website/auth? :deserializer edn/read-string)
(br/set-form-validated!))

View file

@ -3,10 +3,7 @@
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
[clojure.spec.test.alpha :as st]
[dda.c4k-common.test-helper :as th]
[dda.c4k-common.base64 :as b64]
[dda.c4k-website.ingress :as cut]
[clojure.spec.alpha :as s]))
[dda.c4k-website.ingress :as cut]))
(st/instrument `cut/generate-host-rule)
(st/instrument `cut/generate-http-ingress)