spec: selenium coverage of proxy submissions

closes EVAL-2714
flag=proxy_file_uploads

Test Plan:
    - specs pass

Change-Id: I32462617cb38ad6be38939922142d621437debe4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/309122
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Shafovaloff <ashafovaloff@instructure.com>
Reviewed-by: Derek Williams <derek.williams@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
This commit is contained in:
Kai Bjorkman 2023-01-18 14:28:25 -07:00 committed by Aaron Shafovaloff
parent 9643e90fc8
commit 18ae8d5932
8 changed files with 166 additions and 1 deletions

View File

@ -376,6 +376,31 @@ describe "assignments" do
end
end
context "proxy submitted assignment" do
before do
@teacher = teacher_in_course(name: "teacher", course: @course, enrollment_state: :active).user
@assignment.update!(submission_types: "online_upload,online_text_entry")
Account.site_admin.enable_feature!(:proxy_file_uploads)
teacher_role = Role.get_built_in_role("TeacherEnrollment", root_account_id: Account.default.id)
RoleOverride.create!(
permission: "proxy_assignment_submission",
enabled: true,
role: teacher_role,
account: @course.root_account
)
file_attachment = attachment_model(content_type: "application/pdf", context: @student)
submission = @assignment.submit_homework(@student, submission_type: "online_upload", attachments: [file_attachment])
@teacher.update!(short_name: "Test Teacher")
submission.update!(proxy_submitter: @teacher)
user_session(@student)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
end
it "identifies the proxy submitter in the submission details" do
expect(f(".details").text).to include("by " + @teacher.short_name)
end
end
context "with more than one page of assignment groups" do
before do
ApplicationController::ASSIGNMENT_GROUPS_TO_FETCH_PER_PAGE_ON_ASSIGNMENTS_INDEX = 10

View File

