diff --git a/app/components/bulk_upload_error_row_component.html.erb b/app/components/bulk_upload_error_row_component.html.erb
index 6f8de6919..54a2c6c93 100644
--- a/app/components/bulk_upload_error_row_component.html.erb
+++ b/app/components/bulk_upload_error_row_component.html.erb
@@ -1,9 +1,9 @@
diff --git a/app/components/bulk_upload_error_row_component.rb b/app/components/bulk_upload_error_row_component.rb
index 13ac326ef..f4f129cbc 100644
--- a/app/components/bulk_upload_error_row_component.rb
+++ b/app/components/bulk_upload_error_row_component.rb
@@ -15,14 +15,38 @@ class BulkUploadErrorRowComponent < ViewComponent::Base
bulk_upload_errors.first.tenant_code
end
+ def tenant_code_html
+ return if tenant_code.blank?
+
+ content_tag :span, class: "govuk-!-margin-left-3" do
+ "Tenant code: #{tenant_code}"
+ end
+ end
+
def purchaser_code
bulk_upload_errors.first.purchaser_code
end
+ def purchaser_code_html
+ return if purchaser_code.blank?
+
+ content_tag :span, class: "govuk-!-margin-left-3" do
+ "Purchaser code: #{purchaser_code}"
+ end
+ end
+
def property_ref
bulk_upload_errors.first.property_ref
end
+ def property_ref_html
+ return if property_ref.blank?
+
+ content_tag :span, class: "govuk-!-margin-left-3" do
+ "Property reference: #{property_ref}"
+ end
+ end
+
def question_for_field(field)
bulk_upload.prefix_namespace::RowParser.question_for_field(field.to_sym)
end
diff --git a/spec/components/bulk_upload_error_row_component_spec.rb b/spec/components/bulk_upload_error_row_component_spec.rb
index 4950817f0..665a630c8 100644
--- a/spec/components/bulk_upload_error_row_component_spec.rb
+++ b/spec/components/bulk_upload_error_row_component_spec.rb
@@ -5,6 +5,7 @@ RSpec.describe BulkUploadErrorRowComponent, type: :component do
let(:row) { rand(9_999) }
let(:tenant_code) { SecureRandom.hex(4) }
let(:property_ref) { SecureRandom.hex(4) }
+ let(:purchaser_code) { nil }
let(:field) { :field_134 }
let(:error) { "some error" }
let(:bulk_upload) { create(:bulk_upload, :lettings) }
@@ -16,6 +17,7 @@ RSpec.describe BulkUploadErrorRowComponent, type: :component do
row:,
tenant_code:,
property_ref:,
+ purchaser_code:,
field:,
error:,
),
@@ -49,6 +51,33 @@ RSpec.describe BulkUploadErrorRowComponent, type: :component do
expect(result).to have_content(expected)
end
+ context "when tenant_code not present" do
+ let(:tenant_code) { nil }
+
+ it "does not render tenant code label" do
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).not_to have_content("Tenant code")
+ end
+ end
+
+ context "when property_ref not present" do
+ let(:property_ref) { nil }
+
+ it "does not render the property_ref label" do
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).not_to have_content("Property reference")
+ end
+ end
+
+ context "when purchaser_code not present" do
+ let(:bulk_upload) { create(:bulk_upload, :sales) }
+
+ it "does not render the purchaser_code label" do
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).not_to have_content("Purchaser code")
+ end
+ end
+
context "when multiple errors for a row" do
subject(:component) { described_class.new(bulk_upload_errors:) }