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:
@@ -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
|
||||
const mockWindow = {
|
||||
VIDEO_CONFERENCE_BASE_URL: 'https://meet.linagora.com'
|
||||
VIDEO_CONFERENCE_BASE_URL: "https://meet.linagora.com",
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
global.window = mockWindow;
|
||||
|
||||
describe('videoConferenceUtils', () => {
|
||||
describe('generateMeetingId', () => {
|
||||
it('should generate meeting ID in correct format', () => {
|
||||
describe("videoConferenceUtils", () => {
|
||||
describe("generateMeetingId", () => {
|
||||
it("should generate meeting ID in correct format", () => {
|
||||
const meetingId = generateMeetingId();
|
||||
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 id2 = generateMeetingId();
|
||||
expect(id1).not.toBe(id2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateMeetingLink', () => {
|
||||
it('should generate link with default base URL', () => {
|
||||
describe("generateMeetingLink", () => {
|
||||
it("should generate link with default base URL", () => {
|
||||
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', () => {
|
||||
const customBase = 'https://custom-meet.example.com';
|
||||
it("should generate link with custom base URL", () => {
|
||||
const customBase = "https://custom-meet.example.com";
|
||||
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', () => {
|
||||
it('should add video conference footer to empty description', () => {
|
||||
const description = '';
|
||||
const meetingLink = 'https://meet.linagora.com/abc-defg-hij';
|
||||
describe("addVideoConferenceToDescription", () => {
|
||||
it("should add video conference footer to empty description", () => {
|
||||
const description = "";
|
||||
const meetingLink = "https://meet.linagora.com/abc-defg-hij";
|
||||
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', () => {
|
||||
const description = 'This is a meeting description.';
|
||||
const meetingLink = 'https://meet.linagora.com/abc-defg-hij';
|
||||
it("should add video conference footer to existing description", () => {
|
||||
const description = "This is a meeting description.";
|
||||
const meetingLink = "https://meet.linagora.com/abc-defg-hij";
|
||||
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', () => {
|
||||
it('should extract video conference link from description', () => {
|
||||
const description = 'Meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij';
|
||||
describe("extractVideoConferenceFromDescription", () => {
|
||||
it("should extract video conference link from description", () => {
|
||||
const description =
|
||||
"Meeting description.\n\nVisio: https://meet.linagora.com/abc-defg-hij";
|
||||
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', () => {
|
||||
const description = 'Just a regular meeting description.';
|
||||
it("should return null when no video conference link found", () => {
|
||||
const description = "Just a regular meeting description.";
|
||||
const result = extractVideoConferenceFromDescription(description);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null for empty description', () => {
|
||||
const description = '';
|
||||
it("should return null for empty description", () => {
|
||||
const description = "";
|
||||
const result = extractVideoConferenceFromDescription(description);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
* @returns {string} Random meeting ID
|
||||
*/
|
||||
export function generateMeetingId(): string {
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||
const chars = "abcdefghijklmnopqrstuvwxyz";
|
||||
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)}`;
|
||||
}
|
||||
|
||||
@@ -21,7 +24,10 @@ export function generateMeetingId(): string {
|
||||
* @returns {string} Complete meeting link
|
||||
*/
|
||||
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();
|
||||
return `${base}/${meetingId}`;
|
||||
}
|
||||
@@ -32,7 +38,10 @@ export function generateMeetingLink(baseUrl?: string): string {
|
||||
* @param {string} meetingLink - Generated meeting link
|
||||
* @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}`;
|
||||
return description + footer;
|
||||
}
|
||||
@@ -42,7 +51,9 @@ export function addVideoConferenceToDescription(description: string, meetingLink
|
||||
* @param {string} description - Event description
|
||||
* @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]+)/);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user