From a7a117058ca56e69e1312a6599aa8c76ea391767 Mon Sep 17 00:00:00 2001 From: Leonie Koch Date: Mon, 13 Jan 2025 17:07:39 +0100 Subject: [PATCH] Fix condition for empty long texts RISDEV-5945 --- .../src/components/category-import/CategoryImport.vue | 9 +++++++-- frontend/test/e2e/caselaw/category-import.spec.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/category-import/CategoryImport.vue b/frontend/src/components/category-import/CategoryImport.vue index faf1f8ce60..14a4c46cc5 100644 --- a/frontend/src/components/category-import/CategoryImport.vue +++ b/frontend/src/components/category-import/CategoryImport.vue @@ -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 } @@ -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 } diff --git a/frontend/test/e2e/caselaw/category-import.spec.ts b/frontend/test/e2e/caselaw/category-import.spec.ts index 2b0a05a1ed..ee92c0d501 100644 --- a/frontend/test/e2e/caselaw/category-import.spec.ts +++ b/frontend/test/e2e/caselaw/category-import.spec.ts @@ -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 }, )