Skip to content

Commit

Permalink
add change notes to document timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Harriethw committed Jan 28, 2025
1 parent 544fa51 commit 2449ba4
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
}
}

.timeline__header {
margin-bottom: govuk-spacing(1);
}

.timeline__item {
padding-bottom: govuk-spacing(6);
padding-left: govuk-spacing(4);
Expand Down Expand Up @@ -51,8 +55,8 @@

.timeline__date {
@include govuk-font($size: 16);
margin-top: govuk-spacing(1);
margin-bottom: 0;
margin-top: govuk-spacing(2);
margin-bottom: govuk-spacing(2);
}

.timeline__description {
Expand Down Expand Up @@ -80,3 +84,9 @@
padding-left: 0;
}
}

.timeline__note {
.govuk-body {
margin-bottom: govuk-spacing(2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
<% end %>
</div>
<% end %>

<div>
<% if item[:internal_change_note].present? %>
<div class="timeline__note">
<h2 class="timeline__title">Internal note</h2>
<p class="govuk-body"><%= item[:internal_change_note] %></p>
</div>
<% end %>

<% if item[:change_note].present? %>
<div class="timeline__note">
<h2 class="timeline__title">Public note</h2>
<p class="govuk-body"><%= item[:change_note] %></p>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def items
byline: User.find_by_id(version.whodunnit)&.then { |user| helpers.linked_author(user, { class: "govuk-link" }) } || "unknown user",
date: time_html(version.created_at),
table_rows: table_rows(version),
internal_change_note: internal_change_note(version),
change_note: change_note(version),
}
end
end
Expand Down Expand Up @@ -47,4 +49,12 @@ def table_rows(version)
end
end
end

def internal_change_note(version)
version.item.internal_change_note
end

def change_note(version)
version.item.change_note
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Feature: Edit a content object
Then the edition should have been updated successfully
And I should be taken back to the document page
And I should see 2 publish events on the timeline
And I should see the notes on the timeline
And I should see the edition diff in a table

Scenario: GDS editor cancels the creation of an object when reviewing links
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
expect(page).to have_selector(".timeline__title", text: "Email address published", count:)
end

Then("I should see the notes on the timeline") do
expect(page).to have_selector("p", text: @internal_note)
expect(page).to have_selector("p", text: @change_note)
end

Then("I should see the publish event on the timeline") do
expect(page).to have_selector(".timeline__title", text: "Email address published")
expect(page).to have_selector(".timeline__byline", text: "by Scheduled Publishing Robot")
Expand Down
6 changes: 4 additions & 2 deletions lib/engines/content_block_manager/features/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ def update_content_block
end

def add_internal_note
fill_in "Describe the change for internal users", with: "Some internal note goes here"
@internal_note = "Some internal note goes here"
fill_in "Describe the change for internal users", with: @internal_note
click_save_and_continue
end

def add_change_note
@change_note = "Some text"
choose "Yes - information has been added, updated or removed"
fill_in "Describe the edit for users", with: "Some text"
fill_in "Describe the edit for users", with: @change_note
click_save_and_continue
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,30 @@ class ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineCompone
include ActionView::Helpers::UrlHelper
include ApplicationHelper
extend Minitest::Spec::DSL

let(:user) { create(:user) }

test "renders a timeline component with events in correct order" do
item = build(:content_block_edition, :email_address, change_note: nil, internal_change_note: nil)
version_1 = create(
:content_block_version,
event: "created",
whodunnit: user.id,
item:,
)
version_2 = create(
:content_block_version,
event: "updated",
whodunnit: user.id,
state: "published",
item:,
)
version_3 = create(
:content_block_version,
event: "updated",
whodunnit: user.id,
state: "scheduled",
item:,
)

render_inline(ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineComponent.new(
Expand All @@ -44,6 +48,8 @@ class ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineCompone
page.all("time[datetime='#{version_2.created_at.iso8601}']")[1].text

assert_no_selector ".govuk-table"
assert_no_selector "h2", text: "Internal note"
assert_no_selector "h2", text: "Public note"
end

test "renders the edition diff table in correct order" do
Expand Down Expand Up @@ -83,4 +89,36 @@ class ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineCompone
assert_equal "old instructions", page.all("td")[4].text
assert_equal "new instructions", page.all("td")[5].text
end

test "renders an internal change note" do
edition = create(:content_block_edition, :email_address, internal_change_note: "changed x to y")
version = create(
:content_block_version,
item: edition,
event: "updated",
state: "published",
)

render_inline(ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineComponent.new(
content_block_versions: [version],
))

assert_selector "p", text: "changed x to y"
end

test "renders a public change note" do
edition = create(:content_block_edition, :email_address, change_note: "changed a to b")
version = create(
:content_block_version,
item: edition,
event: "updated",
state: "published",
)

render_inline(ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineComponent.new(
content_block_versions: [version],
))

assert_selector "p", text: "changed a to b"
end
end

0 comments on commit 2449ba4

Please sign in to comment.