Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jest.mock('../../../../utils/date-time/DateTimeUtils', () => ({
getEpochMillisForPastDays: jest.fn().mockReturnValue(1709424034000),
getStartOfDayInMillis: jest.fn().mockImplementation((val) => val),
getEndOfDayInMillis: jest.fn().mockImplementation((val) => val),
convertMillisecondsToHumanReadableFormat: jest
convertSecondsToHumanReadableFormat: jest
.fn()
.mockImplementation((val) => `${val}ms`),
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock implementation returns a string with 'ms' suffix, which is misleading since this function converts seconds (not milliseconds) to human-readable format. Consider using a more accurate suffix like 's' or 'sec' to make the mock clearer and avoid confusion.

Suggested change
.mockImplementation((val) => `${val}ms`),
.mockImplementation((val) => `${val}s`),

Copilot uses AI. Check for mistakes.
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import {
} from '../../../../utils/ChartUtils';
import { prepareChartData } from '../../../../utils/DataQuality/TestSummaryGraphUtils';
import {
convertMillisecondsToHumanReadableFormat,
convertSecondsToHumanReadableFormat,
formatDateTime,
} from '../../../../utils/date-time/DateTimeUtils';
import { useActivityFeedProvider } from '../../../ActivityFeed/ActivityFeedProvider/ActivityFeedProvider';
Expand Down Expand Up @@ -179,8 +179,8 @@ function TestSummaryGraph({
// Todo: need to find better approach to create dynamic scale for graph, need to work with @TeddyCr for the same!
const formatYAxis = (value: number) => {
return testDefinitionName === TABLE_DATA_TO_BE_FRESH || isFreshnessTest
? // table freshness will always have output value in seconds, so we need to convert it to milliseconds
convertMillisecondsToHumanReadableFormat(value * 1000, 2)
? // table freshness value is in seconds from Python/backend, use dedicated seconds converter
convertSecondsToHumanReadableFormat(value, 2)
: axisTickFormatter(value);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { TABLE_FRESHNESS_KEY } from '../../../../constants/TestSuite.constant';
import { Thread } from '../../../../generated/entity/feed/thread';
import { formatNumberWithComma } from '../../../../utils/CommonUtils';
import {
convertMillisecondsToHumanReadableFormat,
convertSecondsToHumanReadableFormat,
formatDateTimeLong,
} from '../../../../utils/date-time/DateTimeUtils';
import { getTaskDetailPath } from '../../../../utils/TasksUtils';
Expand Down Expand Up @@ -91,11 +91,10 @@ const TestSummaryCustomTooltip = (
</span>
<span className="font-medium" data-testid={key}>
{key === TABLE_FRESHNESS_KEY && isNumber(value)
? // freshness will always be in seconds, so we need to convert it to milliseconds
convertMillisecondsToHumanReadableFormat(
value * 1000,
? // freshness value is in seconds from Python/backend, use dedicated seconds converter
convertSecondsToHumanReadableFormat(
value,
undefined,
false,
// negative value will be shown as late by
`${t('label.late-by')} `
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jest.mock('../../../../utils/date-time/DateTimeUtils', () => ({
formatDateTimeLong: jest
.fn()
.mockReturnValue('Jan 3, 2024, 6:45 PM (UTC+05:30)'),
convertMillisecondsToHumanReadableFormat: jest
convertSecondsToHumanReadableFormat: jest
.fn()
.mockReturnValue('7Y 2M 22d 9m 24s'),
}));
Expand All @@ -88,29 +88,29 @@ describe('Test TestSummaryCustomTooltip component', () => {
expect(
await screen.findByTestId('test-summary-tooltip-container')
).toBeInTheDocument();
expect((await screen.findByTestId('status')).textContent).toEqual('Failed');
expect((await screen.findByTestId('minValueLength')).textContent).toEqual(
expect((await screen.findByTestId('status')).textContent).toBe('Failed');
expect((await screen.findByTestId('minValueLength')).textContent).toBe(
'12'
);
expect((await screen.findByTestId('maxValueLength')).textContent).toEqual(
expect((await screen.findByTestId('maxValueLength')).textContent).toBe(
'24'
);
expect((await screen.findByTestId('passedRows')).textContent).toEqual('4');
expect((await screen.findByTestId('failedRows')).textContent).toEqual('2');
expect((await screen.findByTestId('passedRows')).textContent).toBe('4');
expect((await screen.findByTestId('failedRows')).textContent).toBe('2');
expect(
(await screen.findByTestId('passedRowsPercentage')).textContent
).toEqual('60%');
).toBe('60%');
expect(
(await screen.findByTestId('failedRowsPercentage')).textContent
).toEqual('40%');
).toBe('40%');
expect(screen.queryByText('name')).not.toBeInTheDocument();
});

it('should display freshness in values in milliseconds', async () => {
it('should display freshness values in seconds', async () => {
render(<TestSummaryCustomTooltip {...mockPropsWithFreshness} />);

expect((await screen.findByTestId('status')).textContent).toEqual('Failed');
expect((await screen.findByTestId('freshness')).textContent).toEqual(
expect((await screen.findByTestId('status')).textContent).toBe('Failed');
expect((await screen.findByTestId('freshness')).textContent).toBe(
'7Y 2M 22d 9m 24s'
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2025 Collate.
* Licensed 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.
*/
export const MONTHS_IN_YEAR = 12;
export const DAYS_IN_MONTH = 30;
export const HOURS_IN_DAY = 24;
export const HOUR_SECONDS = 3600;
export const MINUTE_SECONDS = 60;
export const YEAR_SECONDS =
MONTHS_IN_YEAR * DAYS_IN_MONTH * HOURS_IN_DAY * HOUR_SECONDS; // 31,104,000 seconds (12 months × 30 days)
export const MONTH_SECONDS = DAYS_IN_MONTH * HOURS_IN_DAY * HOUR_SECONDS; // 2,592,000 seconds (average month)
export const DAY_SECONDS = HOURS_IN_DAY * HOUR_SECONDS; // 86,400 seconds
Loading