-
Notifications
You must be signed in to change notification settings - Fork 363
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
base: develop
Are you sure you want to change the base?
Conversation
…s, Table rows and added the GET api endpoint and mockServer for fetching alert definitions
…or the AlertListing Table and minor changes
Coverage Report: ✅ |
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. |
"@linode/manager": Added | ||
--- | ||
|
||
AlertListing component and AlertTableRow component with UT ([#11346](https://github.com/linode/manager/pull/11346)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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'); | ||
}); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 AlertTableRow
s 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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @santoshp210-akamai!
…ses, unabbreviated UT to Unit Tests in changeset
Cloud Manager UI test results🔺 2 failing tests on test run #4 ↗︎
Details
TroubleshootingUse 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" |
There was a problem hiding this comment.
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.
import { BETA_API_ROOT as API_ROOT } from 'src/constants'; | ||
import { Params, Filter, ResourcePage } from 'src/types'; |
There was a problem hiding this comment.
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.
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 />} |
There was a problem hiding this comment.
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:
component={() => <AlertListing />} | |
component={AlertListing} |
/* | ||
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 | ||
*/ |
There was a problem hiding this comment.
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:
If you format your comment like this:
/* | |
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
} | ||
|
||
export interface AlertActionMenuProps { | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
/** |
Refer to other comment about code comments
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()); |
There was a problem hiding this comment.
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
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(); |
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, | ||
}, |
There was a problem hiding this comment.
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
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 && ( |
There was a problem hiding this comment.
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
{isError === true && ( | |
{isError && ( |
message={'Error in fetching the alerts.'} | ||
/> | ||
)} | ||
{isLoading === true && <TableRowLoading columns={7} />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{isLoading === true && <TableRowLoading columns={7} />} | |
{isLoading && <TableRowLoading columns={7} />} |
handleClick={() => { | ||
'asc'; | ||
}} |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
Description 📝
Changes 🔄
List any change(s) relevant to the reviewer.
GET
request to fetch the alert definitionsAlertDefinitionType
to'system'|'user'
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 📷
How to test 🧪
Prerequisites
aclpAlerting
, the flag has been currently disabled. For testing enable the definitions part of theaclpAlerting
flag to be true.Verification steps
(How to verify changes)
/monitor/alerts/definitions
is the AlertListing componentAuthor 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
As an Author, before moving this PR from Draft to Open, I confirmed ✅