refactor(ssr): full Selmer migration of Transaction Edit; remove the wizard
Squashed Phase-2 SSR work: migrate the Transaction Edit modal's render path entirely to Selmer templates (zero Hiccup in the render path), rip out the multi-step wizard abstraction (EditWizard/LinksStep records, MultiStepFormState, step-params[...] field names, mm/* middleware) in favor of a plain form with flat derived state, and promote shared UI components to reusable Selmer partials under resources/templates/components/. Adds the Selmer interop bridge, the auto-ap.ssr.components.selmer (sc) wrapper library, and the ssr-form-migration skill capturing the learnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
36
test/clj/auto_ap/ssr/selmer_test.clj
Normal file
36
test/clj/auto_ap/ssr/selmer_test.clj
Normal file
@@ -0,0 +1,36 @@
|
||||
(ns auto-ap.ssr.selmer-test
|
||||
(:require
|
||||
[auto-ap.ssr.selmer :as sut]
|
||||
[clojure.string :as str]
|
||||
[clojure.test :refer [deftest is testing]]
|
||||
[hiccup2.core :as h2]))
|
||||
|
||||
(deftest hiccup->html
|
||||
(testing "renders a Hiccup form to an HTML string"
|
||||
(is (= "<span class=\"label\">A & B</span>"
|
||||
(sut/hiccup->html [:span.label "A & B"])))))
|
||||
|
||||
(deftest selmer-embeds-hiccup
|
||||
(testing "a Hiccup component renders inside a Selmer template via |safe"
|
||||
(let [frag (sut/hiccup->html [:span.badge "from hiccup"])
|
||||
out (sut/render-str "<div>{{frag|safe}}</div>" {:frag frag})]
|
||||
(is (str/includes? out "<span class=\"badge\">from hiccup</span>"))
|
||||
;; without |safe the markup would be escaped; |safe keeps it verbatim
|
||||
(is (not (str/includes? out "<span"))))))
|
||||
|
||||
(deftest selmer-fragment-inside-hiccup
|
||||
(testing "a Selmer fragment renders inside a Hiccup tree without double-escaping"
|
||||
(let [sel (sut/render-str "<a href=\"{{url}}\">{{label}}</a>" {:url "/x" :label "Go"})
|
||||
out (str (h2/html {} [:div (sut/raw sel)]))]
|
||||
(is (= "<div><a href=\"/x\">Go</a></div>" out)))))
|
||||
|
||||
(deftest render-file-from-classpath
|
||||
(testing "render-file resolves a template under resources/templates and keeps plain-HTML Alpine/HTMX attrs"
|
||||
(let [out (sut/render "templates/interop-smoke.html"
|
||||
{:title "Interop OK"
|
||||
:hiccup_frag (sut/hiccup->html [:span.badge "from hiccup"])})]
|
||||
(is (str/includes? out "Interop OK"))
|
||||
(is (str/includes? out "from hiccup"))
|
||||
;; plain-HTML attributes (the whole point of Selmer) survive unambiguously
|
||||
(is (str/includes? out "x-model=\"value.value\""))
|
||||
(is (str/includes? out "tippy?.show()")))))
|
||||
@@ -100,6 +100,9 @@
|
||||
{:db/id "vendor-id"
|
||||
:vendor/name "Test Vendor"
|
||||
:vendor/default-account "account-id"}
|
||||
{:db/id "vendor-id-2"
|
||||
:vendor/name "Second Vendor"
|
||||
:vendor/default-account "account-id-2"}
|
||||
(test-transaction :db/id "transaction-id"
|
||||
:transaction/client "client-id"
|
||||
:transaction/bank-account "bank-account-id"
|
||||
@@ -166,7 +169,8 @@
|
||||
:second-account (get tempids "account-id-2")
|
||||
:fixed-location-account (get tempids "account-id-fixed-loc")
|
||||
:ap-account (get tempids "ap-account-id")
|
||||
:vendor (get tempids "vendor-id")})
|
||||
:vendor (get tempids "vendor-id")
|
||||
:vendor2 (get tempids "vendor-id-2")})
|
||||
(reset! test-client-ids
|
||||
{:test (get tempids "client-id")
|
||||
:test2 (get tempids "client-id-2")})
|
||||
|
||||
Reference in New Issue
Block a user