Skip to content

Commit 8afb668

Browse files
committed
Update/remove tests in anticipation of posit-dev/shinychat#62
1 parent 3d05a92 commit 8afb668

File tree

12 files changed

+29
-296
lines changed

12 files changed

+29
-296
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1+
from shinychat.express import Chat
2+
13
from shiny.express import render, ui
24

35
# Set some Shiny page options
46
ui.page_opts(title="Hello Chat")
57

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

1411
# Display the chat
15-
chat.ui()
12+
chat.ui(messages=["Hello! How can I help you today?"])
1613

1714

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

tests/playwright/shiny/components/chat/basic/test_chat_basic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from playwright.sync_api import Page, expect
2-
from utils.deploy_utils import skip_on_webkit
2+
from shinychat.playwright import ChatController
33

44
from shiny.playwright import controller
55
from shiny.run import ShinyAppProc
66

77

8-
@skip_on_webkit
98
def test_validate_chat_basic(page: Page, local_app: ShinyAppProc) -> None:
109
page.goto(local_app.url)
1110

12-
chat = controller.Chat(page, "chat")
11+
chat = ChatController(page, "chat")
1312

1413
# Verify starting state
1514
expect(chat.loc).to_be_visible(timeout=30 * 1000)
@@ -44,7 +43,6 @@ def test_validate_chat_basic(page: Page, local_app: ShinyAppProc) -> None:
4443
message_state = controller.OutputCode(page, "message_state")
4544
message_state_expected = tuple(
4645
[
47-
{"content": initial_message, "role": "assistant"},
4846
{"content": f"\n{user_message}", "role": "user"},
4947
{"content": f"You said: \n{user_message}", "role": "assistant"},
5048
{"content": f"{user_message2}", "role": "user"},

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33

44
import faicons
5+
from shinychat.express import Chat
56

67
from shiny.express import app_opts, input, ui
78

@@ -11,27 +12,22 @@
1112

1213
with ui.layout_columns():
1314
# Default Bot ---------------------------------------------------------------------
14-
chat_default = ui.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-
)
15+
chat_default = Chat(id="chat_default")
2316

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

2824
@chat_default.on_user_submit
2925
async def handle_user_input_default(user_input: str):
3026
await asyncio.sleep(1)
3127
await chat_default.append_message(f"You said: {user_input}")
3228

3329
# Animal Bot ----------------------------------------------------------------------
34-
chat_animal = ui.Chat(id="chat_animal")
30+
chat_animal = Chat(id="chat_animal")
3531

3632
with ui.div():
3733
ui.h2("Animal Bot")
@@ -63,7 +59,7 @@ async def handle_user_input_otter(user_input: str):
6359
</svg>
6460
"""
6561

66-
chat_svg = ui.Chat(id="chat_svg")
62+
chat_svg = Chat(id="chat_svg")
6763

6864
with ui.div():
6965
ui.h2("SVG Bot")
@@ -77,7 +73,7 @@ async def handle_user_input_svg(user_input: str):
7773
await chat_svg.append_message(f"You said: {user_input}")
7874

7975
# Image Bot -----------------------------------------------------------------------
80-
chat_image = ui.Chat(id="chat_image")
76+
chat_image = Chat(id="chat_image")
8177

8278
with ui.div():
8379
ui.h2("Image Bot")

tests/playwright/shiny/components/chat/input-suggestion/app.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from shiny.express import ui
1+
from shinychat.express import Chat
2+
3+
import shiny.express # noqa: F401
24

35
suggestions1 = """
46
<p>Here is the <span id="first" class='suggestion'>1st input suggestion</span>.
@@ -11,9 +13,9 @@
1113
And <span id="fifth" data-suggestion="another suggestion" data-suggestion-submit="true">this suggestion will also auto-submit</span>.</p>
1214
"""
1315

14-
chat = ui.Chat("chat", messages=[suggestion2])
16+
chat = Chat("chat")
1517

16-
chat.ui(messages=[suggestions1])
18+
chat.ui(messages=[suggestions1, suggestion2])
1719

1820

1921
@chat.on_user_submit

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from shinychat.express import Chat
2+
13
from shiny import reactive
24
from shiny.express import input, ui
35

@@ -16,11 +18,11 @@
1618
),
1719
)
1820

19-
chat = ui.Chat(
20-
id="chat",
21+
chat = Chat(id="chat")
22+
chat.ui(
23+
class_="mb-5",
2124
messages=[welcome],
2225
)
23-
chat.ui(class_="mb-5")
2426

2527

2628
@reactive.effect

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ipyleaflet as ipyl # pyright: ignore[reportMissingTypeStubs]
22
import pandas as pd
33
import plotly.express as px # pyright: ignore[reportMissingTypeStubs]
4+
from shinychat.express import Chat
45
from shinywidgets import render_plotly, render_widget
56

67
from shiny import reactive, render
@@ -19,12 +20,9 @@ def map():
1920
return ipyl.Map(center=(52, 10), zoom=8)
2021

2122

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

27-
chat.ui()
25+
chat.ui(messages=[map_ui])
2826

2927
with ui.hold() as df_1:
3028

@@ -49,7 +47,7 @@ def df2():
4947

5048
@reactive.effect
5149
async def _():
52-
await chat.append_message_stream(df_2)
50+
await chat.append_message(df_2)
5351

5452

5553
with ui.hold() as plot_ui:

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

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

tests/playwright/shiny/components/chat/transform/test_chat_transform.py

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

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

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

tests/playwright/shiny/components/chat/transform_assistant/test_chat_transform_assistant.py

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

0 commit comments

Comments
 (0)