bito-code-review[bot] commented on code in PR #38807:
URL: https://github.com/apache/superset/pull/38807#discussion_r3611298709


##########
superset-frontend/packages/superset-ui-core/src/components/RlsBadge/RlsBadge.test.tsx:
##########
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { render, screen, userEvent, waitFor } from '@superset-ui/core/spec';
+import { RlsBadge, type RlsBadgeProps } from '.';
+
+const mockFilters = [
+  { id: 1, name: 'Finance filter', filter_type: 'Regular', group_key: 'dept' },
+  { id: 2, name: 'Base restriction', filter_type: 'Base', group_key: null },
+];
+
+const asyncRender = (props: RlsBadgeProps) =>
+  waitFor(() => render(<RlsBadge {...props} />));
+
+test('renders nothing when rlsFilters is empty', async () => {
+  const { container } = await asyncRender({ rlsFilters: [] });
+  expect(container.firstChild).toBeNull();
+});
+
+test('renders a lock icon when filters exist', async () => {
+  await asyncRender({ rlsFilters: mockFilters });
+  expect(screen.getByTestId('rls-badge')).toBeInTheDocument();

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Wrong test attribute selector</b></div>
   <div id="fix">
   
   The test uses `getByTestId('rls-badge')` which looks for 
`data-testid="rls-badge"`, but the component (index.tsx:102) renders 
`data-test="rls-badge"`. These attributes don't match — RTL's `getByTestId` 
doesn't search `data-test`. This causes the test to fail with a 'Unable to find 
an accessible element' error. Align with the existing pattern used in other 
tests at lines 42, 51, 59, 75, 97, and 115 which correctly use 
`getByRole('img')`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #335171</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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