Skip to content

Commit

Permalink
Added files for a component integration test. The tests are failing r…
Browse files Browse the repository at this point in the history
…ight now so we need to get those green. Added a functional test. Need to set up kbn-es to be able to set up a file repository before being able to run the functional tests.
  • Loading branch information
John Dorlus committed Dec 21, 2019
1 parent c6cac4a commit 4d2b85f
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => {
]);
};

const setCleanupRepositoryResponse = (response?: HttpResponse, error?: any) => {
const status = error ? error.status || 503 : 200;

server.respondWith('POST', `${API_BASE_PATH}repositories/:name/cleanup`, [
status,
{ 'Content-Type': 'application/json' },
JSON.stringify(response),
]);
};

const setGetPolicyResponse = (response?: HttpResponse) => {
server.respondWith('GET', `${API_BASE_PATH}policy/:name`, [
200,
Expand All @@ -113,6 +123,7 @@ const registerHttpRequestMockHelpers = (server: SinonFakeServer) => {
setLoadIndicesResponse,
setAddPolicyResponse,
setGetPolicyResponse,
setCleanupRepositoryResponse,
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { EuiButton } from '@elastic/eui';
import { registerTestBed, TestBed } from '../../../../../../test_utils';
import { WithProviders } from './providers';

const initTestBed = registerTestBed<RepositoryDetailTestSubjects>(WithProviders(EuiButton), {
doMountAsync: true,
});

export interface RepositoryDetailTestBed extends TestBed<RepositoryDetailTestSubjects> {
actions: {
clickCleanupRepositoryButton: () => void;
getResponseText: () => void;
};
}

export const setup = async (): Promise<RepositoryDetailTestBed> => {
const testBed = await initTestBed();

// User actions
const clickCleanupRepositoryButton = () => {
testBed.find('cleanupRepositoryButton').simulate('click');
};

const getResponseText = () => {
//
};
return {
...testBed,
actions: {
clickCleanupRepositoryButton,
getResponseText,
},
};
};

export type RepositoryDetailTestSubjects = TestSubjects;

type TestSubjects = 'cleanupRepositoryButton' | `cleanupRepositoryResponseEditor`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
// TODO: Add Component Integration test for cleanup repository
// TODO: Add component integration test for repository verification.
// TODO: Add component integration test for repository detail.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const SnapshotRestoreHome: React.FunctionComponent<RouteComponentProps<Ma
onClick={() => onSectionChange(tab.id)}
isSelected={tab.id === section}
key={tab.id}
data-test-subj="tab"
data-test-subj={tab.id.toLowerCase() + '_tab'}
>
{tab.name}
</EuiTab>
Expand Down
18 changes: 18 additions & 0 deletions x-pack/test/functional/apps/snapshot_restore/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'snapshotRestore']);
const log = getService('log');
const es = getService('legacyEs');
// const testSubjects = getService('testSubjects');

describe('Home page', function() {
this.tags('smoke');
Expand All @@ -26,5 +28,21 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const repositoriesButton = await pageObjects.snapshotRestore.registerRepositoryButton();
expect(await repositoriesButton.isDisplayed()).to.be(true);
});

it('Reposiories Tab', async () => {
before(async () => {
await es.snapshot.createRepository({
repository: 'my-repository',
body: {
type: 'fs',
},
verify: true,
});

it('cleanup repository', async () => {
await pageObjects.snapshotRestore.navToRepositories();
});
});
});
});
};
2 changes: 1 addition & 1 deletion x-pack/test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default async function({ readConfigFile }) {
esTestCluster: {
license: 'trial',
from: 'snapshot',
serverArgs: [],
serverArgs: ['path.repo=/tmp/'],
},

kbnTestServer: {
Expand Down
4 changes: 4 additions & 0 deletions x-pack/test/functional/page_objects/snapshot_restore_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FtrProviderContext } from '../ftr_provider_context';

export function SnapshotRestorePageProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
// const wait = getService('waitFor');

return {
async appTitleText() {
Expand All @@ -16,5 +17,8 @@ export function SnapshotRestorePageProvider({ getService }: FtrProviderContext)
async registerRepositoryButton() {
return await testSubjects.find('registerRepositoryButton');
},
async navToRepositories() {
await testSubjects.click('repositories_tab');
},
};
}

0 comments on commit 4d2b85f

Please sign in to comment.