This repository has been archived by the owner on Jul 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sitelinks_spec.rb
272 lines (245 loc) · 9.26 KB
/
sitelinks_spec.rb
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# -*- encoding : utf-8 -*-
# Wikidata UI tests
#
# Author:: Tobias Gritschacher (tobias.gritschacher@wikimedia.de)
# License:: GNU GPL v2+
#
# tests for sitelinks
require 'spec_helper'
describe "Check functionality of add/edit/remove sitelinks" do
context "Check for empty site links UI" do
it "should check that there are no site links and if there's an add button" do
visit_page(SitelinksItemPage) do |page|
page.create_new_item(generate_random_string(10), generate_random_string(20))
page.wait_for_sitelinks_to_load
page.sitelinksTable?.should be_true
page.addSitelinkLink?.should be_true
page.siteLinkCounter?.should be_true
numExistingSitelinks = page.countExistingSitelinks
numExistingSitelinks.should == 0
numExistingSitelinks.should == page.getNumberOfSitelinksFromCounter
page.addSitelinkLink
page.siteIdInputField_element.should be_true
page.pageInputField.should be_true
page.saveSitelinkLinkDisabled.should be_true
page.cancelSitelinkLink?.should be_true
page.cancelSitelinkLink
page.countExistingSitelinks.should == 0
@browser.refresh
page.wait_for_sitelinks_to_load
page.countExistingSitelinks.should == 0
end
end
end
context "Check for adding site link to non existing article" do
it "should check if adding sitelink to a non existing article produces an error" do
on_page(SitelinksItemPage) do |page|
page.navigate_to_item
page.wait_for_sitelinks_to_load
page.countExistingSitelinks.should == 0
page.addSitelinkLink
page.siteIdInputField_element.should be_true
page.pageInputField_element.enabled?.should be_false
page.siteIdInputField="en"
ajax_wait
page.wait_until do
page.siteIdAutocompleteList_element.visible?
end
page.siteIdAutocompleteList_element.visible?.should be_true
page.pageInputField_element.enabled?.should be_true
page.pageInputField="xyz_thisarticleshouldneverexist_xyz"
page.siteIdInputField.should == "English (en)"
ajax_wait
page.saveSitelinkLink
ajax_wait
page.wait_for_api_callback
page.wbErrorDiv?.should be_true
page.wbErrorDetailsLink?.should be_true
page.wbErrorDetailsLink
page.wbErrorDetailsDiv?.should be_true
page.wbErrorDetailsDiv_element.text.should == "The external client site did not provide page information."
end
end
end
context "Check for adding site link UI" do
it "should check if adding a sitelink works" do
on_page(SitelinksItemPage) do |page|
page.navigate_to_item
page.wait_for_sitelinks_to_load
page.countExistingSitelinks.should == 0
page.addSitelinkLink
page.siteIdInputField_element.should be_true
page.pageInputField_element.enabled?.should be_false
page.siteIdInputField="en"
ajax_wait
page.wait_until do
page.siteIdAutocompleteList_element.visible?
end
page.siteIdAutocompleteList_element.visible?.should be_true
page.pageInputField_element.enabled?.should be_true
page.pageInputField="Ber"
page.siteIdInputField.should == "English (en)"
ajax_wait
page.wait_until do
page.pageAutocompleteList_element.visible?
end
page.saveSitelinkLink
ajax_wait
page.wait_for_api_callback
# let's check if we are not allowed to change the siteId when editing
page.getNthSitelinksTableRow(1).click
page.wait_until do
page.editSitelinkLink_element.visible?
end
page.editSitelinkLink
page.siteIdInputField?.should be_false
page.pageInputField?.should be_true
page.cancelSitelinkLink
numExistingSitelinks = page.countExistingSitelinks
numExistingSitelinks.should == 1
@browser.refresh
page.wait_for_sitelinks_to_load
numExistingSitelinks = page.countExistingSitelinks
numExistingSitelinks.should == 1
end
end
end
context "Check for adding multiple site links UI" do
it "should check if adding multiple sitelinks works" do
count = 1
sitelinks = [["de", "Ber", "Deutsch (de)"], ["ja", "Ber", "日本語 (ja)"], ["he", "Ber", "עברית (he)"]]
on_page(SitelinksItemPage) do |page|
page.navigate_to_item
page.wait_for_sitelinks_to_load
sitelinks.each do |sitelink|
page.countExistingSitelinks.should == count
page.addSitelinkLink
page.siteIdInputField = sitelink[0]
ajax_wait
page.wait_until do
page.siteIdAutocompleteList_element.visible?
end
page.siteIdAutocompleteList_element.visible?.should be_true
page.pageInputField_element.enabled?.should be_true
page.pageInputField = sitelink[1]
page.siteIdInputField.should == sitelink[2]
ajax_wait
page.wait_until do
page.pageAutocompleteList_element.visible?
end
page.saveSitelinkLink
ajax_wait
page.wait_for_api_callback
count = count+1
#page.getNumberOfSitelinksFromCounter.should == count
@browser.refresh
page.wait_for_sitelinks_to_load
#page.getNumberOfSitelinksFromCounter.should == count
end
#page.countExistingSitelinks.should == count
end
end
end
context "Check for displaying normalized title when adding sitelink" do
it "should check if the normalized version of the title is displayed" do
on_page(SitelinksItemPage) do |page|
page.navigate_to_item
page.wait_for_sitelinks_to_load
page.addSitelinkLink
page.siteIdInputField = "sr"
ajax_wait
page.wait_until do
page.siteIdAutocompleteList_element.visible?
end
page.siteIdInputField_element.send_keys :arrow_down
page.siteIdAutocompleteList_element.visible?.should be_true
aCListElement = page.getNthElementInAutocompleteList(page.siteIdAutocompleteList_element, 1)
aCListElement.visible?.should be_true
aCListElement.click
page.pageInputField_element.enabled?.should be_true
page.pageInputField = "s"
ajax_wait
page.wait_until do
page.pageAutocompleteList_element.visible?
end
page.saveSitelinkLink
ajax_wait
page.wait_for_api_callback
sleep 1 #cause there's a delay before the value is actually set in the dom -> should be changed in the UI
page.pageArticleNormalized?.should be_true
page.pageArticleNormalized_element.text.should == "С"
@browser.refresh
page.wait_for_sitelinks_to_load
page.pageArticleNormalized_element.text.should == "С"
page.pageArticleNormalized?.should be_true
end
end
end
context "Check for editing site links UI" do
it "should check if editing sitelinks works" do
on_page(SitelinksItemPage) do |page|
page.navigate_to_item
page.wait_for_sitelinks_to_load
page.getNthSitelinksTableRow(1).click
page.editSitelinkLink
page.saveSitelinkLinkDisabled?.should be_true
page.cancelSitelinkLink?.should be_true
page.pageInputField_element.enabled?.should be_true
current_page = page.pageInputField
new_page = "Ber"
page.pageInputField = new_page
ajax_wait
page.wait_until do
page.editSitelinkAutocompleteList_element.visible?
end
page.pageInputField_element.send_keys :arrow_down
page.pageInputField_element.send_keys :arrow_down
page.pageInputField_element.send_keys :return
if page.saveSitelinkLink?
page.saveSitelinkLink
end
ajax_wait
page.wait_for_api_callback
@browser.refresh
page.wait_for_sitelinks_to_load
page.getNthSitelinksTableRow(1).click
page.editSitelinkLink
page.pageInputField.should_not == current_page
end
end
end
context "Check clicking on sitelink" do
it "should check if the sitelink leads to the correct page" do
on_page(SitelinksItemPage) do |page|
page.navigate_to_item
page.wait_for_sitelinks_to_load
page.germanSitelink
page.articleTitle.should == "Berlin"
end
end
end
context "Check for removing multiple site link UI" do
it "should check if removing multiple sitelink works" do
on_page(SitelinksItemPage) do |page|
page.navigate_to_item
page.wait_for_sitelinks_to_load
numExistingSitelinks = page.countExistingSitelinks
page.getNthSitelinksTableRow(1).click
page.removeSitelinkLink?.should be_true
for i in 1..numExistingSitelinks
page.getNthSitelinksTableRow(1).click
page.removeSitelinkLink?.should be_true
page.removeSitelinkLink
ajax_wait
page.wait_for_api_callback
@browser.refresh
page.wait_for_sitelinks_to_load
page.countExistingSitelinks.should == (numExistingSitelinks-i)
end
@browser.refresh
page.wait_for_sitelinks_to_load
page.countExistingSitelinks.should == 0
end
end
end
end