aminghadersohi commented on code in PR #41121:
URL: https://github.com/apache/superset/pull/41121#discussion_r3437364976


##########
superset-frontend/src/features/alerts/components/AlertStatusIcon.tsx:
##########
@@ -79,8 +84,10 @@ export default function AlertStatusIcon({
       lastStateConfig.status = AlertState.Error;
       break;
     case AlertState.Noop:
-      lastStateConfig.icon = Icons.CheckOutlined;
-      lastStateConfig.label = t('Nothing triggered');
+      lastStateConfig.icon = Icons.CalendarOutlined;
+      lastStateConfig.label = isReportEnabled

Review Comment:
   [MEDIUM] New tooltip label `'Report not yet run'` for reports doesn't match 
the list-view filter option `AlertStateLabel[AlertState.Noop] = t('Not 
triggered')` in `AlertReportList/index.tsx:78`. Three different strings now 
exist for the same backend state (`Not triggered` in filter, `Report not yet 
run` in icon tooltip for reports, `Nothing triggered` in icon tooltip for 
alerts). Either update `AlertStateLabel` to align with this wording, or keep 
the tooltip consistent with the existing filter term.



##########
superset-frontend/src/features/alerts/components/AlertStatusIcon.test.tsx:
##########
@@ -0,0 +1,72 @@
+/**
+ * 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 userEvent from '@testing-library/user-event';
+import { render, screen } from 'spec/helpers/testing-library';
+import AlertStatusIcon from './AlertStatusIcon';
+import { AlertState } from '../types';
+
+const renderIcon = (state: string, isReportEnabled = false) =>
+  render(<AlertStatusIcon state={state} isReportEnabled={isReportEnabled} />);
+
+test('renders a check icon for the Success state', () => {
+  const { container } = renderIcon(AlertState.Success);
+  expect(container.querySelector('[data-icon="check"]')).toBeInTheDocument();
+});
+
+test('renders a close icon for the Error state', () => {
+  const { container } = renderIcon(AlertState.Error);
+  expect(container.querySelector('[data-icon="close"]')).toBeInTheDocument();
+});
+
+test('renders a warning icon for the Grace state', () => {
+  const { container } = renderIcon(AlertState.Grace);
+  expect(container.querySelector('[data-icon="warning"]')).toBeInTheDocument();
+});
+
+// Regression for issue #29622: a report that has never run has
+// last_state="Not triggered" (the backend default), which previously rendered
+// a green success check and looked like a successful run. It should now render
+// a neutral calendar icon instead.
+test('renders a neutral calendar icon (not a success check) for the Not 
triggered state', () => {
+  const { container } = renderIcon(AlertState.Noop);
+  
expect(container.querySelector('[data-icon="calendar"]')).toBeInTheDocument();
+  expect(
+    container.querySelector('[data-icon="check"]'),
+  ).not.toBeInTheDocument();
+});
+
+test('renders the neutral calendar icon for an unknown/never-run state', () => 
{
+  const { container } = renderIcon('');
+  
expect(container.querySelector('[data-icon="calendar"]')).toBeInTheDocument();
+  expect(
+    container.querySelector('[data-icon="check"]'),
+  ).not.toBeInTheDocument();
+});
+
+test('labels the Not triggered state "Report not yet run" for reports', async 
() => {
+  renderIcon(AlertState.Noop, /* isReportEnabled */ true);
+  userEvent.hover(screen.getByRole('img'));
+  expect(await screen.findByText('Report not yet run')).toBeInTheDocument();
+});
+
+test('labels the Not triggered state "Nothing triggered" for alerts', async () 
=> {

Review Comment:
   [MEDIUM] False-positive test: `'Nothing triggered'` was the unconditional 
Noop label before this PR (for both reports and alerts), so this test passes 
even when the new conditional is reverted. It guards unchanged alert behavior, 
not the new `isReportEnabled`-based split. Only the report-label test at line 
62 actually exercises new code.



##########
superset-frontend/src/features/alerts/components/AlertStatusIcon.tsx:
##########
@@ -89,8 +96,10 @@ export default function AlertStatusIcon({
       lastStateConfig.status = AlertState.Grace;
       break;
     default:
-      lastStateConfig.icon = Icons.CheckOutlined;
-      lastStateConfig.label = t('Nothing triggered');
+      lastStateConfig.icon = Icons.CalendarOutlined;
+      lastStateConfig.label = isReportEnabled

Review Comment:
   [NIT] `isReportEnabled ? t('Report not yet run') : t('Nothing triggered')` 
is duplicated verbatim in the Noop case (line 88) and this default case. 
Consider `const noopLabel = isReportEnabled ? t('Report not yet run') : 
t('Nothing triggered')` before the switch.



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