mirror of
https://github.com/we-promise/sure.git
synced 2026-05-12 15:15:01 +00:00
feat(api): expose import status details (#1599)
* feat(api): expose import status details * fix(api): reuse import status validation counts * fix(api): cache Sure import status reads * fix(imports): invalidate cached Sure import blobs * docs(api): split import status schemas * fix(api): refine import status detail contract
This commit is contained in:
@@ -79,6 +79,17 @@ class SureImportTest < ActiveSupport::TestCase
|
||||
assert @import.publishable?
|
||||
end
|
||||
|
||||
test "status predicates honor validation stats" do
|
||||
attach_ndjson(build_ndjson([
|
||||
{ type: "Account", data: { id: "uuid-1", name: "Test", balance: "1000", currency: "USD", accountable_type: "Depository" } }
|
||||
]))
|
||||
|
||||
assert @import.cleaned_from_validation_stats?(invalid_rows_count: 0)
|
||||
assert @import.publishable_from_validation_stats?(invalid_rows_count: 0)
|
||||
assert_not @import.cleaned_from_validation_stats?(invalid_rows_count: 1)
|
||||
assert_not @import.publishable_from_validation_stats?(invalid_rows_count: 1)
|
||||
end
|
||||
|
||||
test "dry_run returns counts by type" do
|
||||
attach_ndjson(build_ndjson([
|
||||
{ type: "Account", data: { id: "uuid-1" } },
|
||||
@@ -97,6 +108,22 @@ class SureImportTest < ActiveSupport::TestCase
|
||||
assert_equal 0, dry_run[:tags]
|
||||
end
|
||||
|
||||
test "cached ndjson content is refreshed when attachment is replaced" do
|
||||
attach_ndjson(build_ndjson([
|
||||
{ type: "Account", data: { id: "uuid-1" } }
|
||||
]))
|
||||
assert_equal 1, @import.dry_run[:accounts]
|
||||
|
||||
attach_ndjson(build_ndjson([
|
||||
{ type: "Transaction", data: { id: "uuid-2" } }
|
||||
]))
|
||||
|
||||
dry_run = @import.dry_run
|
||||
assert_equal 0, dry_run[:accounts]
|
||||
assert_equal 1, dry_run[:transactions]
|
||||
assert_equal 1, @import.rows_count
|
||||
end
|
||||
|
||||
test "sync_ndjson_rows_count! sets total row count" do
|
||||
attach_ndjson(build_ndjson([
|
||||
{ type: "Account", data: { id: "uuid-1" } },
|
||||
|
||||
Reference in New Issue
Block a user