Brijesh619 commented on code in PR #703:
URL: https://github.com/apache/atlas/pull/703#discussion_r3860317347
##########
dashboard/src/views/DashboardOverview/ClassificationDistributionCard.tsx:
##########
@@ -60,8 +66,13 @@ const ClassificationDistributionCard = memo(({ tag,
isLoading }: ClassificationD
);
const handleBarClick = useCallback(
- (entry: { name: string }) => {
- navigateToClassificationSearch(navigate, entry.name);
+ (barProps: unknown) => {
Review Comment:
Done. I've mirrored the pattern from `EntityTypeBarChart.test.tsx` by
updating the Recharts `Bar` mock to support a customizable
`mockBarClickPayload` and added the following tests:
1. **Positive case**: Confirmed that a valid bar click successfully
navigates to the classification search.
2. **Negative cases**: Added tests to ensure that invalid payloads (`null`,
string, and empty objects) are safely ignored by the type guard and do not
trigger navigation.
##########
dashboard/src/views/DashboardOverview/__tests__/EntityStatusDonut.test.tsx:
##########
@@ -0,0 +1,131 @@
+/*
+ * 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, fireEvent } from "@testing-library/react";
Review Comment:
Good catch! Fixed. I've removed the `any` type in the `onClick` handler
inside `EntityStatusDonut.tsx` and replaced it with `unknown`, using a strict
structural type assertion to safely extract `data?.name`. All Recharts test
mocks have also been updated to use typed interfaces.
##########
dashboard/src/views/Statistics/EntityStatsChart.tsx:
##########
@@ -87,21 +98,24 @@ const EntityStatsChart = ({
cursor={{ stroke: "rgba(0, 0, 0, 0.1)",
strokeWidth: 2 }}
/>
<Legend
- onClick={(e) => {
- if (e && e.id) {
-
onLegendClick(String(e.id));
- }
- }}
-
payload={Object.keys(activeKeys).map((key) => ({
- id: key,
- type: "square",
- value: key,
- color:
- activeKeys[key as keyof
ActiveKeys] === true
- ?
getColorForKey(key)
- : "#d3d3d3",
- inactive: !activeKeys[key as
keyof ActiveKeys],
- }))}
+ content={() => (
Review Comment:
Done. I've added a focused isolated test file for this component at
`EntityStatsChart.test.tsx` which tests the custom legend renderer
independently. The tests cover the click toggling behavior, `aria-label`
assignments, and verify the correct application of active (`getColorForKey`)
and inactive (`#d3d3d3`) styling states.
##########
dashboard/src/views/Statistics/__tests__/EntityStats.test.tsx:
##########
@@ -165,15 +165,20 @@ jest.mock('recharts', () => ({
YAxis: ({ domain, tickFormatter }: any) => <div data-testid="y-axis"
data-domain={JSON.stringify(domain)} data-tick-formatter={tickFormatter ?
tickFormatter(10) : ''} />,
Review Comment:
Done. I've removed the inline `LABEL_LIST_STYLE` object and replaced it with
a new `.chart-label-list-sm` SCSS class as suggested.
--
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]