Fix #15438: Update filters and destination for 'Conversation' source in notification alert (#15443)

* Add 'Mentions' enum for subscriptionCategory

* fix the user list selection field not showing for 'Mentioned Users' filter

* update the cypress for new changes

* fix teams not showing in the mention suggestions
This commit is contained in:
Aniket Katkar 2024-03-04 21:40:31 +05:30 committed by GitHub
parent 7b5f36b374
commit 110e7a4f4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 943 additions and 790 deletions

View File

@ -86,6 +86,7 @@
"Admins", "Admins",
"Assignees", "Assignees",
"Owners", "Owners",
"Mentions",
"Followers", "Followers",
"External" "External"
] ]

View File

@ -127,7 +127,8 @@ export const addEventTypeFilter = (
} }
}; };
export const addUpdaterNameFilter = ( export const addFilterWithUsersListInput = (
filterTestId,
filterNumber, filterNumber,
updaterName, updaterName,
exclude = false exclude = false
@ -136,9 +137,7 @@ export const addUpdaterNameFilter = (
cy.get(`[data-testid="filter-select-${filterNumber}"]`).click({ cy.get(`[data-testid="filter-select-${filterNumber}"]`).click({
waitForAnimations: true, waitForAnimations: true,
}); });
cy.get('[data-testid="Updater Name-filter-option"]') cy.get(`[data-testid="${filterTestId}"]`).filter(':visible').click();
.filter(':visible')
.click();
// Search and select user // Search and select user
interceptURL('GET', `/api/v1/search/query?q=*`, 'getSearchResult'); interceptURL('GET', `/api/v1/search/query?q=*`, 'getSearchResult');

View File

@ -19,10 +19,10 @@ import {
addEntityFQNFilter, addEntityFQNFilter,
addEventTypeFilter, addEventTypeFilter,
addExternalDestination, addExternalDestination,
addFilterWithUsersListInput,
addGMEFilter, addGMEFilter,
addInternalDestination, addInternalDestination,
addOwnerFilter, addOwnerFilter,
addUpdaterNameFilter,
deleteAlertSteps, deleteAlertSteps,
verifyAlertDetails, verifyAlertDetails,
} from '../../common/AlertUtils'; } from '../../common/AlertUtils';
@ -54,8 +54,13 @@ const SOURCE_NAME_2 = 'dashboard';
const SOURCE_DISPLAY_NAME_2 = 'Dashboard'; const SOURCE_DISPLAY_NAME_2 = 'Dashboard';
const SOURCE_NAME_3 = 'task'; const SOURCE_NAME_3 = 'task';
const SOURCE_DISPLAY_NAME_3 = 'Task'; const SOURCE_DISPLAY_NAME_3 = 'Task';
const SOURCE_NAME_4 = 'conversation';
const SOURCE_DISPLAY_NAME_4 = 'Conversation';
describe('Notification Alert Flow', { tags: 'Settings' }, () => { describe(
'Notification Alert Flow',
{ tags: ['Settings', 'Observability'] },
() => {
const data = { const data = {
user: { user: {
displayName: '', displayName: '',
@ -131,7 +136,11 @@ describe('Notification Alert Flow', { tags: 'Settings' }, () => {
beforeEach(() => { beforeEach(() => {
interceptURL('POST', '/api/v1/events/subscriptions', 'createAlert'); interceptURL('POST', '/api/v1/events/subscriptions', 'createAlert');
interceptURL('PUT', '/api/v1/events/subscriptions', 'updateAlert'); interceptURL('PUT', '/api/v1/events/subscriptions', 'updateAlert');
interceptURL('GET', '/api/v1/events/subscriptions/name/*', 'alertDetails'); interceptURL(
'GET',
'/api/v1/events/subscriptions/name/*',
'alertDetails'
);
cy.login(); cy.login();
cy.sidebarClick(SidebarItem.SETTINGS); cy.sidebarClick(SidebarItem.SETTINGS);
interceptURL('GET', '/api/v1/events/subscriptions?*', 'alertsPage'); interceptURL('GET', '/api/v1/events/subscriptions?*', 'alertsPage');
@ -238,17 +247,30 @@ describe('Notification Alert Flow', { tags: 'Settings' }, () => {
true true
); );
addEventTypeFilter(2, 'entityCreated'); addEventTypeFilter(2, 'entityCreated');
addUpdaterNameFilter(3, data.user.displayName, true); addFilterWithUsersListInput(
'Updater Name-filter-option',
3,
data.user.displayName,
true
);
addDomainFilter(4, data.domain.name); addDomainFilter(4, data.domain.name);
addGMEFilter(5); addGMEFilter(5);
// Add multiple destinations // Add multiple destinations
[...Array(3).keys()].forEach(() => { [...Array(3).keys()].forEach(() => {
cy.get('[data-testid="add-destination-button"]').scrollIntoView().click(); cy.get('[data-testid="add-destination-button"]')
.scrollIntoView()
.click();
}); });
addInternalDestination(1, 'Owners', 'G Chat'); addInternalDestination(1, 'Owners', 'G Chat');
addInternalDestination(2, 'Teams', 'Slack', 'Team-select', 'Organization'); addInternalDestination(
2,
'Teams',
'Slack',
'Team-select',
'Organization'
);
addInternalDestination( addInternalDestination(
3, 3,
'Users', 'Users',
@ -310,13 +332,20 @@ describe('Notification Alert Flow', { tags: 'Settings' }, () => {
true true
); );
addEventTypeFilter(2, 'entityCreated'); addEventTypeFilter(2, 'entityCreated');
addUpdaterNameFilter(3, data.user.displayName, true); addFilterWithUsersListInput(
'Updater Name-filter-option',
3,
data.user.displayName,
true
);
addDomainFilter(4, data.domain.name); addDomainFilter(4, data.domain.name);
addGMEFilter(5); addGMEFilter(5);
// Add multiple destinations // Add multiple destinations
[...Array(6).keys()].forEach(() => { [...Array(6).keys()].forEach(() => {
cy.get('[data-testid="add-destination-button"]').scrollIntoView().click(); cy.get('[data-testid="add-destination-button"]')
.scrollIntoView()
.click();
}); });
addInternalDestination(0, 'Followers', 'Email'); addInternalDestination(0, 'Followers', 'Email');
@ -430,4 +459,90 @@ describe('Notification Alert Flow', { tags: 'Settings' }, () => {
it('Delete alert for task source', () => { it('Delete alert for task source', () => {
deleteAlertSteps(ALERT_NAME); deleteAlertSteps(ALERT_NAME);
}); });
it('Create alert for conversation source', () => {
verifyResponseStatusCode('@alertsPage', 200);
cy.get('[data-testid="create-notification"]').click();
// Enter alert name
cy.get('#name').type(ALERT_NAME);
// Enter description
cy.get(descriptionBox).clear().type(ALERT_DESCRIPTION);
// Select all source
cy.get('[data-testid="add-source-button"]').scrollIntoView().click();
cy.get(
`[data-testid="drop-down-menu"] [data-testid="${SOURCE_NAME_4}-option"]`
)
.contains(SOURCE_DISPLAY_NAME_4)
.click();
cy.get('[data-testid="source-select"]').should(
'contain',
SOURCE_DISPLAY_NAME_4
);
// Select Destination
cy.get('[data-testid="add-destination-button"]').scrollIntoView().click();
addInternalDestination(0, 'Owners', 'Email');
// Click save
cy.get('[data-testid="save-button"]').scrollIntoView().click();
cy.wait('@createAlert').then((interception) => {
data.alertDetails = interception?.response?.body;
expect(interception?.response?.statusCode).equal(201);
}); });
toastNotification('Alerts created successfully.');
// Check if the alert details page is visible
verifyResponseStatusCode('@alertDetails', 200);
cy.get('[data-testid="alert-details-container"]').should('exist');
});
it('Edit and check alert by adding mentions filter', () => {
const { id: alertId } = data.alertDetails;
// Go to edit alert page
cy.get('table').should('contain', ALERT_NAME).click();
cy.get(
`[data-row-key="${alertId}"] [data-testid="alert-edit-${ALERT_NAME}"]`
).click();
// Add filter
cy.get('[data-testid="add-filters"]').scrollIntoView().click();
addFilterWithUsersListInput(
'Mentioned Users-filter-option',
0,
data.user.displayName,
true
);
// Add mentions destination
cy.get('[data-testid="add-destination-button"]').scrollIntoView().click();
addInternalDestination(1, 'Mentions', 'Slack');
// Click save
cy.get('[data-testid="save-button"]').scrollIntoView().click();
cy.wait('@updateAlert').then((interception) => {
data.alertDetails = interception?.response?.body;
expect(interception?.response?.statusCode).equal(200);
// Verify the edited alert changes
verifyAlertDetails(interception?.response?.body);
});
});
it('Delete alert for conversation source', () => {
deleteAlertSteps(ALERT_NAME);
});
}
);

View File

@ -55,7 +55,10 @@ import { SERVICE_CATEGORIES } from '../../constants/service.constants';
const SOURCE_NAME_1 = 'Container'; const SOURCE_NAME_1 = 'Container';
const SOURCE_NAME_2 = 'Pipeline'; const SOURCE_NAME_2 = 'Pipeline';
describe('Observability Alert Flow', { tags: 'Settings' }, () => { describe(
'Observability Alert Flow',
{ tags: ['Settings', 'Observability'] },
() => {
const data = { const data = {
testCase: {}, testCase: {},
testSuite: {}, testSuite: {},
@ -215,7 +218,11 @@ describe('Observability Alert Flow', { tags: 'Settings' }, () => {
beforeEach(() => { beforeEach(() => {
interceptURL('POST', '/api/v1/events/subscriptions', 'createAlert'); interceptURL('POST', '/api/v1/events/subscriptions', 'createAlert');
interceptURL('PUT', '/api/v1/events/subscriptions', 'updateAlert'); interceptURL('PUT', '/api/v1/events/subscriptions', 'updateAlert');
interceptURL('GET', '/api/v1/events/subscriptions/name/*', 'alertDetails'); interceptURL(
'GET',
'/api/v1/events/subscriptions/name/*',
'alertDetails'
);
interceptURL('GET', '/api/v1/events/subscriptions?*', 'alertsPage'); interceptURL('GET', '/api/v1/events/subscriptions?*', 'alertsPage');
cy.login(); cy.login();
cy.sidebarClick(SidebarItem.OBSERVABILITY_ALERT); cy.sidebarClick(SidebarItem.OBSERVABILITY_ALERT);
@ -325,11 +332,19 @@ describe('Observability Alert Flow', { tags: 'Settings' }, () => {
// Add multiple destinations // Add multiple destinations
[...Array(2).keys()].forEach(() => { [...Array(2).keys()].forEach(() => {
cy.get('[data-testid="add-destination-button"]').scrollIntoView().click(); cy.get('[data-testid="add-destination-button"]')
.scrollIntoView()
.click();
}); });
addInternalDestination(1, 'Owners', 'G Chat'); addInternalDestination(1, 'Owners', 'G Chat');
addInternalDestination(2, 'Teams', 'Slack', 'Team-select', 'Organization'); addInternalDestination(
2,
'Teams',
'Slack',
'Team-select',
'Organization'
);
// Click save // Click save
cy.get('[data-testid="save-button"]').scrollIntoView().click(); cy.get('[data-testid="save-button"]').scrollIntoView().click();
@ -460,7 +475,8 @@ describe('Observability Alert Flow', { tags: 'Settings' }, () => {
}); });
// Add Destinations // Add Destinations
alertDetails.destinations.forEach((destination, destinationNumber) => { alertDetails.destinations.forEach(
(destination, destinationNumber) => {
cy.get('[data-testid="add-destination-button"]') cy.get('[data-testid="add-destination-button"]')
.scrollIntoView() .scrollIntoView()
.click(); .click();
@ -480,7 +496,8 @@ describe('Observability Alert Flow', { tags: 'Settings' }, () => {
destination.inputValue destination.inputValue
); );
} }
}); }
);
// Click save // Click save
cy.get('[data-testid="save-button"]').scrollIntoView().click(); cy.get('[data-testid="save-button"]').scrollIntoView().click();
@ -516,7 +533,11 @@ describe('Observability Alert Flow', { tags: 'Settings' }, () => {
`Delete subscription "${ALERT_NAME}"` `Delete subscription "${ALERT_NAME}"`
); );
cy.get('[data-testid="confirmation-text-input"]').type(DELETE_TERM); cy.get('[data-testid="confirmation-text-input"]').type(DELETE_TERM);
interceptURL('DELETE', '/api/v1/events/subscriptions/*', 'deleteAlert'); interceptURL(
'DELETE',
'/api/v1/events/subscriptions/*',
'deleteAlert'
);
cy.get('[data-testid="confirm-button"]').click(); cy.get('[data-testid="confirm-button"]').click();
verifyResponseStatusCode('@deleteAlert', 200); verifyResponseStatusCode('@deleteAlert', 200);
@ -524,4 +545,5 @@ describe('Observability Alert Flow', { tags: 'Settings' }, () => {
}); });
} }
); );
}); }
);

View File

@ -268,14 +268,14 @@ const SignInPage = () => {
</div> </div>
</div> </div>
)} )}
{(!isAuthProviderLDAP) && ( {!isAuthProviderLDAP && (
<div className="mt-8" onClick={onClickForgotPassword}> <div className="mt-8" onClick={onClickForgotPassword}>
<Typography.Link underline data-testid="forgot-password"> <Typography.Link underline data-testid="forgot-password">
{t('label.forgot-password')} {t('label.forgot-password')}
</Typography.Link> </Typography.Link>
</div> </div>
)} )}
{(authConfig?.enableSelfSignup) && (!isAuthProviderLDAP) && ( {authConfig?.enableSelfSignup && !isAuthProviderLDAP && (
<> <>
<Divider className="w-min-0 mt-8 mb-12 justify-center"> <Divider className="w-min-0 mt-8 mb-12 justify-center">
<Typography.Text className="text-sm" type="secondary"> <Typography.Text className="text-sm" type="secondary">

View File

@ -528,6 +528,7 @@ export const getFieldByArgumentType = (
break; break;
case 'updateByUserList': case 'updateByUserList':
case 'userList':
field = ( field = (
<Col key="user-select" span={12}> <Col key="user-select" span={12}>
<Form.Item <Form.Item
@ -921,8 +922,10 @@ export const getFilteredDestinationOptions = (
// Logic to filter options for destination type "Internal" // Logic to filter options for destination type "Internal"
// Show all options except "Assignees" for all sources. // Show all options except "Assignees" and "Mentions" for all sources.
let shouldShowOption = option.value !== SubscriptionCategory.Assignees; let shouldShowOption =
option.value !== SubscriptionCategory.Assignees &&
option.value !== SubscriptionCategory.Mentions;
// Only show "Owners" and "Assignees" options for "Task" source. // Only show "Owners" and "Assignees" options for "Task" source.
if (selectedSource === 'task') { if (selectedSource === 'task') {
@ -932,6 +935,14 @@ export const getFilteredDestinationOptions = (
].includes(option.value as SubscriptionCategory); ].includes(option.value as SubscriptionCategory);
} }
// Only show "Owners" and "Mentions" options for "Conversation" source.
if (selectedSource === 'conversation') {
shouldShowOption = [
SubscriptionCategory.Owners,
SubscriptionCategory.Mentions,
].includes(option.value as SubscriptionCategory);
}
return shouldShowOption; return shouldShowOption;
}); });

View File

@ -164,7 +164,7 @@ export async function suggestions(
'isBot:false', 'isBot:false',
'displayName.keyword', 'displayName.keyword',
'asc', 'asc',
SearchIndex.USER [SearchIndex.USER, SearchIndex.TEAM]
); );
const hits = data.data.hits.hits; const hits = data.data.hits.hits;

View File

@ -15,6 +15,7 @@ import { includes, isNil } from 'lodash';
import React from 'react'; import React from 'react';
import { ReactComponent as AdminIcon } from '../assets/svg/admin-colored-icon.svg'; import { ReactComponent as AdminIcon } from '../assets/svg/admin-colored-icon.svg';
import { ReactComponent as GChatIcon } from '../assets/svg/gchat.svg'; import { ReactComponent as GChatIcon } from '../assets/svg/gchat.svg';
import { ReactComponent as MentionIcon } from '../assets/svg/ic-mentions.svg';
import { ReactComponent as MSTeamsIcon } from '../assets/svg/ms-teams.svg'; import { ReactComponent as MSTeamsIcon } from '../assets/svg/ms-teams.svg';
import { ReactComponent as SlackIcon } from '../assets/svg/slack.svg'; import { ReactComponent as SlackIcon } from '../assets/svg/slack.svg';
import { ReactComponent as TeamIcon } from '../assets/svg/team-colored-icon.svg'; import { ReactComponent as TeamIcon } from '../assets/svg/team-colored-icon.svg';
@ -42,6 +43,10 @@ export const getAlertDestinationCategoryIcons = (type: string) => {
case 'Assignees': case 'Assignees':
Icon = AssigneeIcon; Icon = AssigneeIcon;
break;
case 'Mentions':
Icon = MentionIcon;
break; break;
case 'GChat': case 'GChat':
Icon = GChatIcon; Icon = GChatIcon;