eeue56 / eeue56/elm-html-test

Selector.oneOf

Open
#49 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Elm
Stars
68
Forks
15
PR merge metrics
No merged PRs in 30d

Description

@avh4 [proposed](https://github.com/eeue56/elm-html-test/issues/32#issuecomment-306840487):

> some way to write a query that will find the button when given `a`, and the input when given `b`:

```elm
a = div [] [ button [] [ text "Click me" ] ]
b = div [] [ input [ type_ "button", value "Click me" ] ]
```

The use case would be writing a reusable function to detect equivalent UI elements—e.g. a `fancyButton` function that queries for buttons with either the class `smallFancyButton` or `largeFancyButton`.

He proposed two potential APIs. One was:

```elm
Query.find
[ Selector.oneOf
[ [ tag "button", text "Click me" ]
, [ tag "input", attribute "type" "button", attribute "value" "Click me" ]
]
]
```

The other potential API he proposed was:

```elm
case Query.toResult <| Query.find [ tag "button", text "Click me" ] of
Err _ ->
Query.find [ tag "input", attribute "type" "button", attribute "value" "Click me" ]
Ok single ->
single
```

The `oneOf` API seems like a good choice to me.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the proposed Selector.oneOf API and the existing Query.find and Query.toResult approaches shown in the issue. Compare the two alternatives and determine which API fits the project; done means reusable queries can match either the button or input example and equivalent UI elements can be detected.

Written by the indexing model from the issue text.

Assessment

Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.