diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-03-07 19:54:07 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-03-07 19:59:01 +0100 |
commit | e8678a7155ff64d797693f7a8ec84c196d1d4748 (patch) | |
tree | 1ef7e872b4a2965841c75d08acb930f5b96d1cbe /tests/playwright/test_transformers.py | |
parent | f232660e17f9dfe642f986ebb0de34a3c8f24c83 (diff) | |
download | fietsboek-e8678a7155ff64d797693f7a8ec84c196d1d4748.tar.gz fietsboek-e8678a7155ff64d797693f7a8ec84c196d1d4748.tar.bz2 fietsboek-e8678a7155ff64d797693f7a8ec84c196d1d4748.zip |
switch order of expect & assert
While it shouldn't change the outcome of the test, it might make the
test less flaky, as the expect call will wait until the page is loaded -
which also indicates that the data is updated. Without this, the test
depends on the backend being "fast enough" with applying the
transformation.
Diffstat (limited to 'tests/playwright/test_transformers.py')
-rw-r--r-- | tests/playwright/test_transformers.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/tests/playwright/test_transformers.py b/tests/playwright/test_transformers.py index d12be5e..0b2e4de 100644 --- a/tests/playwright/test_transformers.py +++ b/tests/playwright/test_transformers.py @@ -15,13 +15,14 @@ def test_transformer_zero_elevation_disabled(page: Page, playwright_helper, tmp_ page.locator(".btn", has_text="Upload").click() - # Once we have finished the upload, extract the ID of the track and check - # the properties + # 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 - expect(page.locator("#detailsUphill")).to_contain_text("167.7 m") def test_transformer_zero_elevation_enabled(page: Page, playwright_helper, tmp_path, dbaccess): @@ -37,13 +38,11 @@ def test_transformer_zero_elevation_enabled(page: Page, playwright_helper, tmp_p page.locator(".btn", has_text="Upload").click() - # Once we have finished the upload, extract the ID of the track and check - # the properties + 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 - expect(page.locator("#detailsUphill")).to_contain_text("0 m") def test_transformer_zero_elevation_edited(page: Page, playwright_helper, tmp_path, dbaccess): @@ -63,11 +62,11 @@ def test_transformer_zero_elevation_edited(page: Page, playwright_helper, tmp_pa 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 - expect(page.locator("#detailsUphill")).to_contain_text("0 m") def test_transformer_steep_slope_disabled(page: Page, playwright_helper, tmp_path, dbaccess): @@ -80,13 +79,11 @@ def test_transformer_steep_slope_disabled(page: Page, playwright_helper, tmp_pat page.locator(".btn", has_text="Upload").click() - # Once we have finished the upload, extract the ID of the track and check - # the properties + 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 - expect(page.locator("#detailsUphill")).to_contain_text("61.54 m") def test_transformer_steep_slope_enabled(page: Page, playwright_helper, tmp_path, dbaccess): @@ -102,13 +99,11 @@ def test_transformer_steep_slope_enabled(page: Page, playwright_helper, 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 + 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 - expect(page.locator("#detailsUphill")).to_contain_text("1.2 m") def test_transformer_steep_slope_edited(page: Page, playwright_helper, tmp_path, dbaccess): @@ -128,8 +123,8 @@ def test_transformer_steep_slope_edited(page: Page, playwright_helper, tmp_path, 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 - expect(page.locator("#detailsUphill")).to_contain_text("1.2 m") |