annotate tests/e2e/libervia-web/test_libervia-web.py @ 3642:cc3b453670a2

tools (common/uri): fix uri parsing for Python 3.9+
author Goffi <goffi@goffi.org>
date Wed, 08 Sep 2021 11:14:47 +0200
parents d78b5eae912a
children 6c87c00b344a
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
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 import pytest
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from helium import (
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
23 go_to, write, press, click, drag_file, find_all, wait_until, S, Text, Link, Button,
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
24 get_driver, ENTER
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 )
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
26
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
28 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
29 pytest.skip(
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 "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
31 allow_module_level=True
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 )
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 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
35
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
36
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 class TestLogin:
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
38
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 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
40 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
41 click("no account yet")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 write("new_account", into="login")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 write("some_email@example.net", into="email")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 write("testtest", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 click("register new account")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 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
47 write("testtest", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 click("log in")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 wait_until(Text("you are logged").exists)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 wait_until(lambda: len(sent_emails) == 2)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 if sent_emails[0].to == "admin@server1.test":
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 admin_email, user_email = sent_emails
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 else:
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 user_email, admin_email = sent_emails
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 assert admin_email.to == "admin@server1.test"
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 # profile name must be specified in admin email
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 assert "new_account" in admin_email.body
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 assert user_email.to == "some_email@example.net"
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 # user jid must be specified in the email
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 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
61 # use can now log-in
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
62
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 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
64 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
65 write("account1_s3", into="login")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 write("test", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 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
68 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
69 assert Button("Disconnect").exists()
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
70
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 def test_wrong_password_fails(self, nobody_logged_in):
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
72 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
73 write("account1_s2", into="login")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 write("wrong_password", into="password")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 click("log in")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 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
77
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 class TestPhotos:
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
80 ACCOUNT1_ALBUMS_URL = (
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
81 "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
82 )
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
83 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
84
3441
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
85 @pytest.mark.dependency(name="create_album")
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 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
87 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
88 wait_until(Link("create").exists)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 click("create")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 write("test album", into="album name")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 click("create")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 album_link = Link("test album")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 wait_until(album_link.exists)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 click(album_link)
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
95 wait_until(lambda: S("#file_drop").exists())
3429
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 wait_until(lambda: not S("#loading_screen").exists())
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 drag_file("/src/sat/tests/_files/test_1.jpg", "drop photos here")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 wait_until(lambda: len(find_all(S("div.progress_finished")))==1)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 drag_file("/src/sat/tests/_files/test_2.jpg", "drop photos here")
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 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
101 assert S('img[alt="test_1.jpg"]').exists()
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 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
103
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
104 @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
105 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
106 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
107 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
108 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
109 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
110 click(thumb_1)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
111 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
112 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
113 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
114 # 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
115 # 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
116 # 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
117 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
118 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
119 wait_until(
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
120 lambda:
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
121 "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
122 )
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
123 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
124 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
125 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
126 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
127 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
128 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
129
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
130 @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
131 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
132 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
133 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
134 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
135
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
136 @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
137 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
138 """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
139 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
140 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
141 click("manage invitations")
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
142 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
143 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
144 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
145 press(ENTER)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
146 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
147 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
148
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
149 @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
150 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
151 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
152 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
153 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
154 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
155
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
156 @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
157 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
158 """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
159 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
160 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
161 click("manage invitations")
3498
d78b5eae912a tests: update following names change
Goffi <goffi@goffi.org>
parents: 3480
diff changeset
162 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
163 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
164 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
165 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
166 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
167 click("send invitation")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
168 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
169 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
170 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
171 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
172 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
173 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
174
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
175 @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
176 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
177 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
178 click("test album")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
179 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
180 assert len(find_all(S("img.is-photo-thumbnail"))) == 2