Skip to content

Commit

Permalink
[alerting] fixes View In App Functional test (#60606) (#60787)
Browse files Browse the repository at this point in the history
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.

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
gmmorris and elasticmachine authored Mar 23, 2020
1 parent bc32e31 commit ef1f00d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand All @@ -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() {
Expand Down
23 changes: 18 additions & 5 deletions x-pack/test/functional_with_es_ssl/page_objects/alert_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,28 @@ export function AlertDetailsPageProvider({ getService }: FtrProviderContext) {
const nextButton = await testSubjects.find(`pagination-button-next`);
nextButton.click();
},
async isViewInAppDisabled() {
await retry.try(async () => {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
expect(await viewInAppButton.getAttribute('disabled')).to.eql('true');
});
return true;
},
async isViewInAppEnabled() {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
return (await viewInAppButton.getAttribute('disabled')) !== 'disabled';
await retry.try(async () => {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
expect(await viewInAppButton.getAttribute('disabled')).to.not.eql('true');
});
return true;
},
async clickViewInAppEnabled() {
const viewInAppButton = await testSubjects.find(`alertDetails-viewInApp`);
return viewInAppButton.click();
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');
},
};
Expand Down

0 comments on commit ef1f00d

Please sign in to comment.