Skip to content

Commit bc5bc7d

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

File tree

12 files changed

+27
-300
lines changed

12 files changed

+27
-300
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
from shiny.express import render, ui
2+
from shinychat.express import Chat
23

34
# Set some Shiny page options
45
ui.page_opts(title="Hello Chat")
56

67
# 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-
)
8+
chat = Chat(id="chat")
139

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

1713

1814
# 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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
from playwright.sync_api import Page, expect
2-
from utils.deploy_utils import skip_on_webkit
3-
42
from shiny.playwright import controller
53
from shiny.run import ShinyAppProc
4+
from shinychat.playwright import ChatController
65

76

8-
@skip_on_webkit
97
def test_validate_chat_basic(page: Page, local_app: ShinyAppProc) -> None:
108
page.goto(local_app.url)
119

12-
chat = controller.Chat(page, "chat")
10+
chat = ChatController(page, "chat")
1311

1412
# Verify starting state
1513
expect(chat.loc).to_be_visible(timeout=30 * 1000)
@@ -44,7 +42,6 @@ def test_validate_chat_basic(page: Page, local_app: ShinyAppProc) -> None:
4442
message_state = controller.OutputCode(page, "message_state")
4543
message_state_expected = tuple(
4644
[
47-
{"content": initial_message, "role": "assistant"},
4845
{"content": f"\n{user_message}", "role": "user"},
4946
{"content": f"You said: \n{user_message}", "role": "assistant"},
5047
{"content": f"{user_message2}", "role": "user"},

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,31 @@
22
from pathlib import Path
33

44
import faicons
5-
65
from shiny.express import app_opts, input, ui
6+
from shinychat.express import Chat
77

88
ui.page_opts(title="Chat Icons")
99

1010
app_opts(static_assets={"/img": Path(__file__).parent / "img"})
1111

1212
with ui.layout_columns():
1313
# 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-
)
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):
3025
await asyncio.sleep(1)
3126
await chat_default.append_message(f"You said: {user_input}")
3227

3328
# Animal Bot ----------------------------------------------------------------------
34-
chat_animal = ui.Chat(id="chat_animal")
29+
chat_animal = Chat(id="chat_animal")
3530

3631
with ui.div():
3732
ui.h2("Animal Bot")
@@ -63,7 +58,7 @@ async def handle_user_input_otter(user_input: str):
6358
</svg>
6459
"""
6560

66-
chat_svg = ui.Chat(id="chat_svg")
61+
chat_svg = Chat(id="chat_svg")
6762

6863
with ui.div():
6964
ui.h2("SVG Bot")
@@ -77,7 +72,7 @@ async def handle_user_input_svg(user_input: str):
7772
await chat_svg.append_message(f"You said: {user_input}")
7873

7974
# Image Bot -----------------------------------------------------------------------
80-
chat_image = ui.Chat(id="chat_image")
75+
chat_image = Chat(id="chat_image")
8176

8277
with ui.div():
8378
ui.h2("Image Bot")

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

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

34
suggestions1 = """
45
<p>Here is the <span id="first" class='suggestion'>1st input suggestion</span>.
@@ -11,9 +12,9 @@
1112
And <span id="fifth" data-suggestion="another suggestion" data-suggestion-submit="true">this suggestion will also auto-submit</span>.</p>
1213
"""
1314

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

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

1819

1920
@chat.on_user_submit

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from shiny import reactive
22
from shiny.express import input, ui
3+
from shinychat.express import Chat
34

45
ui.page_opts(title="Testing input bindings in Chat", gap="3rem")
56

@@ -16,11 +17,11 @@
1617
),
1718
)
1819

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

2526

2627
@reactive.effect

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import ipyleaflet as ipyl # pyright: ignore[reportMissingTypeStubs]
22
import pandas as pd
33
import plotly.express as px # pyright: ignore[reportMissingTypeStubs]
4-
from shinywidgets import render_plotly, render_widget
5-
64
from shiny import reactive, render
75
from shiny.express import ui
6+
from shinychat.express import Chat
7+
from shinywidgets import render_plotly, render_widget
88

99
ui.page_opts(
1010
title="Hello output bindings in Chat",
@@ -19,12 +19,9 @@ def map():
1919
return ipyl.Map(center=(52, 10), zoom=8)
2020

2121

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

27-
chat.ui()
24+
chat.ui(messages=[map_ui])
2825

2926
with ui.hold() as df_1:
3027

@@ -49,7 +46,7 @@ def df2():
4946

5047
@reactive.effect
5148
async def _():
52-
await chat.append_message_stream(df_2)
49+
await chat.append_message(df_2)
5350

5451

5552
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)