Skip to content

Commit f2e523d

Browse files
TASK-1862336: testing RichText
1 parent cec0416 commit f2e523d

File tree

2 files changed

+61
-21
lines changed

2 files changed

+61
-21
lines changed

test/src/commonMain/composeResources/files/responses/dx/cases/SDKTesting-POST.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"Surname": "",
1212
"Name": "",
1313
"Description": "",
14+
"RichDescription": "<p><strong>Description</strong></p>\n<p><em>This is a description</em></p>\n<ul>\n<li><em>one</em></li>\n<li><em>two</em></li>\n<li><em>three</em></li>\n</ul>",
1415
"Url": "",
1516
"DateOfBirth": "",
1617
"Adult": false,
@@ -315,6 +316,16 @@
315316
"helperText": "@L Some description"
316317
}
317318
},
319+
{
320+
"type": "RichText",
321+
"config": {
322+
"label": "@L Rich description",
323+
"value": "@P .RichDescription",
324+
"labelOption": "custom",
325+
"placeholder": "",
326+
"helperText": "Rich description helper text"
327+
}
328+
},
318329
{
319330
"type": "reference",
320331
"config": {
@@ -530,6 +541,15 @@
530541
"label": "description"
531542
}
532543
],
544+
"RichDescription": [
545+
{
546+
"classID": "DIXL-MediaCo-Work-SDKTesting",
547+
"type": "Text",
548+
"displayAs": "pxRichTextEditor",
549+
"additionalInformation": "",
550+
"label": "Rich description"
551+
}
552+
],
533553
"Url": [
534554
{
535555
"classID": "DIXL-MediaCo-Work-SDKTesting",

test/src/commonTest/kotlin/com/pega/constellation/sdk/kmp/test/ConstellationSdkBaseTest.kt

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.pega.constellation.sdk.kmp.core.components.containers.RegionComponent
1414
import com.pega.constellation.sdk.kmp.core.components.containers.RootContainerComponent
1515
import com.pega.constellation.sdk.kmp.core.components.containers.ViewComponent
1616
import com.pega.constellation.sdk.kmp.core.components.containers.ViewContainerComponent
17+
import com.pega.constellation.sdk.kmp.core.components.fields.RichTextComponent
1718
import com.pega.constellation.sdk.kmp.core.components.fields.TextInputComponent
1819
import kotlinx.coroutines.Dispatchers
1920
import kotlinx.coroutines.flow.first
@@ -94,32 +95,36 @@ abstract class ConstellationSdkBaseTest {
9495
--------------Date#19
9596
--------------URL#20
9697
--------------TextArea#21
97-
--------------View#22
98-
---------------DefaultForm#24
99-
----------------Region#25
100-
-----------------Checkbox#26
101-
-----------------TextArea#27
102-
--------------Email#23
98+
--------------RichText#22
99+
--------------View#23
100+
---------------DefaultForm#25
101+
----------------Region#26
102+
-----------------Checkbox#27
103+
-----------------TextArea#28
104+
--------------Email#24
103105
104106
""".trimIndent(),
105107
root.structure()
106108
)
109+
val defaultForm = root.getDefaultForm()
110+
val region3 = defaultForm.children[0] as RegionComponent
111+
val textInput = region3.children[0] as TextInputComponent
112+
assertEquals("caseInfo.content.Name", textInput.pConnectPropertyReference)
113+
}
114+
115+
@Test
116+
fun test_rich_text() = runTest {
117+
val sdk = ConstellationSdk.create(config, engine)
118+
sdk.createCase(CASE_CLASS)
107119

108-
val viewContainer = root.children()[1] as? ViewContainerComponent
109-
val view = viewContainer?.children[0] as? ViewComponent
110-
val oneColumn = view?.children[0] as? OneColumnComponent
111-
val region = oneColumn?.children[0] as? RegionComponent
112-
val view2 = region?.children[0] as? ViewComponent
113-
val region2 = view2?.children[0] as? RegionComponent
114-
val view3 = region2?.children[0] as? ViewComponent
115-
val flowContainer = view3?.children[0] as? FlowContainerComponent
116-
val assignment = flowContainer?.assignment
117-
val assignmentCard = assignment?.children[0] as? AssignmentCardComponent
118-
val view4 = assignmentCard?.children[0] as? ViewComponent
119-
val defaultForm = view4?.children[0] as? DefaultFormComponent
120-
val region3 = defaultForm?.children[0] as? RegionComponent
121-
val textInput = region3?.children[0] as? TextInputComponent
122-
assertEquals("caseInfo.content.Name", textInput?.pConnectPropertyReference)
120+
val defaultForm = sdk.assertState<State.Ready>().root.getDefaultForm()
121+
val region3 = defaultForm.children[0] as RegionComponent
122+
val richText = region3.children[6] as RichTextComponent
123+
assertEquals(
124+
"<p><strong>Description</strong></p>\n<p><em>This is a description</em></p>\n<ul>\n<li><em>one</em></li>\n<li><em>two</em></li>\n<li><em>three</em></li>\n</ul>",
125+
richText.value
126+
)
127+
assertEquals("caseInfo.content.RichDescription", richText.pConnectPropertyReference)
123128
}
124129

125130
companion object {
@@ -156,5 +161,20 @@ abstract class ConstellationSdkBaseTest {
156161
is FlowContainerComponent -> listOfNotNull(assignment) + alertBanners
157162
else -> emptyList()
158163
}
164+
165+
private fun RootContainerComponent.getDefaultForm(): DefaultFormComponent {
166+
val viewContainer = children()[1] as ViewContainerComponent
167+
val view = viewContainer?.children[0] as ViewComponent
168+
val oneColumn = view.children[0] as OneColumnComponent
169+
val region = oneColumn.children[0] as RegionComponent
170+
val view2 = region.children[0] as ViewComponent
171+
val region2 = view2.children[0] as RegionComponent
172+
val view3 = region2.children[0] as ViewComponent
173+
val flowContainer = view3.children[0] as FlowContainerComponent
174+
val assignment = flowContainer.assignment
175+
val assignmentCard = assignment?.children[0] as AssignmentCardComponent
176+
val view4 = assignmentCard.children[0] as ViewComponent
177+
return view4.children[0] as DefaultFormComponent
178+
}
159179
}
160180
}

0 commit comments

Comments
 (0)