Skip to content

Commit 33e7cd1

Browse files
authored
[FIX] Events Page Violates The Figma Style Guide (#3280)
* ui fix * ui fix * code coverage disable statement removed * code coverage disable statement removed * code coverage disable statement remove * code coverage statement remove * fix * fix test * test fix * fix failing test
1 parent 2490b2e commit 33e7cd1

File tree

9 files changed

+253
-126
lines changed

9 files changed

+253
-126
lines changed

src/components/EventCalendar/EventCalendar.tsx

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
348348
{months[parseInt(holiday.date.slice(0, 2), 10) - 1]}{' '}
349349
{holiday.date.slice(3)}
350350
</span>
351-
<span>{holiday.name}</span>
351+
<span className={styles.holiday_name}>{holiday.name}</span>
352352
</li>
353353
))}
354354
</ul>
@@ -357,21 +357,15 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
357357
<div className={styles.events_card} role="region" aria-label="Events">
358358
<h3 className={styles.card_title}>Events</h3>
359359
<div className={styles.legend}>
360-
<div className={styles.list_container}>
361-
<span className={styles.holidayIndicator}></span>
362-
<span className={styles.holidayText}>Holidays</span>
363-
</div>
364360
<div className={styles.eventsLegend}>
365361
<span className={styles.organizationIndicator}></span>
366362
<span className={styles.legendText}>
367363
Events Created by Organization
368364
</span>
369365
</div>
370-
<div className={styles.eventsLegend}>
371-
<span className={styles.userEvents__color}></span>
372-
<span className={styles.legendText}>
373-
Events Created by User
374-
</span>
366+
<div className={styles.list_container_holidays}>
367+
<span className={styles.holidayIndicator}></span>
368+
<span className={styles.holidayText}>Holidays</span>
375369
</div>
376370
</div>
377371
</div>
@@ -519,34 +513,36 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
519513
<div className={styles.calendar}>
520514
{viewType != ViewType.YEAR && (
521515
<div className={styles.calendar__header}>
522-
<Button
523-
variant="outlined"
524-
className={styles.buttonEventCalendar}
525-
onClick={
526-
viewType == ViewType.DAY ? handlePrevDate : handlePrevMonth
527-
}
528-
data-testid="prevmonthordate"
529-
>
530-
<ChevronLeft />
531-
</Button>
516+
<div className={styles.calender_month}>
517+
<Button
518+
variant="outlined"
519+
className={styles.buttonEventCalendar}
520+
onClick={
521+
viewType == ViewType.DAY ? handlePrevDate : handlePrevMonth
522+
}
523+
data-testid="prevmonthordate"
524+
>
525+
<ChevronLeft />
526+
</Button>
532527

533-
<div
534-
className={styles.calendar__header_month}
535-
data-testid="current-date"
536-
>
537-
{viewType == ViewType.DAY ? `${currentDate}` : ``} {currentYear}{' '}
538-
<div>{months[currentMonth]}</div>
528+
<div
529+
className={styles.calendar__header_month}
530+
data-testid="current-date"
531+
>
532+
{viewType == ViewType.DAY ? `${currentDate}` : ``} {currentYear}{' '}
533+
<div>{months[currentMonth]}</div>
534+
</div>
535+
<Button
536+
variant="outlined"
537+
className={styles.buttonEventCalendar}
538+
onClick={
539+
viewType == ViewType.DAY ? handleNextDate : handleNextMonth
540+
}
541+
data-testid="nextmonthordate"
542+
>
543+
<ChevronRight />
544+
</Button>
539545
</div>
540-
<Button
541-
variant="outlined"
542-
className={styles.buttonEventCalendar}
543-
onClick={
544-
viewType == ViewType.DAY ? handleNextDate : handleNextMonth
545-
}
546-
data-testid="nextmonthordate"
547-
>
548-
<ChevronRight />
549-
</Button>
550546
<div>
551547
<Button
552548
className={styles.editButton}

src/components/EventCalendar/EventHeader.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react';
22
import { Button, Form } from 'react-bootstrap';
3-
import { Search } from '@mui/icons-material';
3+
import SearchOutlinedIcon from '@mui/icons-material/SearchOutlined';
4+
import AddIcon from '@mui/icons-material/Add';
45
import styles from '../../style/app.module.css';
56
import { ViewType } from '../../screens/OrganizationEvents/OrganizationEvents';
67
import { useTranslation } from 'react-i18next';
@@ -35,7 +36,10 @@ function eventHeader({
3536
});
3637

3738
return (
38-
<div className={styles.calendarEventHeader}>
39+
<div
40+
className={styles.calendarEventHeader}
41+
data-testid="calendarEventHeader"
42+
>
3943
<div className={styles.calendar__header}>
4044
<div className={styles.input}>
4145
<Form.Control
@@ -57,12 +61,13 @@ function eventHeader({
5761
/>
5862
<Button
5963
className={styles.searchButton}
64+
data-testid="searchButton"
6065
style={{ marginBottom: '10px' }}
6166
>
62-
<Search />
67+
<SearchOutlinedIcon />
6368
</Button>
6469
</div>
65-
<div className={styles.flex_grow}></div>
70+
{/* <div className={styles.flex_grow}></div> */}
6671
<div className={styles.space}>
6772
<SortingButton
6873
title={t('viewType')}
@@ -88,14 +93,25 @@ function eventHeader({
8893
className={styles.dropdown}
8994
buttonLabel={t('eventType')}
9095
/>
91-
<Button
92-
variant="success"
93-
className={styles.dropdown}
94-
onClick={showInviteModal}
95-
data-testid="createEventModalBtn"
96-
>
97-
Create Event
98-
</Button>
96+
<div className={styles.selectTypeEventHeader}>
97+
<Button
98+
variant="success"
99+
className={styles.dropdown}
100+
onClick={showInviteModal}
101+
data-testid="createEventModalBtn"
102+
>
103+
<div className="">
104+
<AddIcon
105+
sx={{
106+
fontSize: '25px',
107+
marginBottom: '2px',
108+
marginRight: '2px',
109+
}}
110+
/>
111+
<span>Create</span>
112+
</div>
113+
</Button>
114+
</div>
99115
</div>
100116
</div>
101117
</div>

src/components/EventCalendar/constants.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ export const holidays = [
1313
},
1414
{ name: 'Christmas Day', date: '12-25', month: 'December' }, // December 25th
1515
];
16-
export const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
16+
export const weekdays = [
17+
'Sunday',
18+
'Monday',
19+
'Tuesday',
20+
'Wednesday',
21+
'Thursday',
22+
'Friday',
23+
'Saturday',
24+
];
1725
export const months = [
1826
'January',
1927
'February',

src/components/HolidayCards/HolidayCard.module.css

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import { describe, test, expect } from 'vitest';
3+
import { render, screen } from '@testing-library/react';
4+
import HolidayCard from './HolidayCard';
5+
import styles from './../../style/app.module.css';
6+
7+
describe('HolidayCard Component', () => {
8+
test('renders without crashing', () => {
9+
render(<HolidayCard holidayName="Christmas" />);
10+
expect(screen.getByTestId('holiday-card')).toBeDefined();
11+
});
12+
13+
test('displays the provided holiday name', () => {
14+
const testHolidayName = 'New Year';
15+
render(<HolidayCard holidayName={testHolidayName} />);
16+
17+
const cardElement = screen.getByTestId('holiday-card');
18+
expect(cardElement.textContent).toBe(testHolidayName);
19+
});
20+
21+
test('applies the correct CSS class', () => {
22+
render(<HolidayCard holidayName="Easter" />);
23+
24+
const cardElement = screen.getByTestId('holiday-card');
25+
expect(cardElement.className).toBe(styles.holidayCard);
26+
});
27+
28+
test('handles empty holiday name', () => {
29+
render(<HolidayCard holidayName="" />);
30+
31+
const cardElement = screen.getByTestId('holiday-card');
32+
expect(cardElement.textContent).toBe('');
33+
});
34+
35+
test('handles long holiday names', () => {
36+
const longHolidayName = 'International Talk Like a Pirate Day Celebration';
37+
render(<HolidayCard holidayName={longHolidayName} />);
38+
39+
const cardElement = screen.getByTestId('holiday-card');
40+
expect(cardElement.textContent).toBe(longHolidayName);
41+
});
42+
43+
// TypeScript compile-time tests
44+
test('TypeScript props validation', () => {
45+
// @ts-expect-error - Testing TypeScript validation for missing required prop
46+
render(<HolidayCard />);
47+
48+
// @ts-expect-error - Testing TypeScript validation for wrong prop type
49+
render(<HolidayCard holidayName={123} />);
50+
});
51+
});

src/components/HolidayCards/HolidayCard.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styles from './HolidayCard.module.css';
2+
import styles from './../../style/app.module.css';
33

44
// Props for the HolidayCard component
55
interface InterfaceHolidayList {
@@ -13,8 +13,11 @@ interface InterfaceHolidayList {
1313
* @returns JSX element representing a card with the holiday name.
1414
*/
1515
const HolidayCard = (props: InterfaceHolidayList): JSX.Element => {
16-
/*istanbul ignore next*/
17-
return <div className={styles.card}>{props?.holidayName}</div>;
16+
return (
17+
<div className={styles.holidayCard} data-testid="holiday-card">
18+
{props?.holidayName}
19+
</div>
20+
);
1821
};
1922

2023
export default HolidayCard;

src/screens/UserPortal/Events/Events.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ describe('Testing Events Screen [User Portal]', () => {
650650
const calenderView = 'Calendar View';
651651

652652
expect(screen.queryAllByText(calenderView)).not.toBeNull();
653-
expect(screen.getByText('Sun')).toBeInTheDocument();
653+
expect(screen.getByText('Sunday')).toBeInTheDocument();
654654
});
655655

656656
it('Testing DatePicker and TimePicker', async () => {

src/screens/UserPortal/Events/Events.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ export default function events(): JSX.Element {
121121
createChat: createChatCheck,
122122
},
123123
});
124-
125-
/* istanbul ignore next */
126124
if (createEventData) {
127125
toast.success(t('eventCreated') as string);
128126
refetch();
@@ -137,7 +135,6 @@ export default function events(): JSX.Element {
137135
setCreateEventmodalisOpen(false);
138136
} catch (error: unknown) {
139137
console.error('create event error', error);
140-
/* istanbul ignore next */
141138
errorHandler(t, error);
142139
}
143140
};
@@ -147,7 +144,6 @@ export default function events(): JSX.Element {
147144
*
148145
* @returns Void.
149146
*/
150-
/* istanbul ignore next */
151147
const toggleCreateEventModal = (): void =>
152148
setCreateEventmodalisOpen(!createEventModal);
153149

@@ -188,7 +184,6 @@ export default function events(): JSX.Element {
188184
};
189185

190186
// Update the list of events when the data from the query changes
191-
/* istanbul ignore next */
192187
React.useEffect(() => {
193188
if (data) {
194189
setEvents(data.eventsByOrganizationConnection);
@@ -200,7 +195,6 @@ export default function events(): JSX.Element {
200195
*
201196
* @returns Void.
202197
*/
203-
/* istanbul ignore next */
204198
const showInviteModal = (): void => {
205199
setCreateEventmodalisOpen(true);
206200
};
@@ -211,9 +205,7 @@ export default function events(): JSX.Element {
211205
* @param item - The view type to set, or null to reset.
212206
* @returns Void.
213207
*/
214-
/* istanbul ignore next */
215208
const handleChangeView = (item: string | null): void => {
216-
/*istanbul ignore next*/
217209
if (item) {
218210
setViewType(item as ViewType);
219211
}
@@ -222,7 +214,7 @@ export default function events(): JSX.Element {
222214
return (
223215
<>
224216
<div className={`d-flex flex-row`}>
225-
<div className={`${styles.mainContainer}`}>
217+
<div className={`${styles.mainContainerEvent}`}>
226218
<EventHeader
227219
viewType={viewType}
228220
showInviteModal={showInviteModal}

0 commit comments

Comments
 (0)