From e37e056c36272e5f0c0e23bd993290208e14a979 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 1 Apr 2023 13:08:02 +0200 Subject: add some very basic tests for profiles I'd like to have more, but this is a start (and already caught some errors, see the last two commits). --- tests/playwright/test_profiles.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/playwright/test_profiles.py (limited to 'tests/playwright') diff --git a/tests/playwright/test_profiles.py b/tests/playwright/test_profiles.py new file mode 100644 index 0000000..40d8ba8 --- /dev/null +++ b/tests/playwright/test_profiles.py @@ -0,0 +1,27 @@ +from playwright.sync_api import Page, expect + +from .conftest import Helper + + +def test_forbidden(page: Page, playwright_helper: Helper): + john = playwright_helper.john_doe() + + with page.expect_response(lambda resp: resp.status == 403): + page.goto(f"/user/{john.id}") + + +def test_profile(page: Page, playwright_helper: Helper): + playwright_helper.login() + + page.goto("/") + page.get_by_role("button", name="User").click() + page.get_by_role("link", name="Profile").click() + + expect(page.locator("#profileLength")).to_have_text("0 km") + expect(page.locator("#profileUphill")).to_have_text("0 m") + expect(page.locator("#profileDownhill")).to_have_text("0 m") + expect(page.locator("#profileMovingTime")).to_have_text("0:00:00") + expect(page.locator("#profileStoppedTime")).to_have_text("0:00:00") + expect(page.locator("#profileMaxSpeed")).to_have_text("0 km/h") + expect(page.locator("#profileAvgSpeed")).to_have_text("0 km/h") + expect(page.locator("#profileNumberOfTracks")).to_have_text("0") -- cgit v1.2.3 From e3b9e0e1de60acb441794c36b1aee55ff8f1d94f Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 1 Apr 2023 13:17:40 +0200 Subject: remove import across toplevel Python seems to do fine, but pylint complains (probably rightfully, since the tests do not represent packages). We lose type hinting for the playwright_helper, but there's probably a better way to do it in the future. --- tests/playwright/test_profiles.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/playwright') diff --git a/tests/playwright/test_profiles.py b/tests/playwright/test_profiles.py index 40d8ba8..7e5fb3c 100644 --- a/tests/playwright/test_profiles.py +++ b/tests/playwright/test_profiles.py @@ -1,16 +1,14 @@ from playwright.sync_api import Page, expect -from .conftest import Helper - -def test_forbidden(page: Page, playwright_helper: Helper): +def test_forbidden(page: Page, playwright_helper): john = playwright_helper.john_doe() with page.expect_response(lambda resp: resp.status == 403): page.goto(f"/user/{john.id}") -def test_profile(page: Page, playwright_helper: Helper): +def test_profile(page: Page, playwright_helper): playwright_helper.login() page.goto("/") -- cgit v1.2.3