annotate tests/e2e/libervia-web/test_libervia-web.py @ 4260:57ff857bf96e

doc (components/AP Gateway): document new `http_sign_get` configuration option.
author Goffi <goffi@goffi.org>
date Wed, 05 Jun 2024 22:34:43 +0200
parents dfccc90cacc6
children 4cd4922de876
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
3480
7550ae9cfbac Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
3 # Libervia: an XMPP client
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3441
diff changeset
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 import os
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
20 import re
4227
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
21
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import pytest
4227
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
23
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from helium import (
4227
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
25 Button,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
26 ENTER,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
27 Link,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
28 S,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
29 Text,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
30 click,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
31 drag_file,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
32 find_all,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
33 get_driver,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
34 go_to,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
35 press,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
36 scroll_down,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
37 select,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
38 wait_until,
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
39 write,
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 )
4227
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
41 from selenium.webdriver.common.by import By
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
42
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
43
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
44 if os.getenv("LIBERVIA_TEST_ENV_E2E_WEB") is None:
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 pytest.skip(
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 "skipping end-to-end tests, we are not in a test environment for Libervia",
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 allow_module_level=True
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 )
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 pytestmark = pytest.mark.usefixtures("test_profiles", "screenshot_on_failure")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
51
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
52
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 class TestLogin:
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
54
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 def test_user_can_create_account(self, nobody_logged_in, sent_emails):
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
56 go_to("https://libervia-web.test:8443/login")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 click("no account yet")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 write("new_account", into="login")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 write("some_email@example.net", into="email")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 write("testtest", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 click("register new account")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 wait_until(lambda: get_driver().current_url.endswith("/login"))
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 write("testtest", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 click("log in")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 wait_until(Text("you are logged").exists)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 wait_until(lambda: len(sent_emails) == 2)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 if sent_emails[0].to == "admin@server1.test":
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 admin_email, user_email = sent_emails
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 else:
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 user_email, admin_email = sent_emails
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 assert admin_email.to == "admin@server1.test"
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 # profile name must be specified in admin email
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 assert "new_account" in admin_email.body
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 assert user_email.to == "some_email@example.net"
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 # user jid must be specified in the email
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 assert "new_account@server1.test" in user_email.body
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 # use can now log-in
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
78
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 def test_user_can_log_in(self, nobody_logged_in):
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
80 go_to("https://libervia-web.test:8443/login")
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
81 write("account1_s3", into="login")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 write("test", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 click("log in")
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
84 wait_until(Text("you are logged").exists)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
85 assert Button("Disconnect").exists()
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
86
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 def test_wrong_password_fails(self, nobody_logged_in):
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
88 go_to("https://libervia-web.test:8443/login")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 write("account1_s2", into="login")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 write("wrong_password", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 click("log in")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 assert Text("Your login and/or password is incorrect. Please try again.")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
93
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
94
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 class TestPhotos:
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
96 ACCOUNT1_ALBUMS_URL = (
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
97 "https://libervia-web.test:8443/photos/album/account1@files.server1.test/albums"
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
98 )
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
99 TEST_ALBUM_URL = f"{ACCOUNT1_ALBUMS_URL}/test%20album"
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
101 @pytest.mark.dependency(name="create_album")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 def test_user_can_create_album(self, log_in_account1):
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
103 go_to("https://libervia-web.test:8443/photos")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 wait_until(Link("create").exists)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 click("create")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 write("test album", into="album name")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 click("create")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 album_link = Link("test album")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 wait_until(album_link.exists)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 click(album_link)
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
111 wait_until(lambda: S("#file_drop").exists())
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 wait_until(lambda: not S("#loading_screen").exists())
3657
6c87c00b344a tests (e2e/web): fix test files paths following global name change
Goffi <goffi@goffi.org>
parents: 3498
diff changeset
113 drag_file("/src/libervia-backend/tests/_files/test_1.jpg", "drop photos here")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 wait_until(lambda: len(find_all(S("div.progress_finished")))==1)
3657
6c87c00b344a tests (e2e/web): fix test files paths following global name change
Goffi <goffi@goffi.org>
parents: 3498
diff changeset
115 drag_file("/src/libervia-backend/tests/_files/test_2.jpg", "drop photos here")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 wait_until(lambda: len(find_all(S("div.progress_finished")))==2)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 assert S('img[alt="test_1.jpg"]').exists()
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 assert S('img[alt="test_2.jpg"]').exists()
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
119
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
120 @pytest.mark.dependency(depends=["create_album"])
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
121 def test_user_can_slideshow(self, log_in_account1):
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
122 go_to(self.TEST_ALBUM_URL)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
123 wait_until(lambda: not S("#loading_screen").exists())
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
124 thumb_1 = S("img[alt='test_1.jpg'].is-photo-thumbnail")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
125 assert thumb_1.exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
126 click(thumb_1)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
127 assert S("div.slideshow").exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
128 active_slide_1 = S("div.swiper-slide-active")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
129 assert active_slide_1.exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
130 # if we don't save the web_element here, the test in wait_until fails
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
131 # it seems that Helium is re-using the selector, i.e. we get the other
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
132 # slide in active_slide_1.
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
133 active_slide_1_elt = active_slide_1.web_element
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
134 click(S(".swiper-button-next"))
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
135 wait_until(
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
136 lambda:
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
137 "swiper-slide-active" not in active_slide_1_elt.get_attribute("class")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
138 )
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
139 active_slide_2 = S("div.swiper-slide-active")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
140 assert active_slide_2.exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
141 active_slide_2_elt = active_slide_2.web_element
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
142 assert active_slide_1_elt != active_slide_2_elt
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
143 click(S(".click_to_close"))
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
144 assert not S("div.slideshow").exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
145
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
146 @pytest.mark.dependency(name="ext_user_no_access", depends=["create_album"])
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
147 def test_external_user_cant_access_album(self, log_in_account1_s2):
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
148 go_to(self.TEST_ALBUM_URL)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
149 assert Text("Unauthorized").exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
150 assert "Error" in get_driver().title
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
151
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
152 @pytest.mark.dependency(name="invite_ext_user", depends=["create_album", "ext_user_no_access"])
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
153 def test_invitation_of_external_user(self, log_in_account1):
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
154 """User can invite somebody not in its roster by its full JID"""
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
155 go_to(self.TEST_ALBUM_URL)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
156 wait_until(lambda: not S("#loading_screen").exists())
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
157 click("manage invitations")
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
158 assert Text("people who can access this page").exists()
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
159 contact_input = S("input[name='contact']")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
160 write("account1@server2.test", into=contact_input)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
161 press(ENTER)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
162 assert contact_input.web_element.get_attribute("value") == ""
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
163 assert Text("account1@server2.test").exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
164
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
165 @pytest.mark.dependency(depends=["create_album", "invite_ext_user"])
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
166 def test_invited_user_can_access_album(self, log_in_account1_s2):
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
167 go_to(self.TEST_ALBUM_URL)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
168 assert not Text("Unauthorized").exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
169 assert not "Error" in get_driver().title
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
170 assert len(find_all(S("img.is-photo-thumbnail"))) == 2
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
171
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
172 @pytest.mark.dependency(name="invite_by_email", depends=["create_album"])
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
173 def test_invitation_by_email(self, log_in_account1, sent_emails, shared_data):
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
174 """User can invite somebody without XMPP account by email"""
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
175 go_to(self.TEST_ALBUM_URL)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
176 wait_until(lambda: not S("#loading_screen").exists())
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
177 click("manage invitations")
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
178 assert Text("people who can access this page").exists()
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
179 click("invite by email")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
180 wait_until(Text("Invite somebody by email").exists)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
181 write("somebody@example.net", "email")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
182 write("Some Guest", "name")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
183 click("send invitation")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
184 wait_until(lambda: len(sent_emails) == 1)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
185 invitation_email = sent_emails[0]
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
186 assert "Welcome" in invitation_email.body
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
187 url_match = re.search(r"https:\/\/.+\/g\/\w+", sent_emails[0].body)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
188 assert url_match is not None
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
189 shared_data["invitation_url"] = url_match.group()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
190
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
191 @pytest.mark.dependency(depends=["invite_by_email"])
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
192 def test_email_guest_can_access_album(self, nobody_logged_in, shared_data):
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
193 go_to(shared_data["invitation_url"])
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
194 click("test album")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
195 wait_until(lambda: not S("#loading_screen").exists())
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
196 assert len(find_all(S("img.is-photo-thumbnail"))) == 2
3703
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
197
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
198
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
199 class TestLists:
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
200 TEST_GENERIC_LIST_URL = (
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
201 "https://libervia-web.test:8443/lists/view/account1@server1.test/"
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
202 "fdp%2Fsubmitted%2Forg.salut-a-toi.tickets%3A0_test-generic-list"
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
203 )
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
204
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
205 @pytest.mark.dependency(name="create_generic_list")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
206 def test_user_can_create_generic(self, log_in_account1):
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
207 go_to("https://libervia-web.test:8443/lists/view")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
208 click("create a list")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
209 tickets_btn = S("//span[text()='Tickets']")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
210 click(tickets_btn)
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
211 write("test-generic-list", "name of the list")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
212 click("create list")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
213 wait_until(Text("Success").exists)
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
214
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
215
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
216 @pytest.mark.dependency(
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
217 name="create_generic_list_item", depends=["create_generic_list"]
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
218 )
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
219 def test_user_can_create_generic_list_item(self):
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
220 go_to(self.TEST_GENERIC_LIST_URL)
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
221 click("create")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
222 write("test item", "title")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
223 write("label 1, label 2", "labels")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
224 select("type", "feature request")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
225 write("this is a test body", "body")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
226 scroll_down(600)
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
227 click("create list item")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
228 wait_until(Text("Success").exists)
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
229 assert Link("create").exists()
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
230 assert Link("manage invitations").exists()
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
231 item = Link("test item")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
232 assert item.exists()
4227
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
233 labels_elt = item.web_element.find_element(By.CLASS_NAME, "xmlui_field__labels")
dfccc90cacc6 tests: fix and update tests:
Goffi <goffi@goffi.org>
parents: 3703
diff changeset
234 labels = [t.text for t in labels_elt.find_elements(By.TAG_NAME, "span")]
3703
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
235 assert labels == ["label 1", "label 2"]
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
236
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
237 @pytest.mark.dependency(depends=["create_generic_list_item"])
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
238 def test_list_item_can_be_displayed(self):
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
239 go_to(self.TEST_GENERIC_LIST_URL)
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
240 item = Link("test item")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
241 # FIXME: we can't click on the item created above with Selenium, looks like a
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
242 # Selenium bug, to be checked
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
243 go_to(item.href)
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
244 item_title = Text("test item")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
245 assert item_title.exists()
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
246 item_body = Text("this is a test body")
de133b180941 tests (e2e/web): add basic tests for generic lists
Goffi <goffi@goffi.org>
parents: 3657
diff changeset
247 assert item_body.exists()