git.iko.soy/typeable/elm-ui
on master help sign in
fix spacing calculation for width
commitd188db23a744076aa05aa8e902daa464c3af7b41 authorElm UI Automation <automation@elm-ui.com> dateSat 9 May 2020, 14:39 (6 years ago) parentc40b207
5 files changed+53−15
tests-rendering/automation/view.js+5−4 tests-rendering/src/Testable.elm+28−2 tests-rendering/src/Testable/Element.elm+7−4 tests-rendering/src/Testable/Runner.elm+12−4 tests-rendering/src/Tests/Basic.elm+1−1
tests-rendering/automation/view.js+5−4
@@ -10,6 +10,7 @@ const http = require("http");
1010var filepath = null;
1111program
1212 .option("--run", "run all the tests")
13+ .option("--debug", "run with debug on")
1314 .arguments("<filepath>")
1415 .action(function (p) {
1516 filepath = path.join("./cases/open", p);
@@ -17,7 +18,7 @@ program
1718 .parse(process.argv);
1819
1920(async () => {
20− if (filepath == null) {
21+ if (filepath == null && !program.run) {
2122 console.log("Open Cases");
2223 console.log("");
2324 fs.readdirSync("./tests-rendering/cases/open").forEach((file) => {
@@ -29,13 +30,13 @@ program
2930 return;
3031 }
3132 if (program.run) {
32− filepath = "src/";
33+ filepath = "./src/Tests/Run.elm";
3334 }
3435 console.log("Compiling tests");
3536 let content = await build.compile_to_string({
3637 template: "./tests-rendering/automation/templates/gather-styles.html",
3738 elm: filepath,
38− elmOptions: { cwd: "./tests-rendering" },
39+ elmOptions: { cwd: "./tests-rendering", debug: program.debug },
3940 });
4041 console.log("Finished compiling");
4142 // console.log(content);
@@ -45,7 +46,7 @@ program
4546 content = build.compile_to_string({
4647 template: "./tests-rendering/automation/templates/gather-styles.html",
4748 elm: filepath,
48− elmOptions: { cwd: "./tests-rendering" },
49+ elmOptions: { cwd: "./tests-rendering", debug: program.debug },
4950 });
5051 });
5152 console.log("Serving on http://localhost:8080");
tests-rendering/src/Testable.elm+28−2
@@ -19,6 +19,7 @@ module Testable exposing
1919 , formatColorWithAlpha
2020 , getIds
2121 , getSpacing
22+ , getSpacingFromAttributes
2223 , runTests
2324 , textHeight
2425 , toElement
@@ -481,6 +482,10 @@ createTest { siblings, parent, cache, level, element, location, parentSpacing }
481482
482483 id =
483484 levelToString level
485+ |> Debug.log "id"
486+
487+ _ =
488+ Debug.log "element" element
484489
485490 testChildren : Found -> List (Element msg) -> List LayoutTest
486491 testChildren found children =
@@ -620,6 +625,7 @@ createTest { siblings, parent, cache, level, element, location, parentSpacing }
620625
621626 attributeTests =
622627 attributes
628+ |> Debug.log "attributes"
623629 |> List.indexedMap
624630 -- Found -> Dict String Found -> List Int -> Int -> Surroundings -> Attr msg -> List Test
625631 (\i attr ->
@@ -698,8 +704,13 @@ createAttributeTest :
698704 -> List LayoutTest
699705createAttributeTest parent cache level attrIndex surroundings attr =
700706 let
707+ _ =
708+ Debug.log "attribute test" attr
709+
701710 domId =
702− "#" ++ levelToString level
711+ "#"
712+ ++ levelToString level
713+ |> Debug.log "domid"
703714 in
704715 case attr of
705716 Attr _ ->
@@ -739,7 +750,7 @@ createAttributeTest parent cache level attrIndex surroundings attr =
739750
740751 Batch batch ->
741752 batch
742− |> List.indexedMap (\i attribute -> createAttributeTest parent cache (attrIndex :: level) i surroundings attribute)
753+ |> List.indexedMap (\i attribute -> createAttributeTest parent cache level i surroundings attribute)
743754 |> List.concat
744755
745756 LabeledTest { label, test } ->
@@ -812,6 +823,21 @@ formatColor (Internal.Rgba red green blue alpha) =
812823 ++ ")"
813824
814825
826+getSpacingFromAttributes attrs =
827+ case attrs of
828+ [] ->
829+ 0
830+
831+ (Spacing i) :: remain ->
832+ i
833+
834+ (Batch batched) :: remain ->
835+ getSpacingFromAttributes (batched ++ remain)
836+
837+ _ :: remain ->
838+ getSpacingFromAttributes remain
839+
840+
815841getSpacing : Element msg -> Maybe Int
816842getSpacing el =
817843 let
tests-rendering/src/Testable/Element.elm+7−4
@@ -436,7 +436,7 @@ widthHelper maybeMin maybeMax len =
436436 }
437437 ]
438438
439− Testable.Row _ _ ->
439+ Testable.Row rowAttrs _ ->
440440 -- width of row is the sum of all children widths
441441 -- both text elements and others.
442442 let
@@ -452,11 +452,14 @@ widthHelper maybeMin maybeMax len =
452452 horizontalPadding =
453453 context.self.bbox.padding.left + context.self.bbox.padding.right
454454
455− spacingValue =
456− toFloat context.parentSpacing * (toFloat (List.length context.children) - 1)
455+ spacingAmount =
456+ Testable.getSpacingFromAttributes rowAttrs
457+
458+ totalSpacing =
459+ toFloat spacingAmount * (toFloat (List.length context.children) - 1)
457460 in
458461 [ expectRoundedEquality
459− { expected = totalChildren + horizontalPadding + spacingValue
462+ { expected = totalChildren + horizontalPadding + totalSpacing
460463 , found = context.self.bbox.width
461464 }
462465 ]
tests-rendering/src/Testable/Runner.elm+12−4
@@ -246,11 +246,17 @@ view model =
246246 Element.layout
247247 [ Font.size 16
248248 , Element.inFront (Element.html (viewElementHighlight model))
249+ , Element.height Element.fill
249250 ]
250251 <|
251− Element.row [ Element.width Element.fill ]
252+ Element.row [ Element.width Element.fill, Element.height Element.fill ]
252253 [ Element.el
253− [ Element.width Element.fill
254+ [ Element.width
255+ (Element.fill
256+ |> Element.maximum 900)
257+ , Element.alignTop
258+ , Element.height Element.fill
259+ , Element.scrollbars
254260 ]
255261 (Element.el
256262 [ Element.centerX
@@ -273,6 +279,8 @@ view model =
273279 [ Element.spacing 20
274280 , Element.padding 20
275281 , Element.width Element.fill
282+ , Element.height Element.fill
283+ , Element.scrollbarY
276284 ]
277285 (List.map viewResult (finished :: remaining))
278286 ]
@@ -292,7 +300,7 @@ viewElementHighlight model =
292300 Just highlightDomId ->
293301 let
294302 elementHighlight =
295− highlightDomId ++ " { outline: solid; }"
303+ highlightDomId ++ " { outline: solid black; }"
296304
297305 testId =
298306 highlightDomId
@@ -300,7 +308,7 @@ viewElementHighlight model =
300308 |> String.append "#tests-"
301309
302310 testHighlight =
303− testId ++ " { outline: dashed; }"
311+ testId ++ " { outline: dashed black; }"
304312
305313 styleSheet =
306314 String.join "\n"
tests-rendering/src/Tests/Basic.elm+1−1
@@ -5,7 +5,7 @@ module Tests.Basic exposing (view)
55import Element as Actual
66import Html
77import Testable
8−import Testable.Element as Element exposing (..)
8+import Testable.Element exposing (..)
99import Testable.Element.Background as Background
1010import Testable.Element.Font as Font
1111import Testable.Runner