Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.2] [Cases] Fix flaky test on e2e view case (#129558) #129891

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion x-pack/test/functional/services/cases/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function CasesCreateViewServiceProvider({ getService, getPageObject }: Ft
const testSubjects = getService('testSubjects');
const find = getService('find');
const comboBox = getService('comboBox');
const config = getService('config');

return {
/**
Expand Down Expand Up @@ -57,7 +58,9 @@ export function CasesCreateViewServiceProvider({ getService, getPageObject }: Ft
// save
await testSubjects.click('create-case-submit');

await testSubjects.existOrFail('case-view-title');
await testSubjects.existOrFail('case-view-title', {
timeout: config.get('timeouts.waitFor'),
});
},
};
}
27 changes: 24 additions & 3 deletions x-pack/test/functional/services/cases/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function CasesTableServiceProvider({ getService, getPageObject }: FtrProv
const find = getService('find');
const header = getPageObject('header');
const retry = getService('retry');
const config = getService('config');

return {
/**
Expand All @@ -25,8 +26,27 @@ export function CasesTableServiceProvider({ getService, getPageObject }: FtrProv
*/
async goToFirstListedCase() {
await testSubjects.existOrFail('cases-table');
await testSubjects.existOrFail('case-details-link', {
timeout: config.get('timeouts.waitFor'),
});
await testSubjects.click('case-details-link');
await testSubjects.existOrFail('case-view-title');
await testSubjects.existOrFail('case-view-title', {
timeout: config.get('timeouts.waitFor'),
});
},

async deleteFirstListedCase() {
await testSubjects.existOrFail('action-delete', {
timeout: config.get('timeouts.waitFor'),
});
await testSubjects.click('action-delete');
await testSubjects.existOrFail('confirmModalConfirmButton', {
timeout: config.get('timeouts.waitFor'),
});
await testSubjects.click('confirmModalConfirmButton');
await testSubjects.existOrFail('euiToastHeader', {
timeout: config.get('timeouts.waitFor'),
});
},

async bulkDeleteAllCases() {
Expand Down Expand Up @@ -55,8 +75,8 @@ export function CasesTableServiceProvider({ getService, getPageObject }: FtrProv
},

async validateCasesTableHasNthRows(nrRows: number) {
await retry.tryForTime(2000, async () => {
const rows = await find.allByCssSelector('[data-test-subj*="cases-table-row-"', 100);
await retry.tryForTime(3000, async () => {
const rows = await find.allByCssSelector('[data-test-subj*="cases-table-row-"');
expect(rows.length).equal(nrRows);
});
},
Expand All @@ -66,6 +86,7 @@ export function CasesTableServiceProvider({ getService, getPageObject }: FtrProv
this.refreshTable();
return await testSubjects.exists('case-details-link');
});
await header.waitUntilLoadingHasFinished();
},

async waitForCasesToBeDeleted() {
Expand Down
13 changes: 5 additions & 8 deletions x-pack/test/functional_with_es_ssl/apps/cases/list_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import expect from '@kbn/expect';
import uuid from 'uuid';
import { FtrProviderContext } from '../../ftr_provider_context';
import { CaseStatuses } from '../../../../plugins/cases/common';

Expand Down Expand Up @@ -64,9 +63,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
});

it('deletes a case correctly from the list', async () => {
await testSubjects.click('action-delete');
await testSubjects.click('confirmModalConfirmButton');
await testSubjects.existOrFail('euiToastHeader');
await cases.casesTable.deleteFirstListedCase();
await cases.casesTable.waitForTableToFinishLoading();

await retry.tryForTime(2000, async () => {
Expand All @@ -83,13 +80,13 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
});

describe('filtering', () => {
const id = uuid.v4();
const caseTitle = 'matchme-' + id;
const caseTitle = 'matchme';

before(async () => {
await cases.api.createNthRandomCases(2);
await cases.api.createCase({ title: caseTitle, tags: ['one'] });
await cases.api.createCase({ tags: ['two'] });
await cases.api.createCase({ title: 'test2', tags: ['two'] });
await cases.api.createCase({ title: 'test3' });
await cases.api.createCase({ title: 'test4' });
await header.waitUntilLoadingHasFinished();
await cases.casesTable.waitForCasesToBeListed();
});
Expand Down