|
|
|
|
@ -9,6 +9,7 @@ RSpec.describe BulkUploadErrorSummaryTableComponent, type: :component do
|
|
|
|
|
stub_const("BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD", 0) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#sorted_errors" do |
|
|
|
|
context "when no errors" do |
|
|
|
|
it "does not renders any tables" do |
|
|
|
|
result = render_inline(component) |
|
|
|
|
@ -93,6 +94,32 @@ RSpec.describe BulkUploadErrorSummaryTableComponent, type: :component do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when mix of setup and other errors" do |
|
|
|
|
let!(:error_1) { create(:bulk_upload_error, bulk_upload:, col: "A", row: 1, category: "setup") } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
create(:bulk_upload_error, bulk_upload:, col: "B", row: 2, category: nil) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "only returns the setup errors" do |
|
|
|
|
result = render_inline(component) |
|
|
|
|
|
|
|
|
|
tables = result.css("table") |
|
|
|
|
|
|
|
|
|
expect(tables.size).to be(1) |
|
|
|
|
|
|
|
|
|
table = result.css("table").css("th, td").map(&:content) |
|
|
|
|
|
|
|
|
|
expect(table).to eql([ |
|
|
|
|
bulk_upload.prefix_namespace::RowParser.question_for_field(error_1.field.to_sym).to_s, |
|
|
|
|
"Column A", |
|
|
|
|
error_1.error, |
|
|
|
|
"1 error", |
|
|
|
|
]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#errors?" do |
|
|
|
|
context "when there are no errors" do |
|
|
|
|
it "returns false" do |
|
|
|
|
|