Skip to content

Commit

Permalink
Add CCR client integration test that asserts that the UI consumes the…
Browse files Browse the repository at this point in the history
… expected API when editing a follower index (#64440)
  • Loading branch information
cjcenizal authored Apr 27, 2020
1 parent 9e8809b commit 84aef39
Showing 1 changed file with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { API_BASE_PATH } from '../../../common/constants';
import { FollowerIndexForm } from '../../app/components/follower_index_form/follower_index_form';
import './mocks';
import { FOLLOWER_INDEX_EDIT } from './helpers/constants';
Expand All @@ -12,7 +13,7 @@ import { setupEnvironment, pageHelpers, nextTick } from './helpers';
const { setup } = pageHelpers.followerIndexEdit;
const { setup: setupFollowerIndexAdd } = pageHelpers.followerIndexAdd;

describe('Edit Auto-follow pattern', () => {
describe('Edit follower index', () => {
let server;
let httpRequestsMockHelpers;

Expand Down Expand Up @@ -88,6 +89,53 @@ describe('Edit Auto-follow pattern', () => {
});
});

describe('API', () => {
const remoteClusters = [{ name: 'new-york', seeds: ['localhost:123'], isConnected: true }];
let testBed;

beforeEach(async () => {
httpRequestsMockHelpers.setLoadRemoteClustersResponse(remoteClusters);
httpRequestsMockHelpers.setGetFollowerIndexResponse(FOLLOWER_INDEX_EDIT);

testBed = await setup();
await testBed.waitFor('followerIndexForm');
});

test('is consumed correctly', async () => {
const { actions, form, component, find, waitFor } = testBed;

form.setInputValue('maxRetryDelayInput', '10s');

actions.clickSaveForm();
component.update(); // The modal to confirm the update opens
await waitFor('confirmModalTitleText');
find('confirmModalConfirmButton').simulate('click');

await nextTick(); // Make sure the Request went through

const latestRequest = server.requests[server.requests.length - 1];
const requestBody = JSON.parse(JSON.parse(latestRequest.requestBody).body);

// Verify the API endpoint called: method, path and payload
expect(latestRequest.method).toBe('PUT');
expect(latestRequest.url).toBe(
`${API_BASE_PATH}/follower_indices/${FOLLOWER_INDEX_EDIT.name}`
);
expect(requestBody).toEqual({
maxReadRequestOperationCount: 7845,
maxOutstandingReadRequests: 16,
maxReadRequestSize: '64mb',
maxWriteRequestOperationCount: 2456,
maxWriteRequestSize: '1048b',
maxOutstandingWriteRequests: 69,
maxWriteBufferCount: 123456,
maxWriteBufferSize: '256mb',
maxRetryDelay: '10s',
readPollTimeout: '2m',
});
});
});

describe('when the remote cluster is disconnected', () => {
let find;
let exists;
Expand Down

0 comments on commit 84aef39

Please sign in to comment.