aboutsummaryrefslogtreecommitdiff
path: root/tests/playwright
diff options
context:
space:
mode:
Diffstat (limited to 'tests/playwright')
-rw-r--r--tests/playwright/conftest.py3
-rw-r--r--tests/playwright/test_basic.py6
-rw-r--r--tests/playwright/test_home.py40
3 files changed, 42 insertions, 7 deletions
diff --git a/tests/playwright/conftest.py b/tests/playwright/conftest.py
index 1130df2..efa82c6 100644
--- a/tests/playwright/conftest.py
+++ b/tests/playwright/conftest.py
@@ -118,8 +118,9 @@ class Helper:
title="Another awesome track",
visibility=Visibility.PRIVATE,
description="Another description",
+ type=TrackType.ORGANIC,
)
- track.date = datetime.datetime.now(datetime.timezone.utc)
+ track.date = datetime.datetime(2022, 12, 21, 17, 5, tzinfo=datetime.timezone.utc)
user.tracks.append(track)
self.dbaccess.flush()
self.dbaccess.refresh(track, ["id"])
diff --git a/tests/playwright/test_basic.py b/tests/playwright/test_basic.py
index a2e6030..3b3329a 100644
--- a/tests/playwright/test_basic.py
+++ b/tests/playwright/test_basic.py
@@ -9,12 +9,6 @@ from fietsboek import models
from fietsboek.models.track import Visibility
-def test_homepage(page: Page):
- page.goto("/")
- assert "Welcome to Fietsboek!" in page.content()
- assert "Here you can …" in page.content()
-
-
def test_login_failed(page: Page):
page.goto("/")
page.get_by_role("button", name="User").click()
diff --git a/tests/playwright/test_home.py b/tests/playwright/test_home.py
new file mode 100644
index 0000000..096a7ff
--- /dev/null
+++ b/tests/playwright/test_home.py
@@ -0,0 +1,40 @@
+from playwright.sync_api import Page, expect
+
+
+def test_homepage(page: Page):
+ page.goto("/")
+ assert "Welcome to Fietsboek!" in page.content()
+ assert "Here you can …" in page.content()
+
+
+def test_homepage_logged_in(page: Page, playwright_helper):
+ playwright_helper.login()
+ playwright_helper.add_track()
+
+ page.goto("/")
+
+ expect(page.locator("h1", has_text="Home")).to_be_visible()
+ expect(page.locator("a", has_text="Another awesome track")).to_be_visible()
+
+
+def test_homepage_collapse(page: Page, playwright_helper):
+ playwright_helper.login()
+ playwright_helper.add_track()
+
+ page.goto("/")
+
+ page.locator(".summary-toggler").nth(0).click()
+ expect(page.locator("a", has_text="Another awesome track")).not_to_be_visible()
+ expect(page.locator(".list-group-item-secondary", has_text="December")).not_to_be_visible()
+
+ page.locator(".summary-toggler").nth(0).click()
+ expect(page.locator("a", has_text="Another awesome track")).to_be_visible()
+ expect(page.locator(".list-group-item-secondary", has_text="December")).to_be_visible()
+
+ page.locator(".summary-toggler").nth(1).click()
+ expect(page.locator("a", has_text="Another awesome track")).not_to_be_visible()
+ expect(page.locator(".list-group-item-secondary", has_text="December")).to_be_visible()
+
+ page.locator(".summary-toggler").nth(1).click()
+ expect(page.locator("a", has_text="Another awesome track")).to_be_visible()
+ expect(page.locator(".list-group-item-secondary", has_text="December")).to_be_visible()