aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-11-13 18:51:52 +0100
committerDaniel Schadt <kingdread@gmx.de>2023-11-13 18:52:27 +0100
commit9aac19a422addda40e802c0b94d7a237b742d8e1 (patch)
tree6840f0f4128469a023ba6e0971c7390e113ffde1
parenteac4f7a7f7fec9585a7c080400c4ae8fa9b67578 (diff)
downloadfietsboek-9aac19a422addda40e802c0b94d7a237b742d8e1.tar.gz
fietsboek-9aac19a422addda40e802c0b94d7a237b742d8e1.tar.bz2
fietsboek-9aac19a422addda40e802c0b94d7a237b742d8e1.zip
add tests for disabled image uploads
-rw-r--r--fietsboek/templates/edit_form.jinja22
-rw-r--r--tests/playwright/test_no_image_uploads.py33
2 files changed, 34 insertions, 1 deletions
diff --git a/fietsboek/templates/edit_form.jinja2 b/fietsboek/templates/edit_form.jinja2
index 89cefa4..43f3400 100644
--- a/fietsboek/templates/edit_form.jinja2
+++ b/fietsboek/templates/edit_form.jinja2
@@ -114,7 +114,7 @@
{% endfor %}
</div>
<input type="file" name="image[]" id="imageSelector" class="form-control" accept="image/*" style="display:none;" multiple>
- <button type="button" onclick="document.querySelector('#imageSelector').click()" class="btn btn-primary" {% if not request.config.enable_image_uploads %}disabled{% endif %}>
+ <button type="button" onclick="document.querySelector('#imageSelector').click()" class="btn btn-primary" id="selectImagesButton" {% if not request.config.enable_image_uploads %}disabled{% endif %}>
<i class="bi bi-images"></i> {{ _("page.track.form.select_images") }}
</button>
{% if not request.config.enable_image_uploads %}
diff --git a/tests/playwright/test_no_image_uploads.py b/tests/playwright/test_no_image_uploads.py
new file mode 100644
index 0000000..ce45ebb
--- /dev/null
+++ b/tests/playwright/test_no_image_uploads.py
@@ -0,0 +1,33 @@
+import pytest
+from playwright.sync_api import Page, expect
+
+from testutils import extract_and_upload
+
+
+@pytest.fixture(scope="module")
+def app_settings(app_settings):
+ app_settings["fietsboek.enable_image_uploads"] = "false"
+ return app_settings
+
+
+def test_image_button_disabled_during_upload(page: Page, playwright_helper, tmp_path, dbaccess):
+ playwright_helper.login()
+
+ page.goto("/")
+ page.get_by_text("Upload").click()
+
+ # We unpack one of the test GPX files
+ extract_and_upload(page, "Teasi_1.gpx.gz", tmp_path)
+
+ # We now fill in most of the data
+ expect(page.locator("#selectImagesButton")).to_be_disabled()
+
+
+def test_image_button_disabled_during_edit(page: Page, playwright_helper, dbaccess):
+ playwright_helper.login()
+ track_id = playwright_helper.add_track().id
+
+ page.goto(f"/track/{track_id}")
+ page.locator(".btn", has_text="Edit").click()
+
+ expect(page.locator("#selectImagesButton")).to_be_disabled()