Skip to content

Commit

Permalink
Merge pull request #411 from alphagov/use_data_test_attribute_in_audi…
Browse files Browse the repository at this point in the history
…t_content_item_page_model

Refactor audit content item page object
  • Loading branch information
pmanrubia authored Nov 22, 2017
2 parents 5cf2f96 + 748075d commit b8a308a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion app/views/audits/audits/_boolean_question.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="row <%= attribute.to_s.dasherize %>">
<div class="row <%= attribute.to_s.dasherize %>" data-test-id="<%= attribute.to_s.dasherize %>">
<div class="col-sm-8">
<p><%= question %></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/audits/audits/_free_text_question.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row <% unless related_question_answered %>if-js-hide<% end %> <%= attribute.to_s.dasherize %> js-free-text-question">
<div class="col-sm-12">
<%= form.label attribute, question %>
<%= form.text_area attribute, class: 'form-control' %>
<%= form.text_area attribute, class: 'form-control', data: { test_id: attribute.to_s.dasherize } %>
</div>
</div>
34 changes: 18 additions & 16 deletions app/views/audits/audits/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="audit-content-item col-sm-7">
<% if flash.notice %>
<div class="alert alert-success" role="alert">
<div class="alert alert-success" role="alert" data-test-id="audit-success-message">
<p>
<%= flash.notice %>
</p>
Expand All @@ -18,9 +18,11 @@
<%= link_to "< All items", audits_path(filter_params.without(:page)), class: "all-items" %>
</nav>

<h2><%= link_to content_item.title, content_item.url, target: :_blank %></h2>
<h2 data-test-id='content-item-title'>
<%= link_to content_item.title, content_item.url, target: :_blank %>
</h2>

<p class="description">
<p class="description" data-test-id="content-item-description">
<%= content_item.description %>
</p>

Expand All @@ -29,12 +31,12 @@
<%= link_to "Audit guidance", audits_guidance_path, target: "_blank", rel: "noopener noreferrer" %>

<% if audit.errors.any? %>
<div class="alert alert-danger" role="alert">
<div class="alert alert-danger" role="alert" data-test-id="audit-error-message">
<p>Please answer all the questions.</p>
</div>
<% end %>

<h4>Do these things need to change?</h4>
<h4 data-test-id="questions-title">Do these things need to change?</h4>

<%= form_for audit, url: content_item_audit_path(filter_params) do |form| %>
<%= render 'boolean_question', form: form,
Expand Down Expand Up @@ -88,15 +90,15 @@
question: 'Notes',
related_question_answered: {} %>

<%= form.submit "Save and continue", class: "btn btn-success" %>
<%= form.submit "Save and continue", class: "btn btn-success", data: { test_id: 'save-audit-form'} %>
<% end %>
</div>

<div class="col-sm-1"></div>

<div class="col-sm-4">
<div id="metadata" class="audit-metadata">
<div id="allocated">
<div id="allocated" data-test-id="allocated" >
<h4>Assigned to</h4>
<% if content_item.allocation %>
<p><%= content_item.auditor %></p>
Expand All @@ -105,7 +107,7 @@
<p>No one</p>
<% end %>
</div>
<div id="audited">
<div id="audited" data-test-id="audited">
<h4>Audited</h4>

<% if audit.incomplete? %>
Expand All @@ -117,42 +119,42 @@
<% end %>
</div>

<div id="organisations">
<div id="organisations" data-test-id="organisations">
<h4>Organisations</h4>
<p><%= content_item.organisations %></p>
</div>

<div id="last-updated">
<div id="last-updated" data-test-id="last-updated">
<h4>Last major update</h4>
<p><%= content_item.last_updated %></p>
</div>

<div id="content-type">
<div id="content-type" data-test-id="content-type">
<h4>Content type</h4>
<p><%= content_item.document_type %></p>
</div>

<div id="guidance">
<div id="guidance" data-test-id="guidance">
<h4>Guidance</h4>
<p><%= content_item.guidance %></p>
</div>

<div id="topics">
<div id="topics" data-test-id="topics">
<h4>Topics</h4>
<p><%= content_item.topics %></p>
</div>

<div id="policy-areas">
<div id="policy-areas" data-test-id="policy-areas">
<h4>Policy areas</h4>
<p><%= content_item.policy_areas %></p>
</div>

<div id="withdrawn">
<div id="withdrawn" data-test-id="withdrawn">
<h4>Withdrawn</h4>
<p><%= content_item.withdrawn %></p>
</div>

<div id="pageviews">
<div id="pageviews" data-test-id="pageviews">
<h4>Unique pageviews</h4>
<p><%= content_item.one_month_page_views %> in the last month</p>
<p><%= content_item.six_months_page_views %> in the last six months</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
class AuditContentItemPage < SitePrism::Page
set_url '/content_items{/content_id}/audit{?query*}'

element :error_message, '.alert-danger'
element :success_message, '.alert-success'
element :error_message, '[data-test-id=audit-error-message]'
element :success_message, '[data-test-id=audit-success-message]'

element :content_item_description, 'p.description'
element :content_item_title, 'h2'
element :questions_title, 'h4'
element :content_item_description, '[data-test-id=content-item-description]'
element :content_item_title, '[data-test-id=content-item-title]'
element :questions_title, '[data-test-id=questions-title]'

section :audit_form, 'form' do
element :attachments, '.change-attachments'
element :content_out_of_date, '.outdated'
element :content_should_be_removed, '.redundant'
element :content_similar, '.similar'
element :content_type, '.reformat'
element :notes, '.notes textarea'
element :page_detail, '.change-body'
element :redirect_urls, '#audits_audit_redirect_urls'
element :save_and_continue, 'input[type=submit]'
element :similar_urls, '#audits_audit_similar_urls'
element :summary, '.change-description'
element :title, '.change-title'
element :attachments, '[data-test-id=change-attachments]'
element :content_out_of_date, '[data-test-id=outdated]'
element :content_should_be_removed, '[data-test-id=redundant]'
element :content_similar, '[data-test-id=similar]'
element :content_type, '[data-test-id=reformat]'
element :notes, '[data-test-id=notes]'
element :page_detail, '[data-test-id=change-body]'
element :redirect_urls, '[data-test-id=redirect-urls]'
element :save_and_continue, '[data-test-id=save-audit-form]'
element :similar_urls, '[data-test-id=similar-urls]'
element :summary, '[data-test-id=change-description]'
element :title, '[data-test-id=change-title]'
end

section :metadata, '#metadata' do
element :assigned_to, '#allocated'
element :audited, '#audited'
element :content_type, '#content-type'
element :guidance, '#guidance'
element :last_major_update, '#last-updated'
element :organisations, '#organisations'
element :policy_areas, '#policy-areas'
element :topics, '#topics'
element :unique_page_views, '#pageviews'
element :withdrawn, '#withdrawn'
element :assigned_to, '[data-test-id=allocated]'
element :audited, '[data-test-id=audited]'
element :content_type, '[data-test-id=content-type]'
element :guidance, '[data-test-id=guidance]'
element :last_major_update, '[data-test-id=last-updated]'
element :organisations, '[data-test-id=organisations]'
element :policy_areas, '[data-test-id=policy-areas]'
element :topics, '[data-test-id=topics]'
element :unique_page_views, '[data-test-id=pageviews]'
element :withdrawn, '[data-test-id=withdrawn]'
end
end

0 comments on commit b8a308a

Please sign in to comment.