Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
3428:a6ea53248c14 | 3429:d4558f3cbf13 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 # SàT: an XMPP client | |
4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 import os | |
20 import pytest | |
21 from helium import ( | |
22 go_to, write, click, drag_file, find_all, wait_until, S, Text, Link, get_driver | |
23 ) | |
24 | |
25 | |
26 if os.getenv("SAT_TEST_ENV_E2E_LIBERVIA") is None: | |
27 pytest.skip( | |
28 "skipping end-to-end tests, we are not in a test environment for Libervia", | |
29 allow_module_level=True | |
30 ) | |
31 | |
32 pytestmark = pytest.mark.usefixtures("test_profiles", "screenshot_on_failure") | |
33 | |
34 | |
35 class TestLogin: | |
36 | |
37 def test_user_can_create_account(self, nobody_logged_in, sent_emails): | |
38 go_to("https://libervia.test:8443/login") | |
39 click("no account yet") | |
40 write("new_account", into="login") | |
41 write("some_email@example.net", into="email") | |
42 write("testtest", into="password") | |
43 click("register new account") | |
44 wait_until(lambda: get_driver().current_url.endswith("/login")) | |
45 write("testtest", into="password") | |
46 click("log in") | |
47 wait_until(Text("you are logged").exists) | |
48 wait_until(lambda: len(sent_emails) == 2) | |
49 if sent_emails[0].to == "admin@server1.test": | |
50 admin_email, user_email = sent_emails | |
51 else: | |
52 user_email, admin_email = sent_emails | |
53 assert admin_email.to == "admin@server1.test" | |
54 # profile name must be specified in admin email | |
55 assert "new_account" in admin_email.body | |
56 assert user_email.to == "some_email@example.net" | |
57 # user jid must be specified in the email | |
58 assert "new_account@server1.test" in user_email.body | |
59 # use can now log-in | |
60 | |
61 def test_user_can_log_in(self, nobody_logged_in): | |
62 go_to("https://libervia.test:8443/login") | |
63 write("account1_s2", into="login") | |
64 write("test", into="password") | |
65 click("log in") | |
66 assert Text("you are logged").exists() | |
67 | |
68 def test_wrong_password_fails(self, nobody_logged_in): | |
69 go_to("https://libervia.test:8443/login") | |
70 write("account1_s2", into="login") | |
71 write("wrong_password", into="password") | |
72 click("log in") | |
73 assert Text("Your login and/or password is incorrect. Please try again.") | |
74 | |
75 | |
76 class TestPhotos: | |
77 | |
78 def test_user_can_create_album(self, log_in_account1): | |
79 go_to("https://libervia.test:8443/photos") | |
80 wait_until(Link("create").exists) | |
81 click("create") | |
82 write("test album", into="album name") | |
83 click("create") | |
84 album_link = Link("test album") | |
85 wait_until(album_link.exists) | |
86 click(album_link) | |
87 wait_until(lambda: not S("#loading_screen").exists()) | |
88 drag_file("/src/sat/tests/_files/test_1.jpg", "drop photos here") | |
89 wait_until(lambda: len(find_all(S("div.progress_finished")))==1) | |
90 drag_file("/src/sat/tests/_files/test_2.jpg", "drop photos here") | |
91 wait_until(lambda: len(find_all(S("div.progress_finished")))==2) | |
92 assert S('img[alt="test_1.jpg"]').exists() | |
93 assert S('img[alt="test_2.jpg"]').exists() |