Skip to content

Commit

Permalink
Fix condition for empty long texts
Browse files Browse the repository at this point in the history
RISDEV-5945
  • Loading branch information
leonie-koch committed Jan 13, 2025
1 parent f02d9f8 commit a7a1170
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions frontend/src/components/category-import/CategoryImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ const hasContent = (key: keyof typeof labels): boolean => {
key as keyof typeof documentUnitToImport.value.longTexts
]
return !!longText || !!(Array.isArray(longText) && longText.length > 0)
if (typeof longText === "string" && longText.trim().length > 0) {
return true
}
if (Array.isArray(longText) && longText.length > 0) {
return true
}
}
return false
}
Expand All @@ -94,7 +99,7 @@ const isImportable = (key: keyof typeof labels): boolean => {
store.documentUnit!.longTexts[
key as keyof typeof documentUnitToImport.value.longTexts
]
// Return false if longText is a non-empty string or a non-empty array
if (typeof longText === "string" && longText.trim().length > 0) {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/e2e/caselaw/category-import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test.describe("category import", () => {
async ({ page, documentNumber }) => {
await navigateToCategoryImport(page, documentNumber)
await searchForDocumentUnitToImport(page, documentNumber)
await expect(page.getByText("Quellrubrik leer")).toHaveCount(15) // we have 15 importable categories
await expect(page.getByText("Quellrubrik leer")).toHaveCount(16) // we have 16 importable categories
},
)

Expand Down

0 comments on commit a7a1170

Please sign in to comment.