Skip to content

Commit

Permalink
ensuring that the wizards buttons travers in the same order forwards …
Browse files Browse the repository at this point in the history
…and backwards (#1728)

* testing the wizard in reverse order

* rubocop 🚨

* Make sure the wizard buttons are a mirror image in forward and reverse

* ensuring that the wizards buttons travers in the same order forwards and backwards

---------

Co-authored-by: Carolyn Cole <[email protected]>
  • Loading branch information
JaymeeH and carolyncole authored Apr 1, 2024
1 parent d876ab3 commit 1f4e14e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/controllers/works_wizard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ def attachment_selected

if params[:save_only] == "true"
render :attachment_select
elsif @work.files_location == "file_upload"
redirect_to work_file_upload_url(@work)
else
redirect_to work_file_other_url(@work)
redirect_to file_location_url
end
end

Expand Down Expand Up @@ -168,6 +166,11 @@ def readme_uploaded
end
end

def file_location_url
WorkMetadataService.file_location_url(@work)
end
helper_method :file_location_url

private

def load_work
Expand Down
8 changes: 8 additions & 0 deletions app/services/work_metadata_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def new_submission
end
end

def self.file_location_url(work)
if work.files_location == "file_upload"
Rails.application.routes.url_helpers.work_file_upload_path(work)
else
Rails.application.routes.url_helpers.work_file_other_path(work)
end
end

private

def update_work
Expand Down
2 changes: 1 addition & 1 deletion app/views/works_wizard/readme_select.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>

<div class="actions">
<%= link_to t('works.form.readme_upload.go_back'), edit_work_path(@work, wizard: true), class: "btn btn-secondary" %>
<%= link_to t('works.form.readme_upload.go_back'), edit_work_wizard_path(@work), class: "btn btn-secondary" %>
<%= f.submit(t('works.form.readme_upload.continue'), class: "btn btn-primary wizard-next-button", id: 'readme-upload', disabled: @readme.blank?) %>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/works_wizard/review.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<textarea id="submission_notes" name="submission_notes" cols="80", rows="10"
placeholder="(optional) Type here to leave a message for the curators"><%= @work.submission_notes %></textarea>
<div class="actions">
<%= link_to "Go Back", work_attachment_select_url(@work, wizard: true), class: "btn btn-secondary" %>
<%= link_to "Go Back", file_location_url , class: "btn btn-secondary" %>
<%= submit_tag "Grant License and Complete", class: "btn btn-primary wizard-next-button" %>
</div>
<% end %>
Expand Down
37 changes: 37 additions & 0 deletions spec/system/work_wizard_reverse_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true
require "rails_helper"

describe "walk the wizard in reverse", type: :system, js: true do
it "follow the same path in reverse or forward" do
work = FactoryBot.create :draft_work, files_location: "file_upload"
stub_s3 data: [FactoryBot.build(:s3_readme, work:)]
sign_in work.created_by_user
visit work_review_path(work)

expect(page).to have_content "Data curators will review"
click_on "Go Back"

expect(page).to have_content "Once you have uploaded"
click_on "Go Back"

expect(page).to have_content "Begin the process to upload your submission"
click_on "Go Back"

expect(page).to have_content "Please upload the README"
click_on "Go Back"

expect(page).to have_content "By initiating this new submission"
click_on "Save Work"

expect(page).to have_content "Please upload the README"
click_on "Continue"

expect(page).to have_content "Begin the process to upload your submission"
click_on "Continue"

expect(page).to have_content "Once you have uploaded"
click_on "Continue"

expect(page).to have_content "Data curators will review"
end
end

0 comments on commit 1f4e14e

Please sign in to comment.