From 0d389ba5af89bad45bd786aad0ff05f405658d8a Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 30 Aug 2023 19:48:09 +0200 Subject: add test for favourite on detail page --- tests/playwright/test_basic.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') 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] -- cgit v1.2.3 From 15c63fcf923a1a996fa9aa02c33eee6e68850e8f Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 30 Aug 2023 19:52:42 +0200 Subject: fix upload test The new favourite icon messes up the old HTML, so we need to adjust the test's expectations. --- tests/integration/test_upload.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/integration/test_upload.py b/tests/integration/test_upload.py index 454785f..f09b468 100644 --- a/tests/integration/test_upload.py +++ b/tests/integration/test_upload.py @@ -1,3 +1,5 @@ +import re + from sqlalchemy import select, func from webtest import Upload @@ -30,7 +32,7 @@ def test_upload(testapp, dbsession, route_path, logged_in): ] result = finish_form.submit().maybe_follow() - assert "

FoOoOo Bar's Testtrack

" in result.text + assert re.search("

\\s*FoOoOo Bar's Testtrack", result.text) # Step 4: Ensure the track is stored right track = dbsession.execute(select(models.Track)).scalar_one() -- cgit v1.2.3