Commit 6defb30f authored by Illya Klymov's avatar Illya Klymov

Merge branch '230572-display-alert-number-in-list' into 'master'

Add alert ID to list view

Closes #230572

See merge request gitlab-org/gitlab!39706
parents 925b98af ed634d29
...@@ -35,6 +35,7 @@ const tdClass = ...@@ -35,6 +35,7 @@ const tdClass =
const thClass = 'gl-hover-bg-blue-50'; const thClass = 'gl-hover-bg-blue-50';
const bodyTrClass = const bodyTrClass =
'gl-border-1 gl-border-t-solid gl-border-gray-100 gl-hover-bg-blue-50 gl-hover-cursor-pointer gl-hover-border-b-solid gl-hover-border-blue-200'; 'gl-border-1 gl-border-t-solid gl-border-gray-100 gl-hover-bg-blue-50 gl-hover-cursor-pointer gl-hover-border-b-solid gl-hover-border-blue-200';
const TH_TEST_ID = { 'data-testid': 'alert-management-severity-sort' };
const initialPaginationState = { const initialPaginationState = {
currentPage: 1, currentPage: 1,
...@@ -61,6 +62,7 @@ export default { ...@@ -61,6 +62,7 @@ export default {
key: 'severity', key: 'severity',
label: s__('AlertManagement|Severity'), label: s__('AlertManagement|Severity'),
thClass: `${thClass} gl-w-eighth`, thClass: `${thClass} gl-w-eighth`,
thAttr: TH_TEST_ID,
tdClass: `${tdClass} rounded-top text-capitalize sortable-cell`, tdClass: `${tdClass} rounded-top text-capitalize sortable-cell`,
sortable: true, sortable: true,
}, },
...@@ -72,7 +74,7 @@ export default { ...@@ -72,7 +74,7 @@ export default {
sortable: true, sortable: true,
}, },
{ {
key: 'title', key: 'alertLabel',
label: s__('AlertManagement|Alert'), label: s__('AlertManagement|Alert'),
thClass: `gl-pointer-events-none`, thClass: `gl-pointer-events-none`,
tdClass, tdClass,
...@@ -397,8 +399,14 @@ export default { ...@@ -397,8 +399,14 @@ export default {
{{ item.eventCount }} {{ item.eventCount }}
</template> </template>
<template #cell(title)="{ item }"> <template #cell(alertLabel)="{ item }">
<div class="gl-max-w-full text-truncate" :title="item.title">{{ item.title }}</div> <div
class="gl-max-w-full text-truncate"
:title="`${item.iid} - ${item.title}`"
data-testid="idField"
>
#{{ item.iid }} {{ item.title }}
</div>
</template> </template>
<template #cell(issue)="{ item }"> <template #cell(issue)="{ item }">
......
---
title: Add Alert Id to Alert list view
merge_request: 39706
author:
type: changed
...@@ -39,11 +39,13 @@ describe('AlertManagementTable', () => { ...@@ -39,11 +39,13 @@ describe('AlertManagementTable', () => {
const findStatusFilterBadge = () => wrapper.findAll(GlBadge); const findStatusFilterBadge = () => wrapper.findAll(GlBadge);
const findDateFields = () => wrapper.findAll(TimeAgo); const findDateFields = () => wrapper.findAll(TimeAgo);
const findFirstStatusOption = () => findStatusDropdown().find(GlDeprecatedDropdownItem); const findFirstStatusOption = () => findStatusDropdown().find(GlDeprecatedDropdownItem);
const findAssignees = () => wrapper.findAll('[data-testid="assigneesField"]');
const findSeverityFields = () => wrapper.findAll('[data-testid="severityField"]');
const findSeverityColumnHeader = () => wrapper.findAll('th').at(0);
const findPagination = () => wrapper.find(GlPagination); const findPagination = () => wrapper.find(GlPagination);
const findSearch = () => wrapper.find(GlSearchBoxByType); const findSearch = () => wrapper.find(GlSearchBoxByType);
const findSeverityColumnHeader = () =>
wrapper.find('[data-testid="alert-management-severity-sort"]');
const findFirstIDField = () => wrapper.findAll('[data-testid="idField"]').at(0);
const findAssignees = () => wrapper.findAll('[data-testid="assigneesField"]');
const findSeverityFields = () => wrapper.findAll('[data-testid="severityField"]');
const findIssueFields = () => wrapper.findAll('[data-testid="issueField"]'); const findIssueFields = () => wrapper.findAll('[data-testid="issueField"]');
const findAlertError = () => wrapper.find('[data-testid="alert-error"]'); const findAlertError = () => wrapper.find('[data-testid="alert-error"]');
const alertsCount = { const alertsCount = {
...@@ -192,6 +194,17 @@ describe('AlertManagementTable', () => { ...@@ -192,6 +194,17 @@ describe('AlertManagementTable', () => {
).toContain('gl-hover-bg-blue-50'); ).toContain('gl-hover-bg-blue-50');
}); });
it('displays the alert ID and title formatted correctly', () => {
mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
data: { alerts: { list: mockAlerts }, alertsCount, hasError: false },
loading: false,
});
expect(findFirstIDField().exists()).toBe(true);
expect(findFirstIDField().text()).toBe(`#${mockAlerts[0].iid} ${mockAlerts[0].title}`);
});
it('displays status dropdown', () => { it('displays status dropdown', () => {
mountComponent({ mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true }, props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment