mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Add free Safari landing page checks
This commit is contained in:
1 parent
27fbd3cd10
commit
c5635102f0
2 files changed
+135
No files matched your search
@@ -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
|
||||
|
||||
@@ -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()
|
||||
Reference in new issue
Block a user