Skip to content

Commit d0c124c

Browse files
BUG-985954: do not handle events for readonly fields
extending tests to cover that edge case
1 parent 248aae8 commit d0c124c

File tree

9 files changed

+316
-151
lines changed

9 files changed

+316
-151
lines changed

samples/android-cmp-app/src/androidInstrumentedTest/kotlin/com/pega/constellation/sdk/kmp/samples/androidcmpapp/test/cases/DataReferenceListOfRecordsTest.kt

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.pega.constellation.sdk.kmp.samples.androidcmpapp.test.cases
22

33
import androidx.compose.ui.test.ComposeUiTest
44
import androidx.compose.ui.test.ExperimentalTestApi
5+
import androidx.compose.ui.test.onAllNodesWithText
56
import androidx.compose.ui.test.onNodeWithText
67
import androidx.compose.ui.test.performClick
78
import androidx.compose.ui.test.performTextInput
@@ -17,50 +18,48 @@ class DataReferenceListOfRecordsTest : ComposeTest(PegaVersion.v25_1) {
1718
val columns = listOf("BRAND", "MODEL")
1819

1920
@Test
20-
fun test_table_simple_table() =
21-
runComposeUiTest {
22-
val cars =
23-
listOf(
24-
listOf("Ford", "Focus"),
25-
listOf("Toyota", "Corolla"),
26-
listOf("Fiat", "126p"),
27-
listOf("Skoda", "Octavia"),
28-
listOf("Audi", "A5"),
29-
)
30-
val cars2 =
31-
listOf(
32-
listOf("Ford", "Focus"),
33-
listOf("Fiat", "126p"),
34-
)
35-
36-
setupApp("O40M3A-MarekCo-Work-DataReferenceListOfRecordsTest")
37-
38-
// create case
39-
onNodeWithText("New Service").performClick()
40-
41-
// Editable Table
42-
waitForNode("DataReference ListOfRecords - Table", substring = true)
43-
waitForNodes("DataReferenceListOfRecordsCars", count = 1)
44-
verifyTable(cars)
45-
onNodeWithText("Next").performClick()
46-
47-
// Editable SimpleTable
48-
waitForNode("DataReference ListOfRecords - SimpleTable", substring = true)
49-
waitForNode("DataReferenceListOfRecordsCars")
50-
verifyTable(cars)
51-
onNodeWithText("Next").performClick()
52-
53-
// Readonly Table
54-
waitForNode("DataReference ListOfRecords - Table readonly", substring = true)
55-
waitForNode("DataReferenceListOfRecordsCars")
56-
verifyTable(cars2)
57-
onNodeWithText("Next").performClick()
58-
59-
// Readonly SimpleTable
60-
waitForNode("DataReference ListOfRecords - SimpleTable readonly", substring = true)
61-
waitForNode("DataReferenceListOfRecordsCars")
62-
verifyTable(cars2)
63-
}
21+
fun test_table_simple_table() = runComposeUiTest {
22+
val cars = listOf(
23+
listOf("Audi", "A4", "30000"),
24+
listOf("Ford", "Focus", "25000"),
25+
listOf("Fiat", "Panda", "10000"),
26+
listOf("Skoda", "Octavia", "35000")
27+
)
28+
val cars2 = listOf(
29+
listOf("Ford", "Focus", "25000"),
30+
listOf("Fiat", "Panda", "10000")
31+
)
32+
33+
setupApp("O40M3A-MarekCo-Work-DataReferenceListOfRecordsTest")
34+
35+
// create case
36+
onNodeWithText("New Service").performClick()
37+
38+
// Editable Table
39+
waitForNode("DataReference ListOfRecords - Table", substring = true)
40+
waitForNodes("DataReferenceListOfRecordsCars", count = 1)
41+
verifyTable(cars)
42+
onAllNodesWithText("Focus")[0].performClick()
43+
onAllNodesWithText("Panda")[0].performClick()
44+
onNodeWithText("Next").performClick()
45+
46+
// Editable SimpleTable
47+
waitForNode("DataReference ListOfRecords - SimpleTable", substring = true)
48+
waitForNode("DataReferenceListOfRecordsCars")
49+
verifyTable(cars)
50+
onNodeWithText("Next").performClick()
51+
52+
// Readonly Table
53+
waitForNode("DataReference ListOfRecords - Table readonly", substring = true)
54+
waitForNode("DataReferenceListOfRecordsCars")
55+
verifyTable(cars2)
56+
onNodeWithText("Next").performClick()
57+
58+
// Readonly SimpleTable
59+
waitForNode("DataReference ListOfRecords - SimpleTable readonly", substring = true)
60+
waitForNode("DataReferenceListOfRecordsCars")
61+
verifyTable(cars2)
62+
}
6463

6564
private fun ComposeUiTest.verifyTable(data: List<List<String>>) {
6665
columns.forEach { waitForNodes(it, 2) }

scripts/dxcomponents/components/fields/field-base.component.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export class FieldBaseComponent extends BaseComponent {
7171
}
7272

7373
onEvent(event) {
74+
if (this.props.readOnly) return;
75+
7476
const value = event.componentData !== undefined ? event.componentData.value : undefined;
7577
const focused = event.eventData !== undefined ? event.eventData.focused : undefined;
7678
switch (event.type) {
@@ -99,7 +101,7 @@ export class FieldBaseComponent extends BaseComponent {
99101
const submittedValue = this.pConn.resolveConfigProps(this.pConn.getConfigProps()).value ?? "";
100102
// Preventing 'changeNblur' events for unchanged field values.
101103
// Sending it for field which is a dropdown param causes dropdown value to be cleared
102-
if (submittedValue !== this.props.value) {
104+
if (submittedValue.toString() !== this.props.value) {
103105
handleEvent(this.pConn.getActionsApi(), "changeNblur", this.propName, this.props.value);
104106
}
105107
this.clearErrorMessagesIfNoErrors(this.pConn, this.propName, this.jsComponentPConnectData.validateMessage);

test/src/commonMain/composeResources/files/responses/dx/assignments/DataReferenceListOfRecordsTest-1-SimpleTable.json

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"links": {
99
"open": {
1010
"rel": "self",
11-
"href": "/cases/OI1OYV-MARCO2-WORK D-3020/actions/pyUpdateCaseDetails",
11+
"href": "/cases/OI1OYV-MARCO2-WORK D-7004/actions/pyUpdateCaseDetails",
1212
"type": "GET",
1313
"title": "Get case action details"
1414
}
@@ -20,7 +20,7 @@
2020
"links": {
2121
"open": {
2222
"rel": "self",
23-
"href": "/cases/OI1OYV-MARCO2-WORK D-3020/actions/pyChangeStage",
23+
"href": "/cases/OI1OYV-MARCO2-WORK D-7004/actions/pyChangeStage",
2424
"type": "GET",
2525
"title": "Get case action details"
2626
}
@@ -41,7 +41,7 @@
4141
"type": "worklist"
4242
},
4343
"processID": "CreateForm_Default",
44-
"createTime": "2026-03-25T12:37:22.460Z",
44+
"createTime": "2026-04-07T10:11:23.770Z",
4545
"urgency": 10,
4646
"processName": "Create",
4747
"isMultiStep": "true",
@@ -50,30 +50,30 @@
5050
"links": {
5151
"open": {
5252
"rel": "self",
53-
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT",
53+
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT",
5454
"type": "GET",
5555
"title": "Get assignment details"
5656
}
5757
},
58-
"ID": "ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT",
58+
"ID": "ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT",
5959
"actions": [{
6060
"name": "DataReference ListOfRecords - SimpleTable",
6161
"links": {
6262
"submit": {
6363
"rel": "self",
64-
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT/actions/DataReferenceListOfRecordsSimpleTable",
64+
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/actions/DataReferenceListOfRecordsSimpleTable",
6565
"type": "PATCH",
6666
"title": "Submit assignment action "
6767
},
6868
"save": {
6969
"rel": "self",
70-
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT/actions/DataReferenceListOfRecordsSimpleTable/save",
70+
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/actions/DataReferenceListOfRecordsSimpleTable/save",
7171
"type": "PATCH",
7272
"title": "Save assignment action "
7373
},
7474
"open": {
7575
"rel": "self",
76-
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT/actions/DataReferenceListOfRecordsSimpleTable",
76+
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/actions/DataReferenceListOfRecordsSimpleTable",
7777
"type": "GET",
7878
"title": "Get assignment action details"
7979
}
@@ -83,24 +83,24 @@
8383
}]
8484
}],
8585
"hasNewAttachments": false,
86-
"businessID": "D-3020",
86+
"businessID": "D-7004",
8787
"sla": {
8888
"goal": "",
8989
"deadline": ""
9090
},
9191
"WidgetsToRefresh": ["TaskList"],
9292
"caseTypeName": "DataReferenceListOfRecordsTest",
9393
"urgency": 10,
94-
"createTime": "2026-03-25T12:37:17.707Z",
94+
"createTime": "2026-04-07T10:11:19.739Z",
9595
"createdBy": "user@marco",
9696
"name": "DataReferenceListOfRecordsTest",
9797
"stages": [{
98-
"entryTime": "2026-03-25T12:37:17.711Z",
98+
"entryTime": "2026-04-07T10:11:19.746Z",
9999
"name": "Create",
100100
"links": {
101101
"open": {
102102
"rel": "self",
103-
"href": "/cases/OI1OYV-MARCO2-WORK D-3020/stages/PRIM0",
103+
"href": "/cases/OI1OYV-MARCO2-WORK D-7004/stages/PRIM0",
104104
"type": "PUT",
105105
"title": "Jump to this stage"
106106
}
@@ -110,28 +110,30 @@
110110
"type": "Primary",
111111
"transitionType": "create"
112112
}],
113-
"ID": "OI1OYV-MARCO2-WORK D-3020",
113+
"ID": "OI1OYV-MARCO2-WORK D-7004",
114114
"caseTypeIcon": "cmicons/pycase.svg",
115115
"status": "New",
116116
"stageID": "PRIM0",
117117
"stageLabel": "Create",
118-
"lastUpdateTime": "2026-03-25T12:37:22.462Z",
118+
"lastUpdateTime": "2026-04-07T10:11:23.773Z",
119119
"content": {
120120
"classID": "OI1OYV-Marco2-Work-DataReferenceListOfRecordsTest",
121121
"DataReferenceListOfRecordsCars": [{
122122
"pyGUID": "909106bf-f108-4751-9357-8a628a01dc3f",
123123
"classID": "OI1OYV-Marco2-Data-Car",
124124
"Brand": "Ford",
125-
"Model": "Focus"
125+
"Model": "Focus",
126+
"Price": 25000.000000000
126127
}, {
127128
"pyGUID": "ddbe3b2a-1ffa-4685-8c14-356349906617",
128129
"classID": "OI1OYV-Marco2-Data-Car",
129130
"Brand": "Fiat",
130-
"Model": "Panda"
131+
"Model": "Panda",
132+
"Price": 10000.000000000
131133
}],
132134
"pxObjClass": "OI1OYV-Marco2-Work-DataReferenceListOfRecordsTest",
133135
"pyLabel": "DataReferenceListOfRecordsTest",
134-
"pyID": "D-3020"
136+
"pyID": "D-7004"
135137
}
136138
}
137139
},
@@ -196,6 +198,16 @@
196198
"value": "@P .Model"
197199
},
198200
"type": "TextInput"
201+
}, {
202+
"config": {
203+
"allowDecimals": true,
204+
"isoCodeSelection": "constant",
205+
"label": "@FL .Price",
206+
"labelOption": "default",
207+
"readOnly": true,
208+
"value": "@P .Price"
209+
},
210+
"type": "Currency"
199211
}],
200212
"name": "Columns",
201213
"type": "Region"
@@ -208,7 +220,7 @@
208220
}],
209221
"primaryField": ".Brand",
210222
"readonlyContextList": "@P .DataReferenceListOfRecordsCars",
211-
"referenceList": "D_CarsList",
223+
"referenceList": "D_CarsList2",
212224
"referenceType": "Data",
213225
"selectionKey": ".pyGUID",
214226
"selectionList": ".DataReferenceListOfRecordsCars",
@@ -233,7 +245,7 @@
233245
"brand": ""
234246
},
235247
"parentContextClass": "OI1OYV-Marco2-Work-DataReferenceListOfRecordsTest",
236-
"referenceList": "D_CarsList",
248+
"referenceList": "D_CarsList2",
237249
"ruleClass": "OI1OYV-Marco2-Data-Car",
238250
"selectionMode": "multi",
239251
"template": "DataReference"
@@ -257,7 +269,7 @@
257269
"isAlternateKeyStorage": true,
258270
"structure": "page"
259271
},
260-
"D_CarsList": {
272+
"D_CarsList2": {
261273
"parameters": [{
262274
"name": "brand",
263275
"defaultValue": ""
@@ -334,6 +346,12 @@
334346
"displayAs": "pxTextInput",
335347
"label": "model"
336348
}],
349+
"Price": [{
350+
"classID": "OI1OYV-Marco2-Data-Car",
351+
"type": "Decimal",
352+
"displayAs": "pxCurrency",
353+
"label": "price"
354+
}],
337355
"pyLabel": [{
338356
"classID": "OI1OYV-Marco2-Work-DataReferenceListOfRecordsTest",
339357
"type": "Text",
@@ -355,7 +373,7 @@
355373
}]
356374
}
357375
},
358-
"components": ["DefaultForm", "Region", "SimpleTableSelect", "TextInput", "View", "DataReference"],
376+
"components": ["DefaultForm", "Currency", "Region", "SimpleTableSelect", "TextInput", "View", "DataReference"],
359377
"localeReferences": ["OI1OYV-MARCO2-WORK-DATAREFERENCELISTOFRECORDSTEST!CASE!DATAREFERENCELISTOFRECORDSTEST"],
360378
"root": {
361379
"type": "reference",
@@ -376,7 +394,7 @@
376394
"links": {
377395
"open": {
378396
"rel": "self",
379-
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT/navigation_steps/AssignmentSF1",
397+
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/navigation_steps/AssignmentSF1",
380398
"type": "PATCH",
381399
"title": "Go to DataReference ListOfRecords - Table"
382400
}
@@ -396,7 +414,7 @@
396414
"links": {
397415
"open": {
398416
"rel": "self",
399-
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT/navigation_steps/AssignmentSF3",
417+
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/navigation_steps/AssignmentSF3",
400418
"type": "PATCH",
401419
"title": "Go to DataReference ListOfRecords - Table readonly"
402420
}
@@ -410,12 +428,26 @@
410428
"links": {
411429
"open": {
412430
"rel": "self",
413-
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT/navigation_steps/AssignmentSF4",
431+
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/navigation_steps/AssignmentSF4",
414432
"type": "PATCH",
415433
"title": "Go to DataReference ListOfRecords - SimpleTable readonly"
416434
}
417435
},
418436
"ID": "AssignmentSF4"
437+
}, {
438+
"allow_jump": true,
439+
"name": "DataReference ListOfRecords Checkbox group",
440+
"actionID": "DataReferenceListOfRecordsCheckbox",
441+
"visited_status": "future",
442+
"links": {
443+
"open": {
444+
"rel": "self",
445+
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/navigation_steps/AssignmentSF5",
446+
"type": "PATCH",
447+
"title": "Go to DataReference ListOfRecords Checkbox group"
448+
}
449+
},
450+
"ID": "AssignmentSF5"
419451
}]
420452
},
421453
"actionButtons": {
@@ -430,7 +462,7 @@
430462
"links": {
431463
"open": {
432464
"rel": "self",
433-
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT/navigation_steps/previous",
465+
"href": "assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT/navigation_steps/previous",
434466
"type": "PATCH",
435467
"title": "Go back to previous step"
436468
}
@@ -449,11 +481,11 @@
449481
"links": {
450482
"open": {
451483
"rel": "self",
452-
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT",
484+
"href": "/assignments/ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT",
453485
"type": "GET",
454486
"title": "Get assignment details"
455487
}
456488
},
457-
"ID": "ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-3020!CREATEFORM_DEFAULT"
489+
"ID": "ASSIGN-WORKLIST OI1OYV-MARCO2-WORK D-7004!CREATEFORM_DEFAULT"
458490
}
459491
}

0 commit comments

Comments
 (0)