Skip to content

Commit e139e36

Browse files
committed
Add CSS compiler integration tests
1 parent e41b455 commit e139e36

3 files changed

Lines changed: 83 additions & 12 deletions

File tree

.spec/planning/css_style_authoring/phase-04-compiler-iur-tooling-and-runtime-alignment.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Back to index: [README](./README.md)
2424
- Examples should demonstrate CSS authoring and canonical output without
2525
implying full browser CSS coverage.
2626

27-
[ ] 4 Phase 4 - Compiler, IUR, Tooling, and Runtime Alignment
27+
[x] 4 Phase 4 - Compiler, IUR, Tooling, and Runtime Alignment
2828
Integrate CSS-derived styles into deterministic compiler output, canonical
2929
IUR representation, author tooling, examples, and runtime realization checks.
3030

@@ -94,24 +94,24 @@ Back to index: [README](./README.md)
9494
[x] 4.3.2.3 Subtask - Document terminal and desktop degradation expectations for style concepts that cannot be visually identical to browser CSS.
9595
[x] 4.3.2.4 Subtask - Ensure runtime-specific stylesheet loading remains a runtime concern and is not required by canonical CSS block lowering.
9696

97-
[ ] 4.4 Section - Phase 4 Integration Tests
97+
[x] 4.4 Section - Phase 4 Integration Tests
9898
Validate end-to-end CSS authoring from DSL input through canonical IUR and
9999
runtime-facing realization checks.
100100

101-
[ ] 4.4.1 Task - End-to-end compiler and IUR scenarios
101+
[x] 4.4.1 Task - End-to-end compiler and IUR scenarios
102102
Verify CSS stylesheet blocks produce deterministic canonical output and
103103
diagnostics through the full compiler path.
104104

105-
[ ] 4.4.1.1 Subtask - Verify a CSS-authored module compiles into canonical IUR style attachments with no raw CSS runtime field.
106-
[ ] 4.4.1.2 Subtask - Verify CSS-derived style values merge correctly with theme defaults, style references, local styles, variants, and direct props.
107-
[ ] 4.4.1.3 Subtask - Verify inspection explains source block, selector, declaration, cascade reason, and ignored constructs for representative CSS-derived values.
108-
[ ] 4.4.1.4 Subtask - Verify canonical IUR validation accepts CSS-derived canonical style data and rejects required raw CSS interchange data.
105+
[x] 4.4.1.1 Subtask - Verify a CSS-authored module compiles into canonical IUR style attachments with no raw CSS runtime field.
106+
[x] 4.4.1.2 Subtask - Verify CSS-derived style values merge correctly with theme defaults, style references, local styles, variants, and direct props.
107+
[x] 4.4.1.3 Subtask - Verify inspection explains source block, selector, declaration, cascade reason, and ignored constructs for representative CSS-derived values.
108+
[x] 4.4.1.4 Subtask - Verify canonical IUR validation accepts CSS-derived canonical style data and rejects required raw CSS interchange data.
109109

110-
[ ] 4.4.2 Task - Tooling and runtime boundary scenarios
110+
[x] 4.4.2 Task - Tooling and runtime boundary scenarios
111111
Verify author tooling and runtime renderers observe the canonical
112112
boundary established by the ADR and specs.
113113

114-
[ ] 4.4.2.1 Subtask - Verify inspect/export/validate commands report CSS authoring summaries and diagnostics deterministically.
115-
[ ] 4.4.2.2 Subtask - Verify maintained examples demonstrate supported selectors, supported declarations, ignored unsupported CSS, and the semantic-equivalence caveat.
116-
[ ] 4.4.2.3 Subtask - Verify `live_ui` renders representative CSS-derived canonical style output through native style realization without needing the authored CSS block.
117-
[ ] 4.4.2.4 Subtask - Verify cross-runtime parity checks compare canonical style meaning and documented degradation rather than raw CSS output.
114+
[x] 4.4.2.1 Subtask - Verify inspect/export/validate commands report CSS authoring summaries and diagnostics deterministically.
115+
[x] 4.4.2.2 Subtask - Verify maintained examples demonstrate supported selectors, supported declarations, ignored unsupported CSS, and the semantic-equivalence caveat.
116+
[x] 4.4.2.3 Subtask - Verify `live_ui` renders representative CSS-derived canonical style output through native style realization without needing the authored CSS block.
117+
[x] 4.4.2.4 Subtask - Verify cross-runtime parity checks compare canonical style meaning and documented degradation rather than raw CSS output.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
defmodule UnifiedUi.CssPhase4IntegrationTest do
2+
use ExUnit.Case, async: true
3+
4+
alias UnifiedUi.{Compiler, Export}
5+
6+
defmodule PhaseFourWorkspace do
7+
use UnifiedUi.Dsl
8+
9+
identity do
10+
id(:css_phase_four_workspace)
11+
title("CSS Phase Four Workspace")
12+
end
13+
14+
themes do
15+
css :styles do
16+
source("""
17+
#panel { color: #2563eb; padding: 8px; }
18+
button:disabled { opacity: 0.35; }
19+
@import url("remote.css");
20+
.unsupported:hover { color: red; }
21+
""")
22+
end
23+
end
24+
25+
composition do
26+
root(:css_phase_four_root)
27+
28+
box :panel do
29+
button :save do
30+
label("Save")
31+
disabled?(true)
32+
end
33+
end
34+
end
35+
end
36+
37+
test "compiles CSS-authored modules into canonical IUR style attachments without raw CSS" do
38+
iur = Compiler.iur!(PhaseFourWorkspace)
39+
panel = iur.children |> hd() |> Map.fetch!(:element)
40+
button = panel.children |> hd() |> Map.fetch!(:element)
41+
42+
assert UnifiedIUR.Validate.element(iur) == :ok
43+
assert panel.attributes.style.foreground == %{mode: :rgb, red: 37, green: 99, blue: 235}
44+
assert panel.attributes.style.spacing.padding_top == %{value: 8, unit: :px}
45+
assert panel.attributes.style.extra.css.properties == ["color", "padding"]
46+
assert button.attributes.style.state_variants.disabled.visibility == %{opacity: 0.35}
47+
48+
refute Map.has_key?(iur.attributes, :css)
49+
refute Map.has_key?(panel.attributes, :css)
50+
end
51+
52+
test "inspection and export report CSS summaries and diagnostics deterministically" do
53+
report = Compiler.inspection(PhaseFourWorkspace)
54+
{:ok, inspection} = Export.module(PhaseFourWorkspace, :inspection)
55+
56+
assert report.listing.css.summary.rule_count == 3
57+
assert report.listing.css.summary.diagnostic_count == 1
58+
assert inspection =~ "css blocks: 1"
59+
assert inspection =~ "css rules: 3"
60+
assert inspection =~ "css diagnostics: 1"
61+
end
62+
end

packages/unified-ui/test/unified_ui/info_test.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ defmodule UnifiedUi.InfoTest do
7575
default_target: :session,
7676
mode: :canonical
7777
},
78+
css: %{
79+
count: 0,
80+
blocks: [],
81+
parser: :csserpent,
82+
rule_count: 0,
83+
declaration_count: 0,
84+
ignored_count: 0,
85+
diagnostic_count: 0
86+
},
7887
theme_catalog: %{
7988
default_theme: :workspace,
8089
inherit?: false,

0 commit comments

Comments
 (0)