From 36fca4c83d543955b4bed40c2b7003537d3a0abb Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 8 Feb 2024 10:09:43 +0000 Subject: [PATCH] Add upload consent document page This makes it possible for the applicant to upload their consent documents. --- .../documents/edit_uploads.html.erb | 58 +++++++++---------- .../teacher_interface/uploads/new.html.erb | 6 +- .../qualification_consent_spec.rb | 30 ++++++++++ 3 files changed, 63 insertions(+), 31 deletions(-) diff --git a/app/views/teacher_interface/documents/edit_uploads.html.erb b/app/views/teacher_interface/documents/edit_uploads.html.erb index 3879db2c10..55d41c61dd 100644 --- a/app/views/teacher_interface/documents/edit_uploads.html.erb +++ b/app/views/teacher_interface/documents/edit_uploads.html.erb @@ -1,38 +1,38 @@ <% content_for :page_title, title_with_error_prefix("Check your uploaded files", error: @form.errors.any?) %> <% content_for :back_link_url, back_history_path(default: teacher_interface_application_form_path) %> -

Check your uploaded files – <%= I18n.t("document.document_type.#{@document.document_type}") %> document

- -

Files added

- -<%= govuk_summary_list do |summary_list| - @document.uploads.order(:created_at).each_with_index do |upload, index| - summary_list.with_row do |row| - if @document.allow_multiple_uploads? - row.with_key(text: "File #{index + 1}") - end +<%= form_with model: @form, url: [:teacher_interface, :application_form, @document], method: :patch do |f| %> + <%= f.govuk_error_summary %> - row.with_value { upload_link_to(upload) } - - if @document.allow_multiple_uploads? - row.with_action( - text: "Delete", - href: delete_teacher_interface_application_form_document_upload_path(@document, upload), - visually_hidden_text: upload.attachment.filename - ) - else - row.with_action( - text: "Change", - href: new_teacher_interface_application_form_document_upload_path(@document), - visually_hidden_text: upload.attachment.filename - ) +

Check your uploaded files – <%= I18n.t("document.document_type.#{@document.document_type}") %> document

+ +

Files added

+ + <%= govuk_summary_list do |summary_list| + @document.uploads.order(:created_at).each_with_index do |upload, index| + summary_list.with_row do |row| + if @document.allow_multiple_uploads? + row.with_key(text: "File #{index + 1}") + end + + row.with_value { upload_link_to(upload) } + + if @document.allow_multiple_uploads? + row.with_action( + text: "Delete", + href: delete_teacher_interface_application_form_document_upload_path(@document, upload), + visually_hidden_text: upload.attachment.filename + ) + else + row.with_action( + text: "Change", + href: new_teacher_interface_application_form_document_upload_path(@document), + visually_hidden_text: upload.attachment.filename + ) + end end end - end -end %> - -<%= form_with model: @form, url: [:teacher_interface, :application_form, @document], method: :patch do |f| %> - <%= f.govuk_error_summary %> + end %> <% if @document.allow_multiple_uploads? %> <%= f.govuk_radio_buttons_fieldset :add_another, diff --git a/app/views/teacher_interface/uploads/new.html.erb b/app/views/teacher_interface/uploads/new.html.erb index b7570d9176..305b02e9cf 100644 --- a/app/views/teacher_interface/uploads/new.html.erb +++ b/app/views/teacher_interface/uploads/new.html.erb @@ -3,7 +3,7 @@ <%= render "upload_timeout_error" if @form.timeout_error %> -<% if @document.uploads.empty? %> +<% if @document.uploads.empty? || !@document.allow_multiple_uploads? %> <% if @document.english_language_proficiency? %>

Upload your English language proficiency test

This document must confirm that you have an English language proficiency test from an approved provider at level B2 of the Common European Framework of Reference for Languages (CEFR) scale.

@@ -69,7 +69,9 @@

<%= I18n.t("application_form.qualifications.upload.transcript.description") %>

<% elsif @document.signed_consent? %> -

Upload your signed consent document

+

Upload consent document

+

<%= qualification_title(@document.documentable.qualification) %>

+

Upload the signed document. Do not send it by email.

<% elsif @document.unsigned_consent? %>

Upload your unsigned consent document

<% elsif @document.written_statement? %> diff --git a/spec/system/teacher_interface/qualification_consent_spec.rb b/spec/system/teacher_interface/qualification_consent_spec.rb index cfdb6e59d8..21a2a64f68 100644 --- a/spec/system/teacher_interface/qualification_consent_spec.rb +++ b/spec/system/teacher_interface/qualification_consent_spec.rb @@ -38,6 +38,15 @@ when_i_check_the_downloaded_checkbox then_i_see_the(:teacher_qualification_requests_page) + + when_i_click_the_upload_task + then_i_see_the(:teacher_upload_document_page) + + when_i_upload_a_file + then_i_see_the(:teacher_check_document_page) + + when_i_dont_need_to_upload_another_file + then_i_see_the(:teacher_qualification_requests_page) end def given_there_is_an_application_form @@ -91,6 +100,27 @@ def when_i_check_the_downloaded_checkbox teacher_qualification_request_download_page.continue_button.click end + def when_i_click_the_upload_task + teacher_qualification_requests_page + .task_list + .sections + .first + .items + .second + .click + end + + def when_i_upload_a_file + teacher_upload_document_page.form.original_attachment.attach_file Rails.root.join( + file_fixture("upload.pdf"), + ) + teacher_upload_document_page.form.continue_button.click + end + + def when_i_dont_need_to_upload_another_file + teacher_check_document_page.form.continue_button.click + end + def teacher @teacher ||= create(:teacher) end