add test structure for canvas for elementary with selective release

Closes LF-810

Test Plan: passes Jenkins

Change-Id: I49207143082ccc876a372bff27819c8a34d3cb1d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/328631
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Sarah Gerard <sarah.gerard@instructure.com>
QA-Review: Sarah Gerard <sarah.gerard@instructure.com>
Product-Review: Robin Kuss <rkuss@instructure.com>
This commit is contained in:
Robin Kuss 2023-09-25 15:05:08 -05:00
parent 8708e837b1
commit aa1d607373
4 changed files with 254 additions and 99 deletions

View File

@ -60,7 +60,7 @@ module ModulesIndexPage
end
def manage_module_button(context_module)
f("#context_module_#{context_module.id} button[aria-label='Manage #{context_module.name}']")
f("#context_module_#{context_module.id} .module_header_items button[aria-label='Manage #{context_module.name}']")
end
def manage_module_item_button(module_item)
@ -85,4 +85,12 @@ module ModulesIndexPage
fj(".add_item_button:visible").click
wait_for_ajax_requests
end
# method to scroll to the top of the modules page, especially for the canvas for elementary pages that
# have a collapsing head that hides content.
def scroll_to_the_top_of_modules_page
where_to_scroll = element_exists?("#student-view-btn") ? "#student-view-btn" : "#easy_student_view"
scroll_to(f(where_to_scroll))
wait_for_ajaximations
end
end

View File

