forked from burbon000/rainforest_livefyre_automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreview_flag.rb
295 lines (220 loc) · 9.22 KB
/
review_flag.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#tester starts at
# https://lemonsarebetter.herokuapp.com/widget.php?network=rainforestqa.fyre.co&site=383920&articleId=ekrfjherf34823&appType=reviews&userId=user1_9080908090
test(id: 191991, title: "Review Post and Reply") do
# You can use any of the following variables in your code:
# - []
# Random number to append to user_ids
Capybara.default_selector = :css
random_num = rand(10000000...99999999).to_s
user1_id = "user1_" + random_num
user2_id = "user2_" + random_num
# App url for the two different users
base_url1 = "https://lemonsarebetter.herokuapp.com/widget.php?network=rainforestqa.fyre.co"\
"&site=383920&articleId=ekrfjherf34823&appType=reviews&userId=user1_#{random_num}"
base_url2 = "https://lemonsarebetter.herokuapp.com/widget.php?network=rainforestqa.fyre.co"\
"&site=383920&articleId=ekrfjherf34823&appType=reviews&userId=user2_#{random_num}"
window = Capybara.current_session.driver.browser.manage.window
#window.maximize
step id: 1,
action: "Review app url loads",
response: "Do you see Review app loaded with 'Average User Rating', 'Rating Breakdown',"\
" 'Sign in' option and 'Write review' button?" do
# *** START EDITING HERE ***
# action
visit base_url1
# response
expect(page).to have_content('Average User Rating', wait: 30)
expect(page).to have_content('Rating Breakdown')
expect(page).to have_content('Sign in')
expect(page).to have_content('Write review')
page.save_screenshot('screenshot_step_1.png')
# *** STOP EDITING HERE ***
end
step id: 2,
action: "Click on 'Sign in' option",
response: "Do you see next to avatar 'user1_{{random.number}}'?" do
# *** START EDITING HERE ***
# action
page.find(:css, "a[role='button']", :text => 'Sign in').click
# reponse
expect(page).to have_selector(:css, "a[role='button']", :text => user1_id)
page.save_screenshot('screenshot_step_2.png')
# *** STOP EDITING HERE ***
end
step id: 3,
action: "Click on 'Write review' button",
response: "Do you see Review comment widget with 5 empty stars, 'Title...'' section,"\
" empty comment section, and 'Post review' button?" do
# *** START EDITING HERE ***
# action
page.find(:css, 'div.fyre-reviews-stats').hover
click_link_or_button 'Write review'
# response
within(:css, ".fyre-editor.fyre-reviews-editor.fyre-editor-small") do
expect(page).to have_css('.goog-ratings')
expect(page).to have_content("Post review")
expect(find(:css, '.goog-ratings')['aria-valuenow']).to eql(nil)
expect(page.find(:css, '.fyre-editor-title')['placeholder']).to eql("Title...")
within_frame(find(:css, '[aria-label=editor]')) do
expect(page.find(:css, 'p')['text']).to eql(nil)
end
end
page.save_screenshot('screenshot_step_3.png')
# *** STOP EDITING HERE ***
end
step id: 4,
action: "Enter text in 'Title...', text in comment section and choose star rating from top right side,"\
" then click 'Post review' button",
response: "Do you see your review posted on the stream below with title, comment text, star options "\
"selected in yellow and username?" do
# *** START EDITING HERE ***
title = "automation" + random_num
review = "User1 Review " + random_num
star_rating = rand(0...9)
rating_perc = star_rating*10 + 10
rating_style = "width: #{rating_perc}%;"
# action
within(:css, ".fyre-editor.fyre-reviews-editor.fyre-editor-small") do
page.find("input[class='fyre-editor-title']").set(title)
within_frame(find(:css, '[aria-label=editor]')) do
page.find(:css, '.editable.fyre-editor-field>p').click
page.find(:css, '.editable.fyre-editor-field>p').native.send_keys(review)
end
all(:css, "span[class*='ratings-star']")[star_rating].click
page.find("div[role='button']", :text => 'Post review').click
end
# response
within(:css, "article[data-author-id^='#{user1_id}']", wait: 20) do
expect(page).not_to have_css('iframe', wait: 5)
expect(page).to have_content(user1_id)
expect(page).to have_content(title)
expect(page).to have_content(review)
expect(find(:css, ".fyre-reviews-rated>label")['style']).to eql(rating_style.to_s)
end
page.save_screenshot('screenshot_step_4.png')
# *** STOP EDITING HERE ***
end
step id: 5,
action: "Go to user avatar and click on 'Sign out' option",
response: "Do you see 'Sign in' option ?" do
# *** START EDITING HERE ***
# action
page.find(:css, "a[role='button']", :text => user1_id).hover
page.find(:css, "a[role='button']", :text => 'Sign out').click
# response
expect(page).to have_content('Sign in')
# Currently the new post is not visible in a sorted list for up to 10 minutes. The
# => work around is to either wait 10 minutes or not use the sort by newest.
for i in 1..11 do
page.go_back
sleep(30)
page.go_forward
sleep(30)
end
page.save_screenshot('screenshot_step_5.png')
# *** STOP EDITING HERE ***
end
step id: 6,
action: "Review app url loads",
response: "Do you see Review app loaded with 'Average User Rating', 'Rating Breakdown', "\
"'Sign in' option and 'Write review' button?" do
# *** START EDITING HERE ***
# action
visit base_url2
# response
expect(page).to have_content('Average User Rating', wait: 15)
expect(page).to have_content('Rating Breakdown')
expect(page).to have_content('Sign in')
expect(page).to have_content('Write review')
page.save_screenshot('screenshot_step_6.png')
# *** STOP EDITING HERE ***
end
step id: 7,
action: "Click on 'Sign in' option",
response: "Do you see next to avatar 'user2_{{random.number}}'?" do
# *** START EDITING HERE ***
# action
page.find(:css, "a[role='button']", :text => 'Sign in').click
# reponse
expect(page).to have_selector(:css, "a[role='button']", :text => user2_id)
page.save_screenshot('screenshot_step_7.png')
# *** STOP EDITING HERE ***
end
step id: 8,
action: "Click on 'Most Helpful' sort option then click 'Newest' option",
response: "Do you see user1's most recent comment shows up?" do
# *** START EDITING HERE ***
# action
page.find(:css, 'div.fyre-reviews-stats').hover
# Currently there is a bug that prevents using the latest because it takes 10 minutes for the Post to show up
within(:css, '.fyre-stream-sort') do
page.find(:css, 'label', :text => 'Most helpful').click
page.find(:css, 'a', :text => 'Newest').click
end
# response
expect(page).to have_selector(:css, "article[data-author-id^='#{user1_id}']")
page.save_screenshot('screenshot_step_8.png')
# *** STOP EDITING HERE ***
end
step id: 9,
action: "Click on the '...More' option.",
response: "Do you see 'Flag' option from the drop down ?" do
# *** START EDITING HERE ***
# action
within(:css, "article[data-author-id^='#{user1_id}']") do
page.find("a", :text => 'More').click
end
# response
within(:css, '.fyre-actions-menu') do
expect(page).to have_selector(:css, "li", :text => 'Flag')
end
page.save_screenshot('screenshot_step_9.png')
# *** STOP EDITING HERE ***
end
step id: 10,
action: "Click the 'Flag' option from the drop down",
response: "Do you see 'Flag' window opens ?" do
# *** START EDITING HERE ***
# action
within(:css, '.fyre-actions-menu') do
page.find(:css, "li", :text => 'Flag').click
end
# response
within(:css, '.fyre-modal') do
expect(page).to have_content("Flag #{user1_id}'s review")
end
page.save_screenshot('screenshot_step_10.png')
# *** STOP EDITING HERE ***
end
step id: 11,
action: "Click the 'Flag' option from the drop down",
response: "Do you see 'Flag' window opens ?" do
# *** START EDITING HERE ***
# action
within(:css, '.fyre-modal') do
expect(page.find(:css, 'select')['value']).to eql('none')
page.select 'Offensive', :from => 'flagType'
end
within(:css, '.fyre-modal') do
expect(page.find(:css, 'select')['value']).to eql('offensive')
end
page.save_screenshot('screenshot_step_10.png')
# *** STOP EDITING HERE ***
end
step id: 12,
action: "Click the '1 Reply' option again.",
response: "Do you see Reply comment widget closes ?
" do
# *** START EDITING HERE ***
# action
within(:css, '.fyre-modal') do
page.find(:css, 'button', :text => 'OK').click
end
# response
expect(page).to have_content('Review has been flagged.', wait: 10)
page.save_screenshot('screenshot_step_11.png')
# *** STOP EDITING HERE ***
end
page.find(:css, "a[role='button']", :text => user2_id).hover
page.find(:css, "a[role='button']", :text => 'Sign out').click
#sleep(10)
end