Skip to content

Commit

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

This will backport the following commits from `main` to `8.14`:
- [[Cases] Fix flaky functional tests
(#181230)](#181230)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Christos
Nasikas","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-04-22T10:44:19Z","message":"[Cases]
Fix flaky functional tests (#181230)\n\n## Summary\r\n\r\nI ran the
flaky test runner multiple times. I did not find any good\r\nreason why
some of the tests were flaky in the first place.\r\n\r\nFlaky test
runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5720,\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5721,\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5727\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/179016,\r\nhttps://github.com/elastic/kibana/issues/178991,\r\nhttps://github.com/elastic/kibana/issues/176716,\r\nhttps://github.com/elastic/kibana/issues/178690\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n### For maintainers\r\n\r\n- [x]
This was checked for breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Kibana Machine
<[email protected]>","sha":"8a992997e9f942b39182a087df44604dc69957cf","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","Feature:Cases","v8.14.0","v8.15.0"],"title":"[Cases]
Fix flaky functional
tests","number":181230,"url":"https://github.com/elastic/kibana/pull/181230","mergeCommit":{"message":"[Cases]
Fix flaky functional tests (#181230)\n\n## Summary\r\n\r\nI ran the
flaky test runner multiple times. I did not find any good\r\nreason why
some of the tests were flaky in the first place.\r\n\r\nFlaky test
runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5720,\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5721,\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5727\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/179016,\r\nhttps://github.com/elastic/kibana/issues/178991,\r\nhttps://github.com/elastic/kibana/issues/176716,\r\nhttps://github.com/elastic/kibana/issues/178690\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n### For maintainers\r\n\r\n- [x]
This was checked for breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Kibana Machine
<[email protected]>","sha":"8a992997e9f942b39182a087df44604dc69957cf"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/181230","number":181230,"mergeCommit":{"message":"[Cases]
Fix flaky functional tests (#181230)\n\n## Summary\r\n\r\nI ran the
flaky test runner multiple times. I did not find any good\r\nreason why
some of the tests were flaky in the first place.\r\n\r\nFlaky test
runner:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5720,\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5721,\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5727\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/179016,\r\nhttps://github.com/elastic/kibana/issues/178991,\r\nhttps://github.com/elastic/kibana/issues/176716,\r\nhttps://github.com/elastic/kibana/issues/178690\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n### For maintainers\r\n\r\n- [x]
This was checked for breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Kibana Machine
<[email protected]>","sha":"8a992997e9f942b39182a087df44604dc69957cf"}}]}]
BACKPORT-->

Co-authored-by: Christos Nasikas <[email protected]>
  • Loading branch information
kibanamachine and cnasikas authored Apr 22, 2024
1 parent 8973465 commit 601ec09
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 601ec09

Please sign in to comment.