Skip to content

Commit 326d6ae

Browse files
mycarguscguanzon
authored andcommitted
spec: fix fragile assessments specs, remove duplicate spec
Test Plan: - pass Jenkins - check for syntax errors Change-Id: Ic16c889d6de328c9638823237b821bee78d570d8 Reviewed-on: https://gerrit.instructure.com/65649 Tested-by: Jenkins Reviewed-by: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Caleb Guanzon <cguanzon@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com>
1 parent 4f8c00c commit 326d6ae

10 files changed

Lines changed: 87 additions & 81 deletions

spec/selenium/discussions/discussions_edit_page_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102
# should correctly save changes to the assignment
103103
set_value f('#discussion_topic_assignment_points_possible'), '123'
104104
end
105-
expect(Assignment.last.points_possible).to eq 123
105+
assignment.reload
106+
expect(assignment.points_possible).to eq 123
106107
end
107108

108109
it "should warn user when leaving page unsaved", priority: "1", test_id: 270919 do

spec/selenium/helpers/assignment_overrides.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ def validate_quiz_show_page(message)
333333
def validate_vdd_quiz_tooltip_dates(context_selector, message)
334334
keep_trying_until(2) do
335335
driver.mouse.move_to fln('Multiple Dates', f("#{context_selector}"))
336-
expect(fj('.ui-tooltip')).to include_text("#{message}")
336+
wait_for_ajaximations
337+
expect(fj('.ui-tooltip:visible')).to include_text("#{message}")
337338
end
338339
end
339340

spec/selenium/helpers/public_courses_context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def ensure_logged_out
66
end
77

88
def validate_selector_displayed(selector)
9-
expect(f(selector)).to be_displayed
9+
expect(f(selector)).to be_truthy
1010
end
1111

1212
let!(:public_course) do

spec/selenium/quizzes/quizzes_restrictions_student_spec.rb

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
describe 'quiz restrictions as a student' do
55
include_context 'in-process server selenium tests'
66

7+
def begin_taking_quiz
8+
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"
9+
expect_new_page_load { f('#take_quiz_link').click }
10+
end
11+
712
context 'restrict access code' do
813
before do
914
course_with_student_logged_in
@@ -14,27 +19,20 @@
1419
@quiz.save!
1520
end
1621

22+
def submit_quiz_access_code(access_code)
23+
begin_taking_quiz
24+
f('#quiz_access_code').send_keys(access_code)
25+
expect_new_page_load { f('button.btn').click }
26+
end
27+
1728
it 'should allow you to enter in a correct access token password to view the quiz' do
18-
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"
19-
f('#take_quiz_link').click
20-
wait_for_ajaximations
21-
22-
f('#quiz_access_code').send_keys(@password)
23-
f('button.btn').click
24-
wait_for_ajaximations
25-
expect(f('h2')).to include_text('Quiz Instructions')
29+
submit_quiz_access_code(@password)
30+
expect(f('.quiz-header')).to include_text 'Quiz Instructions'
2631
end
2732

2833
it 'should not allow you to enter in a incorrect access token password to view the quiz' do
29-
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"
30-
f('#take_quiz_link').click
31-
wait_for_ajaximations
32-
33-
f('#quiz_access_code').send_keys('lechuck')
34-
f('button.btn').click
35-
wait_for_ajaximations
36-
37-
expect(f('#quiz_access_code')).to be
34+
submit_quiz_access_code('lechuck')
35+
expect(f('#quiz_access_code').text).to eq ''
3836
end
3937
end
4038

@@ -49,10 +47,8 @@
4947
end
5048

5149
it 'should not be accessible from invalid ip address' do
52-
get "/courses/#{@course.id}/quizzes/#{@quiz.id}"
53-
f('#take_quiz_link').click
54-
wait_for_ajaximations
55-
expect(f('#content')).to include_text('This quiz is protected and is only available from certain locations')
50+
begin_taking_quiz
51+
expect(f('#content')).to include_text 'This quiz is protected and is only available from certain locations'
5652
end
5753
end
5854
end

spec/selenium/quizzes/varied_due_dates/quizzes_vdd_index_page_observer_spec.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,34 @@
1616

1717
it 'shows the due dates for Section A', priority: "2", test_id: 282169 do
1818
skip('Bug ticket created: CNVS-22794')
19-
validate_vdd_quiz_tooltip_dates('.date-due', \
20-
"Everyone else\n#{format_date_for_view(@due_at_a)}")
19+
validate_vdd_quiz_tooltip_dates(
20+
'.date-due',
21+
"Everyone else\n#{format_date_for_view(@due_at_a)}"
22+
)
2123
end
2224

