[8.9] Saved Object APIs - FTR - Fix flaky test in _find API (#160794) (#160845)

# Backport

This will backport the following commits from `main` to `8.9`:
- [Saved Object APIs - FTR - Fix flaky test in `_find` API
(#160794)](https://github.com/elastic/kibana/pull/160794)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Gerard
Soldevila","email":"gerard.soldevila@elastic.co"},"sourceCommit":{"committedDate":"2023-06-29T08:39:32Z","message":"Saved
Object APIs - FTR - Fix flaky test in `_find` API (#160794)\n\n##
Summary\r\n\r\nAttempt to fix
https://github.com/elastic/kibana/issues/156581\r\n\r\nThe best
explanation I have is that the two retrieved visualisations are\r\nnot
necessarily retrieved in the expected order.\r\nSorting the results
should ensure the expected order.\r\n\r\nWill use the flaky test runner
to check the
fix.","sha":"4e3f6990c2dcb4bf4e3e8edf4e6e2d6fe9e8d99c","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","Feature:Saved
Objects","release_note:skip","test-failure-flaky","backport:prev-minor","v8.9.0","v8.10.0"],"number":160794,"url":"https://github.com/elastic/kibana/pull/160794","mergeCommit":{"message":"Saved
Object APIs - FTR - Fix flaky test in `_find` API (#160794)\n\n##
Summary\r\n\r\nAttempt to fix
https://github.com/elastic/kibana/issues/156581\r\n\r\nThe best
explanation I have is that the two retrieved visualisations are\r\nnot
necessarily retrieved in the expected order.\r\nSorting the results
should ensure the expected order.\r\n\r\nWill use the flaky test runner
to check the
fix.","sha":"4e3f6990c2dcb4bf4e3e8edf4e6e2d6fe9e8d99c"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160794","number":160794,"mergeCommit":{"message":"Saved
Object APIs - FTR - Fix flaky test in `_find` API (#160794)\n\n##
Summary\r\n\r\nAttempt to fix
https://github.com/elastic/kibana/issues/156581\r\n\r\nThe best
explanation I have is that the two retrieved visualisations are\r\nnot
necessarily retrieved in the expected order.\r\nSorting the results
should ensure the expected order.\r\n\r\nWill use the flaky test runner
to check the fix.","sha":"4e3f6990c2dcb4bf4e3e8edf4e6e2d6fe9e8d99c"}}]}]
BACKPORT-->

Co-authored-by: Gerard Soldevila <gerard.soldevila@elastic.co>
This commit is contained in:
Kibana Machine 2023-06-29 05:46:20 -04:00 committed by GitHub
parent 19e0749d3a
commit 83c4474544
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@
* Side Public License, v 1.
*/
import { sortBy } from 'lodash';
import { MAIN_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
import expect from '@kbn/expect';
import { SavedObject } from '@kbn/core/server';
@ -153,8 +154,7 @@ export default function ({ getService }: FtrProviderContext) {
}));
});
// FLAKY: https://github.com/elastic/kibana/issues/156581
describe.skip('wildcard namespace', () => {
describe('wildcard namespace', () => {
it('should return 200 with individual responses from the all namespaces', async () =>
await supertest
.get(
@ -165,7 +165,8 @@ export default function ({ getService }: FtrProviderContext) {
const knownDocuments = resp.body.saved_objects.filter((so: { namespaces: string[] }) =>
so.namespaces.some((ns) => [SPACE_ID, `${SPACE_ID}-foo`].includes(ns))
);
const [obj1, obj2] = knownDocuments.map(
const [obj1, obj2] = sortBy(knownDocuments, 'namespaces').map(
({ id, originId, namespaces }: SavedObject) => ({ id, originId, namespaces })
);