aboutsummaryrefslogtreecommitdiff
path: root/tests/playwright/test_transformers.py
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-03-04 18:24:11 +0100
committerDaniel Schadt <kingdread@gmx.de>2023-03-04 18:24:11 +0100
commite9025533b86228f7073a672269c939c5ae5db8e2 (patch)
tree8a98178672ac4fa5e42e136098c0406cd6c838d0 /tests/playwright/test_transformers.py
parent63779a61151babf9dc60d55acc81e3a97811a60e (diff)
downloadfietsboek-e9025533b86228f7073a672269c939c5ae5db8e2.tar.gz
fietsboek-e9025533b86228f7073a672269c939c5ae5db8e2.tar.bz2
fietsboek-e9025533b86228f7073a672269c939c5ae5db8e2.zip
add tests for the new transformer
Diffstat (limited to 'tests/playwright/test_transformers.py')
-rw-r--r--tests/playwright/test_transformers.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/playwright/test_transformers.py b/tests/playwright/test_transformers.py
new file mode 100644
index 0000000..0fc4ffc
--- /dev/null
+++ b/tests/playwright/test_transformers.py
@@ -0,0 +1,87 @@
+from playwright.sync_api import Page, expect
+from sqlalchemy import select
+
+from testutils import extract_and_upload
+from fietsboek import models
+
+
+def test_transformer_zero_elevation_disabled(page: Page, playwright_helper, tmp_path, dbaccess):
+ playwright_helper.login()
+
+ page.goto("/")
+ page.get_by_text("Upload").click()
+
+ extract_and_upload(page, "Synthetic_Zero_Elevation.gpx.gz", tmp_path)
+
+ page.locator(".btn", has_text="Upload").click()
+
+ # Once we have finished the upload, extract the ID of the track and check
+ # the properties
+ new_track_id = int(page.url.rsplit("/", 1)[1])
+ track = dbaccess.execute(select(models.Track).filter_by(id=new_track_id)).scalar_one()
+
+ assert track.cache.uphill > 160
+ expect(page.locator("#detailsUphill")).to_contain_text("167.7 m")
+
+
+def test_transformer_zero_elevation_enabled(page: Page, playwright_helper, tmp_path, dbaccess):
+ playwright_helper.login()
+
+ page.goto("/")
+ page.get_by_text("Upload").click()
+
+ extract_and_upload(page, "Synthetic_Zero_Elevation.gpx.gz", tmp_path)
+
+ page.locator("#transformer-heading-1 .accordion-button").click()
+ page.locator("#transformer-enabled-1").click()
+
+ page.locator(".btn", has_text="Upload").click()
+
+ # Once we have finished the upload, extract the ID of the track and check
+ # the properties
+ new_track_id = int(page.url.rsplit("/", 1)[1])
+ track = dbaccess.execute(select(models.Track).filter_by(id=new_track_id)).scalar_one()
+
+ assert track.cache.uphill < 0.1
+ expect(page.locator("#detailsUphill")).to_contain_text("0 m")
+
+
+def test_transformer_steep_slope_disabled(page: Page, playwright_helper, tmp_path, dbaccess):
+ playwright_helper.login()
+
+ page.goto("/")
+ page.get_by_text("Upload").click()
+
+ extract_and_upload(page, "Synthetic_Steep_Slope.gpx.gz", tmp_path)
+
+ page.locator(".btn", has_text="Upload").click()
+
+ # Once we have finished the upload, extract the ID of the track and check
+ # the properties
+ new_track_id = int(page.url.rsplit("/", 1)[1])
+ track = dbaccess.execute(select(models.Track).filter_by(id=new_track_id)).scalar_one()
+
+ assert track.cache.uphill > 60
+ expect(page.locator("#detailsUphill")).to_contain_text("61.54 m")
+
+
+def test_transformer_steep_slope_enabled(page: Page, playwright_helper, tmp_path, dbaccess):
+ playwright_helper.login()
+
+ page.goto("/")
+ page.get_by_text("Upload").click()
+
+ extract_and_upload(page, "Synthetic_Steep_Slope.gpx.gz", tmp_path)
+
+ page.locator("#transformer-heading-1 .accordion-button").click()
+ page.locator("#transformer-enabled-1").click()
+
+ page.locator(".btn", has_text="Upload").click()
+
+ # Once we have finished the upload, extract the ID of the track and check
+ # the properties
+ new_track_id = int(page.url.rsplit("/", 1)[1])
+ track = dbaccess.execute(select(models.Track).filter_by(id=new_track_id)).scalar_one()
+
+ assert track.cache.uphill < 2
+ expect(page.locator("#detailsUphill")).to_contain_text("1.2 m")