Skip to content

Commit be98685

Browse files
committed
WIP feat(ui): add test identifiers for ui elements
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
1 parent da35661 commit be98685

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

ui/src/Main/Icons.elm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Main.Icons exposing (..)
22

33
import Html exposing (Html)
4+
import Html.Attributes exposing (attribute)
45
import Svg exposing (path, svg)
56
import Svg.Attributes exposing (class, d, fill, fillRule, height, viewBox, width)
67

@@ -21,6 +22,7 @@ iconMoonStarsFill =
2122
, height "16"
2223
, fill "currentColor"
2324
, class "bi bi-moon-stars-fill"
25+
, attribute "data-testid" "icon-moon"
2426
, viewBox "0 0 16 16"
2527
]
2628
[ path
@@ -41,6 +43,7 @@ iconSunFill =
4143
, height "16"
4244
, fill "currentColor"
4345
, class "bi bi-sun-fill"
46+
, attribute "data-testid" "icon-sun"
4447
, viewBox "0 0 16 16"
4548
]
4649
[ path

ui/src/Main/View.elm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ view model =
4444
, button
4545
[ class "navbar-toggler d-md-none border-0 p-1"
4646
, type_ "button"
47+
, attribute "data-testid" "navbar-toggler"
4748
, attribute "aria-expanded"
4849
(if model.model_navbarExpanded then
4950
"true"
@@ -149,6 +150,7 @@ viewSearchInput model =
149150
"Search options"
150151
, value model.model_search
151152
, id "main-search-bar"
153+
, attribute "data-testid" "main-search-bar"
152154
, onInput (\s -> Update_SearchInput (UpdateSearchInput_Set s))
153155
, preventDefaultOn "keydown"
154156
(decodeEscapeKey
@@ -166,6 +168,7 @@ viewThemeToggle model =
166168
, style "cursor" "pointer"
167169
, title "Toggle theme"
168170
, attribute "aria-label" "Toggle theme"
171+
, attribute "data-testid" "theme-toggle-btn"
169172
, onClick Update_CycleTheme
170173
]
171174
[ case model.model_preferences.preferences_theme of

ui/src/Main/View/Page/App.elm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ viewPageAppHeader _ pageApp =
6565
]
6666
, button
6767
[ class "btn"
68+
, attribute "data-testid" "app-run-button"
6869
, case pageApp.pageApp_runtime of
6970
Nothing ->
7071
class "btn-secondary"

ui/src/Main/View/Page/App/Run.elm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Main.View.Page.App.Run exposing (..)
22

33
import Html exposing (Html, a, br, button, details, div, h5, hr, li, p, small, span, summary, text, ul)
4-
import Html.Attributes exposing (class, href, id, style, tabindex, target)
4+
import Html.Attributes exposing (attribute, class, href, id, style, tabindex, target)
55
import Html.Events exposing (stopPropagationOn)
66
import Json.Decode as Decode
77
import Main.Config exposing (..)
@@ -34,6 +34,7 @@ viewPageAppRun model pageApp =
3434
[ div
3535
[ class "modal show"
3636
, style "display" "block"
37+
, attribute "data-testid" "run-modal-container"
3738
, tabindex -1
3839
, style "background-color" "rgba(0,0,0,0.5)"
3940
, onClick (Update_RouteWithoutHistory onClickRoute)
@@ -47,6 +48,7 @@ viewPageAppRun model pageApp =
4748
[ h5 [ class "modal-title" ] [ text ("Run " ++ pageApp.pageApp_route.routeApp_name) ]
4849
, button
4950
[ class "btn-close"
51+
, attribute "data-testid" "close-modal-button"
5052
, onClick (Update_RouteWithoutHistory onClickRoute)
5153
]
5254
[]
@@ -87,6 +89,7 @@ viewPageAppRunRuntime _ pageApp appRuntime =
8789
)
8890
, style "cursor" "pointer"
8991
, style "border" "none"
92+
, attribute "role" "tab"
9093
, id <| "run-" ++ (showAppRuntime appRuntime |> String.toLower)
9194
, let
9295
route =

ui/src/Main/View/Page/Apps.elm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ viewPageAppsApp _ app =
6565
[ href (onClickRoute |> Route.toString)
6666
, class "card m-item-card shadow-sm p-3"
6767
, style "text-decoration" "none"
68+
, attribute "data-testid" "app-result"
6869
, onClick (Update_Route onClickRoute)
6970
]
7071
[ div

ui/src/Main/View/Page/Recipe.elm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ viewPageRecipeOptionsItem _ pageRecipeOptions ( optionName, option ) =
7575
[ class "list-item list-group-item list-group-item-action flex-column align-items-start"
7676
, href (onClickRoute |> Route.toString)
7777
, id itemId
78+
, attribute "data-testid" "option-result"
7879
, onClick (Update_Route onClickRoute)
7980
]
8081
[ div [ class "d-flex w-100 justify-content-between" ]

0 commit comments

Comments
 (0)