github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/web/elm/tests/SideBar/TeamTests.elm (about) 1 module SideBar.TeamTests exposing (all) 2 3 import Common 4 import Data 5 import Expect 6 import HoverState exposing (TooltipPosition(..)) 7 import Html exposing (Html) 8 import Message.Message exposing (DomID(..), Message, PipelinesSection(..)) 9 import Set 10 import SideBar.Styles as Styles 11 import SideBar.Team as Team 12 import SideBar.Views as Views 13 import Test exposing (Test, describe, test) 14 import Test.Html.Query as Query 15 import Test.Html.Selector exposing (style) 16 17 18 defaultState = 19 { active = False 20 , expanded = False 21 , hovered = False 22 , hasFavorited = False 23 , isFavoritesSection = False 24 } 25 26 27 all : Test 28 all = 29 describe "sidebar team" 30 [ describe "when active" 31 [ describe "when expanded" 32 [ describe "when hovered" 33 [ test "collapse icon is bright" <| 34 \_ -> 35 team 36 { defaultState 37 | active = True 38 , expanded = True 39 , hovered = True 40 } 41 |> .collapseIcon 42 |> .opacity 43 |> Expect.equal Styles.Bright 44 , test "team name is white" <| 45 \_ -> 46 team 47 { defaultState 48 | active = True 49 , expanded = True 50 , hovered = True 51 } 52 |> .name 53 |> .teamColor 54 |> Expect.equal Styles.White 55 , test "team has a light background" <| 56 \_ -> 57 team 58 { defaultState 59 | active = True 60 , expanded = True 61 , hovered = True 62 } 63 |> .background 64 |> Expect.equal Styles.Light 65 , test "team icon is bright" <| 66 \_ -> 67 team 68 { defaultState 69 | active = True 70 , expanded = True 71 , hovered = True 72 } 73 |> .icon 74 |> Expect.equal Styles.Bright 75 ] 76 , describe "when unhovered" 77 [ test "collapse icon is bright" <| 78 \_ -> 79 team 80 { defaultState 81 | active = True 82 , expanded = True 83 } 84 |> .collapseIcon 85 |> .opacity 86 |> Expect.equal Styles.Bright 87 , test "team name is light grey" <| 88 \_ -> 89 team 90 { defaultState 91 | active = True 92 , expanded = True 93 } 94 |> .name 95 |> .teamColor 96 |> Expect.equal Styles.LightGrey 97 , test "team icon is greyed out" <| 98 \_ -> 99 team 100 { defaultState 101 | active = True 102 , expanded = True 103 } 104 |> .icon 105 |> Expect.equal Styles.GreyedOut 106 ] 107 ] 108 , describe "when collapsed" 109 [ describe "when hovered" 110 [ test "collapse icon is bright" <| 111 \_ -> 112 team 113 { defaultState 114 | active = True 115 , hovered = True 116 } 117 |> .collapseIcon 118 |> .opacity 119 |> Expect.equal Styles.Bright 120 , test "team name is white" <| 121 \_ -> 122 team 123 { defaultState 124 | active = True 125 , hovered = True 126 } 127 |> .name 128 |> .teamColor 129 |> Expect.equal Styles.White 130 , test "team icon is bright" <| 131 \_ -> 132 team 133 { defaultState 134 | active = True 135 , hovered = True 136 } 137 |> .icon 138 |> Expect.equal Styles.Bright 139 ] 140 , describe "when unhovered" 141 [ test "collapse icon is bright" <| 142 \_ -> 143 team 144 { defaultState 145 | active = True 146 } 147 |> .collapseIcon 148 |> .opacity 149 |> Expect.equal Styles.Bright 150 , test "team name is light greyed" <| 151 \_ -> 152 team 153 { defaultState 154 | active = True 155 } 156 |> .name 157 |> .teamColor 158 |> Expect.equal Styles.LightGrey 159 , test "team icon is greyed out" <| 160 \_ -> 161 team 162 { defaultState 163 | active = True 164 } 165 |> .icon 166 |> Expect.equal Styles.GreyedOut 167 ] 168 ] 169 ] 170 , describe "when inactive" 171 [ describe "when expanded" 172 [ describe "when hovered" 173 [ test "collapse icon is bright" <| 174 \_ -> 175 team 176 { defaultState 177 | expanded = True 178 , hovered = True 179 } 180 |> .collapseIcon 181 |> .opacity 182 |> Expect.equal Styles.Bright 183 , test "team name is white" <| 184 \_ -> 185 team 186 { defaultState 187 | expanded = True 188 , hovered = True 189 } 190 |> .name 191 |> .teamColor 192 |> Expect.equal Styles.White 193 , test "team icon is bright" <| 194 \_ -> 195 team 196 { defaultState 197 | expanded = True 198 , hovered = True 199 } 200 |> .icon 201 |> Expect.equal Styles.Bright 202 ] 203 , describe "when unhovered" 204 [ test "collapse icon is bright" <| 205 \_ -> 206 team 207 { defaultState 208 | expanded = True 209 } 210 |> .collapseIcon 211 |> .opacity 212 |> Expect.equal Styles.Bright 213 , test "team name is grey" <| 214 \_ -> 215 team 216 { defaultState 217 | expanded = True 218 } 219 |> .name 220 |> .teamColor 221 |> Expect.equal Styles.LightGrey 222 , test "team icon is greyed out" <| 223 \_ -> 224 team 225 { defaultState 226 | expanded = True 227 } 228 |> .icon 229 |> Expect.equal Styles.GreyedOut 230 ] 231 ] 232 , describe "when collapsed" 233 [ describe "when hovered" 234 [ test "collapse icon is bright" <| 235 \_ -> 236 team 237 { defaultState 238 | hovered = True 239 } 240 |> .collapseIcon 241 |> .opacity 242 |> Expect.equal Styles.Bright 243 , test "team name is white" <| 244 \_ -> 245 team 246 { defaultState 247 | hovered = True 248 } 249 |> .name 250 |> .teamColor 251 |> Expect.equal Styles.White 252 , test "team icon is greyed out" <| 253 \_ -> 254 team 255 { defaultState 256 | hovered = True 257 } 258 |> .icon 259 |> Expect.equal Styles.Bright 260 ] 261 , describe "when unhovered" 262 [ test "collapse icon is bright" <| 263 \_ -> 264 team defaultState 265 |> .collapseIcon 266 |> .opacity 267 |> Expect.equal Styles.Bright 268 , test "team name is grey" <| 269 \_ -> 270 team defaultState 271 |> .name 272 |> .teamColor 273 |> Expect.equal Styles.LightGrey 274 , test "team icon is greyed out" <| 275 \_ -> 276 team defaultState 277 |> .icon 278 |> Expect.equal Styles.GreyedOut 279 ] 280 ] 281 ] 282 , describe "when in all pipelines section" 283 [ test "domID is for AllPipelines section" <| 284 \_ -> 285 team { defaultState | isFavoritesSection = False } 286 |> .name 287 |> .domID 288 |> Expect.equal (SideBarTeam AllPipelinesSection "team") 289 ] 290 , describe "when in favorites section" 291 [ test "domID is for Favorites section" <| 292 \_ -> 293 team { defaultState | isFavoritesSection = True } 294 |> .name 295 |> .domID 296 |> Expect.equal (SideBarTeam FavoritesSection "team") 297 ] 298 ] 299 300 301 team : 302 { active : Bool 303 , expanded : Bool 304 , hovered : Bool 305 , hasFavorited : Bool 306 , isFavoritesSection : Bool 307 } 308 -> Views.Team 309 team { active, expanded, hovered, hasFavorited, isFavoritesSection } = 310 let 311 hoveredDomId = 312 if hovered then 313 HoverState.Hovered (SideBarTeam AllPipelinesSection "team") 314 315 else 316 HoverState.NoHover 317 318 pipelines = 319 [ Data.pipeline "team" 0 |> Data.withName "pipeline" ] 320 321 pipelineIdentifier = 322 { teamName = "team", pipelineName = "pipeline" } 323 324 activePipeline = 325 if active then 326 Just pipelineIdentifier 327 328 else 329 Nothing 330 331 favoritedPipelines = 332 if hasFavorited then 333 Set.singleton 0 334 335 else 336 Set.empty 337 in 338 Team.team 339 { hovered = hoveredDomId 340 , pipelines = pipelines 341 , currentPipeline = activePipeline 342 , favoritedPipelines = favoritedPipelines 343 , isFavoritesSection = isFavoritesSection 344 } 345 { name = "team" 346 , isExpanded = expanded 347 }