@ -20,12 +20,19 @@
require_relative "../../helpers/context_modules_common"
require_relative "../page_objects/modules_index_page"
require_relative "../page_objects/modules_settings_tray"
require_relative "../../dashboard/pages/k5_dashboard_page"
require_relative "../../dashboard/pages/k5_dashboard_common_page"
require_relative "../../../helpers/k5_common"
require_relative "../shared_examples/module_selective_release_shared_examples"
describe "selective_release module set up" do
include_context "in-process server selenium tests"
include ContextModulesCommon
include ModulesIndexPage
include ModulesSettingsTray
include K5DashboardPageObject
include K5DashboardCommonPageObject
include K5Common
context "using tray to update settings" do
before(:once) do
@ -38,67 +45,7 @@ describe "selective_release module set up" do
user_session(@teacher)
end
it "accesses the modules tray for a module and closes" do
go_to_modules
manage_module_button(@module).click
# maybe should use a settings option when available
module_index_menu_tool_link("Assign To...").click
click_settings_tray_close_button
expect(settings_tray_exists?).to be_falsey
end
it "accesses the modules tray for a module and cancels" do
go_to_modules
manage_module_button(@module).click
# maybe should use a settings option when available
module_index_menu_tool_link("Assign To...").click
click_settings_tray_cancel_button
expect(settings_tray_exists?).to be_falsey
end
it "accesses the modules tray and click between settings and assign to" do
go_to_modules
manage_module_button(@module).click
# should use a settings option when available
module_index_menu_tool_link("Assign To...").click
expect(assign_to_panel).to be_displayed
click_settings_tab
expect(settings_panel).to be_displayed
click_assign_to_tab
expect(assign_to_tab).to be_displayed
end
it "shows 'View Assign To' when a module has an assignment override" do
@module.assignment_overrides.create!
go_to_modules
expect(view_assign.text).to eq "View Assign To"
end
it "doesn't show 'View Assign To' when a module has no assignment overrides" do
go_to_modules
expect(view_assign.text).to eq ""
end
it "accesses the modules tray for a module via the 'View Assign To' button" do
@module.assignment_overrides.create!
go_to_modules
view_assign.click
expect(settings_tray_exists?).to be true
end
it_behaves_like "selective_release module tray", :context_modules
end
context "uses tray to update prerequisites" do
@ -141,26 +88,7 @@ describe "selective_release module set up" do
expect(prerequisite_message(@module3).text).to eq("Prerequisites: module2")
end
it "adds more than one prerequisite to a module" do
go_to_modules
manage_module_button(@module3).click
module_index_menu_tool_link("Assign To...").click
click_settings_tab
click_add_prerequisites_button
select_prerequisites_dropdown_option(0, "module2")
expect(prerequisites_dropdown_value(0)).to eq("module2")
click_add_prerequisites_button
select_prerequisites_dropdown_option(1, "module")
expect(prerequisites_dropdown_value(1)).to eq("module")
click_settings_tray_update_module_button
expect(prerequisite_message(@module3).text).to eq("Prerequisites: module2, module")
end
it_behaves_like "selective_release module tray prerequisites", :context_modules
it "does not save prerequisites selected when update cancelled." do
go_to_modules
@ -171,9 +99,9 @@ describe "selective_release module set up" do
click_add_prerequisites_button
expect(prerequisites_dropdown[0]).to be_displayed
select_prerequisites_dropdown_option(0, "module")
select_prerequisites_dropdown_option(0, @module.name)
expect(prerequisites_dropdown_value(0)).to eq("module")
expect(prerequisites_dropdown_value(0)).to eq(@module.name)
click_settings_tray_cancel_button
@ -267,20 +195,7 @@ describe "selective_release module set up" do
expect(assignee_selection_item[0].text).to eq("section1")
end
it "adds both user and section to assignee list" do
go_to_modules
manage_module_button(@module).click
module_index_menu_tool_link("Assign To...").click
click_custom_access_radio
assignee_selection.send_keys("user")
click_option(assignee_selection, "user1")
assignee_selection.send_keys("section")
click_option(assignee_selection, "section1")
assignee_list = assignee_selection_item.map(&:text)
expect(assignee_list.sort).to eq(%w[section1 user1])
end
it_behaves_like "selective_release module tray assign to", :context_modules
it "deletes added assignee by clicking on it" do
go_to_modules
@ -308,4 +223,34 @@ describe "selective_release module set up" do
expect(element_exists?(assignee_selection_item_selector)).to be false
end
end
context "Canvas for Elementary Modules Selective Release" do
before :once do
Account.site_admin.enable_feature! :differentiated_modules
teacher_setup
@module = @subject_course.context_modules.create!(name: "Module 1")
@assignment1 = @subject_course.assignments.create!(title: "first item in module")
@module.add_item type: "assignment", id: @assignment1.id
@section1 = @subject_course.course_sections.create!(name: "section1")
@section2 = @subject_course.course_sections.create!(name: "section2")
@student1 = user_factory(name: "user1", active_all: true, active_state: "active")
@student2 = user_factory(name: "user2", active_all: true, active_state: "active", section: @section2)
@subject_course.enroll_user(@student1, "StudentEnrollment", enrollment_state: "active")
@subject_course.enroll_user(@student2, "StudentEnrollment", enrollment_state: "active")
@assignment2 = @subject_course.assignments.create!(title: "first item in module 2")
@assignment3 = @subject_course.assignments.create!(title: "first item in module 3")
@module2 = @course.context_modules.create!(name: "module2")
@module2.add_item type: "assignment", id: @assignment2.id
@module3 = @course.context_modules.create!(name: "module3")
@module3.add_item type: "assignment", id: @assignment3.id
end
before do
user_session(@homeroom_teacher)
end
it_behaves_like "selective_release module tray", :canvas_for_elementary
it_behaves_like "selective_release module tray prerequisites", :canvas_for_elementary
it_behaves_like "selective_release module tray assign to", :canvas_for_elementary
end
end

View File

