aboutsummaryrefslogtreecommitdiff
path: root/tests/playwright/test_transformers.py
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-03-07 20:17:35 +0100
committerDaniel Schadt <kingdread@gmx.de>2023-03-07 20:17:35 +0100
commit40a0f2dbed1034ca02fcb83c820f22976601c777 (patch)
tree6eb1889dbace979442e0058136e49208f8e89903 /tests/playwright/test_transformers.py
parentbb4b8eed4cd0ede4198f5dcf4269f2efed25541a (diff)
parente8678a7155ff64d797693f7a8ec84c196d1d4748 (diff)
downloadfietsboek-40a0f2dbed1034ca02fcb83c820f22976601c777.tar.gz
fietsboek-40a0f2dbed1034ca02fcb83c820f22976601c777.tar.bz2
fietsboek-40a0f2dbed1034ca02fcb83c820f22976601c777.zip
Merge branch 'transformers'
Diffstat (limited to 'tests/playwright/test_transformers.py')
-rw-r--r--tests/playwright/test_transformers.py130
1 files changed, 130 insertions, 0 deletions
diff --git a/tests/playwright/test_transformers.py b/tests/playwright/test_transformers.py
new file mode 100644
index 0000000..0b2e4de
--- /dev/null
+++ b/tests/playwright/test_transformers.py
@@ -0,0 +1,130 @@
+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()
+
+ # Expect early (here and in the other tests) to ensure that the backend has
+ # caught up with executing the transformer. Otherwise it might happen that
+ # we read the database while the request is not finished yet.
+ expect(page.locator("#detailsUphill")).to_contain_text("167.7 m")
+ 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
+
+
+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()
+
+ expect(page.locator("#detailsUphill")).to_contain_text("0 m")
+ 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
+
+
+def test_transformer_zero_elevation_edited(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()
+
+ page.locator(".btn", has_text="Edit").click()
+
+ page.locator("#transformer-heading-1 .accordion-button").click()
+ page.locator("#transformer-enabled-1").click()
+
+ page.locator(".btn", has_text="Save").click()
+
+ expect(page.locator("#detailsUphill")).to_contain_text("0 m")
+ track_id = int(page.url.rsplit("/", 1)[1])
+ track = dbaccess.execute(select(models.Track).filter_by(id=track_id)).scalar_one()
+
+ assert track.cache.uphill < 0.1
+
+
+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()
+
+ expect(page.locator("#detailsUphill")).to_contain_text("61.54 m")
+ 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
+
+
+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()
+
+ expect(page.locator("#detailsUphill")).to_contain_text("1.2 m")
+ 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
+
+
+def test_transformer_steep_slope_edited(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()
+
+ page.locator(".btn", has_text="Edit").click()
+
+ page.locator("#transformer-heading-1 .accordion-button").click()
+ page.locator("#transformer-enabled-1").click()
+
+ page.locator(".btn", has_text="Save").click()
+
+ expect(page.locator("#detailsUphill")).to_contain_text("1.2 m")
+ track_id = int(page.url.rsplit("/", 1)[1])
+ track = dbaccess.execute(select(models.Track).filter_by(id=track_id)).scalar_one()
+
+ assert track.cache.uphill < 2