2325
it 'shows the due dates for Section B', priority: "2", test_id: 315666 do
2426
skip('Bug ticket created: CNVS-22794')
25-
validate_vdd_quiz_tooltip_dates('.date-due', \
26-
"#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
27+
validate_vdd_quiz_tooltip_dates(
28+
'.date-due',
29+
"#{@section_b.name}\n#{format_date_for_view(@due_at_b)}"
30+
)
2731
end
2832

2933
it 'shows the availability dates for Section A', priority: "2", test_id: 282397 do
3034
skip('Bug ticket created: CNVS-22793')
31-
validate_vdd_quiz_tooltip_dates('.date-available', \
32-
"Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
35+
validate_vdd_quiz_tooltip_dates(
36+
'.date-available',
37+
"Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}"
38+
)
3339
end
3440

3541
it 'shows the availability dates for Section B', priority: "2", test_id: 315669 do
3642
skip('Bug ticket created: CNVS-22793')
37-
validate_vdd_quiz_tooltip_dates('.date-available', \
38-
"#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
43+
validate_vdd_quiz_tooltip_dates(
44+
'.date-available',
45+
"#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}"
46+
)
3947
end
4048
end
4149

spec/selenium/quizzes/varied_due_dates/quizzes_vdd_index_page_ta_spec.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,31 @@
1414
end
1515

1616
it 'shows the due dates for Section A', priority: "2", test_id: 282168 do
17-
validate_vdd_quiz_tooltip_dates('.date-due', \
18-
"Everyone else\n#{format_date_for_view(@due_at_a)}")
17+
validate_vdd_quiz_tooltip_dates(
18+
'.date-due',
19+
"Everyone else\n#{format_date_for_view(@due_at_a)}"
20+
)
1921
end
2022

2123
it 'shows the due dates for Section B', priority: "2", test_id: 315651 do
22-
validate_vdd_quiz_tooltip_dates('.date-due', \
23-
"#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
24+
validate_vdd_quiz_tooltip_dates(
25+
'.date-due',
26+
"#{@section_b.name}\n#{format_date_for_view(@due_at_b)}"
27+
)
2428
end
2529

2630
it 'shows the availability dates for Section A', priority: "2", test_id: 282395 do
27-
validate_vdd_quiz_tooltip_dates('.date-available', \
28-
"Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
31+
validate_vdd_quiz_tooltip_dates(
32+
'.date-available',
33+
"Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}"
34+
)
2935
end
3036

3137
it 'shows the availability dates for Section B', priority: "2", test_id: 315653 do
32-
validate_vdd_quiz_tooltip_dates('.date-available', \
33-
"#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
38+
validate_vdd_quiz_tooltip_dates(
39+
'.date-available',
40+
"#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}"
41+
)
3442
end
3543
end
3644
end

spec/selenium/quizzes/varied_due_dates/quizzes_vdd_index_page_teacher_spec.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,31 @@
1414
end
1515

1616
it 'shows the due dates for Section A', priority: "1", test_id: 282167 do
17-
validate_vdd_quiz_tooltip_dates('.date-due', \
18-
"Everyone else\n#{format_date_for_view(@due_at_a)}")
17+
validate_vdd_quiz_tooltip_dates(
18+
'.date-due',
19+
"Everyone else\n#{format_date_for_view(@due_at_a)}"
20+
)
1921
end
2022

2123
it 'shows the due dates for Section B', priority: "1", test_id: 315661 do
22-
validate_vdd_quiz_tooltip_dates('.date-due', \
23-
"#{@section_b.name}\n#{format_date_for_view(@due_at_b)}")
24+
validate_vdd_quiz_tooltip_dates(
25+
'.date-due',
26+
"#{@section_b.name}\n#{format_date_for_view(@due_at_b)}"
27+
)
2428
end
2529

2630
it 'shows the availability dates for Section A', priority: "1", test_id: 282393 do
27-
validate_vdd_quiz_tooltip_dates('.date-available', \
28-
"Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}")
31+
validate_vdd_quiz_tooltip_dates(
32+
'.date-available',
33+
"Everyone else\nAvailable until #{format_date_for_view(@lock_at_a)}"
34+
)
2935
end
3036

3137
it 'shows the availability dates for Section B', priority: "1", test_id: 315663 do
32-
validate_vdd_quiz_tooltip_dates('.date-available', \
33-
"#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}")
38+
validate_vdd_quiz_tooltip_dates(
39+
'.date-available',
40+
"#{@section_b.name}\nNot available until #{format_date_for_view(@unlock_at_b)}"
41+
)
3442
end
3543
end
3644
end

spec/selenium/quizzes_student_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def prepare_quiz
8383

8484
keep_trying_until do
8585
Quizzes::QuizSubmission.last
86-
expect(fj('#times_up_dialog:visible')).to be_present
86+
expect(fj('#times_up_dialog:visible')).to include_text 'Time\'s Up!'
8787
end
8888
end
8989
end

spec/selenium/quizzes_student_with_draft_state_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
it 'shows an error', priority: "1", test_id: 209419 do
2828
get "/courses/#{@course.id}/quizzes/#{@q.id}"
2929
wait_for_ajaximations
30-
expect(f('#unauthorized_holder')).to be_displayed
30+
expect(f('.ui-state-error')).to include_text 'Unauthorized'
3131
end
3232

3333
it 'can\'t take an unpublished quiz', priority: "1", test_id: 209420 do
3434
get "/courses/#{@course.id}/quizzes/#{@q.id}/take"
3535
wait_for_ajaximations
36-
expect(f('#unauthorized_holder')).to be_displayed
36+
expect(f('.ui-state-error')).to include_text 'Unauthorized'
3737
end
3838
end
3939

@@ -47,7 +47,7 @@
4747
it 'shows an error', priority: "1", test_id: 209421 do
4848
get "/courses/#{@course.id}/quizzes/#{@q.id}/"
4949
wait_for_ajaximations
50-
expect(f('.lock_explanation')).to be_displayed
50+
expect(f('.lock_explanation')).to include_text 'This quiz is locked'
5151
end
5252
end
5353
end

spec/selenium/quizzes_teacher_with_draft_state_spec.rb

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,34 @@
1010
@course.update_attributes(name: 'teacher course')
1111
@course.save!
1212
@course.reload
13+
create_quiz_with_due_date
1314
end
1415

15-
it 'clicking the unpublish button unpublishes a quiz', priority: "1", test_id: 210052 do
16-
@context = @course
17-
q = quiz_model
18-
q.publish!
19-
20-
get "/courses/#{@course.id}/quizzes/#{q.id}"
21-
expect(f('#quiz-publish-link')).to include_text('Published')
22-
23-
expect_new_page_load do
24-
f('.quiz-publish-button').click
25-
wait_for_ajaximations
26-
end
27-
28-
# move mouse to not be hover over the button
29-
driver.mouse.move_to f('#footer')
30-
31-
keep_trying_until do
32-
expect(f('#quiz-publish-link')).not_to include_text('Published')
33-
expect(f('#quiz-publish-link')).to include_text('Publish')
16+
context 'when there is a single due date' do
17+
it 'doesn\'t display "Multiple Dates"' do
18+
get "/courses/#{@course.id}/quizzes"
19+
expect(f('.ig-details .date-due')).not_to include_text 'Multiple Dates'
20+
expect(f('.ig-details .date-available')).not_to include_text 'Multiple Dates'
3421
end
3522
end
3623

3724
context 'when there are multiple due dates' do
25+
before(:each) { add_due_date_override(@quiz) }
3826

3927
it 'shows a due date summary', priority: "2", test_id: 210053 do
40-
create_quiz_with_due_date
41-
get "/courses/#{@course.id}/quizzes"
42-
expect(f('.ig-details .date-due')).not_to include_text 'Multiple Dates'
43-
expect(f('.ig-details .date-available')).not_to include_text 'Multiple Dates'
44-
45-
add_due_date_override(@quiz)
46-
28+
# verify page
4729
get "/courses/#{@course.id}/quizzes"
4830
expect(f('.ig-details .date-due')).to include_text 'Multiple Dates'
49-
driver.mouse.move_to f('.ig-details .date-due a')
31+
expect(f('.ig-details .date-available')).to include_text 'Multiple Dates'
32+
33+
# verify tooltips
34+
driver.mouse.move_to f('.ig-details .date-available a')
5035
wait_for_ajaximations
5136
tooltip = fj('.ui-tooltip:visible')
5237
expect(tooltip).to include_text 'New Section'
5338
expect(tooltip).to include_text 'Everyone else'
5439

55-
expect(f('.ig-details .date-available')).to include_text 'Multiple Dates'
56-
driver.mouse.move_to f('.ig-details .date-available a')
40+
driver.mouse.move_to f('.ig-details .date-due a')
5741
wait_for_ajaximations
5842
tooltip = fj('.ui-tooltip:visible')
5943
expect(tooltip).to include_text 'New Section'

0 commit comments

Comments
 (0)