canvas-lms/spec/selenium/dashboard_teacher_spec.rb

304 lines
12 KiB
Ruby
Raw Normal View History

#
# Copyright (C) 2014 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
require_relative 'common'
require_relative 'helpers/notifications_common'
describe "dashboard" do
include NotificationsCommon
include_context "in-process server selenium tests"
context "as a teacher" do
before (:each) do
course_with_teacher_logged_in(:active_cc => true)
end
it "should validate the functionality of soft concluded courses on courses page", priority: "1", test_id: 216396 do
term = EnrollmentTerm.new(:name => "Super Term", :start_at => 1.month.ago, :end_at => 1.week.ago)
term.root_account_id = @course.root_account_id
term.save!
c1 = @course
c1.name = 'a_soft_concluded_course'
c1.update!(:enrollment_term => term)
c1.reload
get "/courses"
expect(fj("#past_enrollments_table a[href='/courses/#{@course.id}']")).to include_text(c1.name)
end
it "should display assignment to grade in to do list for a teacher", priority: "1", test_id: 216397 do
assignment = assignment_model({:submission_types => 'online_text_entry', :course => @course})
student = user_with_pseudonym(:active_user => true, :username => 'student@example.com', :password => 'qwertyuiop')
@course.enroll_user(student, "StudentEnrollment", :enrollment_state => 'active')
assignment.reload
assignment.submit_homework(student, {:submission_type => 'online_text_entry', :body => 'ABC'})
assignment.reload
enable_cache do
get "/"
#verify assignment is in to do list
expect(f('.to-do-list > li')).to include_text('Grade ' + assignment.title)
end
end
it "should be able to ignore an assignment until the next submission", priority: "1", test_id: 216399 do
assignment = assignment_model({:submission_types => 'online_text_entry', :course => @course})
student = user_with_pseudonym(:active_user => true, :username => 'student@example.com', :password => 'qwertyuiop')
student2 = user_with_pseudonym(:active_user => true, :username => 'student2@example.com', :password => 'qwertyuiop')
@course.enroll_user(student, "StudentEnrollment", :enrollment_state => 'active')
@course.enroll_user(student2, "StudentEnrollment", :enrollment_state => 'active')
assignment.reload
assignment.submit_homework(student, {:submission_type => 'online_text_entry', :body => 'ABC'})
assignment.reload
enable_cache do
get "/"
Redesign the To-Do, Coming Up, and Recent Feedback lists Fixes CNVS-25877 Test plan: - Create a user with: - an assignment that needs to be submitted - an assignment that needs to be graded - an assignment whose grades the user needs to moderate - an assignment that they need to peer review - a calendar event that they can see - Go to the user's home page - Ensure all of the assignments show up in the to-do list - Ensure they show up in Coming Up as well - Ensure that the calendar event shows up under Coming Up - Go to the courses where you created the assignments - Ensure that each assignment shows up on its respective course to-do list - Submit an assignment - As a teacher, ensure that the assignment shows up as needing grading, and that the number in the badge to the left is 1 - Ensure that screenreaders read the badge as "1 submission needs grading" - Make another submission as a different user - Clear the cache by running `Rails.cache.clear` at a Rails console - As the teacher, ensure that the badge is now 2 - Ensure that screenreaders read the badge as "2 submissions need grading" - Repeat 8 more times as different users, so that there are now 10 submissions - Clear the cache again - Ensure that the badge now says "9+" - Ensure that screenreaders read the badge as "More than 9 submissions need grading" - As the user who submitted the assignment, ensure that the grade shows up on the To-Do list, Coming Up, and Recent Feedback - As a teacher, leave a submission comment - As the user who submitted the assignment, ensure that the comment shows up under Recent Feedback - Create a public course - You can make a course public by going to its settings page and checking "Make this course publicly visible" - Log out - Visit /courses/<id>, where <id> is the id of the course - Ensure that the course shows as expected, and that nothing shows up on the to-do list - Automated tests should cover everything else Change-Id: I18673995db94d896bf2c39515258e61065b48319 Reviewed-on: https://gerrit.instructure.com/69474 Reviewed-by: Andrew Butterfield <abutterfield@instructure.com> QA-Review: Heath Hales <hhales@instructure.com> Tested-by: Jenkins Product-Review: Allison Weiss <allison@instructure.com>
2015-12-29 08:39:37 +08:00
ignore_link = f('.to-do-list .disable_item_link')
expect(ignore_link['title']).to include("Ignore until new submission")
ignore_link.click
wait_for_ajaximations
spec: rework negative dom assertions fixes SD-1063, speeds up :allthethings: negative DOM assertions are :poop:, but if we must have them, make them more tolerable. the old way: expect(f(".something-that-should-be-gone")).to be_nil expect(fj("buhleeted:visible")).to be_nil expect(fln("Can't Click Here Anymore").to be_nil the new way: expect(container).not_to contain_css(".something-that-should-be-gone") expect(container).not_to contain_jqcss("buhleeted:visible") expect(container).not_to contain_link("Can't Click Here Anymore") (you can of course use these new matchers for positive assertions as well) although it's a tad more verbose, the new way is better because: 1. it's smart enough to bail once the assertion is met (versus the old way which would take 10-20 seconds to not find the thing and *then* run the assertion) 2. it requires them to be scoped, to reduce the likelihood of false positives (e.g. if the page is totally broken, then of course the assertion would pass) also reworked the various flash message assertions... see the new expect_flash_message and expect_no_flash_message this should remove over an hour of linear time off the build (10 sec per old assertion, except fj ones which took 20 sec)... so like a minute of actual time, cuz parallelization :P a consequence of this change is that f/fj/ff/ffj now raise if nothing is found, so you really have to go out of your way to do it the bad way. so don't :) Change-Id: I0fe6e8500947c27d748b70bb2cda585edf71e427 Reviewed-on: https://gerrit.instructure.com/78420 Tested-by: Jenkins Reviewed-by: Landon Wilkins <lwilkins@instructure.com> Product-Review: Landon Wilkins <lwilkins@instructure.com> QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-05-01 06:23:03 +08:00
expect(f("#content")).not_to contain_css('.to-do-list > li')
get "/"
spec: rework negative dom assertions fixes SD-1063, speeds up :allthethings: negative DOM assertions are :poop:, but if we must have them, make them more tolerable. the old way: expect(f(".something-that-should-be-gone")).to be_nil expect(fj("buhleeted:visible")).to be_nil expect(fln("Can't Click Here Anymore").to be_nil the new way: expect(container).not_to contain_css(".something-that-should-be-gone") expect(container).not_to contain_jqcss("buhleeted:visible") expect(container).not_to contain_link("Can't Click Here Anymore") (you can of course use these new matchers for positive assertions as well) although it's a tad more verbose, the new way is better because: 1. it's smart enough to bail once the assertion is met (versus the old way which would take 10-20 seconds to not find the thing and *then* run the assertion) 2. it requires them to be scoped, to reduce the likelihood of false positives (e.g. if the page is totally broken, then of course the assertion would pass) also reworked the various flash message assertions... see the new expect_flash_message and expect_no_flash_message this should remove over an hour of linear time off the build (10 sec per old assertion, except fj ones which took 20 sec)... so like a minute of actual time, cuz parallelization :P a consequence of this change is that f/fj/ff/ffj now raise if nothing is found, so you really have to go out of your way to do it the bad way. so don't :) Change-Id: I0fe6e8500947c27d748b70bb2cda585edf71e427 Reviewed-on: https://gerrit.instructure.com/78420 Tested-by: Jenkins Reviewed-by: Landon Wilkins <lwilkins@instructure.com> Product-Review: Landon Wilkins <lwilkins@instructure.com> QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-05-01 06:23:03 +08:00
expect(f("#content")).not_to contain_css('.to-do-list')
end
assignment.reload
assignment.submit_homework(student2, {:submission_type => 'online_text_entry', :body => 'ABC'})
assignment.reload
enable_cache do
get "/"
expect(f('.to-do-list > li')).to include_text('Grade ' + assignment.title)
end
end
context 'stream items' do
before :once do
setup_notification(@teacher, name: 'Assignment Created')
end
it 'shows an assignment stream item under Recent Activity in dashboard', priority: "1", test_id: 108723 do
assignment_model({:submission_types => ['online_text_entry'], :course => @course})
get "/"
f('#DashboardOptionsMenu_Container button').click
fj('span[role="menuitemradio"]:contains("Recent Activity")').click
find('.toggle-details').click
spec: rework negative dom assertions fixes SD-1063, speeds up :allthethings: negative DOM assertions are :poop:, but if we must have them, make them more tolerable. the old way: expect(f(".something-that-should-be-gone")).to be_nil expect(fj("buhleeted:visible")).to be_nil expect(fln("Can't Click Here Anymore").to be_nil the new way: expect(container).not_to contain_css(".something-that-should-be-gone") expect(container).not_to contain_jqcss("buhleeted:visible") expect(container).not_to contain_link("Can't Click Here Anymore") (you can of course use these new matchers for positive assertions as well) although it's a tad more verbose, the new way is better because: 1. it's smart enough to bail once the assertion is met (versus the old way which would take 10-20 seconds to not find the thing and *then* run the assertion) 2. it requires them to be scoped, to reduce the likelihood of false positives (e.g. if the page is totally broken, then of course the assertion would pass) also reworked the various flash message assertions... see the new expect_flash_message and expect_no_flash_message this should remove over an hour of linear time off the build (10 sec per old assertion, except fj ones which took 20 sec)... so like a minute of actual time, cuz parallelization :P a consequence of this change is that f/fj/ff/ffj now raise if nothing is found, so you really have to go out of your way to do it the bad way. so don't :) Change-Id: I0fe6e8500947c27d748b70bb2cda585edf71e427 Reviewed-on: https://gerrit.instructure.com/78420 Tested-by: Jenkins Reviewed-by: Landon Wilkins <lwilkins@instructure.com> Product-Review: Landon Wilkins <lwilkins@instructure.com> QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-05-01 06:23:03 +08:00
expect(fj('.fake-link:contains("Unnamed")')).to be_present
end
it 'does not show an unpublished assignment under recent activity under dashboard', priority: "2", test_id: 108722 do
# manually creating assignment as assignment created through backend are published by default
get "/courses/#{@course.id}/assignments"
wait_for_ajaximations
# create assignment
f('.new_assignment').click
wait_for_ajaximations
f('#assignment_name').send_keys('unpublished assignment')
f("input[type=checkbox][id=assignment_text_entry]").click
f(".datePickerDateField[data-date-type='due_at']").send_keys(Time.zone.now + 1.day)
expect_new_page_load { f('.btn-primary[type=submit]').click }
wait_for_ajaximations
get "/"
f('#DashboardOptionsMenu_Container button').click
fj('span[role="menuitemradio"]:contains("Recent Activity")').click
expect(f('.no_recent_messages')).to be_truthy
end
end
context "moderation to do" do
before do
@teacher = @user
@student = student_in_course(:course => @course, :active_all => true).user
@assignment = @course.assignments.create!(
title: "some assignment",
submission_types: ['online_text_entry'],
moderated_grading: true,
grader_count: 2,
final_grader: @teacher
)
@assignment.submit_homework(@student, :body => "submission")
end
it "should show assignments needing moderation" do
enable_cache do
Timecop.freeze(1.minute.from_now) do
get "/"
expect(f('.to-do-list')).to_not include_text("Moderate #{@assignment.title}")
end
Timecop.freeze(2.minutes.from_now) do
# create a provisional grade
@assignment.grade_student(@student, :grade => "1", :grader => @teacher, :provisional => true)
run_jobs # touching admins is done in a delayed job
get "/"
expect(f('.to-do-list')).to include_text("Moderate #{@assignment.title}")
end
Timecop.freeze(3.minutes.from_now) do
@assignment.update_attribute(:grades_published_at, Time.now.utc)
@teacher.clear_cache_key(:todo_list) # would be done by the publishing endpoint
get "/"
expect(f('.to-do-list')).to_not include_text("Moderate #{@assignment.title}")
end
end
end
it "should be able to ignore assignments needing moderation until next provisional grade change" do
@assignment.grade_student(@student, :grade => "1", :grader => @teacher, :provisional => true)
pg = @assignment.provisional_grades.first
enable_cache do
get "/"
ff('.to-do-list .disable_item_link').each do |link|
expect(link['title']).to include("Ignore until new mark")
link.click
wait_for_ajaximations
end
spec: rework negative dom assertions fixes SD-1063, speeds up :allthethings: negative DOM assertions are :poop:, but if we must have them, make them more tolerable. the old way: expect(f(".something-that-should-be-gone")).to be_nil expect(fj("buhleeted:visible")).to be_nil expect(fln("Can't Click Here Anymore").to be_nil the new way: expect(container).not_to contain_css(".something-that-should-be-gone") expect(container).not_to contain_jqcss("buhleeted:visible") expect(container).not_to contain_link("Can't Click Here Anymore") (you can of course use these new matchers for positive assertions as well) although it's a tad more verbose, the new way is better because: 1. it's smart enough to bail once the assertion is met (versus the old way which would take 10-20 seconds to not find the thing and *then* run the assertion) 2. it requires them to be scoped, to reduce the likelihood of false positives (e.g. if the page is totally broken, then of course the assertion would pass) also reworked the various flash message assertions... see the new expect_flash_message and expect_no_flash_message this should remove over an hour of linear time off the build (10 sec per old assertion, except fj ones which took 20 sec)... so like a minute of actual time, cuz parallelization :P a consequence of this change is that f/fj/ff/ffj now raise if nothing is found, so you really have to go out of your way to do it the bad way. so don't :) Change-Id: I0fe6e8500947c27d748b70bb2cda585edf71e427 Reviewed-on: https://gerrit.instructure.com/78420 Tested-by: Jenkins Reviewed-by: Landon Wilkins <lwilkins@instructure.com> Product-Review: Landon Wilkins <lwilkins@instructure.com> QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-05-01 06:23:03 +08:00
expect(f("#content")).not_to contain_css('.to-do-list > li')
get "/"
spec: rework negative dom assertions fixes SD-1063, speeds up :allthethings: negative DOM assertions are :poop:, but if we must have them, make them more tolerable. the old way: expect(f(".something-that-should-be-gone")).to be_nil expect(fj("buhleeted:visible")).to be_nil expect(fln("Can't Click Here Anymore").to be_nil the new way: expect(container).not_to contain_css(".something-that-should-be-gone") expect(container).not_to contain_jqcss("buhleeted:visible") expect(container).not_to contain_link("Can't Click Here Anymore") (you can of course use these new matchers for positive assertions as well) although it's a tad more verbose, the new way is better because: 1. it's smart enough to bail once the assertion is met (versus the old way which would take 10-20 seconds to not find the thing and *then* run the assertion) 2. it requires them to be scoped, to reduce the likelihood of false positives (e.g. if the page is totally broken, then of course the assertion would pass) also reworked the various flash message assertions... see the new expect_flash_message and expect_no_flash_message this should remove over an hour of linear time off the build (10 sec per old assertion, except fj ones which took 20 sec)... so like a minute of actual time, cuz parallelization :P a consequence of this change is that f/fj/ff/ffj now raise if nothing is found, so you really have to go out of your way to do it the bad way. so don't :) Change-Id: I0fe6e8500947c27d748b70bb2cda585edf71e427 Reviewed-on: https://gerrit.instructure.com/78420 Tested-by: Jenkins Reviewed-by: Landon Wilkins <lwilkins@instructure.com> Product-Review: Landon Wilkins <lwilkins@instructure.com> QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-05-01 06:23:03 +08:00
expect(f("#content")).not_to contain_css('.to-do-list')
end
pg.save! # reload
enable_cache do
get "/"
expect(f('.to-do-list')).to include_text("Moderate #{@assignment.title}")
end
end
end
describe "Todo Ignore Options Focus Management" do
before :each do
assignment = assignment_model({:submission_types => 'online_text_entry', :course => @course})
@student = user_with_pseudonym(:active_user => true, :username => 'student@example.com', :password => 'qwertyuiop')
@course.enroll_user(@student, "StudentEnrollment", :enrollment_state => 'active')
assignment.submit_homework(@student, {:submission_type => 'online_text_entry', :body => 'ABC'})
end
it "should focus on the previous ignore link after ignoring a todo item", priority: "1", test_id: 216400 do
assignment2 = assignment_model({:submission_types => 'online_text_entry', :course => @course})
assignment2.submit_homework(@student, {:submission_type => 'online_text_entry', :body => 'Number2'})
enable_cache do
get "/"
all_todo_links = ff('.to-do-list .disable_item_link')
all_todo_links.last.click
wait_for_ajaximations
check_element_has_focus(all_todo_links.first)
end
end
it "should focus on the 'To Do' header if there are no other todo items", priority: "1", test_id: 216401 do
enable_cache do
get "/"
f('.to-do-list .disable_item_link').click
wait_for_ajaximations
check_element_has_focus(f('.todo-list-header'))
end
end
end
it "should not display assignment to grade in to do list for a designer", priority: "1", test_id: 216402 do
course_with_designer_logged_in(:active_all => true)
assignment = assignment_model({:submission_types => 'online_text_entry', :course => @course})
student = user_with_pseudonym(:active_user => true, :username => 'student@example.com', :password => 'qwertyuiop')
@course.enroll_user(student, "StudentEnrollment", :enrollment_state => 'active')
assignment.reload
assignment.submit_homework(student, {:submission_type => 'online_text_entry', :body => 'ABC'})
assignment.reload
enable_cache do
get "/"
spec: rework negative dom assertions fixes SD-1063, speeds up :allthethings: negative DOM assertions are :poop:, but if we must have them, make them more tolerable. the old way: expect(f(".something-that-should-be-gone")).to be_nil expect(fj("buhleeted:visible")).to be_nil expect(fln("Can't Click Here Anymore").to be_nil the new way: expect(container).not_to contain_css(".something-that-should-be-gone") expect(container).not_to contain_jqcss("buhleeted:visible") expect(container).not_to contain_link("Can't Click Here Anymore") (you can of course use these new matchers for positive assertions as well) although it's a tad more verbose, the new way is better because: 1. it's smart enough to bail once the assertion is met (versus the old way which would take 10-20 seconds to not find the thing and *then* run the assertion) 2. it requires them to be scoped, to reduce the likelihood of false positives (e.g. if the page is totally broken, then of course the assertion would pass) also reworked the various flash message assertions... see the new expect_flash_message and expect_no_flash_message this should remove over an hour of linear time off the build (10 sec per old assertion, except fj ones which took 20 sec)... so like a minute of actual time, cuz parallelization :P a consequence of this change is that f/fj/ff/ffj now raise if nothing is found, so you really have to go out of your way to do it the bad way. so don't :) Change-Id: I0fe6e8500947c27d748b70bb2cda585edf71e427 Reviewed-on: https://gerrit.instructure.com/78420 Tested-by: Jenkins Reviewed-by: Landon Wilkins <lwilkins@instructure.com> Product-Review: Landon Wilkins <lwilkins@instructure.com> QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-05-01 06:23:03 +08:00
expect(f("#content")).not_to contain_css('.to-do-list')
end
end
it "should show submitted essay quizzes in the todo list", priority: "1", test_id: 216403 do
quiz_title = 'new quiz'
student_in_course(:active_all => true)
q = @course.quizzes.create!(:title => quiz_title)
q.quiz_questions.create!(:question_data => {:id => 31, :name => "Quiz Essay Question 1", :question_type => 'essay_question', :question_text => 'qq1', :points_possible => 10})
q.generate_quiz_data
q.workflow_state = 'available'
q.save
q.reload
qs = q.generate_submission(@user)
qs.mark_completed
qs.submission_data = {"question_31" => "<p>abeawebawebae</p>", "question_text" => "qq1"}
Quizzes::SubmissionGrader.new(qs).grade_submission
get "/"
todo_list = f('.to-do-list')
expect(todo_list).not_to be_nil
expect(todo_list).to include_text(quiz_title)
end
context "course menu customization" do
it "should always have a link to the courses page (with customizations)", priority: "1", test_id: 216404 do
course_with_teacher({:user => @user, :active_course => true, :active_enrollment => true})
get "/"
f('#global_nav_courses_link').click
expect(fj('[aria-label="Courses tray"] a:contains("All Courses")')).to be_present
end
end
end
context 'as a teacher in an unpublished course' do
before do
course_with_teacher_logged_in(:active_course => false)
end
it 'should not show an unpublished assignment for an unpublished course', priority: "2", test_id: 56003 do
name = 'venkman'
due_date = Time.zone.now.utc + 2.days
assignment = @course.assignments.create(name: name,
submission_types: 'online',
due_at: due_date,
lock_at: 1.week.from_now,
unlock_at: due_date)
get '/'
expect(f('.coming_up')).to include_text(name)
assignment.unpublish
get '/'
expect(f('.coming_up')).not_to include_text(name)
end
end
end