annotate tests/e2e/libervia/test_libervia.py @ 3488:c80a0f864b5d

doc: updated doc following global renaming
author Goffi <goffi@goffi.org>
date Sun, 21 Mar 2021 18:23:58 +0100
parents 7550ae9cfbac
children
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
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 if os.getenv("SAT_TEST_ENV_E2E_LIBERVIA") is None:
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):
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 go_to("https://libervia.test:8443/login")
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):
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 go_to("https://libervia.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):
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 go_to("https://libervia.test:8443/login")
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 = (
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
81 "https://libervia.test:8443/photos/album/account1@files.server1.test/albums"
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):
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 go_to("https://libervia.test:8443/photos")
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)
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 wait_until(lambda: not S("#loading_screen").exists())
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 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
97 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
98 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
99 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
100 assert S('img[alt="test_1.jpg"]').exists()
d4558f3cbf13 tests, docker(e2e): added e2e tests for Libervia:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 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
102
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
103 @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
104 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
105 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
106 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
107 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
108 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
109 click(thumb_1)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
110 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
111 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
112 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
113 # 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
114 # 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
115 # 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
116 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
117 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
118 wait_until(
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
119 lambda:
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
120 "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
121 )
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
122 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
123 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
124 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
125 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
126 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
127 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
128
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
129 @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
130 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
131 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
132 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
133 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
134
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
135 @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
136 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
137 """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
138 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
139 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
140 click("manage invitations")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
141 assert Text("people who can access this album").exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
142 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
143 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
144 press(ENTER)
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
145 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
146 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
147
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
148 @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
149 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
150 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
151 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
152 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
153 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
154
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
155 @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
156 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
157 """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
158 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
159 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
160 click("manage invitations")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
161 assert Text("people who can access this album").exists()
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
162 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
163 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
164 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
165 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
166 click("send invitation")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
167 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
168 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
169 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
170 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
171 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
172 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
173
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
174 @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
175 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
176 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
177 click("test album")
fdf56af87719 tests (e2e/libervia): more stable `test_user_can_log_in` + photos tests
Goffi <goffi@goffi.org>
parents: 3429
diff changeset
178 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
179 assert len(find_all(S("img.is-photo-thumbnail"))) == 2