forked from cos-archives/osf-ui-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_registration_tests.py
165 lines (126 loc) · 4.88 KB
/
project_registration_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
"""
Tests for creating project registrations.
"""
# Project imports
import base
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
class RegistrationTests(base.ProjectSmokeTest):
def test_create_open_ended_registration(self):
""" Create an Open-Ended Registration. """
registration_url = self.create_registration('Open-Ended Registration')
self.assertIn(
'This node is a registration of',
self.get_element('span.label.label-important').text,
)
def test_create_osf_standard_registration(self):
""" Create an OSF Standard registration """
registration_url = self.create_registration(
'OSF-Standard Pre-Data Collection Registration'
)
self.assertIn(
'This node is a registration of',
self.get_element('span.label.label-important').text
)
def test_registration_link_to_parent_project(self):
"""Test that a link is created in the registration notice that points to
the project from which it was created.
"""
registration_url = self.create_registration()
self.assertEqual(
self.get_element(
'span.label.label-important a'
).get_attribute('href').strip('/'),
self.project_url.strip('/'),
)
def test_registration_add_files(self):
"""Test that a user cannot add files to a registration"""
# TODO: This test should work, but the functionality is
self.project_url = self.create_registration()
self.goto('files', node_url=self.project_url)
self.assertIn(
'disabled',
self.driver.find_element_by_css_selector("div.span7 span")
.get_attribute("class")
)
self.assertIn(
'disabled',
self.driver.find_element_by_css_selector("div.span7 button")
.get_attribute("class")
)
def test_registration_delete_files(self):
"""Test that files cannot be deleted from registrations"""
# add a file to the project
self.add_file(self.image_files['jpg']['path'])
# create the registration
registration_url = self.create_registration()
# go to the files page
self.goto(
'files',
node_url=registration_url
)
# click delete on a file
self.get_element('table#filesTable button.btn.btn-danger').click()
self.driver.get(self.driver.current_url)
self.assertIn(
self.image_files['jpg']['filename'],
self.get_element('table#filesTable').text
)
def test_registration_add_contributor(self):
second_user = self.create_user()
registration_url = self.create_registration()
# add a contributor
self.driver.get(registration_url)
# with self.assertRaises(TimeoutException):
self.assertTrue(
len(
self.driver.find_element_by_id(
'contributors'
).find_elements_by_link_text("add")
) == 0
)
# refresh the page
self.driver.get(registration_url)
# make sure the added user isn't there.
self.assertNotIn(
second_user['fullname'],
self.get_element('#contributors').text,
)
def test_registration_remove_contributor(self):
""" Attempts to remove a contributor from a registration """
# create a user
second_user = self.create_user()
# add them to the project
self.goto('dashboard')
self.add_contributor(second_user)
# register it.
registration_url = self.create_registration()
# remove them from the registration
self.driver.get(registration_url)
element_to_hover_over = self.get_element('#contributors')\
.find_element_by_link_text(second_user["fullname"])
hover = ActionChains(self.driver).move_to_element(element_to_hover_over)
hover.perform()
self.assertTrue(
len(element_to_hover_over.find_elements_by_css_selector("i")) == 0
)
# make sure they're still there
self.driver.get(registration_url)
self.assertIn(
second_user['fullname'],
self.get_element('#contributors').text
)
def test_registration_modify_wiki(self):
registration_url = self.create_registration()
# go to the registration's wiki
self.goto('wiki', node_url=registration_url)
# "Edit" should be disabled.
self.assertEqual(
len(
self.driver.find_elements_by_css_selector(
'.subnav ul.nav > li:first-child > a.disabled'
)
),
1
)