codeant-ai-for-open-source[bot] commented on code in PR #32995:
URL: https://github.com/apache/superset/pull/32995#discussion_r3546591625


##########
superset-frontend/src/pages/DatasetList/DatasetList.listview.test.tsx:
##########
@@ -1050,11 +1049,10 @@ test('edit action is disabled for non-editor', async () 
=> {
 
   const row = screen.getByText(dataset.table_name).closest('tr');
   const editIcon = within(row!).getByTestId('edit');
-  const editButton = editIcon.closest('.action-button, .disabled');
+  const editButton = editIcon.closest('[role="button"]');
 
-  // Should have disabled class (disabled buttons still have 'action-button' 
class)
-  expect(editButton).toHaveClass('disabled');
-  expect(editButton).toHaveClass('action-button');
+  // Should be disabled
+  expect(editButton).toHaveAttribute('aria-disabled', 'true');

Review Comment:
   **Suggestion:** This assertion is incorrect for the current test setup and 
will fail: the “regular user” in this test is still treated as admin (role key 
is `Admin`), so the edit action should not be disabled. Update the test setup 
to use a truly non-admin user with write permission (for example an `Alpha` 
role) before asserting `aria-disabled="true"`. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   ❌ DatasetList page tests misrepresent admin vs editor behavior.
   ❌ Dataset edit permission test asserts incorrect disabled state.
   ⚠️ CI pipeline may fail on permission regression suite.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Run the Jest test suite including `edit action is disabled for 
non-editor` in
   
`superset-frontend/src/pages/DatasetList/DatasetList.listview.test.tsx:91-117`.
   
   2. In that test, a `regularUser` is constructed by spreading `mockAdminUser` 
from
   `DatasetList.testHelpers.tsx:224-236` and overriding `roles` to `{ Admin: 
[['can_read',
   'Dataset']] }`, still leaving the `Admin` role key.
   
   3. `renderDatasetList(regularUser)` (from 
`DatasetList.testHelpers.tsx:360-39`) renders
   `DatasetList` with this user; inside `DatasetList` (`index.tsx:155-188`), 
`allowEdit` is
   computed via `isUserOwnerOrAdmin(user, original.editors)`.
   
   4. `isUserOwnerOrAdmin` in `dashboard/util/permissionUtils.ts:13-21` calls 
`isUserAdmin`,
   which checks `Object.keys(user.roles).some(role => role.toLowerCase() === 
'admin')`; since
   `regularUser.roles` still contains `Admin`, `allowEdit` is true, the 
IconButton is not
   disabled, so the assertion 
`expect(editButton).toHaveAttribute('aria-disabled', 'true');`
   at `DatasetList.listview.test.tsx:115-116` fails.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a331ab4f0a434bab9f29a9672a6b86eb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a331ab4f0a434bab9f29a9672a6b86eb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/pages/DatasetList/DatasetList.listview.test.tsx
   **Line:** 1054:1055
   **Comment:**
        *Logic Error: This assertion is incorrect for the current test setup 
and will fail: the “regular user” in this test is still treated as admin (role 
key is `Admin`), so the edit action should not be disabled. Update the test 
setup to use a truly non-admin user with write permission (for example an 
`Alpha` role) before asserting `aria-disabled="true"`.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F32995&comment_hash=3da01b5a902d96e9d901b6c14268eb8feff245c5ca3ebf400302f53b6bd7cc2a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F32995&comment_hash=3da01b5a902d96e9d901b6c14268eb8feff245c5ca3ebf400302f53b6bd7cc2a&reaction=dislike'>👎</a>



-- 
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