git.iko.soy/typeable/elm-ui
on master help sign in
support paragraph wrapping case
fe73cbdElm UI Automation
tests-rendering/src/Testable.elm+34−3
@@ -20,6 +20,7 @@ module Testable exposing
20 , getIds
20 , getIds
21 , getSpacing
21 , getSpacing
22 , getSpacingFromAttributes
22 , getSpacingFromAttributes
23+ , lessThanOrEqual
23 , runTests
24 , runTests
24 , textHeight
25 , textHeight
25 , toElement
26 , toElement
@@ -192,9 +193,21 @@ type alias TextMetrics =
192 }
193 }
193
194
194
195
196+{-| The font metrics we currently have are `actual`, meaning for the text actually rendered, not the font as a whole.
197+
198+We also know the font size is 20, so we're just going to return 20.
199+
200+TODO: improve font metric collection using something like opentype.js
201+
202+-}
195textHeight metrics =
203textHeight metrics =
204+ let
205+ actualHeight =
196− metrics.actualBoundingBoxAscent
206+ metrics.actualBoundingBoxAscent
197− + metrics.actualBoundingBoxDescent
207+ + metrics.actualBoundingBoxDescent
208+ in
209+ -- actualHeight / 20
210+ 20
198
211
199
212
200{-| -}
213{-| -}
@@ -238,6 +251,19 @@ type alias LayoutTest =
238{- Expectations -}
251{- Expectations -}
239
252
240
253
254+floatToString : Float -> String
255+floatToString x =
256+ String.fromFloat (toFloat (round (x * 100)) / 100)
257+
258+
259+lessThanOrEqual : String -> Float -> Float -> LayoutExpectation
260+lessThanOrEqual label one two =
261+ Expect
262+ { description = label ++ " " ++ floatToString one ++ " <= " ++ floatToString two
263+ , result = one <= two
264+ }
265+
266+
241equal : a -> a -> LayoutExpectation
267equal : a -> a -> LayoutExpectation
242equal one two =
268equal one two =
243 Expect
269 Expect
@@ -324,7 +350,12 @@ toElement el =
324
350
325toHtml : Element msg -> Html msg
351toHtml : Element msg -> Html msg
326toHtml el =
352toHtml el =
327− Element.layout [ idAttr "0" ] <|
353+ Element.layout
354+ [ idAttr "0"
355+ , Element.width (Element.px 1000)
356+ , Element.height (Element.px 1000)
357+ ]
358+ <|
328 renderElement [ 0, 0 ] el
359 renderElement [ 0, 0 ] el
329
360
330
361
tests-rendering/src/Testable/Element.elm+135−39
@@ -20,6 +20,7 @@ module Testable.Element exposing
20 , isVisible
20 , isVisible
21 , label
21 , label
22 , layout
22 , layout
23+ , link
23 , maximum
24 , maximum
24 , minimum
25 , minimum
25 , moveDown
26 , moveDown
@@ -97,12 +98,36 @@ none =
97
98
98paragraph : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
99paragraph : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
99paragraph attrs =
100paragraph attrs =
100− Testable.Paragraph (implicitWidthHeightShrink attrs)
101+ let
102+ withImplicits =
103+ implicitTest (widthHelper Nothing Nothing (Fill 1))
104+ :: implicitTest (heightHelper Nothing Nothing Shrink)
105+ :: attrs
106+ in
107+ Testable.Paragraph (skipOverridden withImplicits)
101
108
102
109
103textColumn : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
110textColumn : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
104textColumn attrs =
111textColumn attrs =
112+ let
113+ withImplicits =
114+ implicitTest (widthHelper (Just 500) (Just 750) (Fill 1))
115+ :: implicitTest (heightHelper Nothing Nothing Shrink)
116+ :: attrs
117+ in
118+ Testable.TextColumn (skipOverridden withImplicits)
119+
120+
121+link :
122+ List (Testable.Attr msg)
123+ ->
124+ { url : String
125+ , label : Testable.Element msg
126+ }
127+ -> Testable.Element msg
128+link attrs details =
129+ -- TODO: this is not actually a link element!!
105− Testable.TextColumn (implicitWidthHeightShrink attrs)
130+ Testable.El (implicitWidthHeightShrink attrs) details.label
106
131
107
132
108{-| Old labeling mechanism that i removed to hastily
133{-| Old labeling mechanism that i removed to hastily
@@ -344,7 +369,10 @@ widthHelper maybeMin maybeMax len =
344 )
369 )
345 , test =
370 , test =
346 \found ->
371 \found ->
372+ [ expectRoundedEquality
373+ { expected = toFloat val
347− [ Testable.true "exact width is exact" (floor found.self.bbox.width == val)
374+ , found = found.self.bbox.width
375+ }
348 , Testable.true "min/max is upheld" (minMaxTest (floor found.self.bbox.width))
376 , Testable.true "min/max is upheld" (minMaxTest (floor found.self.bbox.width))
349 ]
377 ]
350 }
378 }
@@ -400,6 +428,9 @@ widthHelper maybeMin maybeMax len =
400 Testable.true "element has fill width" <|
428 Testable.true "element has fill width" <|
401 (floor spacePerPortion == floor context.self.bbox.width)
429 (floor spacePerPortion == floor context.self.bbox.width)
402 || minMaxTest (floor context.self.bbox.width)
430 || minMaxTest (floor context.self.bbox.width)
431+ , Testable.lessThanOrEqual "not larger than parent"
432+ context.self.bbox.width
433+ context.parent.bbox.width
403 ]
434 ]
404 }
435 }
405
436
@@ -434,6 +465,9 @@ widthHelper maybeMin maybeMax len =
434 { expected = totalChildren + horizontalPadding
465 { expected = totalChildren + horizontalPadding
435 , found = context.self.bbox.width
466 , found = context.self.bbox.width
436 }
467 }
468+ , Testable.lessThanOrEqual "not larger than parent"
469+ context.self.bbox.width
470+ context.parent.bbox.width
437 ]
471 ]
438
472
439 Testable.Row rowAttrs _ ->
473 Testable.Row rowAttrs _ ->
@@ -462,6 +496,9 @@ widthHelper maybeMin maybeMax len =
462 { expected = totalChildren + horizontalPadding + totalSpacing
496 { expected = totalChildren + horizontalPadding + totalSpacing
463 , found = context.self.bbox.width
497 , found = context.self.bbox.width
464 }
498 }
499+ , Testable.lessThanOrEqual "not larger than parent"
500+ context.self.bbox.width
501+ context.parent.bbox.width
465 ]
502 ]
466
503
467 Testable.Column _ _ ->
504 Testable.Column _ _ ->
@@ -490,10 +527,41 @@ widthHelper maybeMin maybeMax len =
490 { expected = Maybe.withDefault 0 (List.maximum allChildren)
527 { expected = Maybe.withDefault 0 (List.maximum allChildren)
491 , found = context.self.bbox.width
528 , found = context.self.bbox.width
492 }
529 }
530+ , Testable.lessThanOrEqual "not larger than parent"
531+ context.self.bbox.width
532+ context.parent.bbox.width
493 ]
533 ]
494
534
495 Testable.TextColumn _ _ ->
535 Testable.TextColumn _ _ ->
536+ -- The width of the column is the width of the widest child.
537+ let
538+ childWidth child =
539+ child.bbox.width
540+ + context.self.bbox.padding.left
541+ + context.self.bbox.padding.right
542+
543+ textChildren =
544+ List.map
545+ (\txt ->
546+ txt.width
547+ + context.self.bbox.padding.left
548+ + context.self.bbox.padding.right
549+ )
550+ context.self.textMetrics
551+
552+ allChildren =
553+ context.children
554+ |> List.map childWidth
555+ |> List.append textChildren
556+ in
557+ [ expectRoundedEquality
558+ { expected = Maybe.withDefault 0 (List.maximum allChildren)
559+ , found = context.self.bbox.width
560+ }
561+ , Testable.lessThanOrEqual "not larger than parent"
562+ context.self.bbox.width
563+ context.parent.bbox.width
496− []
564+ ]
497
565
498 Testable.Paragraph _ _ ->
566 Testable.Paragraph _ _ ->
499 -- This should be the size it's text,
567 -- This should be the size it's text,
@@ -515,6 +583,9 @@ widthHelper maybeMin maybeMax len =
515 { expected = totalChildren + horizontalPadding
583 { expected = totalChildren + horizontalPadding
516 , found = context.self.bbox.width
584 , found = context.self.bbox.width
517 }
585 }
586+ , Testable.lessThanOrEqual "not larger than parent"
587+ context.self.bbox.width
588+ context.parent.bbox.width
518 ]
589 ]
519
590
520 Testable.Text _ ->
591 Testable.Text _ ->
@@ -593,8 +664,10 @@ heightHelper maybeMin maybeMax len =
593 , id = Testable.IsHeight
664 , id = Testable.IsHeight
594 , test =
665 , test =
595 \found ->
666 \found ->
596− [ Testable.true ("exact height is exact: " ++ String.fromInt (floor found.self.bbox.height) ++ "," ++ String.fromInt val)
667+ [ expectRoundedEquality
668+ { expected = toFloat val
597− (floor found.self.bbox.height == val)
669+ , found = found.self.bbox.height
670+ }
598 , Testable.true "min/max holds true"
671 , Testable.true "min/max holds true"
599 (minMaxTest (floor found.self.bbox.height))
672 (minMaxTest (floor found.self.bbox.height))
600 ]
673 ]
@@ -665,46 +738,60 @@ heightHelper maybeMin maybeMax len =
665 Testable.El _ _ ->
738 Testable.El _ _ ->
666 let
739 let
667 childHeight child =
740 childHeight child =
668− -- TODO: add margin values to heights
669 child.bbox.height
741 child.bbox.height
670−
671− totalChildren =
672− context.children
673− |> List.map childHeight
674− |> List.append (List.map Testable.textHeight context.self.textMetrics)
675− |> List.sum
676−
677− verticalPadding =
678− context.self.bbox.padding.top + context.self.bbox.padding.bottom
679−
680− spacingValue =
681− toFloat context.parentSpacing * (toFloat (List.length context.children) - 1)
682 in
742 in
743+ [ if List.isEmpty context.children then
744+ -- context.self.textMetrics
745+ -- |> List.map Testable.textHeight
746+ -- |> List.sum
747+ -- TODO: apparently the font metrics we have are for the literal characters rendered
748+ -- not for the font itself.
749+ -- so for now, we are stubbing this in as 20, which is the default font size.
750+ Testable.true "expected multiple of 20"
751+ ((round context.self.bbox.height |> modBy 20) == 0)
752+
753+ else
683− [ expectRoundedEquality
754+ expectRoundedEquality
684− { expected = totalChildren + verticalPadding + spacingValue
755+ { expected =
756+ context.children
757+ |> List.map childHeight
758+ |> List.sum
759+ |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
685− , found = context.self.bbox.height
760+ , found = context.self.bbox.height
686− }
761+ }
762+ , Testable.lessThanOrEqual "not larger than parent"
763+ context.self.bbox.height
764+ context.parent.bbox.height
687 ]
765 ]
688
766
689 Testable.Row _ _ ->
767 Testable.Row _ _ ->
690 let
768 let
691 childHeight child =
769 childHeight child =
692 child.bbox.height
770 child.bbox.height
693−
694− totalChildren =
695− context.children
696− |> List.map childHeight
697− |> List.append (List.map Testable.textHeight context.self.textMetrics)
698− |> List.maximum
699− |> Maybe.withDefault 0
700−
701− verticalPadding =
702− context.self.bbox.padding.top + context.self.bbox.padding.bottom
703 in
771 in
772+ [ if List.isEmpty context.children then
773+ -- context.self.textMetrics
774+ -- |> List.map Testable.textHeight
775+ -- |> List.sum
776+ -- TODO: apparently the font metrics we have are for the literal characters rendered
777+ -- not for the font itself.
778+ -- so for now, we are stubbing this in as 20, which is the default font size.
779+ Testable.true "expected multiple of 20"
780+ ((round context.self.bbox.height |> modBy 20) == 0)
781+
782+ else
704− [ expectRoundedEquality
783+ expectRoundedEquality
705− { expected = totalChildren + verticalPadding
784+ { expected =
785+ context.children
786+ |> List.map childHeight
787+ |> List.maximum
788+ |> Maybe.withDefault 0
789+ |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
706− , found = context.self.bbox.height
790+ , found = context.self.bbox.height
707− }
791+ }
792+ , Testable.lessThanOrEqual "not larger than parent"
793+ context.self.bbox.height
794+ context.parent.bbox.height
708 ]
795 ]
709
796
710 Testable.Column colAttrs _ ->
797 Testable.Column colAttrs _ ->
@@ -731,13 +818,22 @@ heightHelper maybeMin maybeMax len =
731 { expected = totalChildren + verticalPadding + totalSpacing
818 { expected = totalChildren + verticalPadding + totalSpacing
732 , found = context.self.bbox.height
819 , found = context.self.bbox.height
733 }
820 }
821+ , Testable.lessThanOrEqual "not larger than parent"
822+ context.self.bbox.height
823+ context.parent.bbox.height
734 ]
824 ]
735
825
736 Testable.TextColumn _ _ ->
826 Testable.TextColumn _ _ ->
827+ [ Testable.lessThanOrEqual "not larger than parent"
828+ context.self.bbox.height
829+ context.parent.bbox.height
737− []
830+ ]
738
831
739 Testable.Paragraph _ _ ->
832 Testable.Paragraph _ _ ->
833+ [ Testable.lessThanOrEqual "not larger than parent"
834+ context.self.bbox.height
835+ context.parent.bbox.height
740− []
836+ ]
741
837
742 Testable.Text _ ->
838 Testable.Text _ ->
743 []
839 []
tests-rendering/src/Testable/Element/Font.elm+6−1
@@ -1,4 +1,4 @@
1−module Testable.Element.Font exposing (color)
1+module Testable.Element.Font exposing (bold, color, size)
2
2
3{-| -}
3{-| -}
4
4
@@ -8,6 +8,11 @@ import Element.Font as Font
8import Testable
8import Testable
9
9
10
10
11+bold : Testable.Attr msg
12+bold =
13+ Testable.Attr Font.bold
14+
15+
11color : Color -> Testable.Attr msg
16color : Color -> Testable.Attr msg
12color clr =
17color clr =
13 Testable.LabeledTest
18 Testable.LabeledTest
tests-rendering/src/Testable/Generator.elm+31−9
@@ -4,7 +4,8 @@ module Testable.Generator exposing (..)
4
4
5import Testable
5import Testable
6import Testable.Element exposing (..)
6import Testable.Element exposing (..)
7−import Testable.Runner
7+import Testable.Element.Background as Background
8+import Testable.Element.Font as Font
8
9
9
10
10{-| Given a list of attributes, generate every context this list of attributes could be in.
11{-| Given a list of attributes, generate every context this list of attributes could be in.
@@ -17,11 +18,8 @@ So, this means,
17-}
18-}
18element : String -> List (Testable.Attr msg) -> List ( String, Testable.Element msg )
19element : String -> List (Testable.Attr msg) -> List ( String, Testable.Element msg )
19element label attrs =
20element label attrs =
20− -- List.map
21− -- (\c ->
22− -- ( label, el attrs c )
21+ -- [ ( label, paragraph attrs [ short ] )
23− -- )
22+ -- ]
24− -- content
25 mapEveryCombo
23 mapEveryCombo
26 (\makeLayout child ->
24 (\makeLayout child ->
27 ( label, makeLayout attrs child )
25 ( label, makeLayout attrs child )
@@ -56,9 +54,33 @@ layouts =
56 ]
54 ]
57
55
58
56
57+nearbys =
58+ [ inFront
59+ , above
60+ , onLeft
61+ , onRight
62+ , below
63+ , behindContent
64+ ]
65+
66+
59contents =
67contents =
60 [ none
68 [ none
61− , text "short and small"
69+ , text short
62− , text "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc."
70+ , text lorem
71+ , el
72+ [ width (px 50)
63− , el [ width (px 50), height (px 50) ] none
73+ , height (px 50)
74+ , Background.color (rgb (240 / 255) 0 (245 / 255))
75+ , Font.color (rgb 1 1 1)
76+ ]
77+ none
64 ]
78 ]
79+
80+
81+short =
82+ "short and small"
83+
84+
85+lorem =
86+ "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc."
tests-rendering/src/Testable/Runner.elm+123−76
@@ -52,10 +52,11 @@ program tests =
52 ( { current = current
52 ( { current = current
53 , upcoming = upcoming
53 , upcoming = upcoming
54 , finished = []
54 , finished = []
55+ , selected = 0
55 , highlightDomId = Nothing
56 , highlightDomId = Nothing
56 }
57 }
57 , Task.perform (always Analyze)
58 , Task.perform (always Analyze)
58− (Process.sleep 32
59+ (Process.sleep 64
59 |> Task.andThen
60 |> Task.andThen
60 (always Time.now)
61 (always Time.now)
61 )
62 )
@@ -77,6 +78,7 @@ type alias Model msg =
77 { current : Maybe ( String, Testable.Element msg )
78 { current : Maybe ( String, Testable.Element msg )
78 , upcoming : List ( String, Testable.Element msg )
79 , upcoming : List ( String, Testable.Element msg )
79 , finished : List (WithResults (Testable.Element msg))
80 , finished : List (WithResults (Testable.Element msg))
81+ , selected : Int
80 , highlightDomId : Maybe String
82 , highlightDomId : Maybe String
81 }
83 }
82
84
@@ -131,6 +133,7 @@ encodeForReport withResults =
131type Msg
133type Msg
132 = NoOp
134 = NoOp
133 | Analyze
135 | Analyze
136+ | Select Int
134 | HighlightDomID (Maybe String)
137 | HighlightDomID (Maybe String)
135 | RefreshBoundingBox
138 | RefreshBoundingBox
136 (List
139 (List
@@ -166,6 +169,11 @@ update msg model =
166 , Cmd.none
169 , Cmd.none
167 )
170 )
168
171
172+ Select index ->
173+ ( { model | selected = index }
174+ , Cmd.none
175+ )
176+
169 RefreshBoundingBox boxes ->
177 RefreshBoundingBox boxes ->
170 case model.current of
178 case model.current of
171 Nothing ->
179 Nothing ->
@@ -208,7 +216,7 @@ update msg model =
208 , upcoming = remaining
216 , upcoming = remaining
209 }
217 }
210 , Task.perform (always Analyze)
218 , Task.perform (always Analyze)
211− (Process.sleep 32
219+ (Process.sleep 64
212 |> Task.andThen
220 |> Task.andThen
213 (always Time.now)
221 (always Time.now)
214 )
222 )
@@ -232,58 +240,60 @@ view model =
232 case model.current of
240 case model.current of
233 Nothing ->
241 Nothing ->
234 if List.isEmpty model.upcoming then
242 if List.isEmpty model.upcoming then
235− case model.finished of
243+ let
236− [] ->
244+ selected =
237− Element.layout [] <|
245+ getByIndex model.selected model.finished
238− Element.column
246+
239− [ Element.spacing 20
247+ -- |> Debug.log "selected"
240− , Element.padding 20
248+ in
241− , Element.width (Element.px 800)
242− ]
243− [ Element.none ]
249+ Element.layout
244−
245− finished :: remaining ->
246− Element.layout
247− [ Font.size 16
250+ [ Font.size 16
248− , Element.inFront (Element.html (viewElementHighlight model))
251+ , Element.inFront (Element.html (viewElementHighlight model))
252+ , Element.height Element.fill
253+ ]
254+ <|
255+ Element.row [ Element.width Element.fill, Element.height Element.fill ]
256+ [ Element.el
257+ [ Element.width
258+ (Element.fill
259+ |> Element.maximum 900
260+ )
261+ , Element.alignTop
249 , Element.height Element.fill
262 , Element.height Element.fill
263+ , Element.scrollbars
250 ]
264 ]
251− <|
252− Element.row [ Element.width Element.fill, Element.height Element.fill ]
253− [ Element.el
265+ (Element.el
254− [ Element.width
266+ [ Element.centerX
255− (Element.fill
267+ , Element.padding 100
256− |> Element.maximum 900)
268+ , Border.dashed
257− , Element.alignTop
269+ , Border.width 2
258− , Element.height Element.fill
270+ , Border.color palette.lightGrey
271+ , Font.size 20
259− , Element.scrollbars
272+ , Element.inFront
260− ]
261 (Element.el
273 (Element.el
262− [ Element.centerX
263− , Element.padding 100
264− , Border.dashed
265− , Border.width 2
266− , Border.color palette.lightGrey
267− , Font.size 20
268− , Element.inFront
269− (Element.el
270− [ Font.size 14
274+ [ Font.size 14
271− , Font.color palette.lightGrey
275+ , Font.color palette.lightGrey
272− ]
273− (Element.text "test case")
274− )
275 ]
276 ]
276− (Testable.toElement finished.element)
277+ (Element.text "test case")
277 )
278 )
278− , Element.column
279− [ Element.spacing 20
280− , Element.padding 20
281− , Element.width Element.fill
282− , Element.height Element.fill
283− , Element.scrollbarY
284− ]
285− (List.map viewResult (finished :: remaining))
286 ]
279 ]
280+ (case selected of
281+ Nothing ->
282+ Element.text "nothing selected"
283+
284+ Just sel ->
285+ Testable.toElement sel.element
286+ )
287+ )
288+ , Element.column
289+ [ Element.spacing 20
290+ , Element.padding 20
291+ , Element.width Element.fill
292+ , Element.height Element.fill
293+ , Element.scrollbarY
294+ ]
295+ (List.indexedMap (viewResult model.selected) model.finished)
296+ ]
287
297
288 else
298 else
289 Html.text ""
299 Html.text ""
@@ -292,6 +302,20 @@ view model =
292 Testable.toHtml current
302 Testable.toHtml current
293
303
294
304
305+getByIndex i ls =
306+ List.foldl
307+ (\elem ( index, found ) ->
308+ if i == index then
309+ ( index + 1, Just elem )
310+
311+ else
312+ ( index + 1, found )
313+ )
314+ ( 0, Nothing )
315+ ls
316+ |> Tuple.second
317+
318+
295viewElementHighlight model =
319viewElementHighlight model =
296 case model.highlightDomId of
320 case model.highlightDomId of
297 Nothing ->
321 Nothing ->
@@ -322,35 +346,58 @@ viewElementHighlight model =
322 ]
346 ]
323
347
324
348
325−viewResult : WithResults (Testable.Element Msg) -> Element.Element Msg
349+viewResult : Int -> Int -> WithResults (Testable.Element Msg) -> Element.Element Msg
326−viewResult testable =
350+viewResult selectedIndex index testable =
327− let
351+ if index == selectedIndex then
328− isExpectationPassing result =
352+ Element.column
329− case result of
353+ [ Element.alignLeft
330− Testable.Todo label ->
354+ , Element.spacing 16
331− True
355+ ]
332−
356+ [ Element.el [ Font.size 24 ] (Element.text testable.label)
333− Testable.Expect details ->
357+ , Element.column
334− details.result
358+ [ Element.alignLeft, Element.spacing 16 ]
335−
359+ (testable.results
336− isPassing layoutTest =
360+ |> groupBy .elementDomId
337− List.any isExpectationPassing layoutTest.expectations
361+ |> List.map (expandDetails >> viewLayoutTestGroup)
362+ )
363+ ]
338
364
365+ else
366+ let
367+ isExpectationPassing result =
368+ case result of
369+ Testable.Todo label ->
370+ True
371+
372+ Testable.Expect details ->
373+ details.result
374+
375+ isPassing layoutTest =
376+ List.all isExpectationPassing layoutTest.expectations
377+
339− ( passing, failing ) =
378+ ( passing, failing ) =
340− List.partition isPassing testable.results
379+ List.partition isPassing testable.results
341− in
380+ in
342− Element.column
381+ Element.column
343− [ Element.alignLeft
382+ [ Element.alignLeft
344− , Element.spacing 16
383+ , Element.spacing 16
345− ]
384+ , Element.pointer
385+ , Events.onClick (Select index)
386+ ]
387+ [ Element.row [ Element.spacing 16 ]
346− [ Element.el [ Font.size 24 ] (Element.text testable.label)
388+ [ Element.el [ Font.size 24 ] (Element.text testable.label)
347− , Element.column
389+ , Element.text (String.fromInt (List.length passing) ++ " passing")
348− [ Element.alignLeft, Element.spacing 16 ]
390+ , let
349− (testable.results
391+ failingCount =
350− |> groupBy .elementDomId
392+ List.length failing
351− |> List.map (expandDetails >> viewLayoutTestGroup)
393+ in
352− )
394+ if failingCount == 0 then
395+ Element.none
396+
397+ else
398+ Element.text (String.fromInt (List.length failing) ++ " failing")
399+ ]
353− ]
400+ ]
354
401
355
402
356expandDetails group =
403expandDetails group =
tests-rendering/src/Tests/Run.elm+14−11
@@ -2,6 +2,7 @@ module Tests.Run exposing (main)
2
2
3{-| -}
3{-| -}
4
4
5+import Testable.Generator
5import Testable.Runner
6import Testable.Runner
6import Tests.Basic
7import Tests.Basic
7import Tests.ColumnAlignment
8import Tests.ColumnAlignment
@@ -10,20 +11,22 @@ import Tests.ElementAlignment
10import Tests.Nearby
11import Tests.Nearby
11import Tests.RowAlignment
12import Tests.RowAlignment
12import Tests.RowSpacing
13import Tests.RowSpacing
14+import Tests.TextWrapping
13import Tests.Transparency
15import Tests.Transparency
14
16
15
17
16main : Testable.Runner.TestableProgram
18main : Testable.Runner.TestableProgram
17main =
19main =
18− Testable.Runner.program
20+ (Testable.Runner.program << List.concat)
21+ [ -- Testable.Generator.element "Basics" []
19− [ Tuple.pair "Basic Element" Tests.Basic.view
22+ -- Tuple.pair "Basic Element" Tests.Basic.view
20− , Tuple.pair "Nearby" Tests.Nearby.view
23+ -- , Tuple.pair "Nearby" Tests.Nearby.view
21− , Tuple.pair "Element Alignment" Tests.ElementAlignment.view
24+ -- , Tuple.pair "Element Alignment" Tests.ElementAlignment.view
22− , Tuple.pair "Transparency" Tests.Transparency.view
25+ -- , Tuple.pair "Transparency" Tests.Transparency.view
23− , Tuple.pair "Column Alignment" Tests.ColumnAlignment.view
26+ -- , Tuple.pair "Column Alignment" Tests.ColumnAlignment.view
24−
25− -- This has 12k cases, so it runs slow and sometimes crashes IE
27+ -- -- This has 12k cases, so it runs slow and sometimes crashes IE
26− , Tuple.pair "Row Alignment" Tests.RowAlignment.view
28+ -- , Tuple.pair "Row Alignment" Tests.RowAlignment.view
27− , Tuple.pair "Column Spacing" Tests.ColumnSpacing.view
29+ -- , Tuple.pair "Column Spacing" Tests.ColumnSpacing.view
28− , Tuple.pair "Row Spacing" Tests.RowSpacing.view
30+ -- , Tuple.pair "Row Spacing" Tests.RowSpacing.view
31+ [ Tuple.pair "Paragraph wrapping" Tests.TextWrapping.view ]
29 ]
32 ]