@ -0,0 +1,202 @@
# frozen_string_literal: true
#
# Copyright (C) 2023 - 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 "../../helpers/context_modules_common"
require_relative "../page_objects/modules_index_page"
require_relative "../page_objects/modules_settings_tray"
require_relative "../../dashboard/pages/k5_dashboard_page"
require_relative "../../dashboard/pages/k5_dashboard_common_page"
require_relative "../../../helpers/k5_common"
shared_examples_for "selective_release module tray" do |context|
include ContextModulesCommon
include ModulesIndexPage
include ModulesSettingsTray
include K5DashboardPageObject
include K5DashboardCommonPageObject
include K5Common
before do
case context
when :context_modules
@mod_course = @course
@mod_url = "/courses/#{@mod_course.id}/modules"
when :canvas_for_elementary
@mod_course = @subject_course
@mod_url = "/courses/#{@mod_course.id}#modules"
end
end
it "accesses the modules tray" do
get @mod_url
scroll_to_the_top_of_modules_page
manage_module_button(@module).click
module_index_menu_tool_link("Assign To...").click
expect(settings_tray_exists?).to be true
end
it "accesses the modules tray for a module and closes" do
get @mod_url
scroll_to_the_top_of_modules_page
manage_module_button(@module).click
# maybe should use a settings option when available
module_index_menu_tool_link("Assign To...").click
click_settings_tray_close_button
expect(settings_tray_exists?).to be_falsey
end
it "accesses the modules tray for a module and cancels" do
get @mod_url
scroll_to_the_top_of_modules_page
manage_module_button(@module).click
# maybe should use a settings option when available
module_index_menu_tool_link("Assign To...").click
click_settings_tray_cancel_button
expect(settings_tray_exists?).to be_falsey
end
it "accesses the modules tray and click between settings and assign to" do
get @mod_url
scroll_to_the_top_of_modules_page
manage_module_button(@module).click
# should use a settings option when available
module_index_menu_tool_link("Assign To...").click
expect(assign_to_panel).to be_displayed
click_settings_tab
expect(settings_panel).to be_displayed
click_assign_to_tab
expect(assign_to_tab).to be_displayed
end
it "shows 'View Assign To' when a module has an assignment override" do
@module.assignment_overrides.create!
get @mod_url
expect(view_assign.text).to eq "View Assign To"
end
it "doesn't show 'View Assign To' when a module has no assignment overrides" do
get @mod_url
expect(view_assign.text).to eq ""
end
it "accesses the modules tray for a module via the 'View Assign To' button" do
@module.assignment_overrides.create!
get @mod_url
view_assign.click
expect(settings_tray_exists?).to be true
end
end
shared_examples_for "selective_release module tray prerequisites" do |context|
include ContextModulesCommon
include ModulesIndexPage
include ModulesSettingsTray
include K5DashboardPageObject
include K5DashboardCommonPageObject
include K5Common
before do
case context
when :context_modules
@mod_course = @course
@mod_url = "/courses/#{@mod_course.id}/modules"
when :canvas_for_elementary
@mod_course = @subject_course
@mod_url = "/courses/#{@mod_course.id}#modules"
end
end
it "adds more than one prerequisite to a module" do
get @mod_url
manage_module_button(@module3).click
module_index_menu_tool_link("Assign To...").click
click_settings_tab
click_add_prerequisites_button
select_prerequisites_dropdown_option(0, @module2.name)
expect(prerequisites_dropdown_value(0)).to eq(@module2.name)
click_add_prerequisites_button
select_prerequisites_dropdown_option(1, @module.name)
expect(prerequisites_dropdown_value(1)).to eq(@module.name)
click_settings_tray_update_module_button
expect(prerequisite_message(@module3).text).to eq("Prerequisites: #{@module2.name}, #{@module.name}")
end
end
shared_examples_for "selective_release module tray assign to" do |context|
include ContextModulesCommon
include ModulesIndexPage
include ModulesSettingsTray
include K5DashboardPageObject
include K5DashboardCommonPageObject
include K5Common
before do
case context
when :context_modules
@mod_course = @course
@mod_url = "/courses/#{@mod_course.id}/modules"
when :canvas_for_elementary
@mod_course = @subject_course
@mod_url = "/courses/#{@mod_course.id}#modules"
end
end
it "adds both user and section to assignee list" do
get @mod_url
scroll_to_the_top_of_modules_page
manage_module_button(@module).click
module_index_menu_tool_link("Assign To...").click
click_custom_access_radio
assignee_selection.send_keys("user")
click_option(assignee_selection, "user1")
assignee_selection.send_keys("section")
click_option(assignee_selection, "section1")
assignee_list = assignee_selection_item.map(&:text)
expect(assignee_list.sort).to eq(%w[section1 user1])
end
end

View File

@ -45,7 +45,7 @@ module ContextModulesCommon
end
def module_setup
@module = @course.context_modules.create!(name: "module")
@module = @course.context_modules.create!(name: "Module 1")
# create module items
# add first and last module items to get previous and next displayed