This is an automated email from the ASF dual-hosted git repository.

jli pushed a commit to branch feat/dataset-playwright-tests
in repository https://gitbox.apache.org/repos/asf/superset.git

commit a6025aba27b8319371d377046c7de60a4d0e78b7
Author: Joe Li <[email protected]>
AuthorDate: Thu Nov 13 22:40:04 2025 -0800

    fix(playwright): use exact cell match in Table.getRow() to prevent 
substring collisions
    
    **Problem**: Duplicate dataset test failing with strict mode violation:
    ```
    Error: locator().filter({ hasText: 'members_channels_2' }) resolved to 2 
elements:
      1) duplicate_members_channels_2_1763101756082
      2) members_channels_2
    ```
    
    **Root Cause**: The `filter({ hasText: rowText })` uses substring matching,
    so searching for 'members_channels_2' matches both the original dataset
    AND any duplicates that contain that substring in their name.
    
    **Solution**: Use exact cell match instead of substring text match
    
    Changed `Table.getRow()` from:
    ```typescript
    .filter({ hasText: rowText })
    ```
    
    To:
    ```typescript
    .filter({ has: this.page.getByRole('cell', { name: rowText, exact: true }) 
})
    ```
    
    **Why this works**:
    - Matches the cell with EXACT text (not substring)
    - Won't match 'duplicate_members_channels_2_XXX' when looking for 
'members_channels_2'
    - More precise and resilient to leftover test data
    - Uses semantic selector (role='cell') + exact match
    
    **Impact**: All tests using `getDatasetRow()` will now use exact matching:
    - Navigate test (finds specific dataset in list)
    - Delete test (finds correct dataset to delete)
    - Duplicate test (distinguishes original from duplicate)
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude <[email protected]>
---
 superset-frontend/playwright/components/core/Table.ts | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/playwright/components/core/Table.ts 
b/superset-frontend/playwright/components/core/Table.ts
index 84dd138b90..854254ae3b 100644
--- a/superset-frontend/playwright/components/core/Table.ts
+++ b/superset-frontend/playwright/components/core/Table.ts
@@ -43,13 +43,16 @@ export class Table {
   }
 
   /**
-   * Gets a table row by text content
-   * @param rowText - Text to find in the row
+   * Gets a table row by exact text match in the first cell (dataset name 
column).
+   * Uses exact match to avoid substring collisions (e.g., 
'members_channels_2' vs 'duplicate_members_channels_2_123').
+   * @param rowText - Exact text to find in the row's first cell
    */
   getRow(rowText: string): Locator {
     return this.element
       .locator(Table.SELECTORS.TABLE_ROW)
-      .filter({ hasText: rowText });
+      .filter({
+        has: this.page.getByRole('cell', { name: rowText, exact: true }),
+      });
   }
 
   /**

Reply via email to