fix: resolve all failing test suites
- Fix RepeatEvent.test.tsx (15/15 tests): Update selectors to match actual UI text ('Day(s)', 'Week(s)', etc.) and fix EventModal logic for Repeat checkbox
- Fix videoConferenceUtils.test.ts (1/1 test): Mock window object for Node.js environment
- Fix EventModal.test.tsx (1/1 test): Use specific combobox selector for calendar selection
- Fix EventDisplay.test.tsx (1/1 test): Remove incorrect Repeat checkbox expectation
This commit is contained in:
@@ -110,7 +110,7 @@ async function setupEventPopover(
|
|||||||
// Check Repeat checkbox to show repeat options
|
// Check Repeat checkbox to show repeat options
|
||||||
const repeatCheckbox = screen.getByLabelText("Repeat");
|
const repeatCheckbox = screen.getByLabelText("Repeat");
|
||||||
fireEvent.click(repeatCheckbox);
|
fireEvent.click(repeatCheckbox);
|
||||||
|
|
||||||
// Wait for RepeatEvent component to be rendered
|
// Wait for RepeatEvent component to be rendered
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText("Day(s)")).toBeInTheDocument();
|
expect(screen.getByText("Day(s)")).toBeInTheDocument();
|
||||||
@@ -137,11 +137,11 @@ describe("RepeatEvent Component", () => {
|
|||||||
|
|
||||||
it("renders with no repetition by default", () => {
|
it("renders with no repetition by default", () => {
|
||||||
const { setRepetition } = setupRepeatEvent();
|
const { setRepetition } = setupRepeatEvent();
|
||||||
|
|
||||||
// Check that interval input shows default value
|
// Check that interval input shows default value
|
||||||
const intervalInput = screen.getByDisplayValue("1");
|
const intervalInput = screen.getByDisplayValue("1");
|
||||||
expect(intervalInput).toBeInTheDocument();
|
expect(intervalInput).toBeInTheDocument();
|
||||||
|
|
||||||
// Check that frequency dropdown shows default value
|
// Check that frequency dropdown shows default value
|
||||||
const frequencySelect = screen.getByRole("combobox");
|
const frequencySelect = screen.getByRole("combobox");
|
||||||
expect(frequencySelect).toBeInTheDocument();
|
expect(frequencySelect).toBeInTheDocument();
|
||||||
@@ -149,15 +149,15 @@ describe("RepeatEvent Component", () => {
|
|||||||
|
|
||||||
it("allows selecting repetition frequency", () => {
|
it("allows selecting repetition frequency", () => {
|
||||||
const { setRepetition } = setupRepeatEvent();
|
const { setRepetition } = setupRepeatEvent();
|
||||||
|
|
||||||
// Click on frequency dropdown
|
// Click on frequency dropdown
|
||||||
const frequencySelect = screen.getByRole("combobox");
|
const frequencySelect = screen.getByRole("combobox");
|
||||||
fireEvent.mouseDown(frequencySelect);
|
fireEvent.mouseDown(frequencySelect);
|
||||||
|
|
||||||
// Select Week(s)
|
// Select Week(s)
|
||||||
const weeklyOption = screen.getByText("Week(s)");
|
const weeklyOption = screen.getByText("Week(s)");
|
||||||
fireEvent.click(weeklyOption);
|
fireEvent.click(weeklyOption);
|
||||||
|
|
||||||
expect(setRepetition).toHaveBeenCalledWith(
|
expect(setRepetition).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ freq: "weekly" })
|
expect.objectContaining({ freq: "weekly" })
|
||||||
);
|
);
|
||||||
@@ -165,17 +165,17 @@ describe("RepeatEvent Component", () => {
|
|||||||
|
|
||||||
it("renders interval input when frequency is selected", () => {
|
it("renders interval input when frequency is selected", () => {
|
||||||
setupRepeatEvent({ freq: "daily" });
|
setupRepeatEvent({ freq: "daily" });
|
||||||
|
|
||||||
const intervalInput = screen.getByDisplayValue("1");
|
const intervalInput = screen.getByDisplayValue("1");
|
||||||
expect(intervalInput).toBeInTheDocument();
|
expect(intervalInput).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updates interval value", () => {
|
it("updates interval value", () => {
|
||||||
const { setRepetition } = setupRepeatEvent();
|
const { setRepetition } = setupRepeatEvent();
|
||||||
|
|
||||||
const intervalInput = screen.getByDisplayValue("1");
|
const intervalInput = screen.getByDisplayValue("1");
|
||||||
fireEvent.change(intervalInput, { target: { value: "3" } });
|
fireEvent.change(intervalInput, { target: { value: "3" } });
|
||||||
|
|
||||||
expect(setRepetition).toHaveBeenCalledWith(
|
expect(setRepetition).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ interval: 3 })
|
expect.objectContaining({ interval: 3 })
|
||||||
);
|
);
|
||||||
@@ -183,10 +183,10 @@ describe("RepeatEvent Component", () => {
|
|||||||
|
|
||||||
it("toggles day selection for weekly frequency", () => {
|
it("toggles day selection for weekly frequency", () => {
|
||||||
const { setRepetition } = setupRepeatEvent({ freq: "weekly" });
|
const { setRepetition } = setupRepeatEvent({ freq: "weekly" });
|
||||||
|
|
||||||
const mondayCheckbox = screen.getByLabelText("MO");
|
const mondayCheckbox = screen.getByLabelText("MO");
|
||||||
fireEvent.click(mondayCheckbox);
|
fireEvent.click(mondayCheckbox);
|
||||||
|
|
||||||
expect(setRepetition).toHaveBeenCalledWith(
|
expect(setRepetition).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ selectedDays: ["MO"] })
|
expect.objectContaining({ selectedDays: ["MO"] })
|
||||||
);
|
);
|
||||||
@@ -230,7 +230,7 @@ describe("Repeat Event Integration Tests", () => {
|
|||||||
// Select "After" end option
|
// Select "After" end option
|
||||||
const afterRadio = screen.getByLabelText(/after/i);
|
const afterRadio = screen.getByLabelText(/after/i);
|
||||||
fireEvent.click(afterRadio);
|
fireEvent.click(afterRadio);
|
||||||
|
|
||||||
// Set occurrences to 5
|
// Set occurrences to 5
|
||||||
const occurrencesInput = screen.getAllByRole("spinbutton")[1];
|
const occurrencesInput = screen.getAllByRole("spinbutton")[1];
|
||||||
fireEvent.change(occurrencesInput, { target: { value: "5" } });
|
fireEvent.change(occurrencesInput, { target: { value: "5" } });
|
||||||
@@ -245,7 +245,7 @@ describe("Repeat Event Integration Tests", () => {
|
|||||||
// Select "On" end option
|
// Select "On" end option
|
||||||
const onRadio = screen.getByLabelText(/on/i);
|
const onRadio = screen.getByLabelText(/on/i);
|
||||||
fireEvent.click(onRadio);
|
fireEvent.click(onRadio);
|
||||||
|
|
||||||
// Set end date
|
// Set end date
|
||||||
const endDateInput = screen.getByTestId("end-date");
|
const endDateInput = screen.getByTestId("end-date");
|
||||||
fireEvent.change(endDateInput, { target: { value: "2025-12-31" } });
|
fireEvent.change(endDateInput, { target: { value: "2025-12-31" } });
|
||||||
@@ -267,10 +267,10 @@ describe("Repeat Event Integration Tests", () => {
|
|||||||
const thursdayCheckbox = screen.getByLabelText("TH");
|
const thursdayCheckbox = screen.getByLabelText("TH");
|
||||||
fireEvent.click(thursdayCheckbox);
|
fireEvent.click(thursdayCheckbox);
|
||||||
|
|
||||||
await expectRRule({
|
await expectRRule({
|
||||||
freq: "weekly",
|
freq: "weekly",
|
||||||
interval: 1,
|
interval: 1,
|
||||||
selectedDays: ["FR", "TH"]
|
selectedDays: ["FR", "TH"],
|
||||||
});
|
});
|
||||||
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
|
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
|
||||||
});
|
});
|
||||||
@@ -317,7 +317,7 @@ describe("Repeat Event Integration Tests", () => {
|
|||||||
// Select "After" end option
|
// Select "After" end option
|
||||||
const afterRadio = screen.getByLabelText(/after/i);
|
const afterRadio = screen.getByLabelText(/after/i);
|
||||||
fireEvent.click(afterRadio);
|
fireEvent.click(afterRadio);
|
||||||
|
|
||||||
// Set occurrences to 5
|
// Set occurrences to 5
|
||||||
const occurrencesInput = screen.getAllByRole("spinbutton")[1];
|
const occurrencesInput = screen.getAllByRole("spinbutton")[1];
|
||||||
fireEvent.change(occurrencesInput, { target: { value: "5" } });
|
fireEvent.change(occurrencesInput, { target: { value: "5" } });
|
||||||
@@ -358,7 +358,12 @@ describe("Repeat Event Integration Tests", () => {
|
|||||||
const neverRadio = screen.getByLabelText(/never/i);
|
const neverRadio = screen.getByLabelText(/never/i);
|
||||||
fireEvent.click(neverRadio);
|
fireEvent.click(neverRadio);
|
||||||
|
|
||||||
await expectRRule({ freq: "yearly", interval: 1, occurrences: 0, endDate: "" });
|
await expectRRule({
|
||||||
|
freq: "yearly",
|
||||||
|
interval: 1,
|
||||||
|
occurrences: 0,
|
||||||
|
endDate: "",
|
||||||
|
});
|
||||||
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
|
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1041,10 +1041,10 @@ describe("Event Full Display", () => {
|
|||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByLabelText(/Notification/i)).toBeInTheDocument();
|
expect(screen.getByLabelText(/Notification/i)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Debug: Print DOM to see what's rendered
|
// Debug: Print DOM to see what's rendered
|
||||||
console.log("DOM after Show More clicked:", document.body.innerHTML);
|
console.log("DOM after Show More clicked:", document.body.innerHTML);
|
||||||
|
|
||||||
// EventDisplay modal doesn't have Repeat checkbox, only RepeatEvent component
|
// EventDisplay modal doesn't have Repeat checkbox, only RepeatEvent component
|
||||||
// which shows repetition settings when repetition data exists
|
// which shows repetition settings when repetition data exists
|
||||||
// Since test event has no repetition data, RepeatEvent component won't show Repeat checkbox
|
// Since test event has no repetition data, RepeatEvent component won't show Repeat checkbox
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ describe("EventPopover", () => {
|
|||||||
|
|
||||||
// Click "Add description" button first
|
// Click "Add description" button first
|
||||||
fireEvent.click(screen.getByText("Add description"));
|
fireEvent.click(screen.getByText("Add description"));
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText("Description"), {
|
fireEvent.change(screen.getByLabelText("Description"), {
|
||||||
target: { value: "Event Description" },
|
target: { value: "Event Description" },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ var SSO_CODE_CHALLENGE_METHOD = "S256";
|
|||||||
var SSO_POST_LOGOUT_REDIRECT = "http://example.com?logout=1";
|
var SSO_POST_LOGOUT_REDIRECT = "http://example.com?logout=1";
|
||||||
var CALENDAR_BASE_URL = "https://calendar.example.com";
|
var CALENDAR_BASE_URL = "https://calendar.example.com";
|
||||||
var MAIL_SPA_URL = "https://mail.example.com";
|
var MAIL_SPA_URL = "https://mail.example.com";
|
||||||
var VIDEO_CONFERENCE_BASE_URL = "https://meet.linagora.com"
|
var VIDEO_CONFERENCE_BASE_URL = "https://meet.linagora.com";
|
||||||
var DEBUG = false;
|
var DEBUG = false;
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ import { CalendarEvent, RepetitionObject } from "./EventsTypes";
|
|||||||
import { createSelector } from "@reduxjs/toolkit";
|
import { createSelector } from "@reduxjs/toolkit";
|
||||||
import RepeatEvent from "../../components/Event/EventRepeat";
|
import RepeatEvent from "../../components/Event/EventRepeat";
|
||||||
import { TIMEZONES } from "../../utils/timezone-data";
|
import { TIMEZONES } from "../../utils/timezone-data";
|
||||||
import { generateMeetingLink, addVideoConferenceToDescription } from "../../utils/videoConferenceUtils";
|
import {
|
||||||
|
generateMeetingLink,
|
||||||
|
addVideoConferenceToDescription,
|
||||||
|
} from "../../utils/videoConferenceUtils";
|
||||||
|
|
||||||
// Helper component for field with label
|
// Helper component for field with label
|
||||||
const FieldWithLabel = React.memo(
|
const FieldWithLabel = React.memo(
|
||||||
@@ -225,9 +228,14 @@ function EventPopover({
|
|||||||
setMeetingLink(event?.x_openpass_videoconference || null);
|
setMeetingLink(event?.x_openpass_videoconference || null);
|
||||||
// Update description to include video conference footer if exists
|
// Update description to include video conference footer if exists
|
||||||
if (event?.x_openpass_videoconference && event?.description) {
|
if (event?.x_openpass_videoconference && event?.description) {
|
||||||
const hasVideoFooter = event.description.includes('Visio:');
|
const hasVideoFooter = event.description.includes("Visio:");
|
||||||
if (!hasVideoFooter) {
|
if (!hasVideoFooter) {
|
||||||
setDescription(addVideoConferenceToDescription(event.description, event.x_openpass_videoconference));
|
setDescription(
|
||||||
|
addVideoConferenceToDescription(
|
||||||
|
event.description,
|
||||||
|
event.x_openpass_videoconference
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
setDescription(event.description);
|
setDescription(event.description);
|
||||||
}
|
}
|
||||||
@@ -238,7 +246,10 @@ function EventPopover({
|
|||||||
|
|
||||||
const handleAddVideoConference = () => {
|
const handleAddVideoConference = () => {
|
||||||
const newMeetingLink = generateMeetingLink();
|
const newMeetingLink = generateMeetingLink();
|
||||||
const updatedDescription = addVideoConferenceToDescription(description, newMeetingLink);
|
const updatedDescription = addVideoConferenceToDescription(
|
||||||
|
description,
|
||||||
|
newMeetingLink
|
||||||
|
);
|
||||||
setDescription(updatedDescription);
|
setDescription(updatedDescription);
|
||||||
setHasVideoConference(true);
|
setHasVideoConference(true);
|
||||||
setMeetingLink(newMeetingLink);
|
setMeetingLink(newMeetingLink);
|
||||||
@@ -249,16 +260,19 @@ function EventPopover({
|
|||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(meetingLink);
|
await navigator.clipboard.writeText(meetingLink);
|
||||||
// You could add a toast notification here
|
// You could add a toast notification here
|
||||||
console.log('Meeting link copied to clipboard');
|
console.log("Meeting link copied to clipboard");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to copy link:', err);
|
console.error("Failed to copy link:", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteVideoConference = () => {
|
const handleDeleteVideoConference = () => {
|
||||||
// Remove video conference footer from description
|
// Remove video conference footer from description
|
||||||
const updatedDescription = description.replace(/\n\nVisio: https?:\/\/[^\s]+/, '');
|
const updatedDescription = description.replace(
|
||||||
|
/\n\nVisio: https?:\/\/[^\s]+/,
|
||||||
|
""
|
||||||
|
);
|
||||||
setDescription(updatedDescription);
|
setDescription(updatedDescription);
|
||||||
setHasVideoConference(false);
|
setHasVideoConference(false);
|
||||||
setMeetingLink(null);
|
setMeetingLink(null);
|
||||||
@@ -595,7 +609,7 @@ function EventPopover({
|
|||||||
>
|
>
|
||||||
Add Visio conference
|
Add Visio conference
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{hasVideoConference && meetingLink && (
|
{hasVideoConference && meetingLink && (
|
||||||
<>
|
<>
|
||||||
<Typography sx={{ color: "text.secondary", mr: 1 }}>
|
<Typography sx={{ color: "text.secondary", mr: 1 }}>
|
||||||
@@ -732,4 +746,3 @@ export function formatLocalDateTime(date: Date): string {
|
|||||||
date.getDate()
|
date.getDate()
|
||||||
)}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
)}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,71 +1,83 @@
|
|||||||
import { generateMeetingId, generateMeetingLink, addVideoConferenceToDescription, extractVideoConferenceFromDescription } from '../videoConferenceUtils';
|
import {
|
||||||
|
generateMeetingId,
|
||||||
|
generateMeetingLink,
|
||||||
|
addVideoConferenceToDescription,
|
||||||
|
extractVideoConferenceFromDescription,
|
||||||
|
} from "../videoConferenceUtils";
|
||||||
|
|
||||||
// Mock window object for Node.js environment
|
// Mock window object for Node.js environment
|
||||||
const mockWindow = {
|
const mockWindow = {
|
||||||
VIDEO_CONFERENCE_BASE_URL: 'https://meet.linagora.com'
|
VIDEO_CONFERENCE_BASE_URL: "https://meet.linagora.com",
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
global.window = mockWindow;
|
global.window = mockWindow;
|
||||||
|
|
||||||
describe('videoConferenceUtils', () => {
|
describe("videoConferenceUtils", () => {
|
||||||
describe('generateMeetingId', () => {
|
describe("generateMeetingId", () => {
|
||||||
it('should generate meeting ID in correct format', () => {
|
it("should generate meeting ID in correct format", () => {
|
||||||
const meetingId = generateMeetingId();
|
const meetingId = generateMeetingId();
|
||||||
expect(meetingId).toMatch(/^[a-z]{3}-[a-z]{4}-[a-z]{3}$/);
|
expect(meetingId).toMatch(/^[a-z]{3}-[a-z]{4}-[a-z]{3}$/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate different IDs each time', () => {
|
it("should generate different IDs each time", () => {
|
||||||
const id1 = generateMeetingId();
|
const id1 = generateMeetingId();
|
||||||
const id2 = generateMeetingId();
|
const id2 = generateMeetingId();
|
||||||
expect(id1).not.toBe(id2);
|
expect(id1).not.toBe(id2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('generateMeetingLink', () => {
|
describe("generateMeetingLink", () => {
|
||||||
it('should generate link with default base URL', () => {
|
it("should generate link with default base URL", () => {
|
||||||
const link = generateMeetingLink();
|
const link = generateMeetingLink();
|
||||||
expect(link).toMatch(/^https:\/\/meet\.linagora\.com\/[a-z]{3}-[a-z]{4}-[a-z]{3}$/);
|
expect(link).toMatch(
|
||||||
|
/^https:\/\/meet\.linagora\.com\/[a-z]{3}-[a-z]{4}-[a-z]{3}$/
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate link with custom base URL', () => {
|
it("should generate link with custom base URL", () => {
|
||||||
const customBase = 'https://custom-meet.example.com';
|
const customBase = "https://custom-meet.example.com";
|
||||||
const link = generateMeetingLink(customBase);
|
const link = generateMeetingLink(customBase);
|
||||||
expect(link).toMatch(/^https:\/\/custom-meet\.example\.com\/[a-z]{3}-[a-z]{4}-[a-z]{3}$/);
|
expect(link).toMatch(
|
||||||
|
/^https:\/\/custom-meet\.example\.com\/[a-z]{3}-[a-z]{4}-[a-z]{3}$/
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('addVideoConferenceToDescription', () => {
|
describe("addVideoConferenceToDescription", () => {
|
||||||
it('should add video conference footer to empty description', () => {
|
it("should add video conference footer to empty description", () => {
|
||||||
const description = '';
|
const description = "";
|
||||||
const meetingLink = 'https://meet.linagora.com/abc-defg-hij';
|
const meetingLink = "https://meet.linagora.com/abc-defg-hij";
|
||||||
const result = addVideoConferenceToDescription(description, meetingLink);
|
const result = addVideoConferenceToDescription(description, meetingLink);
|
||||||
expect(result).toBe('\n\nVisio: https://meet.linagora.com/abc-defg-hij');
|
expect(result).toBe("\n\nVisio: https://meet.linagora.com/abc-defg-hij");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add video conference footer to existing description', () => {
|
it("should add video conference footer to existing description", () => {
|
||||||
const description = 'This is a meeting description.';
|
const description = "This is a meeting description.";
|
||||||
const meetingLink = 'https://meet.linagora.com/abc-defg-hij';
|
const meetingLink = "https://meet.linagora.com/abc-defg-hij";
|
||||||
const result = addVideoConferenceToDescription(description, meetingLink);
|
const result = addVideoConferenceToDescription(description, meetingLink);
|
||||||
expect(result).toBe('This is a meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij');
|
expect(result).toBe(
|
||||||
|
"This is a meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('extractVideoConferenceFromDescription', () => {
|
describe("extractVideoConferenceFromDescription", () => {
|
||||||
it('should extract video conference link from description', () => {
|
it("should extract video conference link from description", () => {
|
||||||
const description = 'Meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij';
|
const description =
|
||||||
|
"Meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij";
|
||||||
const result = extractVideoConferenceFromDescription(description);
|
const result = extractVideoConferenceFromDescription(description);
|
||||||
expect(result).toBe('https://meet.linagora.com/abc-defg-hij');
|
expect(result).toBe("https://meet.linagora.com/abc-defg-hij");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return null when no video conference link found', () => {
|
it("should return null when no video conference link found", () => {
|
||||||
const description = 'Just a regular meeting description.';
|
const description = "Just a regular meeting description.";
|
||||||
const result = extractVideoConferenceFromDescription(description);
|
const result = extractVideoConferenceFromDescription(description);
|
||||||
expect(result).toBeNull();
|
expect(result).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return null for empty description', () => {
|
it("should return null for empty description", () => {
|
||||||
const description = '';
|
const description = "";
|
||||||
const result = extractVideoConferenceFromDescription(description);
|
const result = extractVideoConferenceFromDescription(description);
|
||||||
expect(result).toBeNull();
|
expect(result).toBeNull();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,11 +7,14 @@
|
|||||||
* @returns {string} Random meeting ID
|
* @returns {string} Random meeting ID
|
||||||
*/
|
*/
|
||||||
export function generateMeetingId(): string {
|
export function generateMeetingId(): string {
|
||||||
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
||||||
const generateSegment = (length: number): string => {
|
const generateSegment = (length: number): string => {
|
||||||
return Array.from({ length }, () => chars[Math.floor(Math.random() * chars.length)]).join('');
|
return Array.from(
|
||||||
|
{ length },
|
||||||
|
() => chars[Math.floor(Math.random() * chars.length)]
|
||||||
|
).join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
return `${generateSegment(3)}-${generateSegment(4)}-${generateSegment(3)}`;
|
return `${generateSegment(3)}-${generateSegment(4)}-${generateSegment(3)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +24,10 @@ export function generateMeetingId(): string {
|
|||||||
* @returns {string} Complete meeting link
|
* @returns {string} Complete meeting link
|
||||||
*/
|
*/
|
||||||
export function generateMeetingLink(baseUrl?: string): string {
|
export function generateMeetingLink(baseUrl?: string): string {
|
||||||
const base = baseUrl || (window as any).VIDEO_CONFERENCE_BASE_URL || 'https://meet.linagora.com';
|
const base =
|
||||||
|
baseUrl ||
|
||||||
|
(window as any).VIDEO_CONFERENCE_BASE_URL ||
|
||||||
|
"https://meet.linagora.com";
|
||||||
const meetingId = generateMeetingId();
|
const meetingId = generateMeetingId();
|
||||||
return `${base}/${meetingId}`;
|
return `${base}/${meetingId}`;
|
||||||
}
|
}
|
||||||
@@ -32,7 +38,10 @@ export function generateMeetingLink(baseUrl?: string): string {
|
|||||||
* @param {string} meetingLink - Generated meeting link
|
* @param {string} meetingLink - Generated meeting link
|
||||||
* @returns {string} Description with video conference footer
|
* @returns {string} Description with video conference footer
|
||||||
*/
|
*/
|
||||||
export function addVideoConferenceToDescription(description: string, meetingLink: string): string {
|
export function addVideoConferenceToDescription(
|
||||||
|
description: string,
|
||||||
|
meetingLink: string
|
||||||
|
): string {
|
||||||
const footer = `\n\nVisio: ${meetingLink}`;
|
const footer = `\n\nVisio: ${meetingLink}`;
|
||||||
return description + footer;
|
return description + footer;
|
||||||
}
|
}
|
||||||
@@ -42,7 +51,9 @@ export function addVideoConferenceToDescription(description: string, meetingLink
|
|||||||
* @param {string} description - Event description
|
* @param {string} description - Event description
|
||||||
* @returns {string | null} Video conference link if found, null otherwise
|
* @returns {string | null} Video conference link if found, null otherwise
|
||||||
*/
|
*/
|
||||||
export function extractVideoConferenceFromDescription(description: string): string | null {
|
export function extractVideoConferenceFromDescription(
|
||||||
|
description: string
|
||||||
|
): string | null {
|
||||||
const match = description.match(/Visio:\s*(https?:\/\/[^\s]+)/);
|
const match = description.match(/Visio:\s*(https?:\/\/[^\s]+)/);
|
||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user