diff tests/e2e/libervia/test_libervia.py @ 3429:d4558f3cbf13

tests, docker(e2e): added e2e tests for Libervia: - moved jp tests to `e2e/jp` - new fixtures - adapted docker-compose - improved `run_e2e` with several flags + report on failure - doc to come
author Goffi <goffi@goffi.org>
date Fri, 27 Nov 2020 16:39:40 +0100
parents
children fdf56af87719
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/e2e/libervia/test_libervia.py	Fri Nov 27 16:39:40 2020 +0100
@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+
+# SàT: an XMPP client
+# Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import pytest
+from helium import (
+    go_to, write, click, drag_file, find_all, wait_until, S, Text, Link, get_driver
+)
+
+
+if os.getenv("SAT_TEST_ENV_E2E_LIBERVIA") is None:
+    pytest.skip(
+        "skipping end-to-end tests, we are not in a test environment for Libervia",
+        allow_module_level=True
+    )
+
+pytestmark = pytest.mark.usefixtures("test_profiles", "screenshot_on_failure")
+
+
+class TestLogin:
+
+    def test_user_can_create_account(self, nobody_logged_in, sent_emails):
+        go_to("https://libervia.test:8443/login")
+        click("no account yet")
+        write("new_account", into="login")
+        write("some_email@example.net", into="email")
+        write("testtest", into="password")
+        click("register new account")
+        wait_until(lambda: get_driver().current_url.endswith("/login"))
+        write("testtest", into="password")
+        click("log in")
+        wait_until(Text("you are logged").exists)
+        wait_until(lambda: len(sent_emails) == 2)
+        if sent_emails[0].to == "admin@server1.test":
+            admin_email, user_email = sent_emails
+        else:
+            user_email, admin_email = sent_emails
+        assert admin_email.to == "admin@server1.test"
+        # profile name must be specified in admin email
+        assert "new_account" in admin_email.body
+        assert user_email.to == "some_email@example.net"
+        # user jid must be specified in the email
+        assert "new_account@server1.test" in user_email.body
+        # use can now log-in
+
+    def test_user_can_log_in(self, nobody_logged_in):
+        go_to("https://libervia.test:8443/login")
+        write("account1_s2", into="login")
+        write("test", into="password")
+        click("log in")
+        assert Text("you are logged").exists()
+
+    def test_wrong_password_fails(self, nobody_logged_in):
+        go_to("https://libervia.test:8443/login")
+        write("account1_s2", into="login")
+        write("wrong_password", into="password")
+        click("log in")
+        assert Text("Your login and/or password is incorrect. Please try again.")
+
+
+class TestPhotos:
+
+    def test_user_can_create_album(self, log_in_account1):
+        go_to("https://libervia.test:8443/photos")
+        wait_until(Link("create").exists)
+        click("create")
+        write("test album", into="album name")
+        click("create")
+        album_link = Link("test album")
+        wait_until(album_link.exists)
+        click(album_link)
+        wait_until(lambda: not S("#loading_screen").exists())
+        drag_file("/src/sat/tests/_files/test_1.jpg", "drop photos here")
+        wait_until(lambda: len(find_all(S("div.progress_finished")))==1)
+        drag_file("/src/sat/tests/_files/test_2.jpg", "drop photos here")
+        wait_until(lambda: len(find_all(S("div.progress_finished")))==2)
+        assert S('img[alt="test_1.jpg"]').exists()
+        assert S('img[alt="test_2.jpg"]').exists()