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

upcoming: [DI-22217] - Added the Alert Listing page with Alerting Table and added relevant api endpoints #11346

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

Conversation

santoshp210-akamai
Copy link
Contributor

@santoshp210-akamai santoshp210-akamai commented Dec 2, 2024

Description 📝

  • Added the Alert Listing component
  • Added the AlertTableRow component

Changes 🔄

List any change(s) relevant to the reviewer.

  • Added the AlertListing component with UT
  • Added the AlertTableRow component with UT
  • Added GET request to fetch the alert definitions
  • Changed the AlertDefinitionType to 'system'|'user'
  • Added the AlertIcon svg for the Empty State for AlertListing component

Target release date 🗓️

Please specify a release date (and environment, if applicable) to guarantee timely review of this PR. If exact date is not known, please approximate and update it as needed.

Preview 📷

Before After
image image

How to test 🧪

Prerequisites

  • The tabs are controlled by a featureFlag called aclpAlerting, the flag has been currently disabled. For testing enable the definitions part of the aclpAlerting flag to be true.
  • The API endpoints are not live yet, so use Legacy MSW Handlers for the mock responses.
  • This PR only contains the Table, the ordering, pagination will part of next PR.
  • The Handlers for the rows in the Table are not yet part of this PR. It is dependent on another PR so it will part of that.

Verification steps

(How to verify changes)

  • The page to /monitor/alerts/definitions is the AlertListing component
  • There is a TableRowError component if the API returns an error
  • There is a TableRowLoading component if the API is still loading
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

…s, Table rows and added the GET api endpoint and mockServer for fetching alert definitions
@santoshp210-akamai santoshp210-akamai requested a review from a team as a code owner December 2, 2024 13:10
@santoshp210-akamai santoshp210-akamai requested review from bnussman-akamai and coliu-akamai and removed request for a team December 2, 2024 13:10
@santoshp210-akamai santoshp210-akamai self-assigned this Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

Coverage Report:
Base Coverage: 86.95%
Current Coverage: 86.96%

@santoshp210-akamai
Copy link
Contributor Author

There are still on-going discussions with respect to the columns of the table in the Mockups with UX team, These are the currently agreed upon changes, there's a possibility of couple of columns re ordered or removed.
cc: @jaalah-akamai

"@linode/manager": Added
---

