Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing esArchiver and using new data loader #140807

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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