diff --git a/test/src/commonMain/composeResources/files/responses/dx/cases/SDKTesting-POST.json b/test/src/commonMain/composeResources/files/responses/dx/cases/SDKTesting-POST.json index c16c2cdf..ad1e9701 100644 --- a/test/src/commonMain/composeResources/files/responses/dx/cases/SDKTesting-POST.json +++ b/test/src/commonMain/composeResources/files/responses/dx/cases/SDKTesting-POST.json @@ -11,6 +11,7 @@ "Surname": "", "Name": "", "Description": "", + "RichDescription": "

Description

\n

This is a description

\n", "Url": "", "DateOfBirth": "", "Adult": false, @@ -315,6 +316,16 @@ "helperText": "@L Some description" } }, + { + "type": "RichText", + "config": { + "label": "@L Rich description", + "value": "@P .RichDescription", + "labelOption": "custom", + "placeholder": "", + "helperText": "Rich description helper text" + } + }, { "type": "reference", "config": { @@ -530,6 +541,15 @@ "label": "description" } ], + "RichDescription": [ + { + "classID": "DIXL-MediaCo-Work-SDKTesting", + "type": "Text", + "displayAs": "pxRichTextEditor", + "additionalInformation": "", + "label": "Rich description" + } + ], "Url": [ { "classID": "DIXL-MediaCo-Work-SDKTesting", diff --git a/test/src/commonTest/kotlin/com/pega/constellation/sdk/kmp/test/ConstellationSdkBaseTest.kt b/test/src/commonTest/kotlin/com/pega/constellation/sdk/kmp/test/ConstellationSdkBaseTest.kt index 8b3b2e29..85e439fe 100644 --- a/test/src/commonTest/kotlin/com/pega/constellation/sdk/kmp/test/ConstellationSdkBaseTest.kt +++ b/test/src/commonTest/kotlin/com/pega/constellation/sdk/kmp/test/ConstellationSdkBaseTest.kt @@ -14,6 +14,7 @@ import com.pega.constellation.sdk.kmp.core.components.containers.RegionComponent import com.pega.constellation.sdk.kmp.core.components.containers.RootContainerComponent import com.pega.constellation.sdk.kmp.core.components.containers.ViewComponent import com.pega.constellation.sdk.kmp.core.components.containers.ViewContainerComponent +import com.pega.constellation.sdk.kmp.core.components.fields.RichTextComponent import com.pega.constellation.sdk.kmp.core.components.fields.TextInputComponent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first @@ -94,32 +95,36 @@ abstract class ConstellationSdkBaseTest { --------------Date#19 --------------URL#20 --------------TextArea#21 - --------------View#22 - ---------------DefaultForm#24 - ----------------Region#25 - -----------------Checkbox#26 - -----------------TextArea#27 - --------------Email#23 + --------------RichText#22 + --------------View#23 + ---------------DefaultForm#25 + ----------------Region#26 + -----------------Checkbox#27 + -----------------TextArea#28 + --------------Email#24 """.trimIndent(), root.structure() ) + val defaultForm = root.getDefaultForm() + val region3 = defaultForm.children[0] as RegionComponent + val textInput = region3.children[0] as TextInputComponent + assertEquals("caseInfo.content.Name", textInput.pConnectPropertyReference) + } + + @Test + fun test_rich_text() = runTest { + val sdk = ConstellationSdk.create(config, engine) + sdk.createCase(CASE_CLASS) - val viewContainer = root.children()[1] as? ViewContainerComponent - val view = viewContainer?.children[0] as? ViewComponent - val oneColumn = view?.children[0] as? OneColumnComponent - val region = oneColumn?.children[0] as? RegionComponent - val view2 = region?.children[0] as? ViewComponent - val region2 = view2?.children[0] as? RegionComponent - val view3 = region2?.children[0] as? ViewComponent - val flowContainer = view3?.children[0] as? FlowContainerComponent - val assignment = flowContainer?.assignment - val assignmentCard = assignment?.children[0] as? AssignmentCardComponent - val view4 = assignmentCard?.children[0] as? ViewComponent - val defaultForm = view4?.children[0] as? DefaultFormComponent - val region3 = defaultForm?.children[0] as? RegionComponent - val textInput = region3?.children[0] as? TextInputComponent - assertEquals("caseInfo.content.Name", textInput?.pConnectPropertyReference) + val defaultForm = sdk.assertState().root.getDefaultForm() + val region3 = defaultForm.children[0] as RegionComponent + val richText = region3.children[6] as RichTextComponent + assertEquals( + "

Description

\n

This is a description

\n", + richText.value + ) + assertEquals("caseInfo.content.RichDescription", richText.pConnectPropertyReference) } companion object { @@ -156,5 +161,20 @@ abstract class ConstellationSdkBaseTest { is FlowContainerComponent -> listOfNotNull(assignment) + alertBanners else -> emptyList() } + + private fun RootContainerComponent.getDefaultForm(): DefaultFormComponent { + val viewContainer = children()[1] as ViewContainerComponent + val view = viewContainer?.children[0] as ViewComponent + val oneColumn = view.children[0] as OneColumnComponent + val region = oneColumn.children[0] as RegionComponent + val view2 = region.children[0] as ViewComponent + val region2 = view2.children[0] as RegionComponent + val view3 = region2.children[0] as ViewComponent + val flowContainer = view3.children[0] as FlowContainerComponent + val assignment = flowContainer.assignment + val assignmentCard = assignment?.children[0] as AssignmentCardComponent + val view4 = assignmentCard.children[0] as ViewComponent + return view4.children[0] as DefaultFormComponent + } } } \ No newline at end of file