Skip to content

Commit ffdd9c5

Browse files
committed
fix(console,core-api): resolve CI failures in dashboard branch
- Remove stray setDateRange call in asset-context (TS2552) - Convert raw host asset createdAt string to Date (TS2322) - Make weekly cron test deterministic regardless of weekday - Mock echarts-for-react in dashboard test (jsdom crash)
1 parent b14ceae commit ffdd9c5

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

console/src/__tests__/pages/dashboard.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ vi.mock('recharts', () => {
2626
};
2727
});
2828

29+
vi.mock('echarts-for-react/esm/core', () => ({
30+
default: () => <div />,
31+
}));
32+
2933
vi.mock('react-leaflet', () => ({
3034
MapContainer: ({ children }: { children?: React.ReactNode }) => (
3135
<div>{children}</div>

console/src/components/ui/cron-schedule-builder.test.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ describe('CronScheduleBuilder', () => {
8585
const user = userEvent.setup();
8686
const { onChange } = renderBuilder();
8787
await user.click(screen.getByRole('button', { name: 'Weekly' }));
88-
await user.click(screen.getByRole('button', { name: 'Mon' }));
89-
await user.click(screen.getByRole('button', { name: 'Thu' }));
90-
// Weekly preselects today; selected days are Mon+Thu+today. Local 00:00
88+
// Weekly preselects today; clicking an already-selected day toggles it
89+
// OFF, so pick two days that can never collide with today. Local 00:00
9190
// +07 -> 17:00 UTC the previous day shifts each weekday back one day.
92-
const today = ((new Date().getDay() + 6) % 7) + 1;
91+
const today = ((new Date().getDay() + 6) % 7) + 1; // 1=Mon .. 7=Sun
92+
const others = WEEKDAY_LABELS.map((_, i) => i + 1).filter((d) => d !== today);
93+
const picked = [others[0], others[3]];
94+
for (const day of picked) {
95+
await user.click(screen.getByRole('button', { name: WEEKDAY_LABELS[day - 1] }));
96+
}
9397
const shiftBack = (d: number) => ((((d - 2) % 7) + 7) % 7) + 1;
94-
const expected = [...new Set([1, 4, today].map(shiftBack))].sort().join(',');
98+
const expected = [...new Set([...picked, today].map(shiftBack))].sort().join(',');
9599
expect(onChange).toHaveBeenLastCalledWith({
96100
cron: `0 17 * * ${expected}`,
97101
timezone: 'Asia/Ho_Chi_Minh',

console/src/pages/assets/context/asset-context.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export default function AssetProvider({
126126

127127
const handleDateRangeChange = useCallback(
128128
(date: DateRange | undefined) => {
129-
setDateRange(date);
130129
navigate({
131130
search: ((prev: Record<string, unknown>) => ({
132131
...prev,

core-api/src/modules/assets/assets.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ describe('AssetsService', () => {
279279

280280
expect(result.data[0]).toMatchObject({
281281
host: 'api.x.com',
282-
createdAt: '2026-08-01T00:00:00.000Z',
282+
createdAt: new Date('2026-08-01T00:00:00.000Z'),
283283
});
284284
});
285285
});

core-api/src/modules/assets/assets.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ export class AssetsService {
652652
obj.targetId = item.asset_targetId;
653653
obj.isEnabled = item.asset_isEnabled;
654654
obj.assetCount = item.assetCount;
655-
obj.createdAt = item.asset_createdAt;
655+
obj.createdAt = new Date(item.asset_createdAt);
656656
return obj;
657657
},
658658
);

0 commit comments

Comments
 (0)