Skip to content

Commit

Permalink
[Cases] Fix flaky functional tests (#181230)
Browse files Browse the repository at this point in the history
## Summary

I ran the flaky test runner multiple times. I did not find any good
reason why some of the tests were flaky in the first place.

Flaky test runner:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5720,
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5721,
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5727

Fixes: #179016,
#178991,
#176716,
#178690

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
cnasikas and kibanamachine authored Apr 22, 2024
1 parent 94fe888 commit 8a99299
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export const MultiSelectFilter = <T extends string, K extends string = string>({
closePopover={() => setIsPopoverOpen(false)}
panelPaddingSize="none"
repositionOnScroll
panelProps={{
'data-test-subj': `options-filter-popover-panel-${id}`,
}}
data-test-subj={`options-filter-popover-${id}`}
>
{isInvalid && (
<>
Expand Down
26 changes: 13 additions & 13 deletions x-pack/test/functional/services/cases/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ export function CasesTableServiceProvider(
await testSubjects.click(`options-filter-popover-item-${status}`);
// to close the popup
await testSubjects.click('options-filter-popover-button-status');

await testSubjects.missingOrFail(`options-filter-popover-item-${status}`, {
timeout: 5000,
});
},

async filterBySeverity(severity: CaseSeverity) {
Expand All @@ -202,18 +198,22 @@ export function CasesTableServiceProvider(
await casesCommon.selectFirstRowInAssigneesPopover();
},

async filterByOwner(
owner: string,
options: { popupAlreadyOpen: boolean } = { popupAlreadyOpen: false }
) {
if (!options.popupAlreadyOpen) {
await common.clickAndValidate(
'options-filter-popover-button-owner',
`options-filter-popover-item-${owner}`
);
async filterByOwner(owner: string) {
const isAlreadyOpen = await testSubjects.exists('options-filter-popover-panel-owner');

if (isAlreadyOpen) {
await testSubjects.click(`options-filter-popover-item-${owner}`);
await header.waitUntilLoadingHasFinished();
return;
}

await retry.waitFor(`filterByOwner popover opened`, async () => {
await testSubjects.click('options-filter-popover-button-owner');
return await testSubjects.exists('options-filter-popover-panel-owner');
});

await testSubjects.click(`options-filter-popover-item-${owner}`);
await header.waitUntilLoadingHasFinished();
},

async refreshTable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
const lens = getPageObject('lens');
const listingTable = getService('listingTable');
const toasts = getService('toasts');
const browser = getService('browser');

const createAttachmentAndNavigate = async (attachment: AttachmentRequest) => {
const caseData = await cases.api.createCase({
Expand Down Expand Up @@ -262,8 +263,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/178690
describe.skip('Modal', () => {
describe('Modal', () => {
const createdCases = new Map<string, string>();

const openModal = async () => {
Expand All @@ -273,6 +273,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {

const closeModal = async () => {
await find.clickByCssSelector('[data-test-subj="all-cases-modal"] > button');
await testSubjects.missingOrFail('all-cases-modal');
};

before(async () => {
Expand All @@ -282,6 +283,10 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
}
});

beforeEach(async () => {
await browser.refresh();
});

after(async () => {
await deleteAllCaseItems(es);
});
Expand All @@ -292,46 +297,45 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
await testSubjects.existOrFail('options-filter-popover-button-owner');

for (const [, currentCaseId] of createdCases.entries()) {
await testSubjects.existOrFail(`cases-table-row-${currentCaseId}`);
await cases.casesTable.getCaseById(currentCaseId);
}

await closeModal();
});

it('filters correctly', async () => {
it('filters correctly with owner cases', async () => {
for (const [owner, currentCaseId] of createdCases.entries()) {
await openModal();

await cases.casesTable.filterByOwner(owner);
await cases.casesTable.waitForTableToFinishLoading();
await testSubjects.existOrFail(`cases-table-row-${currentCaseId}`);

await cases.casesTable.getCaseById(currentCaseId);
/**
* We ensure that the other cases are not shown
* The select button matched the query of the
* [data-test-subj*="cases-table-row-" query
*/
for (const otherCaseId of createdCases.values()) {
if (otherCaseId !== currentCaseId) {
await testSubjects.missingOrFail(`cases-table-row-${otherCaseId}`);
}
}

await cases.casesTable.validateCasesTableHasNthRows(2);
await closeModal();
}
});

it('filters with multiple selection', async () => {
await openModal();

let popupAlreadyOpen = false;
for (const [owner] of createdCases.entries()) {
await cases.casesTable.filterByOwner(owner, { popupAlreadyOpen });
popupAlreadyOpen = true;
await cases.casesTable.filterByOwner(owner);
}

await cases.casesTable.waitForTableToFinishLoading();

/**
* The select button matched the query of the
* [data-test-subj*="cases-table-row-" query
*/
await cases.casesTable.validateCasesTableHasNthRows(6);

for (const caseId of createdCases.values()) {
await testSubjects.existOrFail(`cases-table-row-${caseId}`);
await cases.casesTable.getCaseById(caseId);
}

await closeModal();
});

Expand All @@ -340,7 +344,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
await openModal();

await cases.casesTable.waitForTableToFinishLoading();
await testSubjects.existOrFail(`cases-table-row-${currentCaseId}`);
await cases.casesTable.getCaseById(currentCaseId);
await testSubjects.click(`cases-table-row-select-${currentCaseId}`);

await cases.common.expectToasterToContain('has been updated');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/178991
describe.skip('filtering', () => {
describe('filtering', () => {
const caseTitle = 'matchme';
let caseIds: string[] = [];
const profiles: UserProfile[] = [];
Expand Down Expand Up @@ -753,8 +752,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
expect(await testSubjects.exists('all-cases-clear-filters-link-icon')).to.be(false);
});

// FLAKY: https://github.com/elastic/kibana/issues/176716
describe.skip('assignees filtering', () => {
describe('assignees filtering', () => {
it('filters cases by the first cases all user assignee', async () => {
await cases.casesTable.filterByAssignee('all');
await cases.casesTable.validateCasesTableHasNthRows(1);
Expand Down Expand Up @@ -796,8 +794,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/179016
describe.skip('severity filtering', () => {
describe('severity filtering', () => {
before(async () => {
await cases.navigation.navigateToApp();
await cases.api.createCase({ severity: CaseSeverity.LOW });
Expand Down

0 comments on commit 8a99299

Please sign in to comment.