Skip to content

Commit f12e620

Browse files
committed
Add expect_icon() method to controllers; update changelog
1 parent 946bf44 commit f12e620

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### New features
1111

12-
### Improvements
12+
* `ui.sidebar()` is now interactively resizable. (#2020)
1313

14-
* `selectize`, `remove_button`, and `options` parameters of `ui.input_select()` have been deprecated; use `ui.input_selectize()` instead. (Thanks, @ErdaradunGaztea!) (#1947)
14+
* `ui.update_*()` functions now accept `ui.TagChild` (i.e., HTML) as input to the `label` and `icon` arguments. (#2020)
15+
16+
* `playwright.controller.InputActionButton` gains a `expect_icon()` method. As a result, the already existing `expect_label()` no longer includes the icon. (#2020)
17+
18+
### Improvements
1519

1620
* Improved the styling and readability of markdown tables rendered by `ui.Chat()` and `ui.MarkdownStream()`. (#1973)
1721

22+
* `selectize`, `remove_button`, and `options` parameters of `ui.input_select()` have been deprecated; use `ui.input_selectize()` instead. (Thanks, @ErdaradunGaztea!) (#1947)
23+
1824
### Bug fixes
1925

26+
* Fixed an issue with `ui.Chat()` sometimes wanting to scroll a parent element. (#1996)
27+
2028
* Explicitly call out module usage in UI input bookmark button documentation. (#1983)
2129

2230
* Fix missing session when trying to display an error duing bookmarking. (#1984)
2331

24-
* Fixed an issue with `ui.Chat()` sometimes wanting to scroll a parent element. (#1996)
25-
2632

2733
## [1.4.0] - 2025-04-08
2834

shiny/playwright/controller/_base.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ def expect_label(
451451
"""
452452
Expect the label of the input button to have a specific value.
453453
454-
Note: This must include the icon if it is present!
455-
456454
Parameters
457455
----------
458456
value
@@ -461,7 +459,28 @@ def expect_label(
461459
The maximum time to wait for the expectation to be fulfilled. Defaults to `None`.
462460
"""
463461

464-
self.expect.to_have_text(value, timeout=timeout)
462+
loc_label = self.loc.locator(".action-label")
463+
playwright_expect(loc_label).to_have_text(value, timeout=timeout)
464+
465+
def expect_icon(
466+
self,
467+
value: PatternOrStr,
468+
*,
469+
timeout: Timeout = None,
470+
) -> None:
471+
"""
472+
Expect the icon of the input button to have a specific value.
473+
474+
Parameters
475+
----------
476+
value
477+
The expected value of the icon.
478+
timeout
479+
The maximum time to wait for the expectation to be fulfilled. Defaults to `None`.
480+
"""
481+
482+
loc_icon = self.loc.locator(".action-icon")
483+
playwright_expect(loc_icon).to_have_text(value, timeout=timeout)
465484

466485
def click(self, *, timeout: Timeout = None, **kwargs: object) -> None:
467486
"""

tests/playwright/shiny/inputs/test_input_action_button_link.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def test_input_action_kitchen(page: Page, app: ShinyAppProc) -> None:
1111
page.goto(app.url)
1212

1313
button2 = controller.InputActionButton(page, "goButton2")
14-
expect(button2.loc).to_have_text("🤩Go 2")
15-
button2.expect_label("🤩Go 2")
14+
button2.expect_label("Go 2")
15+
button2.expect_icon("🤩")
1616
button2.expect_width(None)
1717

1818
link = controller.InputActionLink(page, "goLink")
@@ -25,8 +25,9 @@ def test_input_action_kitchen(page: Page, app: ShinyAppProc) -> None:
2525

2626
controller.InputActionButton(page, "update").click()
2727

28-
# TODO: why is the space needed here?
29-
button1.expect_label("📅 New label")
28+
button1.expect_label("New label")
29+
button1.expect_icon("📅")
3030
button2.expect_label("Go 2")
3131
button3.expect_label("New label 3")
32-
link.expect_label("🔗New link label")
32+
link.expect_label("New link label")
33+
link.expect_icon("🔗")

0 commit comments

Comments
 (0)