Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright for WebKit, Firefox #50

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Ensure browsers are installed
run: python -m playwright install --with-deps
- name: Run your tests
run: pytest -v
run: pytest -v --browser=firefox --browser=webkit --browser=chromium
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile.pytests
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3.12-slim
WORKDIR /app
COPY poetry.lock pyproject.toml .
RUN pip install poetry && poetry config virtualenvs.create false && poetry install
COPY . .
CMD ["poetry", "run", "pytest"]

5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
docker build -f Dockerfile.pytests -t puepy-pytest .

test: build
docker run -it --rm puepy-pytest
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ python = "^3.9"


[tool.poetry.group.dev.dependencies]
pytest-playwright = "^0.5.0"
pytest = "^8.2.2"
pytest-playwright = "^0.5.1"
pytest = "^8.3.2"

[build-system]
requires = ["poetry-core"]
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_hello_world(http_server, page: Page):
expect(page.locator("h1")).to_contain_text("Hello, World!")


def test_hello_name(page: Page):
def test_hello_name(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")
page.get_by_role("link", name="Example 2: Hello, Name").click()
page.get_by_placeholder("name").click()
Expand All @@ -65,7 +65,7 @@ def test_hello_name(page: Page):
expect(page.locator("h1")).to_contain_text("Hello, Jack!")


def test_counter(page: Page):
def test_counter(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")
page.get_by_role("link", name="Example 3: Counter").click()
page.get_by_role("button", name="+").click()
Expand All @@ -80,7 +80,7 @@ def test_counter(page: Page):
expect(page.locator(".count")).to_contain_text("-1")


def test_refs_problem(page: Page):
def test_refs_problem(http_server, page: Page):
def input_is_active():
return page.evaluate("document.querySelector(\"[placeholder='Type a word']\") === document.activeElement")

Expand All @@ -98,7 +98,7 @@ def input_is_active():
assert not input_is_active()


def test_refs_solution(page: Page):
def test_refs_solution(http_server, page: Page):
def input_is_active():
return page.evaluate("document.querySelector(\"[placeholder='Type a word']\") === document.activeElement")

Expand All @@ -111,7 +111,7 @@ def input_is_active():
assert input_is_active()


def test_watchers(page: Page):
def test_watchers(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")
page.get_by_role("link", name="Example 5: Watchers").click()
page.get_by_placeholder("Enter a guess").click()
Expand All @@ -122,7 +122,7 @@ def test_watchers(page: Page):
page.get_by_text("You guessed the number!").click()


def test_components(page: Page):
def test_components(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")
page.get_by_role("link", name="Example 6: Components").click()

Expand All @@ -134,7 +134,7 @@ def test_components(page: Page):
expect(page.locator("#result")).to_contain_text("Custom event from card with type error")


def test_routing(page: Page):
def test_routing(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")
page.get_by_role("link", name="Example 7: Routing").click()

Expand All @@ -151,7 +151,7 @@ def test_routing(page: Page):
page.get_by_role("heading", name="PuePy Routing Demo: Pet").click()


def test_pypi_libraries(page: Page):
def test_pypi_libraries(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")
page.get_by_role("link", name="Example 8: PyPi Libraries").click()
page.get_by_role("textbox").first.click()
Expand All @@ -169,14 +169,14 @@ def test_pypi_libraries(page: Page):
)


def test_webcomponents(page: Page):
def test_webcomponents(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")
page.get_by_role("link", name="Example 9: WebComponents").click()
page.get_by_role("button", name="Open Dialog").click()
page.locator("sl-button").filter(has_text="Close").get_by_role("button").click()


def test_a_full_app(page: Page):
def test_a_full_app(http_server, page: Page):
page.goto(f"http://localhost:{PORT}/")

page.get_by_role("link", name="Example 10: A full-blown app").click()
Expand Down
Loading