Add outerSync swap; WIP on htmax view engine module

This commit is contained in:
2026-06-14 17:23:41 -04:00
parent fa813ff0fe
commit c1441e0741
10 changed files with 404 additions and 113 deletions
+81 -81
View File
@@ -138,24 +138,6 @@ let hxEvent =
Expect.equal (AfterSettle.ToHxOnString()) "after:settle" "AfterSettle hx-on event name not correct"
}
]
testList "AfterSseMessage" [
test "ToString succeeds" {
Expect.equal (string AfterSseMessage) "afterSseMessage" "AfterSseMessage event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(AfterSseMessage.ToHxOnString()) "after:sse:message" "AfterSseMessage hx-on event name not correct"
}
]
testList "AfterSseStream" [
test "ToString succeeds" {
Expect.equal (string AfterSseStream) "afterSseStream" "AfterSseStream event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(AfterSseStream.ToHxOnString()) "after:sse:stream" "AfterSseStream hx-on event name not correct"
}
]
testList "AfterSwap" [
test "ToString succeeds" {
Expect.equal (string AfterSwap) "afterSwap" "AfterSwap event name not correct"
@@ -232,38 +214,6 @@ let hxEvent =
(BeforeResponse.ToHxOnString()) "before:response" "BeforeResponse hx-on event name not correct"
}
]
testList "BeforeSseMessage" [
test "ToString succeeds" {
Expect.equal (string BeforeSseMessage) "beforeSseMessage" "BeforeSseMessage event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(BeforeSseMessage.ToHxOnString())
"before:sse:message"
"BeforeSseMessage hx-on event name not correct"
}
]
testList "BeforeSseReconnect" [
test "ToString succeeds" {
Expect.equal
(string BeforeSseReconnect) "beforeSseReconnect" "BeforeSseReconnect event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(BeforeSseReconnect.ToHxOnString())
"before:sse:reconnect"
"BeforeSseReconnect hx-on event name not correct"
}
]
testList "BeforeSseStream" [
test "ToString succeeds" {
Expect.equal (string BeforeSseStream) "beforeSseStream" "BeforeSseStream event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(BeforeSseStream.ToHxOnString()) "before:sse:stream" "BeforeSseStream hx-on event name not correct"
}
]
testList "BeforeSwap" [
test "ToString succeeds" {
Expect.equal (string BeforeSwap) "beforeSwap" "BeforeSwap event name not correct"
@@ -673,12 +623,6 @@ let attributes =
dt [ _hxVals """{ "extra": "values" }""" ] []
|> shouldRender """<dt hx-vals="{ &quot;extra&quot;: &quot;values&quot; }"></dt>"""
}
test "_sseConnect succeeds" {
div [ _sseConnect "/gps/sse" ] [] |> shouldRender """<div sse-connect="/gps/sse"></div>"""
}
test "_sseSwap succeeds" {
ul [ _sseSwap "sseMessageName" ] [] |> shouldRender """<ul sse-swap="sseMessageName"></ul>"""
}
]
/// Tests for the HxModifiers module
@@ -719,8 +663,6 @@ let hxTags =
}
]
open Giraffe.Htmx.Common
/// Tests for the Script module
let script =
testList "Script" [
@@ -731,13 +673,6 @@ let script =
$"""<script src="/_content/Giraffe.Htmx.Common/htmx.min.js?ver={HtmxVersion}"></script>"""
"Local script tag is incorrect"
}
test "localMax succeeds" {
let html = RenderView.AsString.htmlNode Script.localMax
Expect.equal
html
$"""<script src="/_content/Giraffe.Htmx.Common/htmax.min.js?ver={HtmxVersion}"></script>"""
"Local script tag is incorrect"
}
test "cdnMinified succeeds" {
let html = RenderView.AsString.htmlNode Script.cdnMinified
Expect.equal
@@ -752,20 +687,29 @@ let script =
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmx.js" integrity="sha384-OFLRIZpuqI2wwFozxvDGcuF3TQ36ySMgp44WEthOiR4wFzRkhZbK72HFaBo2C3cx" crossorigin="anonymous"></script>"""
"CDN unminified script tag is incorrect"
}
test "cdnMaxMinified succeeds" {
let html = RenderView.AsString.htmlNode Script.cdnMaxMinified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.min.js" integrity="sha384-Qoqie5IRtOE79SDFFRSb/yKi+pkzpSnfjgwr1KksyP14OaHkLHar0KrLVxUwlsJF" crossorigin="anonymous"></script>"""
"CDN minified script tag is incorrect"
}
test "cdnMaxUnminified succeeds" {
let html = RenderView.AsString.htmlNode Script.cdnMaxUnminified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.js" integrity="sha384-gGi3Urue6ZkE4NrJCmXWIZkfNkrt1IrdP3fr0kb/v06GWg3V1RnD9Pg/Ul3qhtAK" crossorigin="anonymous"></script>"""
"CDN unminified script tag is incorrect"
}
testList "Max" [
test "localMax succeeds" {
let html = RenderView.AsString.htmlNode Script.Max.local
Expect.equal
html
$"""<script src="/_content/Giraffe.Htmx.Common/htmax.min.js?ver={HtmxVersion}"></script>"""
"Local script tag is incorrect"
}
test "cdnMaxMinified succeeds" {
let html = RenderView.AsString.htmlNode Script.Max.cdnMinified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.min.js" integrity="sha384-Qoqie5IRtOE79SDFFRSb/yKi+pkzpSnfjgwr1KksyP14OaHkLHar0KrLVxUwlsJF" crossorigin="anonymous"></script>"""
"CDN minified script tag is incorrect"
}
test "cdnMaxUnminified succeeds" {
let html = RenderView.AsString.htmlNode Script.Max.cdnUnminified
Expect.equal
html
$"""<script src="https://cdn.jsdelivr.net/npm/htmx.org@{HtmxVersion}/dist/htmax.js" integrity="sha384-gGi3Urue6ZkE4NrJCmXWIZkfNkrt1IrdP3fr0kb/v06GWg3V1RnD9Pg/Ul3qhtAK" crossorigin="anonymous"></script>"""
"CDN unminified script tag is incorrect"
}
]
]
open System.Text
@@ -936,6 +880,24 @@ let hxEventObs =
(AfterProcessNode.ToHxOnString()) "after:process" "AfterProcessNode hx-on event name not correct"
}
]
testList "AfterSseMessage" [
test "ToString succeeds" {
Expect.equal (string AfterSseMessage) "afterSseMessage" "AfterSseMessage event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(AfterSseMessage.ToHxOnString()) "after:sse:message" "AfterSseMessage hx-on event name not correct"
}
]
testList "AfterSseStream" [
test "ToString succeeds" {
Expect.equal (string AfterSseStream) "afterSseStream" "AfterSseStream event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(AfterSseStream.ToHxOnString()) "after:sse:stream" "AfterSseStream hx-on event name not correct"
}
]
testList "BeforeCleanupElement" [
test "ToString succeeds" {
Expect.equal
@@ -984,6 +946,38 @@ let hxEventObs =
Expect.equal (BeforeSend.ToHxOnString()) "before:request" "BeforeSend hx-on event name not correct"
}
]
testList "BeforeSseMessage" [
test "ToString succeeds" {
Expect.equal (string BeforeSseMessage) "beforeSseMessage" "BeforeSseMessage event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(BeforeSseMessage.ToHxOnString())
"before:sse:message"
"BeforeSseMessage hx-on event name not correct"
}
]
testList "BeforeSseReconnect" [
test "ToString succeeds" {
Expect.equal
(string BeforeSseReconnect) "beforeSseReconnect" "BeforeSseReconnect event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(BeforeSseReconnect.ToHxOnString())
"before:sse:reconnect"
"BeforeSseReconnect hx-on event name not correct"
}
]
testList "BeforeSseStream" [
test "ToString succeeds" {
Expect.equal (string BeforeSseStream) "beforeSseStream" "BeforeSseStream event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal
(BeforeSseStream.ToHxOnString()) "before:sse:stream" "BeforeSseStream hx-on event name not correct"
}
]
testList "HistoryCacheError" [
test "ToString succeeds" {
Expect.equal (string HistoryCacheError) "historyCacheError" "HistoryCacheError event name not correct"
@@ -1123,7 +1117,7 @@ let hxEventObs =
Expect.equal (string SseError) "sseError" "SseError event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal (SseError.ToHxOnString()) "error" "SseError hx-on event name not correct"
Expect.equal (SseError.ToHxOnString()) "sse:error" "SseError hx-on event name not correct"
}
]
testList "SseOpen" [
@@ -1131,7 +1125,7 @@ let hxEventObs =
Expect.equal (string SseOpen) "sseOpen" "SseOpen event name not correct"
}
test "ToHxOnString succeeds" {
Expect.equal (SseOpen.ToHxOnString()) "sse-open" "SseOpen hx-on event name not correct"
Expect.equal (SseOpen.ToHxOnString()) "after:sse:connection" "SseOpen hx-on event name not correct"
}
]
testList "SwapError" [
@@ -1327,6 +1321,12 @@ let attributesObs =
test "_hxRequest succeeds" {
u [ _hxRequest "noHeaders" ] [] |> shouldRender """<u hx-request="noHeaders"></u>"""
}
test "_sseConnect succeeds" {
div [ _sseConnect "/gps/sse" ] [] |> shouldRender """<div sse-connect="/gps/sse"></div>"""
}
test "_sseSwap succeeds" {
ul [ _sseSwap "sseMessageName" ] [] |> shouldRender """<ul sse-swap="sseMessageName"></ul>"""
}
]
let obsolete = testList "Obsolete" [ hxEventObs; hxParamsObs; hxRequestObs; attributesObs ]