Skip to content

Commit a03e195

Browse files
committed
Update tests; fix .ui(messages) input type
1 parent ce6c32f commit a03e195

File tree

13 files changed

+15
-296
lines changed

13 files changed

+15
-296
lines changed

pkg-py/src/shinychat/_chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ class ChatExpress(Chat):
10981098
def ui(
10991099
self,
11001100
*,
1101-
messages: Optional[Sequence[str | ChatMessageDict]] = None,
1101+
messages: Optional[Sequence[TagChild | ChatMessageDict]] = None,
11021102
placeholder: str = "Enter a message...",
11031103
width: CssUnit = "min(680px, 100%)",
11041104
height: CssUnit = "auto",

pkg-py/tests/playwright/chat/basic/app.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
ui.page_opts(title="Hello Chat")
66

77
# Create a chat instance, with an initial message
8-
chat = Chat(
9-
id="chat",
10-
messages=[
11-
{"content": "Hello! How can I help you today?", "role": "assistant"},
12-
],
13-
)
8+
chat = Chat(id="chat")
149

1510
# Display the chat
16-
chat.ui()
11+
chat.ui(messages=["Hello! How can I help you today?"])
1712

1813

1914
# Define a callback to run when the user submits a message

pkg-py/tests/playwright/chat/basic/test_chat_basic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def test_validate_chat_basic(page: Page, local_app: ShinyAppProc) -> None:
4242
message_state = controller.OutputCode(page, "message_state")
4343
message_state_expected = tuple(
4444
[
45-
{"content": initial_message, "role": "assistant"},
4645
{"content": f"\n{user_message}", "role": "user"},
4746
{"content": f"You said: \n{user_message}", "role": "assistant"},
4847
{"content": f"{user_message2}", "role": "user"},

pkg-py/tests/playwright/chat/icon/app.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,14 @@
1111

1212
with ui.layout_columns():
1313
# Default Bot ---------------------------------------------------------------------
14-
chat_default = Chat(
15-
id="chat_default",
16-
messages=[
17-
{
18-
"content": "Hello! I'm Default Bot. How can I help you today?",
19-
"role": "assistant",
20-
},
21-
],
22-
)
14+
chat_default = Chat(id="chat_default")
2315

2416
with ui.div():
2517
ui.h2("Default Bot")
26-
chat_default.ui(icon_assistant=None)
18+
chat_default.ui(
19+
messages=["Hello! I'm Default Bot. How can I help you today?"],
20+
icon_assistant=None,
21+
)
2722

2823
@chat_default.on_user_submit
2924
async def handle_user_input_default(user_input: str):

pkg-py/tests/playwright/chat/input-suggestion/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
And <span id="fifth" data-suggestion="another suggestion" data-suggestion-submit="true">this suggestion will also auto-submit</span>.</p>
1313
"""
1414

15-
chat = Chat("chat", messages=[suggestion2])
15+
chat = Chat("chat")
1616

17-
chat.ui(messages=[suggestions1])
17+
chat.ui(messages=[suggestions1, suggestion2])
1818

1919

2020
@chat.on_user_submit

pkg-py/tests/playwright/chat/shiny_input/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
),
2020
)
2121

22-
chat = Chat(
23-
id="chat",
22+
chat = Chat(id="chat")
23+
chat.ui(
24+
class_="mb-5",
2425
messages=[welcome],
2526
)
26-
chat.ui(class_="mb-5")
2727

2828

2929
@reactive.effect

pkg-py/tests/playwright/chat/shiny_output/app.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ def map():
1818
return ipyl.Map(center=(52, 10), zoom=8)
1919

2020

21-
chat = ui.Chat(
22-
id="chat",
23-
messages=[map_ui],
24-
)
21+
chat = ui.Chat(id="chat")
2522

26-
chat.ui()
23+
chat.ui(messages=[map_ui])
2724

2825
with ui.hold() as df_1:
2926

pkg-py/tests/playwright/chat/transform/app.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

pkg-py/tests/playwright/chat/transform/test_chat_transform.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

pkg-py/tests/playwright/chat/transform_assistant/app.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)