diff tests/e2e/libervia-web/test_libervia-web.py @ 3703:de133b180941

tests (e2e/web): add basic tests for generic lists
author Goffi <goffi@goffi.org>
date Fri, 05 Nov 2021 18:11:24 +0100
parents 6c87c00b344a
children dfccc90cacc6
line wrap: on
line diff
--- a/tests/e2e/libervia-web/test_libervia-web.py	Fri Nov 05 18:11:24 2021 +0100
+++ b/tests/e2e/libervia-web/test_libervia-web.py	Fri Nov 05 18:11:24 2021 +0100
@@ -21,7 +21,7 @@
 import pytest
 from helium import (
     go_to, write, press, click, drag_file, find_all, wait_until, S, Text, Link, Button,
-    get_driver, ENTER
+    select, scroll_down, get_driver, ENTER
 )
 
 
@@ -178,3 +178,54 @@
         click("test album")
         wait_until(lambda: not S("#loading_screen").exists())
         assert len(find_all(S("img.is-photo-thumbnail"))) == 2
+
+
+class TestLists:
+    TEST_GENERIC_LIST_URL = (
+        "https://libervia-web.test:8443/lists/view/account1@server1.test/"
+        "fdp%2Fsubmitted%2Forg.salut-a-toi.tickets%3A0_test-generic-list"
+    )
+
+    @pytest.mark.dependency(name="create_generic_list")
+    def test_user_can_create_generic(self, log_in_account1):
+        go_to("https://libervia-web.test:8443/lists/view")
+        click("create a list")
+        tickets_btn = S("//span[text()='Tickets']")
+        click(tickets_btn)
+        write("test-generic-list", "name of the list")
+        click("create list")
+        wait_until(Text("Success").exists)
+
+
+    @pytest.mark.dependency(
+        name="create_generic_list_item", depends=["create_generic_list"]
+    )
+    def test_user_can_create_generic_list_item(self):
+        go_to(self.TEST_GENERIC_LIST_URL)
+        click("create")
+        write("test item", "title")
+        write("label 1, label 2", "labels")
+        select("type", "feature request")
+        write("this is a test body", "body")
+        scroll_down(600)
+        click("create list item")
+        wait_until(Text("Success").exists)
+        assert Link("create").exists()
+        assert Link("manage invitations").exists()
+        item = Link("test item")
+        assert item.exists()
+        labels_elt = item.web_element.find_element_by_class_name("xmlui_field__labels")
+        labels = [t.text for t in labels_elt.find_elements_by_tag_name("span")]
+        assert labels == ["label 1", "label 2"]
+
+    @pytest.mark.dependency(depends=["create_generic_list_item"])
+    def test_list_item_can_be_displayed(self):
+        go_to(self.TEST_GENERIC_LIST_URL)
+        item = Link("test item")
+        # FIXME: we can't click on the item created above with Selenium, looks like a
+        #        Selenium bug, to be checked
+        go_to(item.href)
+        item_title = Text("test item")
+        assert item_title.exists()
+        item_body = Text("this is a test body")
+        assert item_body.exists()