[alerting] fixes View In App Functional test (#60606)

Enables the FT that tests the View inApp functionality.
It addresses an issue that causes a race condition on CI where the ViewInApp button was thought to be enabled when it was, in fact, still disabled.
This meant that the click on the button didn't trigger the handler which, in turn, made the test fail.
This commit is contained in:
Gidi Meir Morris 2020-03-20 17:42:25 +00:00 committed by GitHub
parent 55814addac
commit da2ec4bf40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 10 deletions

View file

@ -35,7 +35,7 @@ jest.mock('../../../lib/capabilities', () => ({
hasSaveAlertsCapability: jest.fn(() => true),
}));
describe('alert_details', () => {
describe('view in app', () => {
describe('link to the app that created the alert', () => {
it('is disabled when there is no navigation', async () => {
const alert = mockAlert();

View file

@ -148,9 +148,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
});
describe.skip('View In App', function() {
describe('View In App', function() {
const testRunUuid = uuid.v4();
before(async () => {
beforeEach(async () => {
await pageObjects.common.navigateToApp('triggersActions');
});
@ -170,10 +171,30 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(await pageObjects.alertDetailsUI.isViewInAppEnabled()).to.be(true);
await pageObjects.alertDetailsUI.clickViewInAppEnabled();
await pageObjects.alertDetailsUI.clickViewInApp();
expect(await pageObjects.alertDetailsUI.getNoOpAppTitle()).to.be(`View Alert ${alert.id}`);
});
it('renders a disabled alert details view in app button', async () => {
const alert = await alerting.alerts.createAlwaysFiringWithActions(
`test-alert-disabled-nav`,
[]
);
// refresh to see alert
await browser.refresh();
await pageObjects.header.waitUntilLoadingHasFinished();
// Verify content
await testSubjects.existOrFail('alertsList');
// click on first alert
await pageObjects.triggersActionsUI.clickOnAlertInAlertsList(alert.name);
expect(await pageObjects.alertDetailsUI.isViewInAppDisabled()).to.be(true);
});
});
describe('Alert Instances', function() {

View file

@ -102,15 +102,28 @@ export function AlertDetailsPageProvider({ getService }: FtrProviderContext) {
const nextButton = await testSubjects.find(`pagination-button-next`);
nextButton.click();
},
async isViewInAppEnabled() {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
return (await viewInAppButton.getAttribute('disabled')) !== 'disabled';
async isViewInAppDisabled() {
await retry.try(async () => {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
expect(await viewInAppButton.getAttribute('disabled')).to.eql('true');
});
return true;
},
async clickViewInAppEnabled() {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
return viewInAppButton.click();
async isViewInAppEnabled() {
await retry.try(async () => {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
expect(await viewInAppButton.getAttribute('disabled')).to.not.eql('true');
});
return true;
},
async clickViewInApp() {
return await testSubjects.click('alertDetails-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');
},
};