spec: E2E selenium tests for FGOGH feature

had to allow Auditors table to read from active record
due to Jenkins still reading from cassandra

closes EVAL-1237
flags=final_grade_override_in_gradebook_history

Test Plan:
-specs pass

Change-Id: Ia8da7f67d43f48a2a59fcbc58bb75e58c53afd36
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251682
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
This commit is contained in:
Kai Bjorkman 2020-10-06 16:47:47 -06:00
parent 4e4fe733c1
commit 7a70b60858
3 changed files with 79 additions and 6 deletions

View File

@ -374,7 +374,11 @@ class SearchFormComponent extends Component {
</View> </View>
{environment.overrideGradesEnabled() && ( {environment.overrideGradesEnabled() && (
<View as="div" margin="medium 0"> <View
as="div"
margin="medium 0"
data-testid="show-final-grade-overrides-only-checkbox"
>
<Checkbox <Checkbox
checked={this.state.selected.showFinalGradeOverridesOnly} checked={this.state.selected.showFinalGradeOverridesOnly}
id="show_final_grade_overrides_only" id="show_final_grade_overrides_only"

View File

@ -23,11 +23,18 @@ require_relative '../pages/gradebook/settings'
require_relative '../pages/gradebook_cells_page' require_relative '../pages/gradebook_cells_page'
require_relative '../pages/srgb_page' require_relative '../pages/srgb_page'
require_relative '../pages/student_grades_page' require_relative '../pages/student_grades_page'
require_relative '../pages/gradebook_history_page'
require_relative '../setup/gb_history_search_setup'
describe 'Final Grade Override' do describe 'Final Grade Override' do
include_context 'in-process server selenium tests' include_context 'in-process server selenium tests'
include GradebookHistorySetup
before(:each) do
# needed until Jenkins starts using active record and cassandra is killed
allow(Auditors).to receive(:config).and_return({'write_paths' => ['active_record'], 'read_path' => 'active_record'})
allow(AuditLogFieldExtension).to receive(:enabled?).and_return(false)
before(:once) do
course_with_teacher(course_name: "Grade Override", active_course: true,active_enrollment: true,name: "Teacher Boss1",active_user: true) course_with_teacher(course_name: "Grade Override", active_course: true,active_enrollment: true,name: "Teacher Boss1",active_user: true)
@course.update!(grading_standard_enabled: true) @course.update!(grading_standard_enabled: true)
@students = create_users_in_course(@course, 5, return_type: :record, name_prefix: "Purple") @students = create_users_in_course(@course, 5, return_type: :record, name_prefix: "Purple")
@ -47,13 +54,10 @@ describe 'Final Grade Override' do
end end
context "Individual Gradebook" do context "Individual Gradebook" do
before(:once) do before(:each) do
@student = @students.first @student = @students.first
@enrollment = @course.enrollments.find_by(user: @student) @enrollment = @course.enrollments.find_by(user: @student)
@enrollment.scores.find_by(course_score: true).update!(override_score: 97.1) @enrollment.scores.find_by(course_score: true).update!(override_score: 97.1)
end
before(:each) do
user_session(@teacher) user_session(@teacher)
SRGB.visit(@course.id) SRGB.visit(@course.id)
SRGB.allow_final_grade_override_option.click SRGB.allow_final_grade_override_option.click
@ -105,4 +109,52 @@ describe 'Final Grade Override' do
expect(StudentGradesPage.final_grade.text).to eql "90%" expect(StudentGradesPage.final_grade.text).to eql "90%"
end end
end end
context "Gradebook History" do
before(:each) do
@course.update!(allow_final_grade_override: true)
@teacher.save
user_session(@teacher)
Gradebook.visit(@course)
Gradebook::Cells.edit_override(@students.first, 90.0)
end
context "when final_grade_override_in_gradebook_history flag is enabled" do
before(:each) do
Account.site_admin.enable_feature!(:final_grade_override_in_gradebook_history)
GradeBookHistory.visit(@course)
wait_for_ajaximations
end
it 'displays checkbox to show final grade overrides only when final_grade_override_in_gradebook_history flag enabled' do
expect(GradeBookHistory.final_grade_override_checkbox).to be_displayed
end
it 'displays final grade override grade changes when final_grade_override_in_gradebook_history flag is enabled' do
expect(GradeBookHistory).to be_contains_final_grade_override_entries
end
it 'displays final grade override grade changes only when filter is applied' do
GradeBookHistory.search_final_grade_override_only
expect(GradeBookHistory).to be_contains_only_final_grade_override_entries
end
end
context "when final_grade_override_in_gradebook_history flag is disabled" do
before(:each) do
Account.site_admin.disable_feature!(:final_grade_override_in_gradebook_history)
GradeBookHistory.visit(@course)
wait_for_ajaximations
end
it 'does not display final grade override grade changes when final_grade_override_in_gradebook_history flag is disabled' do
expect(GradeBookHistory).not_to be_contains_final_grade_override_entries
end
end
end
end end

View File

@ -98,6 +98,11 @@ class GradeBookHistory
click_filter_button click_filter_button
end end
def search_final_grade_override_only
final_grade_override_checkbox.click
click_filter_button
end
def search_with_all_data(type_ahead, student, grader, assignment) def search_with_all_data(type_ahead, student, grader, assignment)
select_student_name(type_ahead, student) select_student_name(type_ahead, student)
select_grader_name(grader) select_grader_name(grader)
@ -127,6 +132,14 @@ class GradeBookHistory
test_passed test_passed
end end
def contains_final_grade_override_entries?
(1...results_table_rows.size + 1).any? { |idx| results_table_assignment_col(idx).text == "Final Grade Override" }
end
def contains_only_final_grade_override_entries?
(1...results_table_rows.size + 1).all? { |idx| results_table_assignment_col(idx).text == "Final Grade Override" }
end
def check_table_for_grader_name(string_in_row) def check_table_for_grader_name(string_in_row)
row_elements = results_table_rows row_elements = results_table_rows
test_passed = true test_passed = true
@ -169,6 +182,10 @@ class GradeBookHistory
f('#assignments') f('#assignments')
end end
def final_grade_override_checkbox
f('div[data-testid="show-final-grade-overrides-only-checkbox"]')
end
def start_date_textfield def start_date_textfield
driver.find_element(:id, fj('label:contains("Start Date")')[:for]) driver.find_element(:id, fj('label:contains("Start Date")')[:for])
end end