From bd3e0c18054fd97a22f037417aa31a62ab8356d7 Mon Sep 17 00:00:00 2001 From: Helen Pickavance Date: Thu, 6 Feb 2025 18:52:57 +0000 Subject: [PATCH 1/4] Add Update Important Note functionality - Add cancel link and important note information. - Add hidden field tag for note type. - Conditionally render _important_note partial if note exists - Include original important note text in update important note text area --- app/controllers/editions_controller.rb | 4 ++ app/views/editions/_important_note.html.erb | 6 ++ .../secondary_nav_tabs/_history.html.erb | 6 ++ .../update_important_note.html.erb | 33 ++++++++++ app/views/editions/show.html.erb | 12 +++- config/routes.rb | 1 + test/functional/notes_controller_test.rb | 21 +++++++ test/integration/edition_edit_test.rb | 62 +++++++++++++++++++ 8 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 app/views/editions/_important_note.html.erb create mode 100644 app/views/editions/secondary_nav_tabs/update_important_note.html.erb diff --git a/app/controllers/editions_controller.rb b/app/controllers/editions_controller.rb index da44874c2..ce82ad98a 100644 --- a/app/controllers/editions_controller.rb +++ b/app/controllers/editions_controller.rb @@ -159,6 +159,10 @@ def add_edition_note render "secondary_nav_tabs/add_edition_note" end + def update_important_note + render "secondary_nav_tabs/update_important_note" + end + def destroy @resource.destroy! flash[:success] = "Edition deleted" diff --git a/app/views/editions/_important_note.html.erb b/app/views/editions/_important_note.html.erb new file mode 100644 index 000000000..c15ba82c0 --- /dev/null +++ b/app/views/editions/_important_note.html.erb @@ -0,0 +1,6 @@ +<%= render "govuk_publishing_components/components/notice", { + description_govspeak: sanitize("

#{h(@edition.important_note&.comment)}

") + + sanitize("

#{h(User.find_by(id: @edition.important_note&.requester_id)&.name)} added an important note on + #{h(@edition.important_note&.created_at&.strftime("%d %B %Y"))}

"), + show_banner_title: true +} %> \ No newline at end of file diff --git a/app/views/editions/secondary_nav_tabs/_history.html.erb b/app/views/editions/secondary_nav_tabs/_history.html.erb index 7344df759..301071e10 100644 --- a/app/views/editions/secondary_nav_tabs/_history.html.erb +++ b/app/views/editions/secondary_nav_tabs/_history.html.erb @@ -19,6 +19,12 @@ margin_bottom: 3, href: history_add_edition_note_edition_path, }), + (render "govuk_publishing_components/components/button", { + text: "Update important note", + margin_bottom: 3, + secondary_solid: true, + href: history_update_important_note_edition_path, + }), ], } %> diff --git a/app/views/editions/secondary_nav_tabs/update_important_note.html.erb b/app/views/editions/secondary_nav_tabs/update_important_note.html.erb new file mode 100644 index 000000000..6f6b89825 --- /dev/null +++ b/app/views/editions/secondary_nav_tabs/update_important_note.html.erb @@ -0,0 +1,33 @@ +<% @edition = @resource %> +<% content_for :title_context, @edition.title %> +<% content_for :page_title, "Update important note" %> +<% content_for :title, "Update important note" %> + +
+
+

Add important notes that anyone who works on this edition needs to see, eg “(Doesn’t) need fact check, don’t publish.”. + Each edition can have only one important note at a time.

+ + <%= form_for(:note, :url=> notes_path) do |f| %> + <%= hidden_field_tag :edition_id, resource.id %> + <%= hidden_field_tag "note[type]", Action::IMPORTANT_NOTE %> + + <%= render "govuk_publishing_components/components/textarea", { + label: { + heading_size: "m", + text: "Important note", + }, + name: "note[comment]", + rows: 14, + value: @edition.important_note&.comment, + } %> + +
+ <%= render "govuk_publishing_components/components/button", { + text: "Save", + } %> + <%= link_to("Cancel", history_edition_path, class: "govuk-link govuk-link--no-visited-state") %> +
+ <% end %> +
+
diff --git a/app/views/editions/show.html.erb b/app/views/editions/show.html.erb index 33ecc1ec7..daba2b71d 100644 --- a/app/views/editions/show.html.erb +++ b/app/views/editions/show.html.erb @@ -20,8 +20,16 @@
- <%= render "govuk_publishing_components/components/summary_list", { - items: document_summary_items(@resource), + <%= render "govuk_publishing_components/components/summary_list", { + items: document_summary_items(@resource), + } %> +
+ +
+ <%= render "govuk_publishing_components/components/notice", { + title: @edition.important_note.comment, + description_govspeak: sanitize("

#{User.find_by(id: @edition.important_note.requester_id).name} added an important note on #{@edition.important_note.created_at.strftime("%d %B %Y")}

"), + show_banner_title: true } %>
diff --git a/config/routes.rb b/config/routes.rb index c8e1517da..0a70d2e3f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,7 @@ get "metadata" get "history" get "history/add_edition_note", to: "editions#add_edition_note", as: "history/add_edition_note" + get "history/update_important_note", to: "editions#update_important_note", as: "history/update_important_note" get "admin" post "duplicate" get "related_external_links" diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index d7499c803..63d033582 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -49,6 +49,27 @@ class NotesControllerTest < ActionController::TestCase end end + context "when an Important note is provided" do + should "confirm the note was successfully recorded" do + post :create, + params: { + edition_id: @edition.id, + note: { + type: "important_note", + comment: @note_text, + }, + } + + @edition.reload + + assert_equal(@note_text, @edition.important_note.comment) + assert_redirected_to history_edition_path(@edition) + assert_includes flash[:success], "Note recorded" + end + end + + # TODO: Test that a blank note is saved and message is "Note resolved" + context "Welsh editors" do setup do login_as_welsh_editor diff --git a/test/integration/edition_edit_test.rb b/test/integration/edition_edit_test.rb index cb7c57c46..d99c2d33a 100644 --- a/test/integration/edition_edit_test.rb +++ b/test/integration/edition_edit_test.rb @@ -56,6 +56,16 @@ class EditionEditTest < IntegrationTest assert_selector(".govuk-summary-list__value", text: @draft_edition.assignee) end end + + should "display the important note if an important note exists" do + setup do + @note_text = "This is really really urgent!" + create_important_note_for_edition(@published_edition, @note_text) + end + + assert page.has_text?("Important") + assert page.has_text?(@note_text) + end end context "edit assignee page" do @@ -134,6 +144,16 @@ class EditionEditTest < IntegrationTest assert_current_path history_add_edition_note_edition_path(@draft_edition.id) end + + should "show an 'Update important note' button" do + assert page.has_link?("Update important note") + end + + should "navigate to the 'Update important note' page when the button is clicked" do + click_link("Update important note") + + assert_current_path history_update_important_note_edition_path(@draft_edition.id) + end end context "Add edition note page" do @@ -162,6 +182,39 @@ class EditionEditTest < IntegrationTest end end + context "Update important note page" do + setup do + visit_draft_edition + click_link("History and notes") + click_link("Update important note") + end + + should "render the 'Update important note' page" do + within :css, ".gem-c-heading" do + assert page.has_css?("h1", text: "Update important note") + assert page.has_css?(".gem-c-heading__context", text: @draft_edition.title) + end + + assert page.has_text?("Add important notes that anyone who works on this edition needs to see, eg “(Doesn’t) need fact check, don’t publish.”.") + assert page.has_text?("Each edition can have only one important note at a time.") + + within :css, ".gem-c-textarea" do + assert page.has_css?("label", text: "Important note") + assert page.has_css?("textarea") + end + + assert page.has_button?("Save") + assert page.has_link?("Cancel") + end + + should "pre-populate with the existing note" do + create_important_note_for_edition(@draft_edition, "An updated note") + click_link("Update important note") + + assert page.has_field?("Important note", with: "An updated note") + end + end + context "unpublish tab" do context "user does not have required permissions" do setup do @@ -1078,4 +1131,13 @@ def visit_old_edition_of_published_edition ) visit edition_path(published_edition) end + + def create_important_note_for_edition(edition, note_text) + FactoryBot.create( + :action, + request_type: Action::IMPORTANT_NOTE, + edition: edition, + comment: note_text, + ) + end end From 859be859ad83fae7d1f3f3df6aa8268760e36031 Mon Sep 17 00:00:00 2001 From: PeterHattyar Date: Wed, 19 Feb 2025 16:28:52 +0000 Subject: [PATCH 2/4] Integration and functionality testing - Handle blank important note saving, whether an important note is present. - Tests for New Edition and Edition History functionality are in place. These will have to be un-skipped in the future, when the functionality is ready. - Refactor for PR comments --- app/controllers/notes_controller.rb | 6 +- app/views/editions/_important_note.html.erb | 11 ++- .../update_important_note.html.erb | 10 ++- app/views/editions/show.html.erb | 15 ++-- test/functional/notes_controller_test.rb | 48 +++++++++- test/integration/edition_edit_test.rb | 88 +++++++++++++++---- test/support/factories.rb | 7 ++ 7 files changed, 140 insertions(+), 45 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 9477fe4bd..12ca55b80 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -22,11 +22,6 @@ def create end end - def resolve - resolve_important_note - redirect_to history_edition_path(parent) - end - def resource parent end @@ -38,5 +33,6 @@ def resolve_important_note current_user.resolve_important_note(parent) flash[:success] = "Note resolved" end + redirect_to history_edition_path(parent) end end diff --git a/app/views/editions/_important_note.html.erb b/app/views/editions/_important_note.html.erb index c15ba82c0..22ee572fc 100644 --- a/app/views/editions/_important_note.html.erb +++ b/app/views/editions/_important_note.html.erb @@ -1,6 +1,9 @@ +<% note_author_name = User.find_by(id: @edition.important_note&.requester_id).name %> +<% note_date = @edition.important_note&.created_at&.strftime("%d %B %Y") %> +<% note_details = @edition.important_note&.comment %> <%= render "govuk_publishing_components/components/notice", { - description_govspeak: sanitize("

#{h(@edition.important_note&.comment)}

") + - sanitize("

#{h(User.find_by(id: @edition.important_note&.requester_id)&.name)} added an important note on - #{h(@edition.important_note&.created_at&.strftime("%d %B %Y"))}

"), - show_banner_title: true + description_govspeak: + sanitize("

#{h(note_details)}

") + + sanitize("

#{h(note_author_name)} added an important note on #{h(note_date)}

"), + show_banner_title: true, } %> \ No newline at end of file diff --git a/app/views/editions/secondary_nav_tabs/update_important_note.html.erb b/app/views/editions/secondary_nav_tabs/update_important_note.html.erb index 6f6b89825..6c77d0d6b 100644 --- a/app/views/editions/secondary_nav_tabs/update_important_note.html.erb +++ b/app/views/editions/secondary_nav_tabs/update_important_note.html.erb @@ -5,11 +5,13 @@
-

Add important notes that anyone who works on this edition needs to see, eg “(Doesn’t) need fact check, don’t publish.”. - Each edition can have only one important note at a time.

+

+ Add important notes that anyone who works on this edition needs to see, eg “(Doesn’t) need fact check, don’t publish.”. + Each edition can have only one important note at a time. +

- <%= form_for(:note, :url=> notes_path) do |f| %> - <%= hidden_field_tag :edition_id, resource.id %> + <%= form_for(:note, :url=> notes_path) do %> + <%= hidden_field_tag :edition_id, @edition.id %> <%= hidden_field_tag "note[type]", Action::IMPORTANT_NOTE %> <%= render "govuk_publishing_components/components/textarea", { diff --git a/app/views/editions/show.html.erb b/app/views/editions/show.html.erb index daba2b71d..98e97476e 100644 --- a/app/views/editions/show.html.erb +++ b/app/views/editions/show.html.erb @@ -20,17 +20,12 @@
- <%= render "govuk_publishing_components/components/summary_list", { - items: document_summary_items(@resource), - } %> -
- -
- <%= render "govuk_publishing_components/components/notice", { - title: @edition.important_note.comment, - description_govspeak: sanitize("

#{User.find_by(id: @edition.important_note.requester_id).name} added an important note on #{@edition.important_note.created_at.strftime("%d %B %Y")}

"), - show_banner_title: true + <%= render "govuk_publishing_components/components/summary_list", { + items: document_summary_items(@resource), } %> + <% if @edition.important_note %> + <%= render partial: "important_note" %> + <% end %>
<% if @edition.in_review? && current_user.has_editor_permissions?(@edition) %> diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index 63d033582..a27409c84 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -49,7 +49,7 @@ class NotesControllerTest < ActionController::TestCase end end - context "when an Important note is provided" do + context "when an important note is provided" do should "confirm the note was successfully recorded" do post :create, params: { @@ -66,9 +66,51 @@ class NotesControllerTest < ActionController::TestCase assert_redirected_to history_edition_path(@edition) assert_includes flash[:success], "Note recorded" end - end - # TODO: Test that a blank note is saved and message is "Note resolved" + should "resolve important note if an empty note is saved, when an important note is already present" do + post :create, + params: { + edition_id: @edition.id, + note: { + type: "important_note", + comment: @note_text, + }, + } + + @edition.reload + + post :create, + params: { + edition_id: @edition.id, + note: { + type: "important_note", + comment: "", + }, + } + + @edition.reload + + # assert_equal("", @edition.important_note&.comment) + assert @edition.important_note.nil? + assert_redirected_to history_edition_path(@edition) + assert_includes flash[:success], "Note resolved" + end + + should "redirect to edit page if user saves an empty note, when there's no important note on the document already" do + post :create, + params: { + edition_id: @edition.id, + note: { + type: "important_note", + comment: "", + }, + } + + @edition.reload + + assert_redirected_to history_edition_path(@edition) + end + end context "Welsh editors" do setup do diff --git a/test/integration/edition_edit_test.rb b/test/integration/edition_edit_test.rb index d99c2d33a..6305846cd 100644 --- a/test/integration/edition_edit_test.rb +++ b/test/integration/edition_edit_test.rb @@ -15,11 +15,9 @@ class EditionEditTest < IntegrationTest end context "edit page" do - setup do + should "show all the tabs when user has required permission and edition is published" do visit_published_edition - end - should "show all the tabs when user has required permission and edition is published" do assert page.has_text?("Edit") assert page.has_text?("Tagging") assert page.has_text?("Metadata") @@ -30,6 +28,8 @@ class EditionEditTest < IntegrationTest end should "show document summary and title" do + visit_published_edition + assert page.has_title?("Edit page title") row = find_all(".govuk-summary-list__row") @@ -42,6 +42,8 @@ class EditionEditTest < IntegrationTest end should "indicate when an edition does not have an assignee" do + visit_published_edition + within all(".govuk-summary-list__row")[0] do assert_selector(".govuk-summary-list__key", text: "Assigned to") assert_selector(".govuk-summary-list__value", text: "None") @@ -58,13 +60,27 @@ class EditionEditTest < IntegrationTest end should "display the important note if an important note exists" do - setup do - @note_text = "This is really really urgent!" - create_important_note_for_edition(@published_edition, @note_text) - end + note_text = "This is really really urgent!" + create_draft_edition + create_important_note_for_edition(@draft_edition, note_text) + visit edition_path(@draft_edition) assert page.has_text?("Important") - assert page.has_text?(@note_text) + assert page.has_text?(note_text) + end + + should "display only the most recent important note at the top" do + first_note = "This is really really urgent!" + second_note = "This should display only!" + create_draft_edition + create_important_note_for_edition(@draft_edition, first_note) + create_important_note_for_edition(@draft_edition, second_note) + + visit edition_path(@draft_edition) + + assert page.has_text?("Important") + assert page.has_text?(second_note) + assert page.has_no_text?(first_note) end end @@ -183,13 +199,10 @@ class EditionEditTest < IntegrationTest end context "Update important note page" do - setup do - visit_draft_edition - click_link("History and notes") - click_link("Update important note") - end - should "render the 'Update important note' page" do + create_draft_edition + visit history_update_important_note_edition_path(@draft_edition) + within :css, ".gem-c-heading" do assert page.has_css?("h1", text: "Update important note") assert page.has_css?(".gem-c-heading__context", text: @draft_edition.title) @@ -208,10 +221,43 @@ class EditionEditTest < IntegrationTest end should "pre-populate with the existing note" do - create_important_note_for_edition(@draft_edition, "An updated note") - click_link("Update important note") + note_text = "This is really really urgent!" + create_draft_edition + create_important_note_for_edition(@draft_edition, note_text) + visit history_update_important_note_edition_path(@draft_edition) + + assert page.has_field?("Important note", with: note_text) + end + + # TODO: Test to be switched on when the Edition notes history is implemented. + should "not show important notes in edition history" do + skip "Until this functionality is complete: #603 - History and notes tab (excluding sidebar) [Edit page]" + note_text = "This is really really urgent!" + note_text_2 = "Another note" + note_text_3 = "Yet another note" + create_draft_edition + create_important_note_for_edition(@draft_edition, note_text) + create_important_note_for_edition(@draft_edition, note_text_2) + create_important_note_for_edition(@draft_edition, note_text_3) + visit edition_path(@draft_edition) + click_link("History and notes") - assert page.has_field?("Important note", with: "An updated note") + # TODO: Expand 'All Notes' sections! Currently in progress. + # New asserts go here + end + + # TODO: Test to be switched on when the "Create new edition" functionality has been implemented. + should "not be carried forward to new editions" do + skip "Until this functionality is complete: #601 - Edit page for Published edition (answer and help)" + note_text = "This important note should not appear on a new edition." + create_published_edition + create_important_note_for_edition(@published_edition, note_text) + visit edition_path(@published_edition) + + assert page.has_content? note_text + + click_on "Create new edition" + assert page.has_no_text?("Important note") end end @@ -1027,8 +1073,12 @@ class EditionEditTest < IntegrationTest private - def visit_draft_edition + def create_draft_edition @draft_edition = FactoryBot.create(:edition, title: "Edit page title", state: "draft", overview: "metatags", in_beta: 1, body: "The body") + end + + def visit_draft_edition + create_draft_edition visit edition_path(@draft_edition) end @@ -1101,7 +1151,6 @@ def create_published_edition state: "published", slug: "can-i-get-a-driving-licence", ) - visit edition_path(@published_edition) end def visit_retired_edition_in_published @@ -1135,6 +1184,7 @@ def visit_old_edition_of_published_edition def create_important_note_for_edition(edition, note_text) FactoryBot.create( :action, + requester: @govuk_editor, request_type: Action::IMPORTANT_NOTE, edition: edition, comment: note_text, diff --git a/test/support/factories.rb b/test/support/factories.rb index d01d31bc6..9921031a8 100644 --- a/test/support/factories.rb +++ b/test/support/factories.rb @@ -384,4 +384,11 @@ end end end + + factory :action do + request_type { Action::IMPORTANT_NOTE } + edition + requester { FactoryBot.create(:user) } + comment { "Default comment" } + end end From aadf4da30255ad049e38920824a4b369870df5f2 Mon Sep 17 00:00:00 2001 From: Helen Pickavance Date: Mon, 3 Mar 2025 14:38:11 +0000 Subject: [PATCH 3/4] Change functionality to allow user to 'resolve' the current important note by saving an empty note --- app/controllers/notes_controller.rb | 2 +- app/views/editions/_important_note.html.erb | 2 +- .../update_important_note.html.erb | 3 ++ test/functional/notes_controller_test.rb | 34 ++++++++++++++----- test/integration/edition_edit_test.rb | 7 ++-- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 12ca55b80..3f931acea 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -18,7 +18,7 @@ def create redirect_to history_edition_path(parent) else flash[:danger] = "Note failed to save" - redirect_to history_add_edition_note_edition_path(resource) + redirect_to type == Action::IMPORTANT_NOTE ? history_update_important_note_edition_path(resource) : history_add_edition_note_edition_path(resource) end end diff --git a/app/views/editions/_important_note.html.erb b/app/views/editions/_important_note.html.erb index 22ee572fc..33508dedb 100644 --- a/app/views/editions/_important_note.html.erb +++ b/app/views/editions/_important_note.html.erb @@ -6,4 +6,4 @@ sanitize("

#{h(note_details)}

") + sanitize("

#{h(note_author_name)} added an important note on #{h(note_date)}

"), show_banner_title: true, -} %> \ No newline at end of file +} %> diff --git a/app/views/editions/secondary_nav_tabs/update_important_note.html.erb b/app/views/editions/secondary_nav_tabs/update_important_note.html.erb index 6c77d0d6b..117015ee6 100644 --- a/app/views/editions/secondary_nav_tabs/update_important_note.html.erb +++ b/app/views/editions/secondary_nav_tabs/update_important_note.html.erb @@ -9,6 +9,9 @@ Add important notes that anyone who works on this edition needs to see, eg “(Doesn’t) need fact check, don’t publish.”. Each edition can have only one important note at a time.

+

+ To delete the important note, clear any comments and select ‘Save’. +

<%= form_for(:note, :url=> notes_path) do %> <%= hidden_field_tag :edition_id, @edition.id %> diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index a27409c84..38149ab7b 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -49,8 +49,8 @@ class NotesControllerTest < ActionController::TestCase end end - context "when an important note is provided" do - should "confirm the note was successfully recorded" do + context "when an Important note is provided" do + should "show 'Note recorded' and save a completed note" do post :create, params: { edition_id: @edition.id, @@ -67,13 +67,13 @@ class NotesControllerTest < ActionController::TestCase assert_includes flash[:success], "Note recorded" end - should "resolve important note if an empty note is saved, when an important note is already present" do + should "show 'Note resolved' if a parent note exists and then an empty note is saved" do post :create, params: { edition_id: @edition.id, note: { type: "important_note", - comment: @note_text, + comment: "Parent note", }, } @@ -87,16 +87,14 @@ class NotesControllerTest < ActionController::TestCase comment: "", }, } - @edition.reload - # assert_equal("", @edition.important_note&.comment) - assert @edition.important_note.nil? + assert_nil(@edition.important_note) assert_redirected_to history_edition_path(@edition) assert_includes flash[:success], "Note resolved" end - should "redirect to edit page if user saves an empty note, when there's no important note on the document already" do + should "show no flash message if no parent note exists and then an empty note is saved" do post :create, params: { edition_id: @edition.id, @@ -106,9 +104,27 @@ class NotesControllerTest < ActionController::TestCase }, } + assert_nil(@edition.important_note) + assert_redirected_to history_edition_path(@edition) + assert flash.empty?, "Expected no flash message, but found: #{flash.inspect}" + end + + should "show 'Note failed to save' if an error occurs while saving the Important note" do + @user.stubs(:record_note).with(@edition, @note_text, "important_note").returns(false) + + post :create, + params: { + edition_id: @edition.id, + note: { + type: "important_note", + comment: @note_text, + }, + } + @edition.reload - assert_redirected_to history_edition_path(@edition) + assert_redirected_to history_update_important_note_edition_path(@edition) + assert_includes flash[:danger], "Note failed to save" end end diff --git a/test/integration/edition_edit_test.rb b/test/integration/edition_edit_test.rb index 6305846cd..99894c58f 100644 --- a/test/integration/edition_edit_test.rb +++ b/test/integration/edition_edit_test.rb @@ -65,8 +65,10 @@ class EditionEditTest < IntegrationTest create_important_note_for_edition(@draft_edition, note_text) visit edition_path(@draft_edition) - assert page.has_text?("Important") - assert page.has_text?(note_text) + within :css, ".govuk-notification-banner" do + assert page.has_text?("Important") + assert page.has_text?(note_text) + end end should "display only the most recent important note at the top" do @@ -210,6 +212,7 @@ class EditionEditTest < IntegrationTest assert page.has_text?("Add important notes that anyone who works on this edition needs to see, eg “(Doesn’t) need fact check, don’t publish.”.") assert page.has_text?("Each edition can have only one important note at a time.") + assert page.has_text?("To delete the important note, clear any comments and select ‘Save’.") within :css, ".gem-c-textarea" do assert page.has_css?("label", text: "Important note") From 9b0c980591dfac8af25d86dd2d4bc031fb9e4624 Mon Sep 17 00:00:00 2001 From: Helen Pickavance Date: Wed, 5 Mar 2025 11:18:52 +0000 Subject: [PATCH 4/4] Unskip test now that edit state for published editions is merged --- test/functional/notes_controller_test.rb | 6 +++--- test/integration/edition_edit_test.rb | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index 38149ab7b..acf902186 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -64,7 +64,7 @@ class NotesControllerTest < ActionController::TestCase assert_equal(@note_text, @edition.important_note.comment) assert_redirected_to history_edition_path(@edition) - assert_includes flash[:success], "Note recorded" + assert_equal "Note recorded", flash[:success] end should "show 'Note resolved' if a parent note exists and then an empty note is saved" do @@ -91,7 +91,7 @@ class NotesControllerTest < ActionController::TestCase assert_nil(@edition.important_note) assert_redirected_to history_edition_path(@edition) - assert_includes flash[:success], "Note resolved" + assert_equal "Note resolved", flash[:success] end should "show no flash message if no parent note exists and then an empty note is saved" do @@ -124,7 +124,7 @@ class NotesControllerTest < ActionController::TestCase @edition.reload assert_redirected_to history_update_important_note_edition_path(@edition) - assert_includes flash[:danger], "Note failed to save" + assert_equal "Note failed to save", flash[:danger] end end diff --git a/test/integration/edition_edit_test.rb b/test/integration/edition_edit_test.rb index 99894c58f..6577e095b 100644 --- a/test/integration/edition_edit_test.rb +++ b/test/integration/edition_edit_test.rb @@ -249,9 +249,7 @@ class EditionEditTest < IntegrationTest # New asserts go here end - # TODO: Test to be switched on when the "Create new edition" functionality has been implemented. should "not be carried forward to new editions" do - skip "Until this functionality is complete: #601 - Edit page for Published edition (answer and help)" note_text = "This important note should not appear on a new edition." create_published_edition create_important_note_for_edition(@published_edition, note_text)