From 6c3e3081b7421e50d64bdd47c3f249aae6094eb4 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Thu, 14 Nov 2024 09:19:06 -0800 Subject: [PATCH] Add nightly tests --- .github/workflows/nightly-tests.yml | 38 +++++++++++++++++++++++++++++ tests/run_smoke_test.py | 30 +++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/nightly-tests.yml create mode 100644 tests/run_smoke_test.py diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml new file mode 100644 index 0000000..78401a5 --- /dev/null +++ b/.github/workflows/nightly-tests.yml @@ -0,0 +1,38 @@ +name: Nightly Tests for Shiny Assistant + +on: + schedule: + - cron: "0 3 * * *" + push: + branches: + - "testing**" + workflow_dispatch: + +jobs: + process-issues: + runs-on: ubuntu-latest + permissions: write-all + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + playwright install chromium --with-deps + + - name: Process issue description + id: process-description + run: python tests/run_smoke_test.py diff --git a/tests/run_smoke_test.py b/tests/run_smoke_test.py new file mode 100644 index 0000000..fb52b35 --- /dev/null +++ b/tests/run_smoke_test.py @@ -0,0 +1,30 @@ +import time + +from playwright.sync_api import Playwright, sync_playwright + + +def run(playwright: Playwright): + chromium = playwright.chromium + browser = chromium.launch() + page = browser.new_page() + page.goto("https://gallery.shinyapps.io/assistant") + page.get_by_label("Python").check() + page.get_by_text("Who can see my activity?").click() + page.get_by_text("Who can see my activity?").click() + page.get_by_role("textbox", name="Enter a message...").click() + page.get_by_role("textbox", name="Enter a message...").fill( + """ +Help me write a shiny app with orange cards +""" + ) + page.get_by_label("Send message").click() + time.sleep(12) # required since we are streaming responses + message_contents = page.query_selector_all(".message-content") + last_message_content = message_contents[-1].text_content() + if "orange" not in last_message_content: + raise AssertionError("Expected orange in last message content") + browser.close() + + +with sync_playwright() as playwright: + run(playwright)