Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -82,6 +82,13 @@ describe("Event Preview Display", () => {
|
|||||||
end: day.toISOString(),
|
end: day.toISOString(),
|
||||||
organizer: { cn: "test", cal_address: "test@test.com" },
|
organizer: { cn: "test", cal_address: "test@test.com" },
|
||||||
},
|
},
|
||||||
|
event3: {
|
||||||
|
uid: "event3",
|
||||||
|
calId: "667037022b752d0026472254/cal1",
|
||||||
|
start: day.toISOString(),
|
||||||
|
end: day.toISOString(),
|
||||||
|
organizer: { cn: "test", cal_address: "test@test.com" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ownerEmails: ["test@test.com"],
|
ownerEmails: ["test@test.com"],
|
||||||
},
|
},
|
||||||
@@ -797,7 +804,21 @@ describe("Event Preview Display", () => {
|
|||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("renders correctly event data event with empty title", () => {
|
||||||
|
renderWithProviders(
|
||||||
|
<EventPreviewModal
|
||||||
|
open={true}
|
||||||
|
onClose={mockOnClose}
|
||||||
|
calId={"667037022b752d0026472254/cal1"}
|
||||||
|
eventId={"event3"}
|
||||||
|
/>,
|
||||||
|
preloadedState
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText("event.untitled")).toBeInTheDocument();
|
||||||
|
|
||||||
|
expect(screen.getByText("Calendar")).toBeInTheDocument();
|
||||||
|
});
|
||||||
describe("BUGFIX", () => {
|
describe("BUGFIX", () => {
|
||||||
it("doesnt render anything next to date of all day preview", () => {
|
it("doesnt render anything next to date of all day preview", () => {
|
||||||
const allDayState = {
|
const allDayState = {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { DateSelectArg } from "@fullcalendar/core";
|
import { DateSelectArg } from "@fullcalendar/core";
|
||||||
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
|
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import preview from "jest-preview";
|
|
||||||
import * as eventThunks from "../../../src/features/Calendars/CalendarSlice";
|
import * as eventThunks from "../../../src/features/Calendars/CalendarSlice";
|
||||||
import EventPopover from "../../../src/features/Events/EventModal";
|
import EventPopover from "../../../src/features/Events/EventModal";
|
||||||
import { api } from "../../../src/utils/apiUtils";
|
import { api } from "../../../src/utils/apiUtils";
|
||||||
import { formatDateToYYYYMMDDTHHMMSS } from "../../../src/utils/dateUtils";
|
|
||||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||||
|
|
||||||
jest.mock("../../../src/utils/apiUtils");
|
jest.mock("../../../src/utils/apiUtils");
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { SlotLabelContentArg } from "@fullcalendar/core";
|
|||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { refreshSingularCalendar } from "../../Event/utils/eventUtils";
|
import { refreshSingularCalendar } from "../../Event/utils/eventUtils";
|
||||||
import { ThunkDispatch } from "@reduxjs/toolkit";
|
import { ThunkDispatch } from "@reduxjs/toolkit";
|
||||||
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
||||||
|
|
||||||
export const updateSlotLabelVisibility = (
|
export const updateSlotLabelVisibility = (
|
||||||
currentTime: Date,
|
currentTime: Date,
|
||||||
@@ -58,13 +59,24 @@ export const eventToFullCalendarFormat = (
|
|||||||
filteredTempEvents: CalendarEvent[],
|
filteredTempEvents: CalendarEvent[],
|
||||||
userId: string | undefined
|
userId: string | undefined
|
||||||
) => {
|
) => {
|
||||||
|
const { t } = useI18n();
|
||||||
return filteredEvents
|
return filteredEvents
|
||||||
.concat(filteredTempEvents.map((e) => ({ ...e, temp: true })))
|
.concat(filteredTempEvents.map((e) => ({ ...e, temp: true })))
|
||||||
.map((e) => {
|
.map((e) => {
|
||||||
if (e.calId.split("/")[0] === userId) {
|
if (e.calId.split("/")[0] === userId) {
|
||||||
return { ...e, colors: e.color, editable: true };
|
return {
|
||||||
|
...e,
|
||||||
|
title: e.title ? e.title : t("event.untitled"),
|
||||||
|
colors: e.color,
|
||||||
|
editable: true,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return { ...e, colors: e.color, editable: false };
|
return {
|
||||||
|
...e,
|
||||||
|
title: e.title ? e.title : t("event.untitled"),
|
||||||
|
colors: e.color,
|
||||||
|
editable: false,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -323,7 +323,6 @@ export default function EventFormFields({
|
|||||||
// Validation logic
|
// Validation logic
|
||||||
const validateForm = React.useCallback(() => {
|
const validateForm = React.useCallback(() => {
|
||||||
return validateEventForm({
|
return validateEventForm({
|
||||||
title,
|
|
||||||
startDate,
|
startDate,
|
||||||
startTime,
|
startTime,
|
||||||
endDate,
|
endDate,
|
||||||
@@ -410,14 +409,7 @@ export default function EventFormFields({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FieldWithLabel
|
<FieldWithLabel label={t("event.form.title")} isExpanded={showMore}>
|
||||||
label={
|
|
||||||
<>
|
|
||||||
{t("event.form.title")} <span style={{ color: "red" }}>*</span>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
isExpanded={showMore}
|
|
||||||
>
|
|
||||||
<TextField
|
<TextField
|
||||||
fullWidth
|
fullWidth
|
||||||
label={!showMore ? t("event.form.title") : ""}
|
label={!showMore ? t("event.form.title") : ""}
|
||||||
@@ -426,8 +418,6 @@ export default function EventFormFields({
|
|||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setTitle(e.target.value);
|
setTitle(e.target.value);
|
||||||
}}
|
}}
|
||||||
error={!!validation.errors.title}
|
|
||||||
helperText={validation.errors.title}
|
|
||||||
size="small"
|
size="small"
|
||||||
margin="dense"
|
margin="dense"
|
||||||
inputRef={titleInputRef}
|
inputRef={titleInputRef}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { combineDateTime } from "./dateTimeHelpers";
|
|||||||
* Validation parameters for event form
|
* Validation parameters for event form
|
||||||
*/
|
*/
|
||||||
export interface ValidationParams {
|
export interface ValidationParams {
|
||||||
title: string;
|
|
||||||
startDate: string;
|
startDate: string;
|
||||||
startTime: string;
|
startTime: string;
|
||||||
endDate: string;
|
endDate: string;
|
||||||
@@ -21,7 +20,6 @@ export interface ValidationParams {
|
|||||||
export interface ValidationResult {
|
export interface ValidationResult {
|
||||||
isValid: boolean;
|
isValid: boolean;
|
||||||
errors: {
|
errors: {
|
||||||
title: string;
|
|
||||||
dateTime: string;
|
dateTime: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -33,7 +31,6 @@ export interface ValidationResult {
|
|||||||
*/
|
*/
|
||||||
export function validateEventForm(params: ValidationParams): ValidationResult {
|
export function validateEventForm(params: ValidationParams): ValidationResult {
|
||||||
const {
|
const {
|
||||||
title,
|
|
||||||
startDate,
|
startDate,
|
||||||
startTime,
|
startTime,
|
||||||
endDate,
|
endDate,
|
||||||
@@ -44,9 +41,6 @@ export function validateEventForm(params: ValidationParams): ValidationResult {
|
|||||||
showMore = false,
|
showMore = false,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const isTitleValid = title.trim().length > 0;
|
|
||||||
const shouldShowTitleError = showValidationErrors && !isTitleValid;
|
|
||||||
|
|
||||||
let isDateTimeValid = true;
|
let isDateTimeValid = true;
|
||||||
let dateTimeError = "";
|
let dateTimeError = "";
|
||||||
|
|
||||||
@@ -154,12 +148,11 @@ export function validateEventForm(params: ValidationParams): ValidationResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isValid = isTitleValid && isDateTimeValid;
|
const isValid = isDateTimeValid;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isValid,
|
isValid,
|
||||||
errors: {
|
errors: {
|
||||||
title: shouldShowTitleError ? "Title is required" : "",
|
|
||||||
dateTime: showValidationErrors ? dateTimeError : "",
|
dateTime: showValidationErrors ? dateTimeError : "",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ export function Menubar({
|
|||||||
value={lang}
|
value={lang}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
dispatch(setLanguage(e.target.value));
|
dispatch(setLanguage(e.target.value));
|
||||||
|
handleLangClose();
|
||||||
}}
|
}}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
aria-label={t("menubar.languageSelector")}
|
aria-label={t("menubar.languageSelector")}
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ export default function EventPreviewModal({
|
|||||||
actionsJustifyContent="center"
|
actionsJustifyContent="center"
|
||||||
style={{ overflow: "auto" }}
|
style={{ overflow: "auto" }}
|
||||||
title={
|
title={
|
||||||
event.title && (
|
|
||||||
<>
|
<>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Box>
|
<Box>
|
||||||
@@ -227,8 +226,7 @@ export default function EventPreviewModal({
|
|||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (isRecurring) {
|
if (isRecurring) {
|
||||||
setAfterChoiceFunc(
|
setAfterChoiceFunc(
|
||||||
() =>
|
() => (typeOfAction?: "solo" | "all" | undefined) =>
|
||||||
(typeOfAction?: "solo" | "all" | undefined) =>
|
|
||||||
handleDelete(
|
handleDelete(
|
||||||
isRecurring,
|
isRecurring,
|
||||||
typeOfAction,
|
typeOfAction,
|
||||||
@@ -288,13 +286,10 @@ export default function EventPreviewModal({
|
|||||||
}}
|
}}
|
||||||
gutterBottom
|
gutterBottom
|
||||||
>
|
>
|
||||||
{event.title}
|
{event.title ? event.title : t("event.untitled")}
|
||||||
</Typography>
|
</Typography>
|
||||||
{event.transp === "TRANSPARENT" && (
|
{event.transp === "TRANSPARENT" && (
|
||||||
<Tooltip
|
<Tooltip title={t("eventPreview.free.tooltip")} placement="top">
|
||||||
title={t("eventPreview.free.tooltip")}
|
|
||||||
placement="top"
|
|
||||||
>
|
|
||||||
<Chip
|
<Chip
|
||||||
icon={<CircleIcon color="success" fontSize="small" />}
|
icon={<CircleIcon color="success" fontSize="small" />}
|
||||||
label={t("eventPreview.free.label")}
|
label={t("eventPreview.free.label")}
|
||||||
@@ -309,7 +304,6 @@ export default function EventPreviewModal({
|
|||||||
` – ${formatEnd(event.start, event.end, t, event.allday)} ${!event.allday ? getTimezoneOffset(timezone) : ""}`}
|
` – ${formatEnd(event.start, event.end, t, event.allday)} ${!event.allday ? getTimezoneOffset(timezone) : ""}`}
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</>
|
||||||
)
|
|
||||||
}
|
}
|
||||||
actions={
|
actions={
|
||||||
currentUserAttendee &&
|
currentUserAttendee &&
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import { addDays } from "../../components/Event/utils/dateRules";
|
|||||||
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
||||||
|
|
||||||
function EventPopover({
|
function EventPopover({
|
||||||
anchorEl,
|
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
selectedRange,
|
selectedRange,
|
||||||
@@ -50,6 +49,7 @@ function EventPopover({
|
|||||||
event?: CalendarEvent;
|
event?: CalendarEvent;
|
||||||
}) {
|
}) {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const { t, lang } = useI18n();
|
||||||
|
|
||||||
const organizer = useAppSelector((state) => state.user.organiserData);
|
const organizer = useAppSelector((state) => state.user.organiserData);
|
||||||
const userId =
|
const userId =
|
||||||
@@ -673,8 +673,6 @@ function EventPopover({
|
|||||||
await updateTempCalendar(tempList, newEvent, dispatch, calendarRange);
|
await updateTempCalendar(tempList, newEvent, dispatch, calendarRange);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const dialogActions = (
|
const dialogActions = (
|
||||||
<Box display="flex" justifyContent="space-between" width="100%" px={2}>
|
<Box display="flex" justifyContent="space-between" width="100%" px={2}>
|
||||||
{!showMore && (
|
{!showMore && (
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
"createEvent": "Create Event",
|
"createEvent": "Create Event",
|
||||||
"updateEvent": "Update Event",
|
"updateEvent": "Update Event",
|
||||||
"organizer": "Organizer",
|
"organizer": "Organizer",
|
||||||
|
"untitled": "Untitled",
|
||||||
"repeat": {
|
"repeat": {
|
||||||
"repeatEvery": "Repeat every",
|
"repeatEvery": "Repeat every",
|
||||||
"frequency": {
|
"frequency": {
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
"createEvent": "Créer un événement",
|
"createEvent": "Créer un événement",
|
||||||
"updateEvent": "Mettre à jour un événement",
|
"updateEvent": "Mettre à jour un événement",
|
||||||
"organizer": "Organisateur",
|
"organizer": "Organisateur",
|
||||||
|
"untitled": "Sans titre",
|
||||||
"repeat": {
|
"repeat": {
|
||||||
"repeatEvery": "Répéter tous les",
|
"repeatEvery": "Répéter tous les",
|
||||||
"frequency": {
|
"frequency": {
|
||||||
|
|||||||
Reference in New Issue
Block a user