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


##########
superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.test.tsx:
##########
@@ -117,20 +114,31 @@ test('renders the correct input fields based on the 
selected operator', async ()
 });
 
 test('renders None for operator when Green for increase is selected', async () 
=> {
-  render(
+  const { container } = render(
     <FormattingPopoverContent
       onChange={mockOnChange}
       columns={columns}
       extraColorChoices={extraColorChoices}
     />,
   );
 
-  // Select the 'Green for increase' color scheme
-  fireEvent.change(screen.getAllByLabelText(/color scheme/i)[0], {
-    target: { value: ColorSchemeEnum.Green },
+  const colorPickerTrigger = container.querySelector(
+    '.ant-color-picker-trigger',
+  );
+  expect(colorPickerTrigger).toBeInTheDocument();
+  await userEvent.click(colorPickerTrigger!);
+
+  await waitFor(() => {
+    expect(
+      document.querySelector('.ant-color-picker-presets-items'),
+    ).toBeInTheDocument();
   });
 
-  fireEvent.click(await screen.findByTitle(/green for increase/i));
+  const presets = document.querySelectorAll('.ant-color-picker-presets-color');
+  const greenPreset = presets[0];

Review Comment:
   Yes. The test should select the **Green trend preset explicitly**, rather 
than relying on `presets[0]`, because the default theme-color group is rendered 
before `extraColorChoices`.
   
   For example, locate the trend preset by its label and click its 
corresponding swatch:
   
   ```typescript
   const trendPreset = await screen.findByText('Colors', {
     // Use the specific label passed in `extraColorChoices`.
   });
   
   const trendGroup = trendPreset.closest('.ant-color-picker-presets-group');
   expect(trendGroup).toBeInTheDocument();
   
   const greenPreset = trendGroup!.querySelector(
     '.ant-color-picker-presets-color',
   );
   expect(greenPreset).toBeInTheDocument();
   
   await userEvent.click(greenPreset!);
   
   expect(screen.getByText(/none/i)).toBeInTheDocument();
   ```
   
   Preferably, give the trend group a unique label such as `Trend colors` in 
the test fixture and select that group, then assert the operator is `None` 
after clicking its first swatch. This makes the test verify the intended 
Green-specific behavior and prevents it from accidentally passing when a 
default theme color is selected.



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