Skip to content

Commit 660c264

Browse files
committed
add playwrite test
1 parent 7e5ecf5 commit 660c264

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

‎tests/test_e2e.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
End-to-end tests for a deployed (non-promoted) App Engine version.
3+
4+
Usage:
5+
pytest tests/test_e2e.py --base-url https://VERSION-dot-glowscript.appspot.com -v
6+
"""
7+
import pytest
8+
from playwright.sync_api import Page, expect
9+
10+
11+
def test_home_page_loads(page: Page, base_url):
12+
"""Home page should return 200 and render the IDE."""
13+
page.goto(base_url)
14+
expect(page).not_to_have_title("")
15+
assert page.title() != ""
16+
17+
18+
def test_api_login_unauthenticated(page: Page, base_url):
19+
"""API login endpoint should return not_logged_in state for anonymous requests."""
20+
response = page.request.get(f"{base_url}/api/login")
21+
assert response.status == 200
22+
data = response.json()
23+
assert data["state"] == "not_logged_in"
24+
assert "login_url" in data
25+
26+
27+
def test_group_docs_page_loads(page: Page, base_url):
28+
"""group.html docs page should load and contain expected content."""
29+
page.goto(f"{base_url}/docs/VPythonDocs/group.html")
30+
expect(page.locator("h1")).to_contain_text("group")
31+
expect(page.locator("body")).to_contain_text("group_to_world")
32+
expect(page.locator("body")).to_contain_text("world_to_group")
33+
34+
35+
def test_group_docs_nav_links(page: Page, base_url):
36+
"""group.html should have working prev/next navigation links."""
37+
page.goto(f"{base_url}/docs/VPythonDocs/group.html")
38+
# Previous: compound
39+
prev = page.locator("a", has_text="compound").first
40+
expect(prev).to_be_visible()
41+
# Next: vertex
42+
next_ = page.locator("a", has_text="vertex").first
43+
expect(next_).to_be_visible()
44+
45+
46+
def test_compound_docs_links_to_group(page: Page, base_url):
47+
"""compound.html should link to group.html and the link should work."""
48+
page.goto(f"{base_url}/docs/VPythonDocs/compound.html")
49+
link = page.locator("a[href='group.html']").first
50+
expect(link).to_be_visible()
51+
link.click()
52+
expect(page).to_have_url(f"{base_url}/docs/VPythonDocs/group.html")
53+
expect(page.locator("h1")).to_contain_text("group")

0 commit comments

Comments
 (0)