From c5635102f0b24d21e1b4814a586701495325f035 Mon Sep 17 00:00:00 2001 From: Moepchi Date: Sat, 22 Aug 2026 22:50:12 +0200 Subject: [PATCH] Add free Safari landing page checks --- .github/workflows/safari-check.yml | 76 ++++++++++++++++++++++++++++++ tests/safari_smoke.py | 59 +++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 .github/workflows/safari-check.yml create mode 100644 tests/safari_smoke.py diff --git a/.github/workflows/safari-check.yml b/.github/workflows/safari-check.yml new file mode 100644 index 0000000..f90fd51 --- /dev/null +++ b/.github/workflows/safari-check.yml @@ -0,0 +1,76 @@ +name: Safari landing page check + +on: + workflow_dispatch: + push: + branches: [main] + paths: + - "web/src/landing.tsx" + - "web/src/landing.css" + - "web/landing/**" + - "web/public/**" + - ".github/workflows/safari-check.yml" + - "tests/safari_smoke.py" + schedule: + - cron: "17 5 * * 1" + +permissions: + contents: read + +concurrency: + group: safari-landing-${{ github.ref }} + cancel-in-progress: true + +jobs: + safari: + name: Safari on macOS + runs-on: macos-15 + timeout-minutes: 15 + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: web/package-lock.json + + - name: Install and build landing page + working-directory: web + run: | + npm ci + npm run build + + - name: Start local preview + working-directory: web + run: | + npm run preview -- --host 127.0.0.1 --port 4173 > /tmp/webspeak3-preview.log 2>&1 & + for attempt in {1..30}; do + curl --fail --silent http://127.0.0.1:4173/landing/ > /dev/null && exit 0 + sleep 1 + done + cat /tmp/webspeak3-preview.log + exit 1 + + - name: Prepare Safari automation + run: | + sudo safaridriver --enable + python3 -m pip install selenium + + - name: Test landing page in Safari + env: + BASE_URL: http://127.0.0.1:4173/landing/ + run: python3 tests/safari_smoke.py + + - name: Upload Safari screenshots + if: always() + uses: actions/upload-artifact@v4 + with: + name: safari-screenshots + path: test-results/safari-*.png + if-no-files-found: ignore + retention-days: 14 + diff --git a/tests/safari_smoke.py b/tests/safari_smoke.py new file mode 100644 index 0000000..0412036 --- /dev/null +++ b/tests/safari_smoke.py @@ -0,0 +1,59 @@ +import os +from pathlib import Path + +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait + + +BASE_URL = os.environ.get("BASE_URL", "https://webspeak3.de/") +RESULTS = Path("test-results") +RESULTS.mkdir(exist_ok=True) + + +def wait_for_text(driver: webdriver.Safari, selector: str, text: str) -> None: + WebDriverWait(driver, 15).until( + lambda current: text in current.find_element(By.CSS_SELECTOR, selector).text + ) + + +def check_page(driver: webdriver.Safari, width: int, height: int, label: str) -> None: + driver.set_window_size(width, height) + driver.get(BASE_URL) + + wait_for_text(driver, "h1", "TeamSpeak 3") + assert "WebSpeak3" in driver.title + + client_link = driver.find_element(By.CSS_SELECTOR, 'a[href="https://client.webspeak3.de/"]') + demo_link = driver.find_element(By.CSS_SELECTOR, 'a[href="https://demo.webspeak3.de/"]') + assert client_link.is_displayed() + assert demo_link.is_displayed() + + english_button = driver.find_element(By.CSS_SELECTOR, ".lang-switch button:last-child") + driver.execute_script("arguments[0].click()", english_button) + WebDriverWait(driver, 10).until( + lambda current: any( + "Enter a server. Connected." in heading.text + for heading in current.find_elements(By.CSS_SELECTOR, "h2") + ) + ) + + connect_demo = driver.find_element(By.CSS_SELECTOR, ".connect-demo") + assert connect_demo.is_displayed() + assert "voice.teamspeak.com" in connect_demo.text + + driver.save_screenshot(str(RESULTS / f"safari-{label}.png")) + + +def main() -> None: + options = webdriver.SafariOptions() + driver = webdriver.Safari(options=options) + try: + check_page(driver, 1440, 1000, "desktop") + check_page(driver, 390, 844, "mobile") + finally: + driver.quit() + + +if __name__ == "__main__": + main()