Skip to content

Commit 178af5b

Browse files
Extension card UI/UX improvements (#663)
* feat: extension card UI/UX improvements * feat: colors deadline date red only if status is pending * fix: failing tests in extension requests * chore: rename variable
1 parent b88976c commit 178af5b

File tree

4 files changed

+268
-105
lines changed

4 files changed

+268
-105
lines changed

__tests__/extension-requests/extension-requests.test.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,31 @@ describe('Tests the Extension Requests Screen', () => {
361361
expect(extensionCardsList.length).toBe(4);
362362
expect(extensionRequestsElement).toBeTruthy();
363363
});
364+
it('Should contain all dates elements', async () => {
365+
const checkContainer = async (containerId) => {
366+
const textExists = await page.$eval(
367+
`${containerId} .card-row-text`,
368+
(el) => !!el,
369+
);
370+
const valueExists = await page.$eval(
371+
`${containerId} .tooltip-container`,
372+
(el) => !!el,
373+
);
374+
const tooltipExists = await page.$eval(
375+
`${containerId} .tooltip`,
376+
(el) => !!el,
377+
);
378+
379+
expect(textExists).toBeTruthy();
380+
expect(valueExists).toBeTruthy();
381+
expect(tooltipExists).toBeTruthy();
382+
};
383+
384+
await checkContainer('#deadline-container');
385+
await checkContainer('#requested-time-container');
386+
await checkContainer('#new-deadline-container');
387+
await checkContainer('#extension-container');
388+
});
364389

365390
it('checks the search functionality', async () => {
366391
await page.type('#assignee-search', 'sunny');
@@ -511,14 +536,14 @@ describe('Tests the Extension Requests Screen', () => {
511536
'.extension-card:first-child .panel',
512537
);
513538
const firstAccordionIsVisible = await firstAccordionContent.evaluate(
514-
(el) => el.style.display === 'block',
539+
(el) => el.style.maxHeight !== '',
515540
);
516541
expect(firstAccordionIsVisible).toBe(true);
517542

518543
await firstAccordionButton.click();
519544

520545
const firstAccordionIsHidden = await firstAccordionContent.evaluate(
521-
(el) => el.style.display !== 'block',
546+
(el) => el.style.maxHeight === '',
522547
);
523548
expect(firstAccordionIsHidden).toBe(true);
524549
});
@@ -630,7 +655,7 @@ describe('Tests the Extension Requests Screen', () => {
630655
await page.$eval('.title-text-input', (el) => (el.value = ''));
631656
await page.type('.title-text-input', newTitle);
632657

633-
const newDate = '2023-09-19T22:20';
658+
const newDate = '2023-09-19';
634659
await page.evaluate((newDate) => {
635660
document.querySelector('.date-input').value = newDate;
636661
}, newDate);
@@ -668,7 +693,7 @@ describe('Tests the Extension Requests Screen', () => {
668693
const newTitle = 'New Title Text';
669694
await page.type('.title-text-input', newTitle);
670695

671-
const newDate = '2023-09-19T22:20';
696+
const newDate = '2023-09-19';
672697
await page.evaluate((newDate) => {
673698
document.querySelector('.date-input').value = newDate;
674699
}, newDate);
@@ -823,7 +848,7 @@ describe('Tests the Extension Requests Screen', () => {
823848
// Click the first element with class '.edit-button'
824849
await page.$$eval('.edit-button', (buttons) => buttons[0].click());
825850
const newTitle = 'This is a new title test case';
826-
const newDate = '2024-09-19T22:20';
851+
const newDate = '2024-09-19';
827852
const newReason = 'This is the new reason';
828853

829854
// Updating all the input fields

extension-requests/local-utils.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,31 @@ function dateTimeString(milliseconds) {
236236
).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
237237
}
238238

239+
/**
240+
Generates a formatted date string from milliseconds.*
241+
@param {number} milliseconds - The number of milliseconds since January 1, 1970 00:00:00 UTC.
242+
@returns {string} The formatted date string in the format 'YYYY-MM-DD'.
243+
244+
*/
245+
function dateString(milliseconds) {
246+
const date = new Date(milliseconds);
247+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
248+
2,
249+
'0',
250+
)}-${String(date.getDate()).padStart(2, '0')}`;
251+
}
252+
239253
const fullDateString = (timestamp) => {
240-
const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
241-
const date = new Date(timestamp);
242-
return `${daysOfWeek[date.getDay()]}, ${date.toLocaleString()}`;
254+
const options = {
255+
weekday: 'short',
256+
year: 'numeric',
257+
month: 'long',
258+
day: 'numeric',
259+
hour: 'numeric',
260+
minute: 'numeric',
261+
hour12: true,
262+
};
263+
return new Intl.DateTimeFormat('en-US', options).format(new Date(timestamp));
243264
};
244265

245266
const shortDateString = (timestamp) => {

0 commit comments

Comments
 (0)