From 1efabf839340a2939257a213d718da5c3211359b Mon Sep 17 00:00:00 2001 From: JohnnyT Date: Wed, 30 Sep 2026 04:59:12 -0600 Subject: [PATCH] Reads the region's stacking rule whole The map regions test "the stylesheet stacks the shown layer over the region" matched only the opening of the rule that makes the region transparent under a shown hover layer. A rule that also set visibility: hidden or display: none would take the region out of the accessibility tree and the test would still pass. The test now collects every rule whose selector picks the region under a shown layer and asserts the list is exactly one body, opacity: 0;. Sabotaged: visibility: hidden added to the rule, a second rule with display: none selecting the region under a shown layer, and the rule dropped; each turned the test red. The first left the test on main green. Test-only; no lib change. Gate: full mix quality green on this staged tree (3,951 of 3,951 tests, 95.3% coverage, dialyzer clean, ADR cites green). Refs: sb-f23v --- .../editor/map_regions_test.exs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/statifier_blocks/editor/map_regions_test.exs b/test/statifier_blocks/editor/map_regions_test.exs index ada6ac60..a72f01de 100644 --- a/test/statifier_blocks/editor/map_regions_test.exs +++ b/test/statifier_blocks/editor/map_regions_test.exs @@ -398,19 +398,32 @@ if Code.ensure_loaded?(Phoenix.LiveView) do # The stylesheet draws the layer in the region's place: one grid cell, # the region transparent while the layer is shown, and the layer with - # no display of its own, so `hidden` keeps it out. + # no display of its own, so `hidden` keeps it out. The region's rule + # under a shown layer is read whole: transparent and nothing else, so + # the region stays in the accessibility tree. # Sabotage: dropped the rule that makes the region transparent under a # shown layer; this went red. + # Sabotage: added `visibility: hidden` to that rule; this went red. + # Sabotage: added a second rule selecting the region under a shown + # layer with `display: none`; this went red. test "the stylesheet stacks the shown layer over the region" do css = File.read!(Path.expand("../../../assets/css/statifier_blocks.css", __DIR__)) + rules = Regex.scan(~r/([^{}]+)\{([^}]*)\}/, css, capture: :all_but_first) - assert css =~ - ~r/\.sb-map__description-hover:not\(\[hidden\]\)\s*\+\s*\.sb-map__description\s*\{\s*opacity:\s*0;/ + region_rules = + for [selectors, body] <- rules, + selector <- String.split(selectors, ","), + selector = String.trim(selector), + selector =~ ~r/\.sb-map__description-hover:not\(\[hidden\]\)/, + String.ends_with?(selector, ".sb-map__description"), + do: body |> String.split() |> Enum.join(" ") + + assert region_rules == ["opacity: 0;"] assert css =~ ~r/\.sb-map__description-frame\s*\{\s*display:\s*grid;/ layer_rules = - for [_all, selectors, body] <- Regex.scan(~r/([^{}]+)\{([^}]*)\}/, css), + for [selectors, body] <- rules, selector <- String.split(selectors, ","), String.ends_with?(String.trim(selector), ".sb-map__description-hover"), do: body