Skip to content

Commit

Permalink
Ensure that API keys are rendered before performing bulk delete in fu…
Browse files Browse the repository at this point in the history
…nctional tests.
  • Loading branch information
azasypkin committed Dec 22, 2022
1 parent cffcab1 commit f67609a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('APIKeysGridPage', () => {
const secondKey = getByText(/second-api-key/).closest('td');
const secondKeyEuiLink = secondKey!.querySelector('button');
expect(secondKeyEuiLink).not.toBeNull();
expect(secondKeyEuiLink!.getAttribute('data-test-subj')).toBe('roleRowName-second-api-key');
expect(secondKeyEuiLink!.getAttribute('data-test-subj')).toBe('apiKeyRowName-second-api-key');
});

afterAll(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ export class APIKeysGridPage extends Component<Props, State> {
return (
<EuiText color="subdued" size="s">
<EuiLink
data-test-subj={`roleRowName-${recordAP.name}`}
data-test-subj={`apiKeyRowName-${recordAP.name}`}
onClick={() => {
this.setState({ selectedApiKey: recordAP, isUpdateFlyoutVisible: true });
}}
Expand Down
18 changes: 16 additions & 2 deletions x-pack/test/functional/apps/api_keys/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const testSubjects = getService('testSubjects');
const find = getService('find');
const browser = getService('browser');
const retry = getService('retry');

const testRoles: Record<string, any> = {
viewer: {
Expand All @@ -37,8 +38,17 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
},
};

// Failing: See https://github.com/elastic/kibana/issues/141868
describe.skip('Home page', function () {
async function ensureApiKeysExist(apiKeysNames: string[]) {
await retry.try(async () => {
for (const apiKeyName of apiKeysNames) {
log.debug(`Checking if API key ("${apiKeyName}") exists.`);
await pageObjects.apiKeys.ensureApiKeyExists(apiKeyName);
log.debug(`API key ("${apiKeyName}") exists.`);
}
});
}

describe('Home page', function () {
before(async () => {
await clearAllApiKeys(es, log);
await security.testUser.setRoles(['kibana_admin']);
Expand Down Expand Up @@ -392,6 +402,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.apiKeys.clickOnPromptCreateApiKey();
await pageObjects.apiKeys.setApiKeyName('api key 1');
await pageObjects.apiKeys.clickSubmitButtonOnApiKeyFlyout();
await ensureApiKeysExist(['api key 1']);
});

it('one by one', async () => {
Expand All @@ -406,6 +417,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.apiKeys.setApiKeyName('api key 2');
await pageObjects.apiKeys.clickSubmitButtonOnApiKeyFlyout();

// Make sure all API keys we want to delete are created and rendered.
await ensureApiKeysExist(['api key 1', 'api key 2']);

await pageObjects.apiKeys.bulkDeleteApiKeys();
expect(await pageObjects.apiKeys.getApiKeysFirstPromptTitle()).to.be(
'Create your first API key'
Expand Down
6 changes: 5 additions & 1 deletion x-pack/test/functional/page_objects/api_keys_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ export function ApiKeysPageProvider({ getService }: FtrProviderContext) {
},

async clickExistingApiKeyToOpenFlyout(apiKeyName: string) {
await testSubjects.click(`roleRowName-${apiKeyName}`);
await testSubjects.click(`apiKeyRowName-${apiKeyName}`);
},

async ensureApiKeyExists(apiKeyName: string) {
await testSubjects.existOrFail(`apiKeyRowName-${apiKeyName}`);
},

async getMetadataSwitch() {
Expand Down

0 comments on commit f67609a

Please sign in to comment.