2025-12-03 17:16:14 +01:00
// wxGrid Cell Editing Tests - Property editing simulation
2026-07-07 10:50:24 +02:00
import { test , expect , waitForWxApp } from './utils/fixtures' ;
import { clickByLabel , clickGridCell , findGridCell , stableShot } from './utils/element-tracker' ;
2025-12-03 17:16:14 +01:00
test . describe ( 'wxGrid Cell Editing Tests' , ( ) = > {
test ( 'GridEdit test app loads successfully' , async ( { page , testLogger } ) = > {
await page . goto ( '/standalone/gridedit/gridedit_test.html' ) ;
2026-07-07 10:50:24 +02:00
await waitForWxApp ( page ) ;
2025-12-03 17:16:14 +01:00
2026-07-07 10:50:24 +02:00
await stableShot ( page , 'gridedit-01-loaded.png' , { fullPage : true } ) ;
2025-12-03 17:16:14 +01:00
expect ( testLogger . errors . filter ( e = > ! e . includes ( 'favicon' ) ) ) . toHaveLength ( 0 ) ;
} ) ;
test ( 'Grid cells can be selected' , async ( { page , testLogger } ) = > {
await page . goto ( '/standalone/gridedit/gridedit_test.html' ) ;
2026-07-07 10:50:24 +02:00
await waitForWxApp ( page ) ;
2025-12-03 17:16:14 +01:00
2025-12-30 14:17:51 +01:00
// Click on a cell using element registry
const clicked = await clickGridCell ( page , 1 , 1 ) ;
expect ( clicked , 'Grid cell should be found and clicked' ) . toBe ( true ) ;
2025-12-03 17:16:14 +01:00
2026-07-07 10:50:24 +02:00
await stableShot ( page , 'gridedit-02-select-cell.png' , { fullPage : true } ) ;
2025-12-03 17:16:14 +01:00
} ) ;
test ( 'Grid cells can be edited' , async ( { page , testLogger } ) = > {
await page . goto ( '/standalone/gridedit/gridedit_test.html' ) ;
2026-07-07 10:50:24 +02:00
await waitForWxApp ( page ) ;
2025-12-03 17:16:14 +01:00
2025-12-30 14:17:51 +01:00
// Double-click to enter edit mode using element registry
const cell = await findGridCell ( page , 1 , 1 ) ;
expect ( cell , 'Grid cell should be found' ) . not . toBeNull ( ) ;
2026-07-07 10:50:24 +02:00
await page . mouse . dblclick ( cell ! . centerX , cell ! . centerY ) ;
2025-12-03 17:16:14 +01:00
2026-07-07 10:50:24 +02:00
await stableShot ( page , 'gridedit-03-edit-cell.png' , { fullPage : true } ) ;
2025-12-03 17:16:14 +01:00
} ) ;
test ( 'Grid rows can be added' , async ( { page , testLogger } ) = > {
await page . goto ( '/standalone/gridedit/gridedit_test.html' ) ;
2026-07-07 10:50:24 +02:00
await waitForWxApp ( page ) ;
2025-12-03 17:16:14 +01:00
2025-12-30 14:17:51 +01:00
// Click Add Row button using element registry
const clicked = await clickByLabel ( page , 'Add Row' ) ;
expect ( clicked , 'Add Row button should be found and clicked' ) . toBe ( true ) ;
2025-12-03 17:16:14 +01:00
2026-07-07 10:50:24 +02:00
await stableShot ( page , 'gridedit-04-add-row.png' , { fullPage : true } ) ;
2025-12-03 17:16:14 +01:00
} ) ;
test ( 'Grid rows can be deleted' , async ( { page , testLogger } ) = > {
await page . goto ( '/standalone/gridedit/gridedit_test.html' ) ;
2026-07-07 10:50:24 +02:00
await waitForWxApp ( page ) ;
2025-12-03 17:16:14 +01:00
2025-12-30 14:17:51 +01:00
// Select a row first using element registry
const cellClicked = await clickGridCell ( page , 1 , 1 ) ;
expect ( cellClicked , 'Grid cell should be found and clicked' ) . toBe ( true ) ;
2026-07-07 10:50:24 +02:00
await page . waitForTimeout ( 100 ) ; // eslint-disable-line -- documented interaction dwell: let the cell-selection commit before the Delete Row click; no observable event is emitted
2025-12-30 14:17:51 +01:00
// Click Delete Row button using element registry
const deleteClicked = await clickByLabel ( page , 'Delete Row' ) ;
expect ( deleteClicked , 'Delete Row button should be found and clicked' ) . toBe ( true ) ;
2025-12-03 17:16:14 +01:00
2026-07-07 10:50:24 +02:00
await stableShot ( page , 'gridedit-05-delete-row.png' , { fullPage : true } ) ;
2025-12-03 17:16:14 +01:00
} ) ;
} ) ;