-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/playwright/shiny/components/chat/append_user_msg/app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from shiny import reactive | ||
from shiny.express import render, ui | ||
|
||
chat = ui.Chat(id="chat") | ||
chat.ui() | ||
|
||
|
||
@reactive.effect | ||
async def _(): | ||
await chat.append_message({"content": "A user message", "role": "user"}) | ||
|
||
|
||
"chat.messages():" | ||
|
||
|
||
@render.code | ||
def message_state(): | ||
return str(chat.messages()) |
19 changes: 19 additions & 0 deletions
19
tests/playwright/shiny/components/chat/append_user_msg/test_chat_append_user_msg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from playwright.sync_api import Page, expect | ||
|
||
from shiny.playwright import controller | ||
from shiny.run import ShinyAppProc | ||
|
||
|
||
def test_validate_chat_append_user_message(page: Page, local_app: ShinyAppProc) -> None: | ||
page.goto(local_app.url) | ||
|
||
chat = controller.Chat(page, "chat") | ||
|
||
# Verify starting state | ||
expect(chat.loc).to_be_visible() | ||
chat.expect_latest_message("A user message") | ||
|
||
# Verify that the message state is as expected | ||
message_state = controller.OutputCode(page, "message_state") | ||
message_state_expected = ({"content": "A user message", "role": "user"},) | ||
message_state.expect_value(str(message_state_expected)) |