Skip to content

Commit

Permalink
Add skip fact check to admin tab when edition is in fact check
Browse files Browse the repository at this point in the history
  • Loading branch information
syed-ali-tw committed Oct 25, 2024
1 parent ab9040d commit 46612d6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/helpers/tabbed_nav_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def current_tab_name
"metadata"
when "unpublish"
"unpublish"
when "admin"
"admin"
else
"temp_nav_text"
end
Expand Down
14 changes: 14 additions & 0 deletions app/views/editions/secondary_nav_tabs/_admin.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% @edition = @resource %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= header_for("Admin") %>
<% if @edition.fact_check? %>
<%= form_for @edition, url: skip_fact_check_for_edition(@edition), method: "post" do %>
<%= render "govuk_publishing_components/components/button", {
text: "Skip fact check",
} %>
<% end %>
<% end %>
</div>
</div>
44 changes: 44 additions & 0 deletions test/integration/edition_edit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ class EditionEditTest < IntegrationTest
assert page.has_field?("artefact[slug]", with: "changed-slug")
end
end

context "admin tab" do
setup do
click_link("Admin")
end
should "show 'Admin' header and not show 'Skip fact check' button" do
within :css, ".gem-c-heading" do
assert page.has_text?("Admin")
end
assert page.has_no_button?("Skip fact check")
end
end
end

context "when edition is published" do
Expand Down Expand Up @@ -157,5 +169,37 @@ class EditionEditTest < IntegrationTest
assert page.has_link?("Cancel")
end
end

context "admin tab" do
setup do
click_link("Admin")
end

should "show 'Admin' header and not show 'Skip fact check' button" do
within :css, ".gem-c-heading" do
assert page.has_text?("Admin")
end
assert page.has_no_button?("Skip fact check")
end
end
end

context "when edition state is 'fact_check'" do
setup do
edition = FactoryBot.create(:guide_edition, title: "Edit page title", state: "fact_check")
visit edition_path(edition)
click_link("Admin")
end

context "admin tab" do
context "when state is 'fact_check'" do
should "show 'Admin' header and an 'Skip fact check' button" do
within :css, ".gem-c-heading" do
assert page.has_text?("Admin")
end
assert page.has_button?("Skip fact check")
end
end
end
end
end

0 comments on commit 46612d6

Please sign in to comment.