Skip to content

Commit

Permalink
PR review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Oct 19, 2021
1 parent a6491bf commit 9be4f61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,8 @@ export class SavedObjectsRepository {

// Construct kueryNode to filter legacy URL aliases (these space-agnostic objects do not use root-level "namespace/s" fields)
const { buildNode } = esKuery.nodeTypes.function;
const targetNamespaceField = `${LEGACY_URL_ALIAS_TYPE}.targetNamespace`;
const match1 = buildNode('is', targetNamespaceField, namespace);
const match2 = buildNode('not', buildNode('exists', targetNamespaceField));
const match1 = buildNode('is', `${LEGACY_URL_ALIAS_TYPE}.targetNamespace`, namespace);
const match2 = buildNode('not', buildNode('is', 'type', LEGACY_URL_ALIAS_TYPE));
const kueryNode = buildNode('or', [match1, match2]);

const { body, statusCode, headers } = await this.client.updateByQuery(
Expand Down
8 changes: 6 additions & 2 deletions x-pack/test/spaces_api_integration/common/suites/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export function deleteTestSuiteFactory(
// @ts-expect-error @elastic/elasticsearch doesn't defined `count.buckets`.
const buckets = response.aggregations?.count.buckets;

// The test fixture contains three legacy URL aliases:
// (1) one for "space_1", (2) one for "space_2", and (3) one for "other_space", which is a non-existent space.
// Each test deletes "space_2", so the agg buckets should reflect that aliases (1) and (3) still exist afterwards.

// Space 2 deleted, all others should exist
const expectedBuckets = [
{
Expand Down Expand Up @@ -84,7 +88,7 @@ export function deleteTestSuiteFactory(
{ key: 'visualization', doc_count: 3 },
{ key: 'dashboard', doc_count: 2 },
{ key: 'index-pattern', doc_count: 1 },
{ key: 'legacy-url-alias', doc_count: 1 },
{ key: 'legacy-url-alias', doc_count: 1 }, // alias (1)
],
},
},
Expand All @@ -94,7 +98,7 @@ export function deleteTestSuiteFactory(
countByType: {
doc_count_error_upper_bound: 0,
sum_other_doc_count: 0,
buckets: [{ key: 'legacy-url-alias', doc_count: 1 }], // this alias is in a non-existent space (for other test suites)
buckets: [{ key: 'legacy-url-alias', doc_count: 1 }], // alias (3)
},
},
];
Expand Down

0 comments on commit 9be4f61

Please sign in to comment.