Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [M3-8451] - List events in event landing page in chronological order #11339

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

harsh-akamai
Copy link
Contributor

Description 📝

Currently not all events in the landing page are sorted in a chronological order. This seems to be because we adjust the event creation date to accommodate the duration for a finished or failed event.

Changes 🔄

  • Created a util function to sort the dates chronologically

Preview 📷

Before After
04_21_09 04_21_30

How to test 🧪

Reproduction steps

This can be most easily reproduced when performing some action that triggers multiple events to happen in a short timeframe.

  • Try creating a Linode attached to a new Firewall

Verification steps

  • Verify that all events in the Event landing page are sorted by date
Author Checklists

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@harsh-akamai harsh-akamai self-assigned this Nov 28, 2024
@harsh-akamai harsh-akamai changed the title change: [M3-8451] - List events in event landing page in chronological order fix: [M3-8451] - List events in event landing page in chronological order Nov 28, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've extended the Event interface to include completionTime for an event and moved the getEventTimeStamp() to the sorting util function.

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 455 passing tests on test run #3 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing455 Passing2 Skipped97m 21s

@harsh-akamai harsh-akamai marked this pull request as ready for review December 2, 2024 10:38
@harsh-akamai harsh-akamai requested a review from a team as a code owner December 2, 2024 10:38
@harsh-akamai harsh-akamai requested review from hana-akamai and carrillo-erik and removed request for a team December 2, 2024 10:38

export interface completionEvent extends Event {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think completedEvent sounds a bit better than completionEvent

Comment on lines +140 to +150
const dates = tableBodyRows.map((row) => {
const cells = within(row).getAllByRole('cell');
return cells[3].textContent || '';
});

// util function to check if the dates are in descending order
const areDatesSorted = dates.every(
(date, i, arr) => i === 0 || new Date(arr[i - 1]) >= new Date(date)
);

expect(areDatesSorted).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test-id to the Absolute Date table cell and grab the dates that way instead of grabbing the cell at index 3?

We can also just hardcode the date string; I think the test is clearer this way:

const mockEvent1 = eventFactory.build({
  ...
  created: '2024-12-10T16:29:52.973-05:00',
  ...
});
const mockEvent2 = eventFactory.build({
  ...
  created: '2024-12-10T16:28:52.974-05:00',
  ...
});
expect(dates).toStrictEqual(['2024-12-11 05:30', '2024-12-11 05:28']);

To test the sorting function, we can add a separate unit test for the sortEventsChronologically function in the utils test file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants