git.iko.soy/typeable/elm-ui
on master help sign in
fix spacing calculation for width
d188db2Elm UI Automation
tests-rendering/automation/view.js+5−4
@@ -10,6 +10,7 @@ const http = require("http");
10var filepath = null;
10var filepath = null;
11program
11program
12 .option("--run", "run all the tests")
12 .option("--run", "run all the tests")
13+ .option("--debug", "run with debug on")
13 .arguments("<filepath>")
14 .arguments("<filepath>")
14 .action(function (p) {
15 .action(function (p) {
15 filepath = path.join("./cases/open", p);
16 filepath = path.join("./cases/open", p);
@@ -17,7 +18,7 @@ program
17 .parse(process.argv);
18 .parse(process.argv);
18
19
19(async () => {
20(async () => {
20− if (filepath == null) {
21+ if (filepath == null && !program.run) {
21 console.log("Open Cases");
22 console.log("Open Cases");
22 console.log("");
23 console.log("");
23 fs.readdirSync("./tests-rendering/cases/open").forEach((file) => {
24 fs.readdirSync("./tests-rendering/cases/open").forEach((file) => {
@@ -29,13 +30,13 @@ program
29 return;
30 return;
30 }
31 }
31 if (program.run) {
32 if (program.run) {
32− filepath = "src/";
33+ filepath = "./src/Tests/Run.elm";
33 }
34 }
34 console.log("Compiling tests");
35 console.log("Compiling tests");
35 let content = await build.compile_to_string({
36 let content = await build.compile_to_string({
36 template: "./tests-rendering/automation/templates/gather-styles.html",
37 template: "./tests-rendering/automation/templates/gather-styles.html",
37 elm: filepath,
38 elm: filepath,
38− elmOptions: { cwd: "./tests-rendering" },
39+ elmOptions: { cwd: "./tests-rendering", debug: program.debug },
39 });
40 });
40 console.log("Finished compiling");
41 console.log("Finished compiling");
41 // console.log(content);
42 // console.log(content);
@@ -45,7 +46,7 @@ program
45 content = build.compile_to_string({
46 content = build.compile_to_string({
46 template: "./tests-rendering/automation/templates/gather-styles.html",
47 template: "./tests-rendering/automation/templates/gather-styles.html",
47 elm: filepath,
48 elm: filepath,
48− elmOptions: { cwd: "./tests-rendering" },
49+ elmOptions: { cwd: "./tests-rendering", debug: program.debug },
49 });
50 });
50 });
51 });
51 console.log("Serving on http://localhost:8080");
52 console.log("Serving on http://localhost:8080");
tests-rendering/src/Testable.elm+28−2
@@ -19,6 +19,7 @@ module Testable exposing
19 , formatColorWithAlpha
19 , formatColorWithAlpha
20 , getIds
20 , getIds
21 , getSpacing
21 , getSpacing
22+ , getSpacingFromAttributes
22 , runTests
23 , runTests
23 , textHeight
24 , textHeight
24 , toElement
25 , toElement
@@ -481,6 +482,10 @@ createTest { siblings, parent, cache, level, element, location, parentSpacing }
481
482
482 id =
483 id =
483 levelToString level
484 levelToString level
485+ |> Debug.log "id"
486+
487+ _ =
488+ Debug.log "element" element
484
489
485 testChildren : Found -> List (Element msg) -> List LayoutTest
490 testChildren : Found -> List (Element msg) -> List LayoutTest
486 testChildren found children =
491 testChildren found children =
@@ -620,6 +625,7 @@ createTest { siblings, parent, cache, level, element, location, parentSpacing }
620
625
621 attributeTests =
626 attributeTests =
622 attributes
627 attributes
628+ |> Debug.log "attributes"
623 |> List.indexedMap
629 |> List.indexedMap
624 -- Found -> Dict String Found -> List Int -> Int -> Surroundings -> Attr msg -> List Test
630 -- Found -> Dict String Found -> List Int -> Int -> Surroundings -> Attr msg -> List Test
625 (\i attr ->
631 (\i attr ->
@@ -698,8 +704,13 @@ createAttributeTest :
698 -> List LayoutTest
704 -> List LayoutTest
699createAttributeTest parent cache level attrIndex surroundings attr =
705createAttributeTest parent cache level attrIndex surroundings attr =
700 let
706 let
707+ _ =
708+ Debug.log "attribute test" attr
709+
701 domId =
710 domId =
711+ "#"
702− "#" ++ levelToString level
712+ ++ levelToString level
713+ |> Debug.log "domid"
703 in
714 in
704 case attr of
715 case attr of
705 Attr _ ->
716 Attr _ ->
@@ -739,7 +750,7 @@ createAttributeTest parent cache level attrIndex surroundings attr =
739
750
740 Batch batch ->
751 Batch batch ->
741 batch
752 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)
743 |> List.concat
754 |> List.concat
744
755
745 LabeledTest { label, test } ->
756 LabeledTest { label, test } ->
@@ -812,6 +823,21 @@ formatColor (Internal.Rgba red green blue alpha) =
812 ++ ")"
823 ++ ")"
813
824
814
825
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+
815getSpacing : Element msg -> Maybe Int
841getSpacing : Element msg -> Maybe Int
816getSpacing el =
842getSpacing el =
817 let
843 let
tests-rendering/src/Testable/Element.elm+7−4
@@ -436,7 +436,7 @@ widthHelper maybeMin maybeMax len =
436 }
436 }
437 ]
437 ]
438
438
439− Testable.Row _ _ ->
439+ Testable.Row rowAttrs _ ->
440 -- width of row is the sum of all children widths
440 -- width of row is the sum of all children widths
441 -- both text elements and others.
441 -- both text elements and others.
442 let
442 let
@@ -452,11 +452,14 @@ widthHelper maybeMin maybeMax len =
452 horizontalPadding =
452 horizontalPadding =
453 context.self.bbox.padding.left + context.self.bbox.padding.right
453 context.self.bbox.padding.left + context.self.bbox.padding.right
454
454
455− spacingValue =
455+ spacingAmount =
456+ Testable.getSpacingFromAttributes rowAttrs
457+
458+ totalSpacing =
456− toFloat context.parentSpacing * (toFloat (List.length context.children) - 1)
459+ toFloat spacingAmount * (toFloat (List.length context.children) - 1)
457 in
460 in
458 [ expectRoundedEquality
461 [ expectRoundedEquality
459− { expected = totalChildren + horizontalPadding + spacingValue
462+ { expected = totalChildren + horizontalPadding + totalSpacing
460 , found = context.self.bbox.width
463 , found = context.self.bbox.width
461 }
464 }
462 ]
465 ]
tests-rendering/src/Testable/Runner.elm+12−4
@@ -246,11 +246,17 @@ view model =
246 Element.layout
246 Element.layout
247 [ Font.size 16
247 [ Font.size 16
248 , Element.inFront (Element.html (viewElementHighlight model))
248 , Element.inFront (Element.html (viewElementHighlight model))
249+ , Element.height Element.fill
249 ]
250 ]
250 <|
251 <|
251− Element.row [ Element.width Element.fill ]
252+ Element.row [ Element.width Element.fill, Element.height Element.fill ]
252 [ Element.el
253 [ 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
254 ]
260 ]
255 (Element.el
261 (Element.el
256 [ Element.centerX
262 [ Element.centerX
@@ -273,6 +279,8 @@ view model =
273 [ Element.spacing 20
279 [ Element.spacing 20
274 , Element.padding 20
280 , Element.padding 20
275 , Element.width Element.fill
281 , Element.width Element.fill
282+ , Element.height Element.fill
283+ , Element.scrollbarY
276 ]
284 ]
277 (List.map viewResult (finished :: remaining))
285 (List.map viewResult (finished :: remaining))
278 ]
286 ]
@@ -292,7 +300,7 @@ viewElementHighlight model =
292 Just highlightDomId ->
300 Just highlightDomId ->
293 let
301 let
294 elementHighlight =
302 elementHighlight =
295− highlightDomId ++ " { outline: solid; }"
303+ highlightDomId ++ " { outline: solid black; }"
296
304
297 testId =
305 testId =
298 highlightDomId
306 highlightDomId
@@ -300,7 +308,7 @@ viewElementHighlight model =
300 |> String.append "#tests-"
308 |> String.append "#tests-"
301
309
302 testHighlight =
310 testHighlight =
303− testId ++ " { outline: dashed; }"
311+ testId ++ " { outline: dashed black; }"
304
312
305 styleSheet =
313 styleSheet =
306 String.join "\n"
314 String.join "\n"
tests-rendering/src/Tests/Basic.elm+1−1
@@ -5,7 +5,7 @@ module Tests.Basic exposing (view)
5import Element as Actual
5import Element as Actual
6import Html
6import Html
7import Testable
7import Testable
8−import Testable.Element as Element exposing (..)
8+import Testable.Element exposing (..)
9import Testable.Element.Background as Background
9import Testable.Element.Background as Background
10import Testable.Element.Font as Font
10import Testable.Element.Font as Font
11import Testable.Runner
11import Testable.Runner