diff --git a/app/components/admin/editions/show/sidebar_actions_component.rb b/app/components/admin/editions/show/sidebar_actions_component.rb index 85333aebc2c..e3494ca2305 100644 --- a/app/components/admin/editions/show/sidebar_actions_component.rb +++ b/app/components/admin/editions/show/sidebar_actions_component.rb @@ -182,6 +182,9 @@ def add_review_reminder_action href:, secondary_quiet: true, }) + if Flipflop.delete_review_reminders? && review_reminder.present? + actions << link_to("Delete review date", confirm_destroy_admin_document_review_reminder_path(@edition.document, @edition.document.review_reminder), class: "govuk-link gem-link--destructive govuk-link--no-visited-state") + end end end diff --git a/app/views/admin/review_reminders/_form.html.erb b/app/views/admin/review_reminders/_form.html.erb index 97043181d37..fff61166578 100644 --- a/app/views/admin/review_reminders/_form.html.erb +++ b/app/views/admin/review_reminders/_form.html.erb @@ -47,9 +47,6 @@ text: "Save", } %> - <% if Flipflop.delete_review_reminders? && review_reminder.persisted? %> - <%= link_to("Delete", confirm_destroy_admin_document_review_reminder_path(document, review_reminder), class: "govuk-link gem-link--destructive govuk-link--no-visited-state") %> - <% end %> <%= link_to("Cancel", admin_edition_path(@document.latest_edition), class: "govuk-link govuk-link--no-visited-state") %> <% end %> diff --git a/app/views/admin/review_reminders/confirm_destroy.html.erb b/app/views/admin/review_reminders/confirm_destroy.html.erb index 85a5910b32c..37b2daec21a 100644 --- a/app/views/admin/review_reminders/confirm_destroy.html.erb +++ b/app/views/admin/review_reminders/confirm_destroy.html.erb @@ -5,6 +5,7 @@
+

Review date: <%= @review_reminder.review_at.strftime("%-d %B %Y") %>

<%= form_tag admin_document_review_reminder_path(@document, @review_reminder), method: :delete do %>

Are you sure you want to delete this review reminder?

@@ -14,7 +15,7 @@ destructive: true, } %> - <%= link_to("Cancel", edit_admin_document_review_reminder_path(@document, @review_reminder), class: "govuk-link govuk-link--no-visited-state") %> + <%= link_to("Cancel", admin_edition_path(@document.latest_edition), class: "govuk-link govuk-link--no-visited-state") %>
<% end %> diff --git a/features/review_reminder.feature b/features/review_reminder.feature index 5ef2475a456..3c23c19d7c6 100644 --- a/features/review_reminder.feature +++ b/features/review_reminder.feature @@ -28,6 +28,7 @@ Feature: Review reminders Given a published publication "Standard Beard Lengths" with a PDF attachment And The delete review reminder feature flag is "enabled" And a review reminder exists for "Standard Beard Lengths" with the date "2032-1-1" - When I click the button "Edit review date" on the edition summary page for "Standard Beard Lengths" - And I delete the review date + When I click the link "Delete review date" on the edition summary page for "Standard Beard Lengths" + Then I should see the review date of "1 January 2032" on the deletion confirmation page + When I delete the review date Then I should not see a review date on the edition summary page diff --git a/features/step_definitions/review_reminder_steps.rb b/features/step_definitions/review_reminder_steps.rb index 9a09e62c0a7..98793759419 100644 --- a/features/step_definitions/review_reminder_steps.rb +++ b/features/step_definitions/review_reminder_steps.rb @@ -24,6 +24,10 @@ assert_selector ".app-view-summary__section .govuk-summary-list__row:nth-child(5) .govuk-summary-list__value", text: date end +Then(/^I should see the review date of "([^"]*)" on the deletion confirmation page$/) do |date| + assert_selector ".govuk-body", text: "Review date: #{date}" +end + Then(/^I should not see a review date on the edition summary page$/) do assert_selector ".app-view-summary__section .govuk-summary-list__row:nth-child(5) .govuk-summary-list__key", text: "Review date" assert_selector ".app-view-summary__section .govuk-summary-list__row:nth-child(5) .govuk-summary-list__value", text: "Not set" @@ -35,6 +39,12 @@ click_on label end +When(/^I click the link "([^"]*)" on the edition summary page for "([^"]*)"$/) do |label, title| + edition = Edition.find_by!(title:) + visit admin_edition_path(edition) + click_link label +end + And(/^a review reminder exists for "([^"]*)" with the date "([^"]*)"$/) do |title, date| edition = Edition.find_by!(title:) create(:review_reminder, document: edition.document, review_at: date) @@ -57,6 +67,5 @@ end And(/^I delete the review date$/) do - click_link "Delete" click_button "Delete" end diff --git a/test/components/admin/editions/show/sidebar_actions_component_test.rb b/test/components/admin/editions/show/sidebar_actions_component_test.rb index 96565726db1..2d9fcced99a 100644 --- a/test/components/admin/editions/show/sidebar_actions_component_test.rb +++ b/test/components/admin/editions/show/sidebar_actions_component_test.rb @@ -26,6 +26,23 @@ class Admin::Editions::Show::SidebarActionsComponentTest < ViewComponent::TestCa assert_selector "a[href='https://www.test.gov.uk/government/generic-editions/#{edition.title}']", text: "View on website (opens in new tab)" end + test "actions for published edition with review date" do + @test_strategy ||= Flipflop::FeatureSet.current.test! + @test_strategy.switch!(:delete_review_reminders, true) + current_user = build_stubbed(:user) + edition = create(:published_edition) + create(:review_reminder, :reminder_due, document: edition.document) + render_inline(Admin::Editions::Show::SidebarActionsComponent.new(edition:, current_user:)) + + assert_selector "li", count: 5 + assert_selector "button", text: "Create new edition" + assert_selector "a", text: "Edit review date" + assert_selector "a", text: "Delete review date" + assert_selector "a", text: "View data about page" + assert_selector "a[href='https://www.test.gov.uk/government/generic-editions/#{edition.title}']", text: "View on website (opens in new tab)" + @test_strategy.switch!(:delete_review_reminders, false) + end + test "actions for published edition for non-english document" do current_user = build_stubbed(:user) edition = create(:non_english_published_edition)