From 661cd99e82a40966e0894f5478f64e54208b5afd Mon Sep 17 00:00:00 2001
From: meeravnagesh <163134444+meeravnagesh@users.noreply.github.com>
Date: Tue, 22 Oct 2024 15:44:43 +0100
Subject: [PATCH] PSD-2717 - add legal name to the business search tables
(#3243)
---
app/views/businesses/_table.html.erb | 8 ++---
app/views/businesses/_table_row.html.erb | 6 ++--
.../search_for_or_add_a_business.html.erb | 2 ++
.../search_for_or_add_a_business.html.erb | 4 ++-
spec/features/businesses_navigation_spec.rb | 32 ++++++++++++++++---
spec/features/businesses_spec.rb | 26 +++++++++++++--
6 files changed, 63 insertions(+), 15 deletions(-)
diff --git a/app/views/businesses/_table.html.erb b/app/views/businesses/_table.html.erb
index 2b985b668d..9a11b6cd54 100644
--- a/app/views/businesses/_table.html.erb
+++ b/app/views/businesses/_table.html.erb
@@ -2,8 +2,8 @@
Businesses: a simple data table.
-
-
+
+
@@ -15,8 +15,8 @@
<% if @count > 11 %>
-
-
+
+
diff --git a/app/views/businesses/_table_row.html.erb b/app/views/businesses/_table_row.html.erb
index 2294b8ed3a..a40e88e7a8 100644
--- a/app/views/businesses/_table_row.html.erb
+++ b/app/views/businesses/_table_row.html.erb
@@ -1,11 +1,11 @@
- <%= date_or_recent_time_ago business.created_at %>
+ <%= sanitize(business&.legal_name) %>
|
- <%= business.company_number %>
+ <%= sanitize(business&.company_number) %>
|
diff --git a/app/views/notifications/create/search_for_or_add_a_business.html.erb b/app/views/notifications/create/search_for_or_add_a_business.html.erb
index 348e43d66f..0c53581619 100644
--- a/app/views/notifications/create/search_for_or_add_a_business.html.erb
+++ b/app/views/notifications/create/search_for_or_add_a_business.html.erb
@@ -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: "Select business".html_safe)
@@ -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)
diff --git a/app/views/notifications/edit/search_for_or_add_a_business.html.erb b/app/views/notifications/edit/search_for_or_add_a_business.html.erb
index 6a834b44d9..d54f45f269 100644
--- a/app/views/notifications/edit/search_for_or_add_a_business.html.erb
+++ b/app/views/notifications/edit/search_for_or_add_a_business.html.erb
@@ -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: "Select business".html_safe)
@@ -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)
diff --git a/spec/features/businesses_navigation_spec.rb b/spec/features/businesses_navigation_spec.rb
index 3db8cbe32d..7992ae7ab5 100644
--- a/spec/features/businesses_navigation_spec.rb
+++ b/spec/features/businesses_navigation_spec.rb
@@ -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)
@@ -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
diff --git a/spec/features/businesses_spec.rb b/spec/features/businesses_spec.rb
index 6a4e8c6892..ed5d52d600 100644
--- a/spec/features/businesses_spec.rb
+++ b/spec/features/businesses_spec.rb
@@ -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
@@ -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))
@@ -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