AlertListing component and AlertTableRow component with UT ([#11346](https://github.com/linode/manager/pull/11346))
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 avoid abbreviations like "UT" in the changelogs? Just so each entry is easier to skim if we're trying to find a particular change while troubleshooting a bug, test failure, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, we will follow that from now. I will change this as well.

Comment on lines 34 to 48
it('should render the alert landing table with items', async () => {
queryMocks.useAllAlertDefinitionsQuery.mockReturnValue({
data: mockResponse,
isError: false,
isLoading: false,
status: 'success',
});
const { getAllByText } = renderWithTheme(<AlertListing />);
getAllByText('Alert Name');
getAllByText('Service Type');
getAllByText('Severity');
getAllByText('Status');
getAllByText('Last Modified');
getAllByText('Created By');
});
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 improve this test so that it checks that the actual mockResponse data is displayed on the page? Confirming that the column titles are present doesn't get us very far.

Copy link
Contributor Author

@santoshp210-akamai santoshp210-akamai Dec 2, 2024

Choose a reason for hiding this comment

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

I have covered that checks in the AlertTableRow component Unit Tests. So omitted them here. Should I check it here again ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should at least check that each expected row is present (and that might just involve confirming that the label for each object in the mockResponse array is present, but you could approach it multiple ways e.g. using and checking a data-test-id attribute on each table row or something like that).

The table row tests (which are good!) confirm that an individual table row renders correctly with the right data given some individual Alert object, but for this test we want to know that AlertListing renders an AlertTableRow for each Alert object in the alerts array.

For example (albeit a bit contrived), if there were ever some logic bug where the AlertTableRows weren't being rendered at all, this test wouldn't catch it. Feel free to reach out on Slack or continue the discussion here if I can answer any questions!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I got it. I will add another test case to check for the label of each object.

Copy link
Contributor

Choose a reason for hiding this comment

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

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🔺 2 failing tests on test run #4 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
2 Failing460 Passing2 Skipped112m 32s

Details

Failing Tests
SpecTest
create-linode-from-image.spec.tscreate linode from image, mocked data » creates linode from image on images tab
create-linode-from-image.spec.tscreate linode from image, mocked data » creates linode from preselected image on images tab

Troubleshooting

Use this command to re-run the failing tests:

yarn cy:run -s "cypress/e2e/core/images/create-linode-from-image.spec.ts,cypress/e2e/core/images/create-linode-from-image.spec.ts"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file will be replaced before the PR is merged as the icon is not looking good on the UI. There are some confirmations from the UX side.

Comment on lines 10 to +11
import { BETA_API_ROOT as API_ROOT } from 'src/constants';
import { Params, Filter, ResourcePage } from 'src/types';
Copy link
Member

Choose a reason for hiding this comment

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

Relative imports should be used in all packages (ui, validation, api-v4) except manager. This is because only the manager package has import aliases setup.

Suggested change
import { BETA_API_ROOT as API_ROOT } from 'src/constants';
import { Params, Filter, ResourcePage } from 'src/types';
import { BETA_API_ROOT as API_ROOT } from '../constants';
import { Params, Filter, ResourcePage } from '../types';

import { CreateAlertDefinition } from '../CreateAlert/CreateAlertDefinition';

export const AlertDefinitionLanding = () => {
return (
<Switch>
<Route
component={AlertDefinition}
component={() => <AlertListing />}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can do this here:

Suggested change
component={() => <AlertListing />}
component={AlertListing}

Comment on lines +31 to +33
/*
The handlers and alertType are made optional only temporarily, they will be enabled but they are dependent on another feature which will be part of next PR
*/
Copy link
Member

Choose a reason for hiding this comment

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

For future reference: Currently, this shows up like this:

Screenshot 2024-12-03 at 1 46 34 PM

If you format your comment like this:

Suggested change
/*
The handlers and alertType are made optional only temporarily, they will be enabled but they are dependent on another feature which will be part of next PR
*/
/**
* The handlers and alertType are made optional only temporarily, they will be enabled but they are dependent on another feature which will be part of next PR
*/

Code editors will be able to display the comment in a more readable way

Screenshot 2024-12-03 at 1 46 05 PM

}

export interface AlertActionMenuProps {
/*
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/*
/**

Refer to other comment about code comments

Comment on lines +43 to +47
await waitFor(() => expect(getByText('Alert Name')).toBeInTheDocument());
await waitFor(() => expect(getByText('Service Type')).toBeInTheDocument());
await waitFor(() => expect(getByText('Status')).toBeInTheDocument());
await waitFor(() => expect(getByText('Last Modified')).toBeInTheDocument());
await waitFor(() => expect(getByText('Created By')).toBeInTheDocument());
Copy link
Member

Choose a reason for hiding this comment

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

Because you are using static mocking to mock the return values of useAllAlertDefinitionsQuery, you don't need to await anything

Suggested change
await waitFor(() => expect(getByText('Alert Name')).toBeInTheDocument());
await waitFor(() => expect(getByText('Service Type')).toBeInTheDocument());
await waitFor(() => expect(getByText('Status')).toBeInTheDocument());
await waitFor(() => expect(getByText('Last Modified')).toBeInTheDocument());
await waitFor(() => expect(getByText('Created By')).toBeInTheDocument());
expect(getByText('Alert Name')).toBeInTheDocument();
expect(getByText('Service Type')).toBeInTheDocument();
expect(getByText('Status')).toBeInTheDocument();
expect(getByText('Last Modified')).toBeInTheDocument();
expect(getByText('Created By')).toBeInTheDocument();

Comment on lines +26 to +39
alert: {
// contextQueries: {
// This query key is a placeholder , it will be updated once the relevant queries are added
queryKey: null,
},
alerts: {
contextQueries: {
all: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getAllAlertsRequest(params, filter),
queryKey: [params, filter],
}),
},
queryKey: null,
},
Copy link
Member

Choose a reason for hiding this comment

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

Optional, but we could organize this a bit better by moving alert inside the context of alerts

Suggested change
alert: {
// contextQueries: {
// This query key is a placeholder , it will be updated once the relevant queries are added
queryKey: null,
},
alerts: {
contextQueries: {
all: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getAllAlertsRequest(params, filter),
queryKey: [params, filter],
}),
},
queryKey: null,
},
alerts: {
contextQueries: {
alert: {
// contextQueries: {
// This query key is a placeholder , it will be updated once the relevant queries are added
queryKey: null,
},
all: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getAllAlertsRequest(params, filter),
queryKey: [params, filter],
}),
},
queryKey: null,
},

</TableRow>
</TableHead>
<TableBody>
{isError === true && (
Copy link
Member

Choose a reason for hiding this comment

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

No need to put === true for a boolean value

Suggested change
{isError === true && (
{isError && (

message={'Error in fetching the alerts.'}
/>
)}
{isLoading === true && <TableRowLoading columns={7} />}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{isLoading === true && <TableRowLoading columns={7} />}
{isLoading && <TableRowLoading columns={7} />}

Comment on lines +53 to +55
handleClick={() => {
'asc';
}}
Copy link
Member

Choose a reason for hiding this comment

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

What is going on here?

active={true}
direction={order}
handleClick={handleOrderChange}
label="lastModified"
Copy link
Member

Choose a reason for hiding this comment

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

Options because it doesn't matter right now, but we usually we make these values align with the API response. So in this case, updated. This makes API ordering work easily when it's time to implement it if you are going that route.

Same goes for other table cells

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

Successfully merging this pull request may close these issues.

5 participants