From 58d1da5606d3bfe241e18fdf9416ec9a28f3a3f1 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 14 Dec 2022 19:12:08 +0100 Subject: add test for track browsing --- tests/playwright/test_basic.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/playwright/test_basic.py b/tests/playwright/test_basic.py index 61779f1..b3e340d 100644 --- a/tests/playwright/test_basic.py +++ b/tests/playwright/test_basic.py @@ -8,7 +8,7 @@ from sqlalchemy import select from testutils import load_gpx_asset from fietsboek import models -from fietsboek.models.track import Visibility +from fietsboek.models.track import Visibility, TrackType from fietsboek.config import Config @@ -150,3 +150,35 @@ def test_edit(page: Page, john_doe, app_settings, dbaccess): assert track.visibility == Visibility.PUBLIC assert track.text_tags() == {"Shitty Tour"} assert track.description == "Not so descriptive anymore" + + +def test_browse(page: Page, john_doe, app_settings, dbaccess): + do_login(app_settings, page, john_doe) + with dbaccess: + track = models.Track( + title="We're looking for this track", + visibility=Visibility.PRIVATE, + description="Another description", + type=TrackType.ORGANIC, + ) + track.date = datetime.datetime.now(datetime.timezone.utc) + track.gpx_data = load_gpx_asset("Teasi_1.gpx.gz") + john_doe.tracks.append(track) + dbaccess.commit() + + page.goto("/") + page.get_by_text("Browse").click() + + expect(page.locator(".card-header", has_text="We're looking for this track")).to_be_visible() + + page.get_by_role("textbox", name="Search terms").fill("Nothing") + page.get_by_role("button", name="Apply filters").click() + + expect( + page.locator("p", has_text="No results matching the filters were found.") + ).to_be_visible() + + page.get_by_role("textbox", name="Search terms").fill("looking for") + page.get_by_role("button", name="Apply filters").click() + + expect(page.locator(".card-header", has_text="We're looking for this track")).to_be_visible() -- cgit v1.2.3