@ -332,6 +332,36 @@ describe "as a student" do
end
end
context "proxy submitted assignment" do
before do
@assignment = @course.assignments.create!(
name: "proxy upload assignment",
due_at: 5.days.ago,
points_possible: 10,
submission_types: "online_upload"
)
Account.site_admin.enable_feature!(:proxy_file_uploads)
teacher_role = Role.get_built_in_role("TeacherEnrollment", root_account_id: Account.default.id)
RoleOverride.create!(
permission: "proxy_assignment_submission",
enabled: true,
role: teacher_role,
account: @course.root_account
)
file_attachment = attachment_model(content_type: "application/pdf", context: @student)
@submission = @assignment.submit_homework(@student, submission_type: "online_upload", attachments: [file_attachment])
@teacher.update!(short_name: "Test Teacher")
@submission.update!(proxy_submitter: @teacher)
user_session(@student)
StudentAssignmentPageV2.visit(@course, @assignment)
wait_for_ajaximations
end
it "submission workflow tracker identifies the proxy submitter" do
expect(StudentAssignmentPageV2.submission_workflow_tracker).to include_text("by " + @teacher.short_name)
end
end
context "mark as done" do
before(:once) do
@assignment = @course.assignments.create!(

View File

@ -21,10 +21,12 @@ require_relative "../pages/gradebook_page"
require_relative "../pages/gradebook_cells_page"
require_relative "../pages/gradebook_grade_detail_tray_page"
require_relative "../../helpers/gradebook_common"
require_relative "../../helpers/files_common"
describe "Grade Detail Tray:" do
include_context "in-process server selenium tests"
include GradebookCommon
include FilesCommon
include_context "late_policy_course_setup"
before(:once) do
@ -292,4 +294,47 @@ describe "Grade Detail Tray:" do
expect(Gradebook::GradeDetailTray.all_comments).not_to contain_css("p")
end
end
context "submit for student" do
before do
Account.site_admin.enable_feature!(:proxy_file_uploads)
teacher_role = Role.get_built_in_role("TeacherEnrollment", root_account_id: Account.default.id)
RoleOverride.create!(
permission: "proxy_assignment_submission",
enabled: true,
role: teacher_role,
account: @course.root_account
)
@a1.update!(submission_types: "online_upload,online_text_entry")
file_attachment = attachment_model(content_type: "application/pdf", context: @students.first)
@submission = @a1.submit_homework(@students.first, submission_type: "online_upload", attachments: [file_attachment])
@teacher.update!(short_name: "Test Teacher")
@submission.update!(proxy_submitter: @teacher)
user_session(@teacher)
Gradebook.visit(@course)
end
it "button is availible for assignments with online uploads" do
Gradebook::Cells.open_tray(@course.students.first, @a1)
expect(Gradebook::GradeDetailTray.submit_for_student_button).to be_displayed
end
it "modal allows multiple files to be uploaded via the file upload drop" do
filename1, fullpath1 = get_file("testfile1.txt")
filename2, fullpath2 = get_file("testfile2.txt")
Gradebook::Cells.open_tray(@course.students.first, @a1)
Gradebook::GradeDetailTray.submit_for_student_button.click
Gradebook::GradeDetailTray.proxy_file_drop.send_keys(fullpath1)
Gradebook::GradeDetailTray.proxy_file_drop.send_keys(fullpath2)
expect(f("table[data-testid='proxy_uploaded_files_table']")).to include_text(filename1)
expect(f("table[data-testid='proxy_uploaded_files_table']")).to include_text(filename2)
expect(Gradebook::GradeDetailTray.proxy_submit_button).to be_displayed
end
it "allows a file to be uploaded via the file upload drop" do
Gradebook::Cells.open_tray(@course.students.first, @a1)
expect(Gradebook::GradeDetailTray.proxy_submitter_name.text).to include("Submitted by " + @teacher.short_name)
expect(Gradebook::GradeDetailTray.proxy_date_time).to be_displayed
end
end
end

View File

@ -79,6 +79,26 @@ module Gradebook
fj("a:contains('SpeedGrader')")
end
def self.submit_for_student_button
f("button[data-testid='submit-for-student-button']")
end
def self.proxy_file_drop
f("#proxyInputFileDrop")
end
def self.proxy_submit_button
f("button[data-testid='proxySubmit']")
end
def self.proxy_submitter_name
f("span[data-testid='proxy_submitter_name']")
end
def self.proxy_date_time
f("span[data-testid='friendly-date-time']")
end
def self.next_assignment_button
f("#assignment-carousel .right-arrow-button-container button")
end

View File

@ -173,6 +173,10 @@ class Speedgrader
f("#submission_to_view")
end
def submitter_info
f("#multiple_submissions")
end
def submission_file_download
f(".submission-file-download")
end

View File

@ -1054,6 +1054,44 @@ describe "Speedgrader" do
Speedgrader.select_option_submission_to_view("0")
expect(Speedgrader.submission_file_name.text).to eq @attachment.filename
end
it "identifies the proxy submitter in the submission dropdown" do
Timecop.freeze(1.hour.ago) { submit_with_attachment }
resubmit_with_text
Account.site_admin.enable_feature!(:proxy_file_uploads)
teacher_role = Role.get_built_in_role("TeacherEnrollment", root_account_id: Account.default.id)
RoleOverride.create!(
permission: "proxy_assignment_submission",
enabled: true,
role: teacher_role,
account: @course.root_account
)
file_attachment = attachment_model(content_type: "application/pdf", context: @students.first)
submission = @assignment_for_course.submit_homework(@students.first, submission_type: "online_upload", attachments: [file_attachment])
@teacher.update!(short_name: "Test Teacher")
submission.update!(proxy_submitter: @teacher)
user_session(@teacher)
Speedgrader.visit(@course.id, @assignment_for_course.id)
expect(Speedgrader.submission_to_view_dropdown).to include_text("(Test Teacher)")
end
it "identifies the proxy submitter in the submission details tray with only a single submission" do
Account.site_admin.enable_feature!(:proxy_file_uploads)
teacher_role = Role.get_built_in_role("TeacherEnrollment", root_account_id: Account.default.id)
RoleOverride.create!(
permission: "proxy_assignment_submission",
enabled: true,
role: teacher_role,
account: @course.root_account
)
file_attachment = attachment_model(content_type: "application/pdf", context: @students.first)
submission = @assignment_for_course.submit_homework(@students.first, submission_type: "online_upload", attachments: [file_attachment])
@teacher.update!(short_name: "Test Teacher")
submission.update!(proxy_submitter: @teacher)
user_session(@teacher)
Speedgrader.visit(@course.id, @assignment_for_course.id)
expect(Speedgrader.submitter_info).to include_text("by Test Teacher")
end
end
context "speedgrader nav bar" do

View File

@ -277,7 +277,9 @@ export default class SubmissionTray extends React.Component<
if (submission.proxySubmitter) {
return (
<View as="div" textAlign="center">
<Text>{I18n.t('Submitted by %{submitter}', {submitter: submission.proxySubmitter})}</Text>
<Text data-testid="proxy_submitter_name">
{I18n.t('Submitted by %{submitter}', {submitter: submission.proxySubmitter})}
</Text>
<br />
<FriendlyDatetime
format={I18n.t('#date.formats.date_at_time')}

View File

@ -502,6 +502,7 @@ const ProxyUploadModal = ({
Close
</Button>
<Button
data-testid="proxySubmit"
color="primary"
type="submit"
disabled={filesUploading || submitting}