Skip to content

Commit 59ad274

Browse files
committed
fixed failing tests
1 parent da9f36f commit 59ad274

File tree

6 files changed

+54
-70
lines changed

6 files changed

+54
-70
lines changed

x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/action_type_filter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const ActionTypeFilter: React.FunctionComponent<ActionTypeFilterProps> =
6262
}
6363
}}
6464
checked={selectedValues.includes(item.id) ? 'on' : undefined}
65-
data-test-subj={`actionType${item.name.replaceAll(' ', '')}FilterOption`}
65+
data-test-subj={`actionType${item.id}FilterOption`}
6666
>
6767
{item.name}
6868
</EuiFilterSelectItem>

x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ describe('alerts_list with show only capability', () => {
498498

499499
it('renders table of alerts with delete button disabled', async () => {
500500
await setup();
501-
expect(wrapper).toMatchShapshot();
502501
expect(wrapper.find('EuiBasicTable')).toHaveLength(1);
503502
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
504503
// TODO: check delete button

x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ export const AlertsList: React.FunctionComponent = () => {
486486
<FormattedMessage
487487
id="xpack.triggersActionsUI.sections.alertsList.totalStausesActiveDescription"
488488
defaultMessage="Active: {totalStausesActive}"
489-
data-test-subj="totalStausesActive"
490489
values={{
491490
totalStausesActive: alertsStatusesTotal.active,
492491
}}
@@ -497,7 +496,6 @@ export const AlertsList: React.FunctionComponent = () => {
497496
<EuiHealth color="danger" data-test-subj="totalErrorAlertsCount">
498497
<FormattedMessage
499498
id="xpack.triggersActionsUI.sections.alertsList.totalStausesErrorDescription"
500-
data-test-subj="totalStausesError"
501499
defaultMessage="Error: {totalStausesError}"
502500
values={{ totalStausesError: alertsStatusesTotal.error }}
503501
/>
@@ -507,7 +505,6 @@ export const AlertsList: React.FunctionComponent = () => {
507505
<EuiHealth color="subdued" data-test-subj="totalOkAlertsCount">
508506
<FormattedMessage
509507
id="xpack.triggersActionsUI.sections.alertsList.totalStausesOkDescription"
510-
data-test-subj="totalStausesOk"
511508
defaultMessage="Ok: {totalStausesOk}"
512509
values={{ totalStausesOk: alertsStatusesTotal.ok }}
513510
/>
@@ -517,7 +514,6 @@ export const AlertsList: React.FunctionComponent = () => {
517514
<EuiHealth color="success" data-test-subj="totalPendingAlertsCount">
518515
<FormattedMessage
519516
id="xpack.triggersActionsUI.sections.alertsList.totalStausesPendingDescription"
520-
data-test-subj="totalStausesPending"
521517
defaultMessage="Pending: {totalStausesPending}"
522518
values={{
523519
totalStausesPending: alertsStatusesTotal.pending,
@@ -529,7 +525,6 @@ export const AlertsList: React.FunctionComponent = () => {
529525
<EuiHealth color="warning" data-test-subj="totalUnknownAlertsCount">
530526
<FormattedMessage
531527
id="xpack.triggersActionsUI.sections.alertsList.totalStausesUnknownDescription"
532-
data-test-subj="totalStausesUnknown"
533528
defaultMessage="Unknown: {totalStausesUnknown}"
534529
values={{
535530
totalStausesUnknown: alertsStatusesTotal.unknown,

x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/type_filter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const TypeFilter: React.FunctionComponent<TypeFilterProps> = ({
6464
}
6565
}}
6666
checked={selectedValues.includes(item.value) ? 'on' : undefined}
67-
data-test-subj={`alertType${item.name.replaceAll(' ', '')}FilterOption`}
67+
data-test-subj={`alertType${item.value}FilterOption`}
6868
>
6969
{item.name}
7070
</EuiFilterSelectItem>

x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -381,54 +381,36 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
381381

382382
it('should filter alerts by the status', async () => {
383383
const createdAlert = await createAlert();
384-
// initialy alert get Pending status, so we need to retry refresh list logic to get the post execution status Ok
384+
const failinfAlert = await createFailingAlert();
385+
// initialy alert get Pending status, so we need to retry refresh list logic to get the post execution statuses
385386
await retry.try(async () => {
386387
await refreshAlertsList();
387-
const refreshResults = await pageObjects.triggersActionsUI.getAlertsList(true);
388-
expect(refreshResults).to.eql([
389-
{
390-
name: createdAlert.name,
391-
tagsText: 'foo, bar',
392-
alertType: 'Test: Noop',
393-
interval: '1m',
394-
status: 'Ok',
395-
},
396-
]);
388+
const refreshResults = await pageObjects.triggersActionsUI.getAlertsListWithStatus();
389+
expect(refreshResults.map((item) => item.status).sort()).to.eql(['Error', 'Ok']);
397390
});
398391
await testSubjects.click('alertStatusFilterButton');
399392
await testSubjects.click('alertStatuserrorFilerOption'); // select Error status filter
400393
await retry.try(async () => {
401-
const filterErrorOnlyResults = await pageObjects.triggersActionsUI.getAlertsList(true);
402-
expect(filterErrorOnlyResults).to.eql([]); // no alerts with errors
403-
});
404-
405-
const alertStatusokFilerOption = await testSubjects.find('alertStatusokFilerOption');
406-
// reopen popup with status filters if it was closed
407-
if (!alertStatusokFilerOption) {
408-
await testSubjects.click('alertStatusFilterButton');
409-
}
410-
await testSubjects.click('alertStatusokFilerOption'); // select Ok status filter
411-
412-
await retry.try(async () => {
413-
const filterOkOnlyResults = await pageObjects.triggersActionsUI.getAlertsList(true);
414-
expect(filterOkOnlyResults).to.eql([
394+
const filterErrorOnlyResults = await pageObjects.triggersActionsUI.getAlertsListWithStatus();
395+
expect(filterErrorOnlyResults).to.eql([
415396
{
416-
name: createdAlert.name,
397+
name: failinfAlert.name,
417398
tagsText: 'foo, bar',
418-
alertType: 'Test: Noop',
419-
interval: '1m',
420-
status: 'Ok',
399+
alertType: 'Test: Failing',
400+
interval: '30s',
401+
status: 'Error',
421402
},
422403
]);
423404
});
424-
await deleteAlerts([createdAlert.id]);
405+
406+
await deleteAlerts([createdAlert.id, failinfAlert.id]);
425407
});
426408

427409
it('should display total alerts by status and error banner only when exists alerts with status error', async () => {
428410
const createdAlert = await createAlert();
429411
await retry.try(async () => {
430412
await refreshAlertsList();
431-
const refreshResults = await pageObjects.triggersActionsUI.getAlertsList(true);
413+
const refreshResults = await pageObjects.triggersActionsUI.getAlertsListWithStatus();
432414
expect(refreshResults).to.eql([
433415
{
434416
name: createdAlert.name,
@@ -476,16 +458,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
476458
const failinfAlert = await createFailingAlert();
477459
await refreshAlertsList();
478460
await testSubjects.click('alertTypeFilterButton');
479-
await testSubjects.click('alertTypeTest:NoopFilterOption');
461+
await testSubjects.click('alertTypetest.failingFilterOption');
480462

481463
await retry.try(async () => {
482464
const filterOkOnlyResults = await pageObjects.triggersActionsUI.getAlertsList();
483465
expect(filterOkOnlyResults).to.eql([
484466
{
485-
name: noopAlert.name,
467+
name: failinfAlert.name,
486468
tagsText: 'foo, bar',
487-
alertType: 'Test: Noop',
488-
interval: '1m',
469+
alertType: 'Test: Failing',
470+
interval: '30s',
489471
},
490472
]);
491473
});
@@ -515,7 +497,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
515497
});
516498
await refreshAlertsList();
517499
await testSubjects.click('actionTypeFilterButton');
518-
await testSubjects.click('actionTypeSlackFilterOption');
500+
await testSubjects.click('actionType.slackFilterOption');
519501

520502
await retry.try(async () => {
521503
const filterOkOnlyResults = await pageObjects.triggersActionsUI.getAlertsList();

x-pack/test/functional_with_es_ssl/page_objects/triggers_actions_ui_page.ts

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import expect from '@kbn/expect';
8+
import { CustomCheerioStatic } from 'test/functional/services/lib/web_element_wrapper/custom_cheerio_api';
89
import { FtrProviderContext } from '../ftr_provider_context';
910

1011
const ENTER_KEY = '\uE007';
@@ -14,6 +15,24 @@ export function TriggersActionsPageProvider({ getService }: FtrProviderContext)
1415
const retry = getService('retry');
1516
const testSubjects = getService('testSubjects');
1617

18+
function getRowItemData(row: CheerioElement, $: CustomCheerioStatic) {
19+
return {
20+
name: $(row).findTestSubject('alertsTableCell-name').find('.euiTableCellContent').text(),
21+
tagsText: $(row)
22+
.findTestSubject('alertsTableCell-tagsText')
23+
.find('.euiTableCellContent')
24+
.text(),
25+
alertType: $(row)
26+
.findTestSubject('alertsTableCell-alertType')
27+
.find('.euiTableCellContent')
28+
.text(),
29+
interval: $(row)
30+
.findTestSubject('alertsTableCell-interval')
31+
.find('.euiTableCellContent')
32+
.text(),
33+
};
34+
}
35+
1736
return {
1837
async getSectionHeadingText() {
1938
return await testSubjects.getVisibleText('appTitle');
@@ -72,40 +91,29 @@ export function TriggersActionsPageProvider({ getService }: FtrProviderContext)
7291
};
7392
});
7493
},
75-
async getAlertsList(includingStatus?: boolean) {
94+
async getAlertsList() {
7695
const table = await find.byCssSelector('[data-test-subj="alertsList"] table');
7796
const $ = await table.parseDomContent();
7897
return $.findTestSubjects('alert-row')
7998
.toArray()
8099
.map((row) => {
81-
const rowItem = {
82-
name: $(row)
83-
.findTestSubject('alertsTableCell-name')
84-
.find('.euiTableCellContent')
85-
.text(),
86-
tagsText: $(row)
87-
.findTestSubject('alertsTableCell-tagsText')
88-
.find('.euiTableCellContent')
89-
.text(),
90-
alertType: $(row)
91-
.findTestSubject('alertsTableCell-alertType')
92-
.find('.euiTableCellContent')
93-
.text(),
94-
interval: $(row)
95-
.findTestSubject('alertsTableCell-interval')
100+
return getRowItemData(row, $);
101+
});
102+
},
103+
async getAlertsListWithStatus() {
104+
const table = await find.byCssSelector('[data-test-subj="alertsList"] table');
105+
const $ = await table.parseDomContent();
106+
return $.findTestSubjects('alert-row')
107+
.toArray()
108+
.map((row) => {
109+
const rowItem = getRowItemData(row, $);
110+
return {
111+
...rowItem,
112+
status: $(row)
113+
.findTestSubject('alertsTableCell-status')
96114
.find('.euiTableCellContent')
97115
.text(),
98116
};
99-
if (includingStatus) {
100-
return {
101-
...rowItem,
102-
status: $(row)
103-
.findTestSubject('alertsTableCell-status')
104-
.find('.euiTableCellContent')
105-
.text(),
106-
};
107-
}
108-
return rowItem;
109117
});
110118
},
111119
async isAlertsListDisplayed() {

0 commit comments

Comments
 (0)