Skip to content

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

@schloerke

Description

@schloerke

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().

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesttestingRelated to testing shiny apps

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions