Skip to content

Commit 658a562

Browse files
committed
tests: Explicitly test returning to no icon
1 parent 68bac09 commit 658a562

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

tests/playwright/shiny/components/chat/icon/app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ async def handle_user_input_default(user_input: str):
4747
async def handle_user_input_otter(user_input: str):
4848
await asyncio.sleep(1)
4949
icon_name = input.animal().lower()
50+
if icon_name == "Otter":
51+
# Don't include the icon in the custom message, i.e. use default icon
52+
icon = None
53+
else:
54+
icon = faicons.icon_svg(icon_name).add_class(f"icon-{icon_name}")
55+
5056
await chat_animal.append_message(
5157
f"{input.animal()} said: {user_input}",
52-
icon=faicons.icon_svg(icon_name).add_class(f"icon-{icon_name}"),
58+
icon=icon,
5359
)
5460

5561
# SVG Bot -------------------------------------------------------------------------

tests/playwright/shiny/components/chat/icon/test_chat_icon.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@ def test_validate_chat_basic(page: Page, local_app: ShinyAppProc) -> None:
5555
chat_animal.chat.set_user_input("hello")
5656
chat_animal.chat.send_user_input()
5757
chat_animal.expect_last_message_icon_to_have_classes("fa icon-frog")
58+
59+
# Test that the icon used is the default if no icon is sent
60+
# (the message-specific icon is just for that message)
61+
animal.set("Otter")
62+
chat_animal.chat.set_user_input("hello")
63+
chat_animal.chat.send_user_input()
64+
chat_animal.expect_last_message_icon_to_have_classes()

0 commit comments

Comments
 (0)