Skip to content

Commit

Permalink
Removing esArchiver and using new data loader (elastic#140807)
Browse files Browse the repository at this point in the history
* Removing esArchiver and using new data loader

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Thomas Watson <[email protected]>
  • Loading branch information
3 people authored Sep 21, 2022
1 parent f6f5efd commit 516b18f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
*/

import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
import { EsArchiver } from '@kbn/es-archiver';
import { SavedObject } from '@kbn/core/server';
import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common/constants';
import { CopyResponse } from '@kbn/spaces-plugin/server/lib/copy_to_spaces';
import { getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
import { FtrProviderContext } from '../ftr_provider_context';
import { getTestDataLoader } from '../lib/test_data_loader';

type TestResponse = Record<string, any>;

Expand Down Expand Up @@ -51,11 +51,11 @@ const getDestinationSpace = (originSpaceId?: string) => {
return DEFAULT_SPACE_ID;
};

export function resolveCopyToSpaceConflictsSuite(
esArchiver: EsArchiver,
supertestWithAuth: SuperTest<any>,
supertestWithoutAuth: SuperTest<any>
) {
export function resolveCopyToSpaceConflictsSuite(context: FtrProviderContext) {
const testDataLoader = getTestDataLoader(context);
const supertestWithAuth = context.getService('supertest');
const supertestWithoutAuth = context.getService('supertestWithoutAuth');

const getVisualizationAtSpace = async (spaceId: string): Promise<SavedObject<any>> => {
return supertestWithAuth
.get(`${getUrlPrefix(spaceId)}/api/saved_objects/visualization/cts_vis_3_${spaceId}`)
Expand Down Expand Up @@ -487,16 +487,8 @@ export function resolveCopyToSpaceConflictsSuite(
});

describe('single-namespace types', () => {
beforeEach(() =>
esArchiver.load(
'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces'
)
);
afterEach(() =>
esArchiver.unload(
'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces'
)
);
beforeEach(async () => await testDataLoader.beforeEach());
afterEach(async () => await testDataLoader.afterEach());

const dashboardObject = { type: 'dashboard', id: `cts_dashboard_${spaceId}` };
const visualizationObject = { type: 'visualization', id: `cts_vis_3_${spaceId}` };
Expand Down Expand Up @@ -638,16 +630,8 @@ export function resolveCopyToSpaceConflictsSuite(
const includeReferences = false;
const createNewCopies = false;
describe(`multi-namespace types with "overwrite" retry`, () => {
before(() =>
esArchiver.load(
'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces'
)
);
after(() =>
esArchiver.unload(
'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces'
)
);
before(async () => await testDataLoader.beforeEach());
after(async () => await testDataLoader.afterEach());

const testCases = tests.multiNamespaceTestCases();
testCases.forEach(({ testTitle, objects, retries, statusCode, response }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { resolveCopyToSpaceConflictsSuite } from '../../common/suites/resolve_co
import { FtrProviderContext } from '../../common/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function resolveCopyToSpaceConflictsTestSuite({ getService }: FtrProviderContext) {
const supertestWithoutAuth = getService('supertestWithoutAuth');
const supertestWithAuth = getService('supertest');
const esArchiver = getService('esArchiver');

export default function resolveCopyToSpaceConflictsTestSuite(context: FtrProviderContext) {
const {
resolveCopyToSpaceConflictsTest,
createExpectNonOverriddenResponseWithReferences,
Expand All @@ -27,7 +23,7 @@ export default function resolveCopyToSpaceConflictsTestSuite({ getService }: Ftr
createExpectUnauthorizedAtSpaceWithoutReferencesResult,
createMultiNamespaceTestCases,
NON_EXISTENT_SPACE_ID,
} = resolveCopyToSpaceConflictsSuite(esArchiver, supertestWithAuth, supertestWithoutAuth);
} = resolveCopyToSpaceConflictsSuite(context);

describe('resolve copy to spaces conflicts', () => {
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
* 2.0.
*/

import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { resolveCopyToSpaceConflictsSuite } from '../../common/suites/resolve_copy_to_space_conflicts';

// eslint-disable-next-line import/no-default-export
export default function resolveCopyToSpaceConflictsTestSuite({ getService }: FtrProviderContext) {
const supertestWithoutAuth = getService('supertestWithoutAuth');
const supertestWithAuth = getService('supertest');
const esArchiver = getService('esArchiver');

export default function resolveCopyToSpaceConflictsTestSuite(context: FtrProviderContext) {
const {
resolveCopyToSpaceConflictsTest,
createExpectNonOverriddenResponseWithReferences,
Expand All @@ -23,7 +19,7 @@ export default function resolveCopyToSpaceConflictsTestSuite({ getService }: Ftr
createMultiNamespaceTestCases,
NON_EXISTENT_SPACE_ID,
originSpaces,
} = resolveCopyToSpaceConflictsSuite(esArchiver, supertestWithAuth, supertestWithoutAuth);
} = resolveCopyToSpaceConflictsSuite(context);

describe('resolve copy to spaces conflicts', () => {
originSpaces.forEach((spaceId) => {
Expand Down

0 comments on commit 516b18f

Please sign in to comment.