github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/web/elm/tests/ApplicationTests.elm (about) 1 module ApplicationTests exposing (all) 2 3 import Application.Application as Application 4 import Browser 5 import Common exposing (queryView) 6 import Expect 7 import Message.Effects as Effects 8 import Message.Message exposing (DomID(..), Message(..)) 9 import Message.Subscription as Subscription exposing (Delivery(..)) 10 import Message.TopLevelMessage as Msgs 11 import Test exposing (..) 12 import Test.Html.Query as Query 13 import Test.Html.Selector exposing (id, style) 14 import Url 15 16 17 all : Test 18 all = 19 describe "top-level application" 20 [ test "should subscribe to clicks from the not-automatically-linked boxes in the pipeline, and the token return" <| 21 \_ -> 22 Common.init "/teams/t/pipelines/p/" 23 |> Application.subscriptions 24 |> Expect.all 25 [ Common.contains Subscription.OnNonHrefLinkClicked 26 , Common.contains Subscription.OnTokenReceived 27 ] 28 , test "subscribes to the favorited pipelines response" <| 29 \_ -> 30 Common.init "/teams/t/pipelines/p/" 31 |> Application.subscriptions 32 |> Common.contains Subscription.OnFavoritedPipelinesReceived 33 , test "loads favorited pipelines on init" <| 34 \_ -> 35 Application.init 36 { turbulenceImgSrc = "" 37 , notFoundImgSrc = "notfound.svg" 38 , csrfToken = "csrf_token" 39 , authToken = "" 40 , pipelineRunningKeyframes = "pipeline-running" 41 } 42 { protocol = Url.Http 43 , host = "" 44 , port_ = Nothing 45 , path = "/teams/t/pipelines/p/" 46 , query = Nothing 47 , fragment = Nothing 48 } 49 |> Tuple.second 50 |> Common.contains Effects.LoadFavoritedPipelines 51 , test "clicking a not-automatically-linked box in the pipeline redirects" <| 52 \_ -> 53 Common.init "/teams/t/pipelines/p/" 54 |> Application.update 55 (Msgs.DeliveryReceived <| 56 NonHrefLinkClicked "/foo/bar" 57 ) 58 |> Tuple.second 59 |> Expect.equal [ Effects.LoadExternal "/foo/bar" ] 60 , test "received token is passed to all subsequent requests" <| 61 \_ -> 62 let 63 pipelineIdentifier = 64 { pipelineName = "p", teamName = "t" } 65 in 66 Common.init "/" 67 |> Application.update 68 (Msgs.DeliveryReceived <| 69 TokenReceived <| 70 Ok "real-token" 71 ) 72 |> Tuple.first 73 |> .session 74 |> .csrfToken 75 |> Expect.equal "real-token" 76 , test "subscribes to mouse events when dragging the side bar handle" <| 77 \_ -> 78 Common.init "/teams/t/pipelines/p/jobs/j" 79 |> Application.update 80 (Msgs.Update <| 81 Click SideBarResizeHandle 82 ) 83 |> Tuple.first 84 |> Application.subscriptions 85 |> Expect.all 86 [ Common.contains Subscription.OnMouse 87 , Common.contains Subscription.OnMouseUp 88 ] 89 , test "cannot select text when dragging sidebar" <| 90 \_ -> 91 Common.init "/teams/t/pipelines/p/jobs/j" 92 |> Application.update 93 (Msgs.Update <| 94 Click SideBarResizeHandle 95 ) 96 |> Tuple.first 97 |> Common.queryView 98 |> Query.has 99 [ style "user-select" "none" 100 , style "-ms-user-select" "none" 101 , style "-moz-user-select" "none" 102 , style "-khtml-user-select" "none" 103 , style "-webkit-user-select" "none" 104 , style "-webkit-touch-callout" "none" 105 ] 106 , test "can select text when not dragging sidebar" <| 107 \_ -> 108 Common.init "/teams/t/pipelines/p/jobs/j" 109 |> Common.queryView 110 |> Query.hasNot [ style "user-select" "none" ] 111 , test "page-wrapper fills height" <| 112 \_ -> 113 Common.init "/teams/t/pipelines/p/jobs/j" 114 |> Application.update 115 (Msgs.Update <| 116 Click SideBarResizeHandle 117 ) 118 |> Tuple.first 119 |> Common.queryView 120 |> Query.find [ id "page-wrapper" ] 121 |> Query.has [ style "height" "100%" ] 122 ]