@@ -1793,14 +1793,21 @@ public void testMultiChoiceValues() throws IOException, CommandException
17931793 checker ().withScreenshot ().verifyEquals ("Row 0 after update: display not as expected" ,
17941794 quotedValue2 , table .getDataAsText (0 , columnName ));
17951795
1796+ // --- Update row 1: change from quoted value to blank ---
1797+ editRow = table .clickEditRow (1 );
1798+ editRow .setField (columnName , List .of ());
1799+ editRow .submit ();
1800+ checker ().withScreenshot ().verifyEquals ("Row 1 after clearing: display not as expected" ,
1801+ "" , table .getDataAsText (1 , columnName ));
1802+
17961803 // GitHub Issue 1073: multi-choice values containing quotes were stored as raw
17971804 // PostgreSQL array syntax (e.g. {"2"}) instead of the proper export-encoded format (e.g. """2""").
17981805 List <Map <String , Object >> auditEvents = getListAuditEventsSince (encodedListName , baselineRowId );
1799- assertEquals ("Expected 4 audit events (3 inserts + 1 update )" , 4 , auditEvents .size ());
1806+ assertEquals ("Expected 5 audit events (3 inserts + 2 updates )" , 5 , auditEvents .size ());
18001807
18011808 Set <String > foundInsertAuditValues = new HashSet <>();
1802- String updateOldAuditValue = null ;
1803- String updateNewAuditValue = null ;
1809+ // Track each update as a [oldValue, newValue] pair; order across updates is not guaranteed.
1810+ List < String []> updateAuditPairs = new ArrayList <>() ;
18041811
18051812 for (Map <String , Object > event : auditEvents )
18061813 {
@@ -1814,8 +1821,9 @@ public void testMultiChoiceValues() throws IOException, CommandException
18141821 }
18151822 else if ("An existing list record was modified" .equals (comment ))
18161823 {
1817- if (oldMapRaw != null ) updateOldAuditValue = AuditLogHelper .decodeValues (oldMapRaw ).get (columnName );
1818- if (newMapRaw != null ) updateNewAuditValue = AuditLogHelper .decodeValues (newMapRaw ).get (columnName );
1824+ String oldVal = oldMapRaw != null ? AuditLogHelper .decodeValues (oldMapRaw ).get (columnName ) : null ;
1825+ String newVal = newMapRaw != null ? AuditLogHelper .decodeValues (newMapRaw ).get (columnName ) : null ;
1826+ updateAuditPairs .add (new String []{oldVal , newVal });
18191827 }
18201828 }
18211829
@@ -1829,11 +1837,18 @@ else if ("An existing list record was modified".equals(comment))
18291837 checker ().verifyTrue ("Insert row 3: mixed values not in audit" ,
18301838 foundInsertAuditValues .contains (_auditLogHelper .joinMultiChoiceForAudit (quotedValue1 , plainValue )));
18311839
1832- // Update: old = "1", new = """3""".
1833- checker ().verifyEquals ("Update: old audit value not as expected" ,
1834- _auditLogHelper .joinMultiChoiceForAudit (plainValue ), updateOldAuditValue );
1835- checker ().verifyEquals ("Update: new audit value not as expected" ,
1836- _auditLogHelper .joinMultiChoiceForAudit (quotedValue2 ), updateNewAuditValue );
1840+ assertEquals ("Expected 2 update audit events" , 2 , updateAuditPairs .size ());
1841+
1842+ // Update row 0: old = "1", new = """3""".
1843+ String expectedUpdate0Old = _auditLogHelper .joinMultiChoiceForAudit (plainValue );
1844+ String expectedUpdate0New = _auditLogHelper .joinMultiChoiceForAudit (quotedValue2 );
1845+ checker ().verifyTrue ("Update row 0: audit pair not found" ,
1846+ updateAuditPairs .stream ().anyMatch (p -> expectedUpdate0Old .equals (p [0 ]) && expectedUpdate0New .equals (p [1 ])));
1847+
1848+ // Update row 1: old = """2""", new = null (clearing all selections removes the field from the audit record).
1849+ String expectedUpdate1Old = _auditLogHelper .joinMultiChoiceForAudit (quotedValue1 );
1850+ checker ().verifyTrue ("Update row 1 (remove value): audit pair not found" ,
1851+ updateAuditPairs .stream ().anyMatch (p -> expectedUpdate1Old .equals (p [0 ]) && p [1 ] == null ));
18371852
18381853 _listHelper .deleteList ();
18391854 }
0 commit comments