aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-08-30 19:48:09 +0200
committerDaniel Schadt <kingdread@gmx.de>2023-08-30 19:48:09 +0200
commit0d389ba5af89bad45bd786aad0ff05f405658d8a (patch)
tree8bf639aaebfe30b841fbc92cc7413aa00161564a
parentf7b6ccdccc84d2d1653e9fcaf9fe3e66d6073a18 (diff)
downloadfietsboek-0d389ba5af89bad45bd786aad0ff05f405658d8a.tar.gz
fietsboek-0d389ba5af89bad45bd786aad0ff05f405658d8a.tar.bz2
fietsboek-0d389ba5af89bad45bd786aad0ff05f405658d8a.zip
add test for favourite on detail page
-rw-r--r--tests/playwright/test_basic.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/playwright/test_basic.py b/tests/playwright/test_basic.py
index a98e52d..66ec326 100644
--- a/tests/playwright/test_basic.py
+++ b/tests/playwright/test_basic.py
@@ -146,3 +146,23 @@ def test_delete(page: Page, playwright_helper, dbaccess, data_manager):
assert track is None
with pytest.raises(FileNotFoundError):
data_manager.open(track_id)
+
+
+def test_favour(page: Page, playwright_helper, dbaccess, data_manager):
+ john = playwright_helper.john_doe()
+ playwright_helper.login()
+ track_id = playwright_helper.add_track().id
+
+ page.goto(f"/track/{track_id}")
+
+ with page.expect_request_finished(predicate=lambda req: "/toggle-favourite" in req.url):
+ page.locator(".favourite-star").click()
+
+ track = dbaccess.execute(select(models.Track).filter_by(id=track_id)).scalar_one_or_none()
+ assert john.id in [user.id for user in track.favourees]
+
+ with page.expect_request_finished(predicate=lambda req: "/toggle-favourite" in req.url):
+ page.locator(".favourite-star").click()
+
+ dbaccess.refresh(track, ["favourees"])
+ assert john.id not in [user.id for user in track.favourees]