Skip to content

Commit

Permalink
PSD-2717 - add legal name to the business search tables (#3243)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeravnagesh authored Oct 22, 2024
1 parent a85e23e commit 661cd99
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
8 changes: 4 additions & 4 deletions app/views/businesses/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<caption class="govuk-table__caption govuk-visually-hidden">Businesses: a simple data table.</caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Name</th>
<th scope="col" class="govuk-table__header">Added</th>
<th scope="col" class="govuk-table__header">Trading name</th>
<th scope="col" class="govuk-table__header">Registered or Legal name</th>
<th scope="col" class="govuk-table__header">Company number</th>
</tr>
</thead>
Expand All @@ -15,8 +15,8 @@
<% if @count > 11 %>
<tfoot class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Name</th>
<th scope="col" class="govuk-table__header">Added</th>
<th scope="col" class="govuk-table__header">Trading name</th>
<th scope="col" class="govuk-table__header">Registered or Legal name</th>
<th scope="col" class="govuk-table__header">Company number</th>
</tr>
</tfoot>
Expand Down
6 changes: 3 additions & 3 deletions app/views/businesses/_table_row.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">
<%= link_to business.trading_name, business, class: "govuk-link govuk-link--no-visited-state" %>
<%= link_to sanitize(business&.trading_name), business, class: "govuk-link govuk-link--no-visited-state" %>
</th>
<td class="govuk-table__cell">
<%= date_or_recent_time_ago business.created_at %>
<%= sanitize(business&.legal_name) %>
</td>
<td class="govuk-table__cell">
<%= business.company_number %>
<%= sanitize(business&.company_number) %>
</td>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
table.with_head do |head|
head.with_row do |row|
row.with_cell(text: "Business name")
row.with_cell(text: "Registered or Legal name")
row.with_cell(text: "Companies House number")
row.with_cell(text: "Address")
row.with_cell(text: "<span class=\"govuk-visually-hidden\">Select business</span>".html_safe)
Expand All @@ -91,6 +92,7 @@

body.with_row do |row|
row.with_cell(text: sanitize(record.trading_name))
row.with_cell(text: sanitize(record.legal_name))
row.with_cell(text: sanitize(record.company_number))
row.with_cell(text: sanitize(addresses).html_safe)
if @existing_business_ids.include?(record.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
govuk_table do |table|
table.with_head do |head|
head.with_row do |row|
row.with_cell(text: "Business name")
row.with_cell(text: "Trading name")
row.with_cell(text: "Registered or Legal name")
row.with_cell(text: "Companies House number")
row.with_cell(text: "Address")
row.with_cell(text: "<span class=\"govuk-visually-hidden\">Select business</span>".html_safe)
Expand All @@ -87,6 +88,7 @@

body.with_row do |row|
row.with_cell(text: sanitize(record.trading_name))
row.with_cell(text: sanitize(record.legal_name))
row.with_cell(text: sanitize(record.company_number))
row.with_cell(text: addresses.html_safe)
if @existing_business_ids.include?(record.id)
Expand Down
32 changes: 28 additions & 4 deletions spec/features/businesses_navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
let(:user) { create :user, :activated, has_viewed_introduction: true, team: }

let(:other_user_same_team) { create :user, :activated, has_viewed_introduction: true, team: }
let(:user_business) { create(:business, trading_name: "user_business") }
let(:team_business) { create(:business, trading_name: "team_business") }
let(:closed_business) { create(:business, trading_name: "closed_business") }
let(:other_business) { create(:business, trading_name: "other_business") }
let(:user_business) { create(:business, trading_name: "user_business", legal_name: "user_business Ltd") }
let(:team_business) { create(:business, trading_name: "team_business", legal_name: "team_business Ltd") }
let(:closed_business) { create(:business, trading_name: "closed_business", legal_name: "closed_business Ltd") }
let(:other_business) { create(:business, trading_name: "other_business", legal_name: "other_business Ltd") }

def create_four_businesses!
user_case = create(:allegation, creator: user)
Expand Down Expand Up @@ -77,6 +77,30 @@ def create_four_businesses!
expect(page).to have_css("form dl.opss-dl-select dd", text: "Active: Newly added") # sort filter drop down
end

scenario "Business table is displayed with columns" do
create_four_businesses!

sign_in(user)
visit "/businesses"

expect(highlighted_tab).to eq "All businesses - Search"

within "table > thead" do
expect(page).to have_text("Trading name")
expect(page).to have_text("Registered or Legal name")
expect(page).to have_text("Company number")
end

within "table tbody.govuk-table__body > tr:nth-child(1) > th:nth-child(1)" do
expect(page).to have_link(other_business.trading_name, href: business_path(other_business))
end

within "table tbody.govuk-table__body > tr:nth-child(1)" do
expect(page).to have_text(other_business.legal_name)
expect(page).to have_text(other_business.company_number)
end
end

def highlighted_tab
find(".opss-left-nav__active").text
end
Expand Down
26 changes: 23 additions & 3 deletions spec/features/businesses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
RSpec.feature "Business listing", :with_stubbed_mailer, type: :feature do
let(:user) { create :user, :opss_user, :activated, has_viewed_introduction: true }
let(:non_opss_user) { create :user, :activated, has_viewed_introduction: true }
let!(:business_one) { create(:business, :online_marketplace, trading_name: "great value", created_at: 1.day.ago) }
let!(:business_two) { create(:business, :retailer, trading_name: "mediocre stuff", created_at: 2.days.ago) }
let!(:business_three) { create(:business, :manufacturer, trading_name: "pretty bad", created_at: 3.days.ago) }
let!(:business_one) { create(:business, :online_marketplace, trading_name: "great value", legal_name: "Great Value Ltd", created_at: 1.day.ago) }
let!(:business_two) { create(:business, :retailer, trading_name: "Business name", legal_name: "Business name Ltd", created_at: 2.days.ago) }
let!(:business_three) { create(:business, :manufacturer, trading_name: "Some Business", legal_name: "Some Business Ltd", created_at: 3.days.ago) }

before do
create_list :business, 18, created_at: 4.days.ago
Expand All @@ -30,14 +30,29 @@
expect(page).to have_link(business_one.trading_name, href: business_path(business_one))
end

within "table tbody.govuk-table__body > tr:nth-child(1)" do
expect(page).to have_text(business_one.legal_name)
expect(page).to have_text(business_one.company_number)
end

within "table tbody.govuk-table__body > tr:nth-child(2) > th:nth-child(1)" do
expect(page).to have_link(business_two.trading_name, href: business_path(business_two))
end

within "table tbody.govuk-table__body > tr:nth-child(2)" do
expect(page).to have_text(business_two.legal_name)
expect(page).to have_text(business_two.company_number)
end

within "table tbody.govuk-table__body > tr:nth-child(3) > th:nth-child(1)" do
expect(page).to have_link(business_three.trading_name, href: business_path(business_three))
end

within "table tbody.govuk-table__body > tr:nth-child(3)" do
expect(page).to have_text(business_three.legal_name)
expect(page).to have_text(business_three.company_number)
end

expect(page).to have_css(".govuk-pagination__link", text: "1")
expect(page).to have_link("Next", href: all_businesses_path(page: 2))

Expand All @@ -47,6 +62,11 @@
within "table tbody.govuk-table__body > tr:nth-child(1) > th:nth-child(1)" do
expect(page).to have_link(business_three.trading_name, href: business_path(business_three))
end

within "table tbody.govuk-table__body > tr:nth-child(1)" do
expect(page).to have_text(business_three.legal_name)
expect(page).to have_text(business_three.company_number)
end
end

scenario "strips leading and trailing whitespace from search queries" do
Expand Down

0 comments on commit 661cd99

Please sign in to comment.