Skip to content

Commit

Permalink
Fix API Keys functional test in cloud (#74075)
Browse files Browse the repository at this point in the history
* check admin description

* split test logic
  • Loading branch information
dmlemeshko authored Aug 3, 2020
1 parent 4758cb1 commit 18e2daa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 11 additions & 4 deletions x-pack/test/functional/apps/api_keys/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'apiKeys']);
const log = getService('log');
const security = getService('security');
const testSubjects = getService('testSubjects');

describe('Home page', function () {
before(async () => {
Expand All @@ -32,10 +33,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
it('Loads the app', async () => {
await security.testUser.setRoles(['test_api_keys']);
log.debug('Checking for section header');
const headerText = await pageObjects.apiKeys.noAPIKeysHeading();
expect(headerText).to.be('No API keys');
const goToConsoleButton = await pageObjects.apiKeys.getGoToConsoleButton();
expect(await goToConsoleButton.isDisplayed()).to.be(true);
const headers = await testSubjects.findAll('noApiKeysHeader');
if (headers.length > 0) {
expect(await headers[0].getVisibleText()).to.be('No API keys');
const goToConsoleButton = await pageObjects.apiKeys.getGoToConsoleButton();
expect(await goToConsoleButton.isDisplayed()).to.be(true);
} else {
// page may already contain EiTable with data, then check API Key Admin text
const description = await pageObjects.apiKeys.getApiKeyAdminDesc();
expect(description).to.be('You are an API Key administrator.');
}
});
});
};
4 changes: 4 additions & 0 deletions x-pack/test/functional/page_objects/api_keys_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export function ApiKeysPageProvider({ getService }: FtrProviderContext) {
return await testSubjects.getVisibleText('noApiKeysHeader');
},

async getApiKeyAdminDesc() {
return await testSubjects.getVisibleText('apiKeyAdminDescriptionCallOut');
},

async getGoToConsoleButton() {
return await testSubjects.find('goToConsoleButton');
},
Expand Down

0 comments on commit 18e2daa

Please sign in to comment.