Copilot commented on code in PR #36149:
URL: https://github.com/apache/superset/pull/36149#discussion_r2536030931


##########
superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx:
##########
@@ -711,24 +727,44 @@ describe('plugin-chart-table', () => {
           // IDs should only contain valid CSS selector characters
           expect(header.id).toMatch(/^header-[a-zA-Z0-9_-]+$/);
         });
+      });
 
-        // Test 6: Verify ALL cells reference valid headers (no broken ARIA)
+      test('should validate ARIA references for regular table cells', () => {
+        // Test that ALL cells with aria-labelledby have valid references
+        // This is critical for screen reader accessibility
+        const props = transformProps(testData.advanced);
+
+        const { container } = render(
+          ProviderWrapper({
+            children: <TableChart {...props} sticky={false} />,
+          }),
+        );
+
+        const allCells = container.querySelectorAll('tbody td');
         const cellsWithLabels = container.querySelectorAll(
-          'td[aria-labelledby]',
+          'tbody td[aria-labelledby]',
         );
+
+        // First assertion: Table must render data cells (catch empty table 
regression)
+        expect(allCells.length).toBeGreaterThan(0);
+
+        // Second assertion: ALL data cells must have aria-labelledby (no 
unlabeled cells)
+        expect(cellsWithLabels.length).toBe(allCells.length);
+
+        // Third assertion: ALL aria-labelledby values should be valid
         cellsWithLabels.forEach(cell => {
           const labelledBy = cell.getAttribute('aria-labelledby');

Review Comment:
   The assertion `expect(labelledBy).toEqual(expect.stringMatching(/\S/))` 
doesn't prevent null values. If `getAttribute` returns null, the type assertion 
on line 758 will cast null to string, causing subsequent operations to fail. 
Add an explicit null check: `expect(labelledBy).not.toBeNull()` before the 
string matching assertion, or use `expect(labelledBy).toBeTruthy()` instead.
   ```suggestion
             const labelledBy = cell.getAttribute('aria-labelledby');
             expect(labelledBy).not.toBeNull();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to