From 9da6679f4953bbf9d584dd5530ef7ca31ce502ab Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 13 Dec 2022 22:13:23 +0100 Subject: add a test for editing tracks --- tests/playwright/test_basic.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests') diff --git a/tests/playwright/test_basic.py b/tests/playwright/test_basic.py index 4c6f9d6..61779f1 100644 --- a/tests/playwright/test_basic.py +++ b/tests/playwright/test_basic.py @@ -111,3 +111,42 @@ def test_upload(page: Page, john_doe, app_settings, tmp_path, dbaccess): assert track.visibility == Visibility.PUBLIC assert track.text_tags() == {"Tolle Tour"} assert track.description == "Beschreibung der tollen Tour" + + +def test_edit(page: Page, john_doe, app_settings, dbaccess): + do_login(app_settings, page, john_doe) + with dbaccess: + track = models.Track( + title="Another awesome track", + visibility=Visibility.PRIVATE, + description="Another description", + ) + track.date = datetime.datetime.now(datetime.timezone.utc) + track.gpx_data = load_gpx_asset("Teasi_1.gpx.gz") + john_doe.tracks.append(track) + dbaccess.flush() + track_id = track.id + dbaccess.commit() + + page.goto(f"/track/{track_id}") + page.locator(".btn", has_text="Edit").click() + + # We now fill in most of the data + page.get_by_label("Title").fill("Not so awesome anymore!") + page.get_by_label("Date").type("09232019") + page.get_by_label("Date").press("Tab") + page.get_by_label("Date").type("15:28") + page.get_by_label("Visibility").select_option(label="Public") + page.get_by_label("Tags").fill("Shitty Tour") + page.get_by_role("button", name="Add Tag").click() + page.get_by_label("Description").fill("Not so descriptive anymore") + + page.locator(".btn", has_text="Save").click() + + track = dbaccess.execute(select(models.Track).filter_by(id=track_id)).scalar_one() + + assert track.title == "Not so awesome anymore!" + assert track.date.replace(tzinfo=None) == datetime.datetime(2019, 9, 23, 15, 28) + assert track.visibility == Visibility.PUBLIC + assert track.text_tags() == {"Shitty Tour"} + assert track.description == "Not so descriptive anymore" -- cgit v1.2.3