Skip to content

Commit

Permalink
[RAM] Create serverless functional tests for rule details (#168101)
Browse files Browse the repository at this point in the history
Serverless functional tests for rule details on Search.

I did not copy all rule details tests to serverless. Some of them will
be copied after soon rules changes:
#168965

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
guskovaue and kibanamachine authored Oct 23, 2023
1 parent 1659434 commit c2e4d40
Show file tree
Hide file tree
Showing 4 changed files with 795 additions and 1 deletion.
2 changes: 2 additions & 0 deletions x-pack/test_serverless/functional/page_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SvlObltOverviewPageProvider } from './svl_oblt_overview_page';
import { SvlSearchLandingPageProvider } from './svl_search_landing_page';
import { SvlSecLandingPageProvider } from './svl_sec_landing_page';
import { SvlTriggersActionsPageProvider } from './svl_triggers_actions_ui_page';
import { SvlRuleDetailsPageProvider } from './svl_rule_details_ui_page';

export const pageObjects = {
...xpackFunctionalPageObjects,
Expand All @@ -30,4 +31,5 @@ export const pageObjects = {
svlSearchLandingPage: SvlSearchLandingPageProvider,
svlSecLandingPage: SvlSecLandingPageProvider,
svlTriggersActionsUI: SvlTriggersActionsPageProvider,
svlRuleDetailsUI: SvlRuleDetailsPageProvider,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';

export function SvlRuleDetailsPageProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const find = getService('find');
const log = getService('log');
const retry = getService('retry');

return {
async getHeadingText() {
return await testSubjects.getVisibleText('ruleDetailsTitle');
},
async getRuleType() {
return await testSubjects.getVisibleText('ruleTypeLabel');
},
async getAPIKeyOwner() {
return await testSubjects.getVisibleText('apiKeyOwnerLabel');
},
async getAlertsList() {
const table = await find.byCssSelector(
'.euiBasicTable[data-test-subj="alertsList"]:not(.euiBasicTable-loading)'
);
const $ = await table.parseDomContent();
return $.findTestSubjects('alert-row')
.toArray()
.map((row) => {
return {
alert: $(row)
.findTestSubject('alertsTableCell-alert')
.find('.euiTableCellContent')
.text(),
status: $(row)
.findTestSubject('alertsTableCell-status')
.find('.euiTableCellContent')
.text(),
start: $(row)
.findTestSubject('alertsTableCell-start')
.find('.euiTableCellContent')
.text(),
duration: $(row)
.findTestSubject('alertsTableCell-duration')
.find('.euiTableCellContent')
.text(),
};
});
},
async getAlertDurationEpoch(): Promise<number> {
const alertDurationEpoch = await find.byCssSelector(
'input[data-test-subj="alertsDurationEpoch"]'
);
return parseInt(await alertDurationEpoch.getAttribute('value'), 10);
},
async clickAlertMuteButton(alert: string) {
const muteAlertButton = await testSubjects.find(`muteAlertButton_${alert}`);
await muteAlertButton.click();
},
async ensureAlertMuteState(alert: string, isMuted: boolean) {
await retry.try(async () => {
const muteAlertButton = await testSubjects.find(`muteAlertButton_${alert}`);
log.debug(`checked:${await muteAlertButton.getAttribute('aria-checked')}`);
expect(await muteAlertButton.getAttribute('aria-checked')).to.eql(
isMuted ? 'true' : 'false'
);
});
},
async ensureAlertExistence(alert: string, shouldExist: boolean) {
await retry.try(async () => {
const table = await find.byCssSelector(
'.euiBasicTable[data-test-subj="alertsList"]:not(.euiBasicTable-loading)'
);
const $ = await table.parseDomContent();
expect(
$.findTestSubjects('alert-row')
.toArray()
.filter(
(row) =>
$(row)
.findTestSubject('alertsTableCell-alert')
.find('.euiTableCellContent')
.text() === alert
)
).to.eql(shouldExist ? 1 : 0);
});
},
async clickPaginationNextPage() {
const nextButton = await testSubjects.find(`pagination-button-next`);
nextButton.click();
},
async isViewInAppDisabled() {
await retry.try(async () => {
const viewInAppButton = await testSubjects.find(`ruleDetails-viewInApp`);
expect(await viewInAppButton.getAttribute('disabled')).to.eql('true');
});
return true;
},
async isViewInAppEnabled() {
await retry.try(async () => {
const viewInAppButton = await testSubjects.find(`ruleDetails-viewInApp`);
await new Promise((resolve) => {});
expect(await viewInAppButton.getAttribute('disabled')).to.not.eql('true');
});
return true;
},
async clickViewInApp() {
return await testSubjects.click('ruleDetails-viewInApp');
},
async getNoOpAppTitle() {
await retry.try(async () => {
const title = await testSubjects.find('noop-title');
expect(title.isDisplayed()).to.eql(true);
});
return await testSubjects.getVisibleText('noop-title');
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./empty_page'));
loadTestFile(require.resolve('./navigation'));
loadTestFile(require.resolve('./cases/attachment_framework'));

loadTestFile(require.resolve('./dashboards/build_dashboard'));
loadTestFile(require.resolve('./dashboards/import_dashboard'));
loadTestFile(require.resolve('./advanced_settings'));
loadTestFile(require.resolve('./rules/rule_details'));

loadTestFile(require.resolve('./ml'));
});
Expand Down
Loading

0 comments on commit c2e4d40

Please sign in to comment.