mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ResponseOps][Connectors] Fixing flaky connectors·ts test (#140989)
* Updating skipped tests * Removing unused fields * Fixing test failure * Fixing other test failure * Fixing failure test * Cleaning up tests * Revert skip for testing * Fixing related test failures * Updating retry * Fixing tests * Fixing types * Rename function
This commit is contained in:
parent
f97bf98e5e
commit
7f49b9caa6
2 changed files with 82 additions and 57 deletions
|
@ -90,6 +90,26 @@ export class FindService extends FtrService {
|
|||
});
|
||||
}
|
||||
|
||||
public async setValueByClass(selector: string, text: string, topOffset?: number): Promise<void> {
|
||||
this.log.debug(`Find.setValueByClass('${selector}', '${text}')`);
|
||||
return await this.retry.try(async () => {
|
||||
const element = await this.byClassName(selector);
|
||||
await element.click(topOffset);
|
||||
|
||||
// in case the input element is actually a child of the testSubject, we
|
||||
// call clearValue() and type() on the element that is focused after
|
||||
// clicking on the testSubject
|
||||
const input = await this.activeElement();
|
||||
if (input) {
|
||||
await input.clearValue();
|
||||
await input.type(text);
|
||||
} else {
|
||||
await element.clearValue();
|
||||
await element.type(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async selectValue(selector: string, value: string): Promise<void> {
|
||||
this.log.debug(`Find.selectValue('${selector}', option[value="${value}"]')`);
|
||||
const combobox = await this.byCssSelector(selector);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { findIndex } from 'lodash';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
import { ObjectRemover } from '../../lib/object_remover';
|
||||
import { generateUniqueKey, getTestActionData } from '../../lib/get_test_data';
|
||||
|
@ -15,13 +16,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const pageObjects = getPageObjects(['common', 'triggersActionsUI', 'header']);
|
||||
const find = getService('find');
|
||||
const retry = getService('retry');
|
||||
const comboBox = getService('comboBox');
|
||||
const supertest = getService('supertest');
|
||||
const objectRemover = new ObjectRemover(supertest);
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/88796
|
||||
describe.skip('Connectors', function () {
|
||||
const objectRemover = new ObjectRemover(supertest);
|
||||
|
||||
describe('Connectors', function () {
|
||||
before(async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`/api/actions/connector`)
|
||||
|
@ -44,7 +42,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
|
||||
await testSubjects.click('.index-card');
|
||||
|
||||
await find.clickByCssSelector('[data-test-subj="backButton"]');
|
||||
await find.clickByCssSelector('[data-test-subj="create-connector-flyout-back-btn"]');
|
||||
|
||||
await testSubjects.click('.slack-card');
|
||||
|
||||
|
@ -68,12 +66,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
actionType: 'Slack',
|
||||
},
|
||||
]);
|
||||
const connector = await getConnector(connectorName);
|
||||
objectRemover.add(connector.id, 'action', 'actions');
|
||||
});
|
||||
|
||||
it('should edit a connector', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const updatedConnectorName = `${connectorName}updated`;
|
||||
await createConnector(connectorName);
|
||||
const createdAction = await createConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
||||
|
@ -107,7 +108,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should test a connector and display a successful result', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const indexName = generateUniqueKey();
|
||||
await createIndexConnector(connectorName, indexName);
|
||||
const createdAction = await createIndexConnector(connectorName, indexName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
||||
|
@ -119,7 +121,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
await find.clickByCssSelector('[data-test-subj="testConnectorTab"]');
|
||||
|
||||
// test success
|
||||
await testSubjects.setValue('documentsJsonEditor', '{ "key": "value" }');
|
||||
await find.setValueByClass('kibanaCodeEditor', '{ "key": "value" }');
|
||||
|
||||
await find.clickByCssSelector('[data-test-subj="executeActionButton"]:not(disabled)');
|
||||
|
||||
|
@ -128,14 +130,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
});
|
||||
|
||||
await find.clickByCssSelector(
|
||||
'[data-test-subj="cancelSaveEditedConnectorButton"]:not(disabled)'
|
||||
'[data-test-subj="edit-connector-flyout-cancel-btn"]:not(disabled)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should test a connector and display a failure result', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const indexName = generateUniqueKey();
|
||||
await createIndexConnector(connectorName, indexName);
|
||||
const createdAction = await createIndexConnector(connectorName, indexName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
||||
|
@ -146,25 +149,23 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
|
||||
await find.clickByCssSelector('[data-test-subj="testConnectorTab"]');
|
||||
|
||||
await testSubjects.setValue('documentsJsonEditor', '{ "": "value" }');
|
||||
await find.setValueByClass('kibanaCodeEditor', '"test"');
|
||||
|
||||
await find.clickByCssSelector('[data-test-subj="executeActionButton"]:not(disabled)');
|
||||
|
||||
await retry.try(async () => {
|
||||
const executionFailureResultCallout = await testSubjects.find('executionFailureResult');
|
||||
expect(await executionFailureResultCallout.getVisibleText()).to.match(
|
||||
/error indexing documents/
|
||||
);
|
||||
await testSubjects.find('executionFailureResult');
|
||||
});
|
||||
|
||||
await find.clickByCssSelector(
|
||||
'[data-test-subj="cancelSaveEditedConnectorButton"]:not(disabled)'
|
||||
'[data-test-subj="edit-connector-flyout-cancel-btn"]:not(disabled)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should reset connector when canceling an edit', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
await createConnector(connectorName);
|
||||
const createdAction = await createConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
||||
const searchResultsBeforeEdit = await pageObjects.triggersActionsUI.getConnectorsList();
|
||||
|
@ -173,9 +174,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
await find.clickByCssSelector('[data-test-subj="connectorsTableCell-name"] button');
|
||||
|
||||
await testSubjects.setValue('nameInput', 'some test name to cancel');
|
||||
await testSubjects.click('cancelSaveEditedConnectorButton');
|
||||
await testSubjects.click('edit-connector-flyout-cancel-btn');
|
||||
|
||||
await find.waitForDeletedByCssSelector('[data-test-subj="cancelSaveEditedConnectorButton"]');
|
||||
await find.waitForDeletedByCssSelector('[data-test-subj="edit-connector-flyout-cancel-btn"]');
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
||||
|
@ -189,8 +190,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should delete a connector', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
await createConnector(connectorName);
|
||||
|
||||
await createConnector(generateUniqueKey());
|
||||
const createdAction = await createConnector(generateUniqueKey());
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
||||
|
@ -214,8 +215,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should bulk delete connectors', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
await createConnector(connectorName);
|
||||
|
||||
await createConnector(generateUniqueKey());
|
||||
const createdAction = await createConnector(generateUniqueKey());
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
||||
|
@ -269,42 +270,46 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
});
|
||||
|
||||
async function createConnector(connectorName: string) {
|
||||
await pageObjects.triggersActionsUI.clickCreateConnectorButton();
|
||||
|
||||
await testSubjects.click('.slack-card');
|
||||
|
||||
await testSubjects.setValue('nameInput', connectorName);
|
||||
|
||||
await testSubjects.setValue('slackWebhookUrlInput', 'https://test.com');
|
||||
|
||||
await find.clickByCssSelector(
|
||||
'[data-test-subj="create-connector-flyout-save-btn"]:not(disabled)'
|
||||
);
|
||||
await pageObjects.common.closeToast();
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: connectorName,
|
||||
config: {},
|
||||
secrets: {
|
||||
webhookUrl: 'https://test.com',
|
||||
},
|
||||
connector_type_id: '.slack',
|
||||
})
|
||||
.expect(200);
|
||||
await testSubjects.click('connectorsTab');
|
||||
return createdAction;
|
||||
}
|
||||
|
||||
async function createIndexConnector(connectorName: string, indexName: string) {
|
||||
await pageObjects.triggersActionsUI.clickCreateConnectorButton();
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
config: {
|
||||
index: indexName,
|
||||
refresh: false,
|
||||
},
|
||||
connector_type_id: '.index',
|
||||
name: connectorName,
|
||||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
await testSubjects.click('connectorsTab');
|
||||
return createdAction;
|
||||
}
|
||||
|
||||
await testSubjects.click('.index-card');
|
||||
|
||||
await testSubjects.setValue('nameInput', connectorName);
|
||||
|
||||
await retry.try(async () => {
|
||||
// At times we find the driver controlling the ComboBox in tests
|
||||
// can select the wrong item, this ensures we always select the correct index
|
||||
await comboBox.set('connectorIndexesComboBox', indexName);
|
||||
expect(
|
||||
await comboBox.isOptionSelected(
|
||||
await testSubjects.find('connectorIndexesComboBox'),
|
||||
indexName
|
||||
)
|
||||
).to.be(true);
|
||||
});
|
||||
|
||||
await find.clickByCssSelector(
|
||||
'[data-test-subj="create-connector-flyout-save-btn"]:not(disabled)'
|
||||
);
|
||||
await pageObjects.common.closeToast();
|
||||
async function getConnector(name: string) {
|
||||
const { body } = await supertest
|
||||
.get(`/api/actions/connectors`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(200);
|
||||
const i = findIndex(body, (c: any) => c.name === name);
|
||||
return body[i];
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue