From 01ea05c16e8e01487cb5cfb81bc02fe248dd6c8a Mon Sep 17 00:00:00 2001 From: Roman Zaiev Date: Sun, 15 Nov 2026 18:34:18 +0000 Subject: [PATCH 1/3] Test rhp's charts as a caller meets them rhp's charts lost their tests when the twins that compared only the templates Solid's compiler made of them went: since then nothing ran a chart in a browser but the one the hydration tests prerender, so a scale's ticks and a changed row's redraw were not held by any test, and the vault could not name a proof of either at a release. Each is now tested as a caller meets it, in OCaml, against what rhp draws: the rows plotted by their slat, the chart's range and its ticks, and a row whose field changes redrawn in place on the next frame, the others untouched. --- AGENTS.md | 3 ++ CHANGES.md | 7 +++ docs/src/content/docs/index.mdx | 2 +- test/rhp/chart_test.mlx | 81 +++++++++++++++++++++++++++++++++ test/rhp/dune | 16 +++++++ test/rhp/harness.ml | 38 ++++++++++++++++ vitest.config.ts | 1 + 7 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 test/rhp/chart_test.mlx create mode 100644 test/rhp/dune create mode 100644 test/rhp/harness.ml diff --git a/AGENTS.md b/AGENTS.md index 585a2ef..da6cf6e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -262,6 +262,9 @@ test/kobalte/ each Kobalte component in OCaml beside its TSX twin in test/headless/ each headless component as a caller meets it: its roles, keys and state, and an axe scan; each of Kobalte's fixed, failing on Kobalte's own +test/rhp/ rhp's charts as a caller meets them: rows plotted by + their slat, a scale's range and ticks, a changed row + redrawn in place on the next frame test/heroui/ each HeroUI port's classes and behaviour, in OCaml, run by vitest, and its state beside the same component in React, its twin in twins/; and the variant functions, diff --git a/CHANGES.md b/CHANGES.md index cf82aa1..89cb841 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## 0.11.1 (2026-11-15) + +- rhp's charts are tested as a caller meets them, in OCaml: each row plotted + by its slat, the chart scaled to its range with a tick at each step, and a + row whose field changes redrawn in place on the next frame, the others + untouched. The libraries are 0.11.0's. + ## 0.11.0 (2026-11-15) - In JSX a value is written as itself, and Solid keeps it current, as its diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index 27e711f..54742bd 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -65,7 +65,7 @@ GitHub release: "solid-js": "~1.9.17", "vite": "^8.3.0", "vite-plugin-solid": "^2.11.14", - "vite-plugin-solidtype": "https://github.com/hyphatech/solidtype/releases/download/0.11.0/vite-plugin-solidtype-0.11.0.tgz" + "vite-plugin-solidtype": "https://github.com/hyphatech/solidtype/releases/download/0.11.1/vite-plugin-solidtype-0.11.1.tgz" } } ``` diff --git a/test/rhp/chart_test.mlx b/test/rhp/chart_test.mlx new file mode 100644 index 0000000..ddaf141 --- /dev/null +++ b/test/rhp/chart_test.mlx @@ -0,0 +1,81 @@ +(* rhp's chart through the binding, as a caller meets it: each row plotted + by its slat, the chart scaled to its range with a tick at each step, and a + row whose field changes redrawn in place, the others untouched. *) + +module Bar = Solidtype_rhp.Bar +module Chart = Solidtype_rhp.Chart +module Jsx = Solidtype.Jsx +module Label = Solidtype_rhp.Label +module Plot = Solidtype_rhp.Plot +module Row = Solidtype_rhp.Row +module Scale = Solidtype_rhp.Scale +module Slat = Solidtype_rhp.Slat +module Ticks = Solidtype_rhp.Ticks +module S = Solidtype.Solid +module E = Jest.Expect +module H = Harness +open Harness.Syntax + +type fruit = { name : string; sold : float } + +let fruit = + Slat.make ~thickness:(Slat.number 32.) (fun d -> + let f = Row.data d in +
+ +
) + +let tick = + Slat.make (fun (d : Scale.tick Row.t) -> + let t = Row.data d in +
) + +let fruits = + [| { name = "Apples"; sold = 5. }; { name = "Bananas"; sold = 15. } |] + +let chart rows = + H.render (fun () -> + + + (Row.data d).name) render=fruit /> + ) + +let bars () = H.query_all "[role=list] .rhp-bar" + +let () = + Jest.describe "rhp's chart" (fun () -> + Jest.afterEach H.cleanup; + Jest.test "plots each row by its slat, a bar to its value" (fun () -> + let rows, _ = S.create_signal fruits in + chart rows; + E.( + expect + ( Array.map H.text (H.query_all "[role=listitem] .rhp-label"), + Array.map (H.custom "--rhp-to") (bars ()) ) + |> toEqual ([| "Apples"; "Bananas" |], [| "5"; "15" |]))); + Jest.test "scales the chart to its range, a tick at each step" (fun () -> + let rows, _ = S.create_signal fruits in + chart rows; + let ticks = H.query_all ".rhp-scale .rhp-label" in + let range = H.query ".rhp-chart" in + E.( + expect + ( Array.map H.text ticks, + Array.map (H.custom "--rhp-at") ticks, + (H.custom "--rhp-min" range, H.custom "--rhp-max" range) ) + |> toEqual + ([| "0"; "10"; "20" |], [| "0"; "10"; "20" |], ("0", "20")))); + Jest.testPromise + "redraws a row whose field changes, in place, the others not" (fun () -> + let rows, set_rows = S.create_signal fruits in + chart rows; + let before = bars () in + S.set set_rows [| fruits.(0); { (fruits.(1)) with sold = 18. } |]; + let* () = H.frame () in + let after = bars () in + Js.Promise.resolve + E.( + expect + ( Array.for_all2 ( == ) before after, + Array.map (H.custom "--rhp-to") after ) + |> toEqual (true, [| "5"; "18" |])))) diff --git a/test/rhp/dune b/test/rhp/dune new file mode 100644 index 0000000..6854f49 --- /dev/null +++ b/test/rhp/dune @@ -0,0 +1,16 @@ +; rhp's charts through the binding, as a caller meets them: rows plotted, +; a scale's ticks drawn, and a row that changes redrawn alone. + +(library + (name rhp_test) + (modes melange) + (libraries solidtype solidtype-rhp melange-jest.jest melange.dom) + (preprocess + (pps melange.ppx ppx_solidtype))) + +(melange.emit + (target out) + (modules) + (libraries rhp_test) + (module_systems + (es6 jsx))) diff --git a/test/rhp/harness.ml b/test/rhp/harness.ml new file mode 100644 index 0000000..39452c0 --- /dev/null +++ b/test/rhp/harness.ml @@ -0,0 +1,38 @@ +(* What the tests of rhp's charts reach: Solid's Testing Library, the page, + and a frame, which rhp draws a changed row on. *) + +module Syntax = struct + let ( let* ) p f = Js.Promise.then_ f p +end + +external promise : ((('a -> unit) -> unit)[@mel.uncurry]) -> 'a Js.Promise.t + = "Promise" +[@@mel.new] + +external request_frame : ((float -> unit)[@mel.uncurry]) -> int + = "requestAnimationFrame" + +let frame () = + promise (fun resolve -> ignore (request_frame (fun _ -> resolve ()) : int)) + +external render : (unit -> Solidtype.Jsx.element) -> unit = "render" +[@@mel.module "@solidjs/testing-library"] + +external cleanup : unit -> unit = "cleanup" +[@@mel.module "@solidjs/testing-library"] + +external query : string -> Dom.element = "querySelector" +[@@mel.scope "document"] + +external query_all : string -> Dom.element array = "querySelectorAll" +[@@mel.scope "document"] + +external text : Dom.element -> string = "textContent" [@@mel.get] +external style : Dom.element -> Dom.cssStyleDeclaration = "style" [@@mel.get] + +external property : Dom.cssStyleDeclaration -> string -> string + = "getPropertyValue" +[@@mel.send] + +(* An element's custom property, the value rhp places it by. *) +let custom name e = property (style e) name diff --git a/vitest.config.ts b/vitest.config.ts index 53156e9..716e118 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -49,6 +49,7 @@ export default defineConfig({ "_build/default/test/kobalte/out/test/kobalte/*_test.jsx", "_build/default/test/headless/out/test/headless/*_test.jsx", "_build/default/test/heroui/out/test/heroui/*_test.jsx", + "_build/default/test/rhp/out/test/rhp/*_test.jsx", ], }, }, From f2f553e64c6b41cd36230ed4dd673e35dc31bda6 Mon Sep 17 00:00:00 2001 From: Roman Zaiev Date: Mon, 16 Nov 2026 17:13:06 +0000 Subject: [PATCH 2/3] Release no version for tests alone A test that runs only in this repository changes nothing a user installs, so it names no version: the charts' tests land with the next release's change, not as one of their own. --- CHANGES.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 89cb841..cf82aa1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,12 +1,5 @@ # Changes -## 0.11.1 (2026-11-15) - -- rhp's charts are tested as a caller meets them, in OCaml: each row plotted - by its slat, the chart scaled to its range with a tick at each step, and a - row whose field changes redrawn in place on the next frame, the others - untouched. The libraries are 0.11.0's. - ## 0.11.0 (2026-11-15) - In JSX a value is written as itself, and Solid keeps it current, as its From 3619d03c4c9c42b1316c432db574067c884b286a Mon Sep 17 00:00:00 2001 From: Roman Zaiev Date: Mon, 16 Nov 2026 17:18:10 +0000 Subject: [PATCH 3/3] Install the release there is, 0.11.0 The page's install line named 0.11.1, whose asset no release has made. --- docs/src/content/docs/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index 54742bd..27e711f 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -65,7 +65,7 @@ GitHub release: "solid-js": "~1.9.17", "vite": "^8.3.0", "vite-plugin-solid": "^2.11.14", - "vite-plugin-solidtype": "https://github.com/hyphatech/solidtype/releases/download/0.11.1/vite-plugin-solidtype-0.11.1.tgz" + "vite-plugin-solidtype": "https://github.com/hyphatech/solidtype/releases/download/0.11.0/vite-plugin-solidtype-0.11.0.tgz" } } ```