Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] InputSelect and InputSelectize 's .expect_choices() should handle values, labels, and groups #1688

Open
schloerke opened this issue Sep 17, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request testing Related to testing shiny apps

Comments

@schloerke
Copy link
Collaborator

The root of the problem is that we can not test which values belong in which labels. Only that their order (and count) is valid.

Proposal:

It should support:

    select_with_custom_size_and_dict.expect_choices({
        "Citrus": {
            "Orange": "Sweet and tangy",
            "Lemon": "Zesty and refreshing",
            "Lime": "Bright and tart",
        },
        "Berries": {
            "Strawberry": "Juicy and sweet",
            "Blueberry": "Tiny and antioxidant-rich",
            "Raspberry": "Delicate and slightly tart",
        },
    })

Internally, if a value array is supplied, then it is auto upgraded to a {value: label} dictionary. Ex:

    select_with_custom_size_and_dict.expect_choices([
        "Orange",
        "Lemon",
        "Lime",
        "Strawberry",
        "Blueberry",
        "Raspberry",
    ])

is auto upgraded to: (which also asserts that there are no groups)

    select_with_custom_size_and_dict.expect_choices({
        "Orange": "Orange",
        "Lemon": "Lemon",
        "Lime": "Lime",
        "Strawberry": "Strawberry",
        "Blueberry": "Blueberry",
        "Raspberry": "Raspberry",
    })

And

    select_with_custom_size_and_dict.expect_choices({
        "Citrus": [
            "Orange",
            "Lemon",
            "Lime",
        ],
        "Berries": [
            "Strawberry",
            "Blueberry",
            "Raspberry",
        ],
    })

to:

    select_with_custom_size_and_dict.expect_choices({
        "Citrus": {
            "Orange": "Orange",
            "Lemon": "Lemon",
            "Lime": "Lime",
        },
        "Berries": {
            "Strawberry": "Strawberry",
            "Blueberry": "Blueberry",
            "Raspberry": "Raspberry",
        },
    })

Groups:

  • If no groups are provided, then assert there are no groups
  • If groups are provided, then assert as expected

However, this will require the deprecation of .expect_choice_labels() and .expect_choice_groups().

@schloerke schloerke added enhancement New feature or request testing Related to testing shiny apps labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing Related to testing shiny apps
Projects
None yet
Development

No branches or pull requests

2 participants