fix: update tests for new Menubar UI implementation

- Remove refresh button test from Calendar.test.tsx
- Update Menubar tests to pass required props (calendarRef, onRefresh, currentDate)
- Update Calendar tests to pass calendarRef prop
- Remove outdated test cases from MiniCalendarColor.test.tsx that tested old headerToolbar
- Format code with prettier
This commit is contained in:
lenhanphung
2025-09-24 12:41:15 +07:00
parent 12dc0d7fe1
commit 0f74ddfc27
8 changed files with 240 additions and 281 deletions
+16 -5
View File
@@ -43,7 +43,10 @@ interface CalendarAppProps {
onDateChange?: (date: Date) => void;
}
export default function CalendarApp({ calendarRef, onDateChange }: CalendarAppProps) {
export default function CalendarApp({
calendarRef,
onDateChange,
}: CalendarAppProps) {
const [selectedDate, setSelectedDate] = useState(new Date());
const [selectedMiniDate, setSelectedMiniDate] = useState(new Date());
const tokens = useAppSelector((state) => state.user.tokens);
@@ -129,7 +132,14 @@ export default function CalendarApp({ calendarRef, onDateChange }: CalendarAppPr
);
}
});
}, [rangeKey, selectedCalendars, pending, dispatch, calendarRange.start, calendarRange.end]);
}, [
rangeKey,
selectedCalendars,
pending,
dispatch,
calendarRange.start,
calendarRange.end,
]);
useEffect(() => {
updateCalsDetails(
@@ -357,8 +367,9 @@ export default function CalendarApp({ calendarRef, onDateChange }: CalendarAppPr
}}
datesSet={(arg) => {
// Get the current date from calendar API to ensure consistency
const calendarCurrentDate = calendarRef.current?.getDate() || new Date(arg.start);
const calendarCurrentDate =
calendarRef.current?.getDate() || new Date(arg.start);
if (arg.view.type === "dayGridMonth") {
setSelectedDate(new Date(arg.start));
setSelectedMiniDate(calendarCurrentDate);
@@ -366,7 +377,7 @@ export default function CalendarApp({ calendarRef, onDateChange }: CalendarAppPr
setSelectedDate(new Date(arg.start));
setSelectedMiniDate(new Date(arg.start));
}
// Always use the calendar's current date for consistency
if (onDateChange) {
onDateChange(calendarCurrentDate);
+4 -3
View File
@@ -16,17 +16,18 @@ export default function CalendarLayout() {
const calendarRef = useRef<any>(null);
const dispatch = useAppDispatch();
const selectedCalendars = useAppSelector((state) => state.calendars.list);
const userId = useAppSelector((state) => state.user.userData?.openpaasId) ?? "";
const userId =
useAppSelector((state) => state.user.userData?.openpaasId) ?? "";
const [currentDate, setCurrentDate] = useState<Date>(new Date());
const handleRefresh = async () => {
await dispatch(getCalendarsListAsync());
// Get current calendar range
if (calendarRef.current) {
const view = calendarRef.current.getApi().view;
const calendarRange = getCalendarRange(view.activeStart);
// Refresh events for selected calendars
Object.keys(selectedCalendars).forEach((id) => {
if (id.split("/")[0] === userId) {
+5 -1
View File
@@ -105,7 +105,11 @@ th.fc-col-header-cell.fc-day {
position: relative;
transform: translate(-15px, -12px);
}
.fc tbody tr:first-of-type .fc-timegrid-slot-label .fc-timegrid-slot-label-frame {
.fc
tbody
tr:first-of-type
.fc-timegrid-slot-label
.fc-timegrid-slot-label-frame {
display: none;
}
.fc .fc-timegrid-slot-label .fc-timegrid-slot-label-frame::after {