* Bumps Jest related packages (#78720) Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co> # Conflicts: # packages/kbn-optimizer/package.json # yarn.lock * Updates kbn-pm dist Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
378236fc10
commit
ff54de0b31
14
package.json
14
package.json
|
@ -288,7 +288,7 @@
|
|||
"@types/hjson": "^2.4.2",
|
||||
"@types/hoek": "^4.1.3",
|
||||
"@types/inert": "^5.1.2",
|
||||
"@types/jest": "^25.2.3",
|
||||
"@types/jest": "^26.0.14",
|
||||
"@types/jest-when": "^2.7.1",
|
||||
"@types/joi": "^13.4.2",
|
||||
"@types/jquery": "^3.3.31",
|
||||
|
@ -334,7 +334,7 @@
|
|||
"@types/supertest-as-promised": "^2.0.38",
|
||||
"@types/tapable": "^1.0.6",
|
||||
"@types/tar": "^4.0.3",
|
||||
"@types/testing-library__jest-dom": "^5.9.2",
|
||||
"@types/testing-library__jest-dom": "^5.9.3",
|
||||
"@types/testing-library__react-hooks": "^3.4.0",
|
||||
"@types/type-detect": "^4.0.1",
|
||||
"@types/uuid": "^3.4.4",
|
||||
|
@ -353,7 +353,7 @@
|
|||
"archiver": "^3.1.1",
|
||||
"axe-core": "^4.0.2",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"babel-jest": "^25.5.1",
|
||||
"babel-jest": "^26.3.0",
|
||||
"babel-plugin-istanbul": "^6.0.0",
|
||||
"backport": "5.4.1",
|
||||
"brace": "0.11.1",
|
||||
|
@ -379,7 +379,7 @@
|
|||
"eslint-plugin-cypress": "^2.8.1",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-import": "^2.19.1",
|
||||
"eslint-plugin-jest": "^23.10.0",
|
||||
"eslint-plugin-jest": "^24.0.2",
|
||||
"eslint-plugin-jsx-a11y": "^6.2.3",
|
||||
"eslint-plugin-mocha": "^6.2.2",
|
||||
"eslint-plugin-no-unsanitized": "^3.0.2",
|
||||
|
@ -408,10 +408,10 @@
|
|||
"iedriver": "^3.14.2",
|
||||
"immer": "^1.5.0",
|
||||
"intl-messageformat-parser": "^1.4.0",
|
||||
"jest": "^25.5.4",
|
||||
"jest": "^26.4.2",
|
||||
"jest-canvas-mock": "^2.2.0",
|
||||
"jest-circus": "^25.5.4",
|
||||
"jest-cli": "^25.5.4",
|
||||
"jest-circus": "^26.4.2",
|
||||
"jest-cli": "^26.4.2",
|
||||
"jest-environment-jsdom-thirteen": "^1.0.1",
|
||||
"jest-raw-loader": "^1.0.1",
|
||||
"jest-when": "^2.7.2",
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"eslint-plugin-jsx-a11y": "^6.2.3",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-import": "^2.19.1",
|
||||
"eslint-plugin-jest": "^23.10.0",
|
||||
"eslint-plugin-jest": "^24.0.2",
|
||||
"eslint-plugin-mocha": "^6.2.2",
|
||||
"eslint-plugin-no-unsanitized": "^3.0.2",
|
||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||
|
|
|
@ -60,7 +60,7 @@ async function ensureResolve(promise) {
|
|||
|
||||
function mockEsBin({ exitCode, start }) {
|
||||
execa.mockImplementationOnce((cmd, args, options) =>
|
||||
require.requireActual('execa')(
|
||||
jest.requireActual('execa')(
|
||||
process.execPath,
|
||||
[
|
||||
require.resolve('./__fixtures__/es_bin.js'),
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('I18n engine', () => {
|
|||
let i18n: typeof i18nModule;
|
||||
|
||||
beforeEach(() => {
|
||||
i18n = require.requireActual('./i18n');
|
||||
i18n = jest.requireActual('./i18n');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"execa": "^4.0.2",
|
||||
"file-loader": "^4.2.0",
|
||||
"istanbul-instrumenter-loader": "^3.0.1",
|
||||
"jest-diff": "^25.5.0",
|
||||
"jest-diff": "^26.4.2",
|
||||
"js-yaml": "^3.14.0",
|
||||
"json-stable-stringify": "^1.0.1",
|
||||
"lmdb-store": "^0.6.10",
|
||||
|
|
2601
packages/kbn-pm/dist/index.js
vendored
2601
packages/kbn-pm/dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -17,7 +17,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/jbudz/spec-to-console#readme",
|
||||
"devDependencies": {
|
||||
"jest": "^25.5.4",
|
||||
"jest": "^26.4.2",
|
||||
"prettier": "^2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -22,6 +22,7 @@ import fs, { existsSync, mkdirSync, statSync, writeFileSync } from 'fs';
|
|||
import { LogRotator } from './log_rotator';
|
||||
import { tmpdir } from 'os';
|
||||
import { dirname, join } from 'path';
|
||||
import lodash from 'lodash';
|
||||
|
||||
const mockOn = jest.fn();
|
||||
jest.mock('chokidar', () => ({
|
||||
|
@ -31,10 +32,7 @@ jest.mock('chokidar', () => ({
|
|||
})),
|
||||
}));
|
||||
|
||||
jest.mock('lodash', () => ({
|
||||
...require.requireActual('lodash'),
|
||||
throttle: (fn: any) => fn,
|
||||
}));
|
||||
lodash.throttle = (fn: any) => fn;
|
||||
|
||||
const tempDir = join(tmpdir(), 'kbn_log_rotator_test');
|
||||
const testFilePath = join(tempDir, 'log_rotator_test_log_file.log');
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
jest.mock(
|
||||
'lodash',
|
||||
() => ({
|
||||
...require.requireActual('lodash'),
|
||||
...jest.requireActual('lodash'),
|
||||
// mock debounce to fire immediately with no internal timer
|
||||
debounce: (func) => {
|
||||
function debounced(...args) {
|
||||
|
|
|
@ -30,7 +30,7 @@ jest.mock('./components/time_field', () => ({ TimeField: 'TimeField' }));
|
|||
jest.mock('./components/advanced_options', () => ({ AdvancedOptions: 'AdvancedOptions' }));
|
||||
jest.mock('./components/action_buttons', () => ({ ActionButtons: 'ActionButtons' }));
|
||||
jest.mock('./../../lib', () => ({
|
||||
extractTimeFields: require.requireActual('./../../lib').extractTimeFields,
|
||||
extractTimeFields: jest.requireActual('./../../lib').extractTimeFields,
|
||||
ensureMinimumTime: async (fields: IFieldType) => Promise.resolve(fields),
|
||||
}));
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@ jest.mock('@elastic/eui', () => ({
|
|||
let counter = 1;
|
||||
return () => `12${counter++}`;
|
||||
}),
|
||||
EuiSpacer: require.requireActual('@elastic/eui').EuiSpacer,
|
||||
EuiFlexItem: require.requireActual('@elastic/eui').EuiFlexItem,
|
||||
EuiButtonEmpty: require.requireActual('@elastic/eui').EuiButtonEmpty,
|
||||
EuiFormErrorText: require.requireActual('@elastic/eui').EuiFormErrorText,
|
||||
EuiSpacer: jest.requireActual('@elastic/eui').EuiSpacer,
|
||||
EuiFlexItem: jest.requireActual('@elastic/eui').EuiFlexItem,
|
||||
EuiButtonEmpty: jest.requireActual('@elastic/eui').EuiButtonEmpty,
|
||||
EuiFormErrorText: jest.requireActual('@elastic/eui').EuiFormErrorText,
|
||||
}));
|
||||
|
||||
describe('NumberList', () => {
|
||||
|
|
|
@ -23,12 +23,12 @@ import { SplitByTermsUI } from './terms';
|
|||
|
||||
jest.mock('@elastic/eui', () => ({
|
||||
htmlIdGenerator: jest.fn(() => () => '42'),
|
||||
EuiFlexGroup: require.requireActual('@elastic/eui').EuiFlexGroup,
|
||||
EuiFlexItem: require.requireActual('@elastic/eui').EuiFlexItem,
|
||||
EuiFormRow: require.requireActual('@elastic/eui').EuiFormRow,
|
||||
EuiFieldNumber: require.requireActual('@elastic/eui').EuiFieldNumber,
|
||||
EuiComboBox: require.requireActual('@elastic/eui').EuiComboBox,
|
||||
EuiFieldText: require.requireActual('@elastic/eui').EuiFieldText,
|
||||
EuiFlexGroup: jest.requireActual('@elastic/eui').EuiFlexGroup,
|
||||
EuiFlexItem: jest.requireActual('@elastic/eui').EuiFlexItem,
|
||||
EuiFormRow: jest.requireActual('@elastic/eui').EuiFormRow,
|
||||
EuiFieldNumber: jest.requireActual('@elastic/eui').EuiFieldNumber,
|
||||
EuiComboBox: jest.requireActual('@elastic/eui').EuiComboBox,
|
||||
EuiFieldText: jest.requireActual('@elastic/eui').EuiFieldText,
|
||||
}));
|
||||
|
||||
describe('src/legacy/core_plugins/metrics/public/components/splits/terms.test.js', () => {
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
"@types/hoist-non-react-statics": "^3.3.1",
|
||||
"@types/http-proxy": "^1.17.4",
|
||||
"@types/http-proxy-agent": "^2.0.2",
|
||||
"@types/jest": "^25.2.3",
|
||||
"@types/jest": "^26.0.14",
|
||||
"@types/jest-specific-snapshot": "^0.5.4",
|
||||
"@types/joi": "^13.4.2",
|
||||
"@types/js-search": "^1.4.0",
|
||||
|
@ -128,7 +128,7 @@
|
|||
"@types/styled-components": "^5.1.0",
|
||||
"@types/supertest": "^2.0.5",
|
||||
"@types/tar-fs": "^1.16.1",
|
||||
"@types/testing-library__jest-dom": "^5.9.2",
|
||||
"@types/testing-library__jest-dom": "^5.9.3",
|
||||
"@types/testing-library__react-hooks": "^3.4.0",
|
||||
"@types/tinycolor2": "^1.4.1",
|
||||
"@types/use-resize-observer": "^6.0.0",
|
||||
|
@ -144,7 +144,7 @@
|
|||
"apollo-link-error": "^1.1.7",
|
||||
"apollo-link-state": "^0.4.1",
|
||||
"autoprefixer": "^9.7.4",
|
||||
"babel-jest": "^25.5.1",
|
||||
"babel-jest": "^26.3.0",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-require-context-hook": "npm:babel-plugin-require-context-hook-babel7@1.0.0",
|
||||
"base64-js": "^1.3.1",
|
||||
|
@ -189,9 +189,9 @@
|
|||
"hoist-non-react-statics": "^3.3.2",
|
||||
"i18n-iso-countries": "^4.3.1",
|
||||
"icalendar": "0.7.1",
|
||||
"jest": "^25.5.4",
|
||||
"jest-circus": "^25.5.4",
|
||||
"jest-cli": "^25.5.4",
|
||||
"jest": "^26.4.2",
|
||||
"jest-circus": "^26.4.2",
|
||||
"jest-cli": "^26.4.2",
|
||||
"jest-styled-components": "^7.0.2",
|
||||
"js-search": "^1.4.3",
|
||||
"jsdom": "13.1.0",
|
||||
|
|
|
@ -4150,14 +4150,13 @@ describe('update()', () => {
|
|||
expect(taskManager.runNow).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('updating the alert should not wait for the rerun the task to complete', async (done) => {
|
||||
test('updating the alert should not wait for the rerun the task to complete', async () => {
|
||||
const alertId = uuid.v4();
|
||||
const taskId = uuid.v4();
|
||||
|
||||
mockApiCalls(alertId, taskId, { interval: '10s' }, { interval: '30s' });
|
||||
|
||||
const resolveAfterAlertUpdatedCompletes = resolvable<{ id: string }>();
|
||||
resolveAfterAlertUpdatedCompletes.then(() => done());
|
||||
|
||||
taskManager.runNow.mockReset();
|
||||
taskManager.runNow.mockReturnValue(resolveAfterAlertUpdatedCompletes);
|
||||
|
@ -4185,7 +4184,6 @@ describe('update()', () => {
|
|||
});
|
||||
|
||||
expect(taskManager.runNow).toHaveBeenCalled();
|
||||
|
||||
resolveAfterAlertUpdatedCompletes.resolve({ id: alertId });
|
||||
});
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ jest.mock('@elastic/eui/lib/components/portal/portal', () => {
|
|||
// Local constants are not supported in Jest mocks-- they must be
|
||||
// imported within the mock.
|
||||
// eslint-disable-next-line no-shadow
|
||||
const React = require.requireActual('react');
|
||||
const React = jest.requireActual('react');
|
||||
return {
|
||||
EuiPortal: (props: any) => <div>{props.children}</div>,
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ jest.mock('@elastic/eui/lib/services/accessibility', () => {
|
|||
});
|
||||
jest.mock('@elastic/eui/lib/components/portal/portal', () => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
const React = require.requireActual('react');
|
||||
const React = jest.requireActual('react');
|
||||
return {
|
||||
EuiPortal: (props: any) => <div>{props.children}</div>,
|
||||
};
|
||||
|
|
|
@ -13,28 +13,9 @@ describe('ReadySignal', () => {
|
|||
readySignal = createReadySignal<number>();
|
||||
});
|
||||
|
||||
test('works as expected', async (done) => {
|
||||
let value = 41;
|
||||
|
||||
timeoutSet(100, async () => {
|
||||
expect(value).toBe(41);
|
||||
});
|
||||
|
||||
timeoutSet(250, async () => readySignal.signal(42));
|
||||
|
||||
timeoutSet(400, async () => {
|
||||
expect(value).toBe(42);
|
||||
|
||||
const innerValue = await readySignal.wait();
|
||||
expect(innerValue).toBe(42);
|
||||
done();
|
||||
});
|
||||
|
||||
value = await readySignal.wait();
|
||||
expect(value).toBe(42);
|
||||
test('works as expected', async () => {
|
||||
readySignal.signal(42);
|
||||
const ready = await readySignal.wait();
|
||||
expect(ready).toBe(42);
|
||||
});
|
||||
});
|
||||
|
||||
function timeoutSet(ms: number, fn: () => Promise<unknown>): void {
|
||||
setTimeout(fn, ms);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { take } from 'rxjs/operators';
|
||||
import { take, toArray } from 'rxjs/operators';
|
||||
import { mountExpiredBannerMock } from './plugin.test.mocks';
|
||||
|
||||
import { LicenseType } from '../common/types';
|
||||
|
@ -92,7 +92,7 @@ describe('licensing plugin', () => {
|
|||
expect(sessionStorage.getItem).toHaveBeenCalledWith(licensingSessionStorageKey);
|
||||
});
|
||||
|
||||
it('observable receives updated licenses', async (done) => {
|
||||
it('observable receives updated licenses', async () => {
|
||||
const types: LicenseType[] = ['gold', 'platinum'];
|
||||
|
||||
const sessionStorage = coreMock.createStorage();
|
||||
|
@ -104,27 +104,17 @@ describe('licensing plugin', () => {
|
|||
Promise.resolve(licenseMock.createLicense({ license: { type: types.shift() } }))
|
||||
);
|
||||
|
||||
await plugin.setup(coreSetup);
|
||||
plugin.setup(coreSetup);
|
||||
const { refresh, license$ } = await plugin.start(coreStart);
|
||||
const promise = license$.pipe(take(3), toArray()).toPromise();
|
||||
|
||||
let i = 0;
|
||||
license$.subscribe((value) => {
|
||||
i++;
|
||||
if (i === 1) {
|
||||
expect(value.type).toBe('basic');
|
||||
refresh();
|
||||
} else if (i === 2) {
|
||||
expect(value.type).toBe('gold');
|
||||
// since this is a synchronous subscription, we need to give the exhaustMap a chance
|
||||
// to mark the subscription as complete before emitting another value on the Subject
|
||||
process.nextTick(() => refresh());
|
||||
} else if (i === 3) {
|
||||
expect(value.type).toBe('platinum');
|
||||
done();
|
||||
} else {
|
||||
throw new Error('unreachable');
|
||||
}
|
||||
});
|
||||
await refresh();
|
||||
await refresh();
|
||||
|
||||
const licenses = await promise;
|
||||
expect(licenses[0].type).toBe('basic');
|
||||
expect(licenses[1].type).toBe('gold');
|
||||
expect(licenses[2].type).toBe('platinum');
|
||||
});
|
||||
|
||||
it('saved fetched license & signature in session storage', async () => {
|
||||
|
|
|
@ -28,9 +28,8 @@ describe('ml_server_info initial state', () => {
|
|||
});
|
||||
|
||||
describe('ml_server_info', () => {
|
||||
beforeEach(async (done) => {
|
||||
beforeEach(async () => {
|
||||
await loadMlServerInfo();
|
||||
done();
|
||||
});
|
||||
|
||||
describe('cloud information', () => {
|
||||
|
@ -41,23 +40,21 @@ describe('ml_server_info', () => {
|
|||
});
|
||||
|
||||
describe('defaults', () => {
|
||||
it('should get defaults', async (done) => {
|
||||
it('should get defaults', async () => {
|
||||
const defaults = getNewJobDefaults();
|
||||
|
||||
expect(defaults.anomaly_detectors.model_memory_limit).toBe('128mb');
|
||||
expect(defaults.anomaly_detectors.categorization_examples_limit).toBe(4);
|
||||
expect(defaults.anomaly_detectors.model_snapshot_retention_days).toBe(1);
|
||||
expect(defaults.datafeeds.scroll_size).toBe(1000);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('limits', () => {
|
||||
it('should get limits', async (done) => {
|
||||
it('should get limits', async () => {
|
||||
const limits = getNewJobLimits();
|
||||
|
||||
expect(limits.max_model_memory_limit).toBe('128mb');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ const indexPattern = ({
|
|||
|
||||
describe('new_job_capabilities_service', () => {
|
||||
describe('cloudwatch newJobCaps()', () => {
|
||||
it('can construct job caps objects from endpoint json', async (done) => {
|
||||
it('can construct job caps objects from endpoint json', async () => {
|
||||
await newJobCapsService.initializeFromIndexPattern(indexPattern);
|
||||
const { fields, aggs } = await newJobCapsService.newJobCaps;
|
||||
|
||||
|
@ -43,27 +43,22 @@ describe('new_job_capabilities_service', () => {
|
|||
|
||||
expect(meanAgg.fields).toHaveLength(7);
|
||||
expect(distinctCountAgg.fields).toHaveLength(10);
|
||||
done();
|
||||
});
|
||||
|
||||
it('job caps including text fields', async (done) => {
|
||||
it('job caps including text fields', async () => {
|
||||
await newJobCapsService.initializeFromIndexPattern(indexPattern, true, false);
|
||||
const { fields, aggs } = await newJobCapsService.newJobCaps;
|
||||
|
||||
expect(fields).toHaveLength(13); // one more field
|
||||
expect(aggs).toHaveLength(35);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('job caps excluding event rate', async (done) => {
|
||||
it('job caps excluding event rate', async () => {
|
||||
await newJobCapsService.initializeFromIndexPattern(indexPattern, false, true);
|
||||
const { fields, aggs } = await newJobCapsService.newJobCaps;
|
||||
|
||||
expect(fields).toHaveLength(11); // one less field
|
||||
expect(aggs).toHaveLength(35);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ const mlClusterClientUpgrade = ({
|
|||
|
||||
describe('check_capabilities', () => {
|
||||
describe('getCapabilities() - right number of capabilities', () => {
|
||||
test('kibana capabilities count', async (done) => {
|
||||
test('kibana capabilities count', async () => {
|
||||
const { getCapabilities } = capabilitiesProvider(
|
||||
mlClusterClientNonUpgrade,
|
||||
getAdminCapabilities(),
|
||||
|
@ -59,12 +59,11 @@ describe('check_capabilities', () => {
|
|||
const { capabilities } = await getCapabilities();
|
||||
const count = Object.keys(capabilities).length;
|
||||
expect(count).toBe(28);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCapabilities() with security', () => {
|
||||
test('ml_user capabilities only', async (done) => {
|
||||
test('ml_user capabilities only', async () => {
|
||||
const { getCapabilities } = capabilitiesProvider(
|
||||
mlClusterClientNonUpgrade,
|
||||
getUserCapabilities(),
|
||||
|
@ -110,10 +109,9 @@ describe('check_capabilities', () => {
|
|||
expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canCreateDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
test('full capabilities', async (done) => {
|
||||
test('full capabilities', async () => {
|
||||
const { getCapabilities } = capabilitiesProvider(
|
||||
mlClusterClientNonUpgrade,
|
||||
getAdminCapabilities(),
|
||||
|
@ -159,10 +157,9 @@ describe('check_capabilities', () => {
|
|||
expect(capabilities.canDeleteDataFrameAnalytics).toBe(true);
|
||||
expect(capabilities.canCreateDataFrameAnalytics).toBe(true);
|
||||
expect(capabilities.canStartStopDataFrameAnalytics).toBe(true);
|
||||
done();
|
||||
});
|
||||
|
||||
test('upgrade in progress with full capabilities', async (done) => {
|
||||
test('upgrade in progress with full capabilities', async () => {
|
||||
const { getCapabilities } = capabilitiesProvider(
|
||||
mlClusterClientUpgrade,
|
||||
getAdminCapabilities(),
|
||||
|
@ -208,10 +205,9 @@ describe('check_capabilities', () => {
|
|||
expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canCreateDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
test('upgrade in progress with partial capabilities', async (done) => {
|
||||
test('upgrade in progress with partial capabilities', async () => {
|
||||
const { getCapabilities } = capabilitiesProvider(
|
||||
mlClusterClientUpgrade,
|
||||
getUserCapabilities(),
|
||||
|
@ -257,10 +253,9 @@ describe('check_capabilities', () => {
|
|||
expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canCreateDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
test('full capabilities, ml disabled in space', async (done) => {
|
||||
test('full capabilities, ml disabled in space', async () => {
|
||||
const { getCapabilities } = capabilitiesProvider(
|
||||
mlClusterClientNonUpgrade,
|
||||
getDefaultCapabilities(),
|
||||
|
@ -306,11 +301,10 @@ describe('check_capabilities', () => {
|
|||
expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canCreateDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('full capabilities, basic license, ml disabled in space', async (done) => {
|
||||
test('full capabilities, basic license, ml disabled in space', async () => {
|
||||
const { getCapabilities } = capabilitiesProvider(
|
||||
mlClusterClientNonUpgrade,
|
||||
getDefaultCapabilities(),
|
||||
|
@ -357,6 +351,5 @@ describe('check_capabilities', () => {
|
|||
expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canCreateDataFrameAnalytics).toBe(false);
|
||||
expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ describe('annotation_service', () => {
|
|||
});
|
||||
|
||||
describe('deleteAnnotation()', () => {
|
||||
it('should delete annotation', async (done) => {
|
||||
it('should delete annotation', async () => {
|
||||
const { deleteAnnotation } = annotationServiceProvider(mlClusterClientSpy);
|
||||
const mockFunct = mlClusterClientSpy;
|
||||
|
||||
|
@ -50,12 +50,11 @@ describe('annotation_service', () => {
|
|||
|
||||
expect(mockFunct.asInternalUser.delete.mock.calls[0][0]).toStrictEqual(deleteParamsMock);
|
||||
expect(response).toBe(acknowledgedResponseMock);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAnnotation()', () => {
|
||||
it('should get annotations for specific job', async (done) => {
|
||||
it('should get annotations for specific job', async () => {
|
||||
const { getAnnotations } = annotationServiceProvider(mlClusterClientSpy);
|
||||
const mockFunct = mlClusterClientSpy;
|
||||
|
||||
|
@ -74,7 +73,6 @@ describe('annotation_service', () => {
|
|||
expect(Object.keys(response.annotations)).toHaveLength(1);
|
||||
expect(response.annotations[jobIdMock]).toHaveLength(2);
|
||||
expect(isAnnotations(response.annotations[jobIdMock])).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
|
||||
it('should throw and catch an error', async () => {
|
||||
|
@ -106,7 +104,7 @@ describe('annotation_service', () => {
|
|||
});
|
||||
|
||||
describe('indexAnnotation()', () => {
|
||||
it('should index annotation', async (done) => {
|
||||
it('should index annotation', async () => {
|
||||
const { indexAnnotation } = annotationServiceProvider(mlClusterClientSpy);
|
||||
const mockFunct = mlClusterClientSpy;
|
||||
|
||||
|
@ -129,10 +127,9 @@ describe('annotation_service', () => {
|
|||
expect(typeof annotation.modified_time).toBe('number');
|
||||
|
||||
expect(response).toBe(acknowledgedResponseMock);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove ._id and .key before updating annotation', async (done) => {
|
||||
it('should remove ._id and .key before updating annotation', async () => {
|
||||
const { indexAnnotation } = annotationServiceProvider(mlClusterClientSpy);
|
||||
const mockFunct = mlClusterClientSpy;
|
||||
|
||||
|
@ -159,10 +156,9 @@ describe('annotation_service', () => {
|
|||
expect(typeof annotation.key).toBe('undefined');
|
||||
|
||||
expect(response).toBe(acknowledgedResponseMock);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should update annotation text and the username for modified_username', async (done) => {
|
||||
it('should update annotation text and the username for modified_username', async () => {
|
||||
const { getAnnotations, indexAnnotation } = annotationServiceProvider(mlClusterClientSpy);
|
||||
const mockFunct = mlClusterClientSpy;
|
||||
|
||||
|
@ -196,7 +192,6 @@ describe('annotation_service', () => {
|
|||
expect(modifiedAnnotation.modified_username).toBe(modifiedUsernameMock);
|
||||
expect(typeof modifiedAnnotation.create_time).toBe('number');
|
||||
expect(typeof modifiedAnnotation.modified_time).toBe('number');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -48,42 +48,38 @@ describe('job_service - job_caps', () => {
|
|||
});
|
||||
|
||||
describe('farequote newJobCaps()', () => {
|
||||
it('can get job caps for index pattern', async (done) => {
|
||||
it('can get job caps for index pattern', async () => {
|
||||
const indexPattern = 'farequote-*';
|
||||
const isRollup = false;
|
||||
const { newJobCaps } = newJobCapsProvider(mlClusterClientNonRollupMock);
|
||||
const response = await newJobCaps(indexPattern, isRollup, savedObjectsClientMock);
|
||||
expect(response).toEqual(farequoteJobCaps);
|
||||
done();
|
||||
});
|
||||
|
||||
it('can get rollup job caps for non rollup index pattern', async (done) => {
|
||||
it('can get rollup job caps for non rollup index pattern', async () => {
|
||||
const indexPattern = 'farequote-*';
|
||||
const isRollup = true;
|
||||
const { newJobCaps } = newJobCapsProvider(mlClusterClientNonRollupMock);
|
||||
const response = await newJobCaps(indexPattern, isRollup, savedObjectsClientMock);
|
||||
expect(response).toEqual(farequoteJobCapsEmpty);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('cloudwatch newJobCaps()', () => {
|
||||
it('can get rollup job caps for rollup index pattern', async (done) => {
|
||||
it('can get rollup job caps for rollup index pattern', async () => {
|
||||
const indexPattern = 'cloud_roll_index';
|
||||
const isRollup = true;
|
||||
const { newJobCaps } = newJobCapsProvider(mlClusterClientRollupMock);
|
||||
const response = await newJobCaps(indexPattern, isRollup, savedObjectsClientMock);
|
||||
expect(response).toEqual(cloudwatchJobCaps);
|
||||
done();
|
||||
});
|
||||
|
||||
it('can get non rollup job caps for rollup index pattern', async (done) => {
|
||||
it('can get non rollup job caps for rollup index pattern', async () => {
|
||||
const indexPattern = 'cloud_roll_index';
|
||||
const isRollup = false;
|
||||
const { newJobCaps } = newJobCapsProvider(mlClusterClientRollupMock);
|
||||
const response = await newJobCaps(indexPattern, isRollup, savedObjectsClientMock);
|
||||
expect(response).not.toEqual(cloudwatchJobCaps);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,28 +7,25 @@
|
|||
import { ensureMinimumTime } from './ensure_minimum_time';
|
||||
|
||||
describe('ensureMinimumTime', () => {
|
||||
it('resolves single promise', async (done) => {
|
||||
it('resolves single promise', async () => {
|
||||
const promiseA = new Promise((resolve) => resolve('a'));
|
||||
const a = await ensureMinimumTime(promiseA, 0);
|
||||
expect(a).toBe('a');
|
||||
done();
|
||||
});
|
||||
|
||||
it('resolves multiple promises', async (done) => {
|
||||
it('resolves multiple promises', async () => {
|
||||
const promiseA = new Promise((resolve) => resolve('a'));
|
||||
const promiseB = new Promise((resolve) => resolve('b'));
|
||||
const [a, b] = await ensureMinimumTime([promiseA, promiseB], 0);
|
||||
expect(a).toBe('a');
|
||||
expect(b).toBe('b');
|
||||
done();
|
||||
});
|
||||
|
||||
it('resolves in the amount of time provided, at minimum', async (done) => {
|
||||
it('resolves in the amount of time provided, at minimum', async () => {
|
||||
const startTime = new Date().getTime();
|
||||
const promise = new Promise((resolve) => resolve());
|
||||
await ensureMinimumTime(promise, 100);
|
||||
const endTime = new Date().getTime();
|
||||
expect(endTime - startTime).toBeGreaterThanOrEqual(100);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,7 +23,13 @@ jest.mock('react-dom', () => ({
|
|||
jest.mock('../legacy_shims', () => {
|
||||
return {
|
||||
Legacy: {
|
||||
shims: { getAngularInjector: () => ({ get: () => ({ get: () => 'utc' }) }) },
|
||||
shims: {
|
||||
getAngularInjector: () => ({ get: () => ({ get: () => 'utc' }) }),
|
||||
toastNotifications: {
|
||||
addDanger: jest.fn(),
|
||||
},
|
||||
I18nContext: '<div>',
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -59,9 +65,6 @@ const angularStateMock = {
|
|||
|
||||
// We are no longer waiting for setup mode data to be fetched when enabling
|
||||
// so we need to wait for the next tick for the async action to finish
|
||||
function waitForSetupModeData(action) {
|
||||
process.nextTick(action);
|
||||
}
|
||||
|
||||
function setModulesAndMocks() {
|
||||
jest.clearAllMocks().resetModules();
|
||||
|
@ -75,6 +78,10 @@ function setModulesAndMocks() {
|
|||
setSetupModeMenuItem = setupMode.setSetupModeMenuItem;
|
||||
}
|
||||
|
||||
function waitForSetupModeData() {
|
||||
return new Promise((resolve) => process.nextTick(resolve));
|
||||
}
|
||||
|
||||
describe('setup_mode', () => {
|
||||
beforeEach(async () => {
|
||||
setModulesAndMocks();
|
||||
|
@ -96,22 +103,22 @@ describe('setup_mode', () => {
|
|||
});
|
||||
|
||||
it('should enable toggle mode', async () => {
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(true);
|
||||
await initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
toggleSetupMode(true);
|
||||
expect(injectorModulesMock.globalState.inSetupMode).toBe(true);
|
||||
});
|
||||
|
||||
it('should disable toggle mode', async () => {
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(false);
|
||||
await initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
toggleSetupMode(false);
|
||||
expect(injectorModulesMock.globalState.inSetupMode).toBe(false);
|
||||
});
|
||||
|
||||
it('should set top nav config', async () => {
|
||||
const render = require('react-dom').render;
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
setSetupModeMenuItem();
|
||||
await toggleSetupMode(true);
|
||||
toggleSetupMode(true);
|
||||
expect(render.mock.calls.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
@ -121,7 +128,7 @@ describe('setup_mode', () => {
|
|||
data = {};
|
||||
});
|
||||
|
||||
it('should not fetch data if the user does not have sufficient permissions', async (done) => {
|
||||
it('should not fetch data if the user does not have sufficient permissions', async () => {
|
||||
const addDanger = jest.fn();
|
||||
jest.doMock('../legacy_shims', () => ({
|
||||
Legacy: {
|
||||
|
@ -129,6 +136,7 @@ describe('setup_mode', () => {
|
|||
toastNotifications: {
|
||||
addDanger,
|
||||
},
|
||||
I18nContext: '<div>',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
@ -138,20 +146,19 @@ describe('setup_mode', () => {
|
|||
},
|
||||
};
|
||||
setModulesAndMocks();
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(true);
|
||||
waitForSetupModeData(() => {
|
||||
const state = getSetupModeState();
|
||||
expect(state.enabled).toBe(false);
|
||||
expect(addDanger).toHaveBeenCalledWith({
|
||||
title: 'Setup mode is not available',
|
||||
text: 'You do not have the necessary permissions to do this.',
|
||||
});
|
||||
done();
|
||||
await initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
toggleSetupMode(true);
|
||||
await waitForSetupModeData();
|
||||
|
||||
const state = getSetupModeState();
|
||||
expect(state.enabled).toBe(false);
|
||||
expect(addDanger).toHaveBeenCalledWith({
|
||||
title: 'Setup mode is not available',
|
||||
text: 'You do not have the necessary permissions to do this.',
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the newly discovered cluster uuid', async (done) => {
|
||||
it('should set the newly discovered cluster uuid', async () => {
|
||||
const clusterUuid = '1ajy';
|
||||
data = {
|
||||
_meta: {
|
||||
|
@ -166,15 +173,14 @@ describe('setup_mode', () => {
|
|||
},
|
||||
},
|
||||
};
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(true);
|
||||
waitForSetupModeData(() => {
|
||||
expect(injectorModulesMock.globalState.cluster_uuid).toBe(clusterUuid);
|
||||
done();
|
||||
});
|
||||
await initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
toggleSetupMode(true);
|
||||
await waitForSetupModeData();
|
||||
|
||||
expect(injectorModulesMock.globalState.cluster_uuid).toBe(clusterUuid);
|
||||
});
|
||||
|
||||
it('should fetch data for a given cluster', async (done) => {
|
||||
it('should fetch data for a given cluster', async () => {
|
||||
const clusterUuid = '1ajy';
|
||||
data = {
|
||||
_meta: {
|
||||
|
@ -190,22 +196,23 @@ describe('setup_mode', () => {
|
|||
},
|
||||
};
|
||||
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(true);
|
||||
waitForSetupModeData(() => {
|
||||
expect(injectorModulesMock.$http.post).toHaveBeenCalledWith(
|
||||
`../api/monitoring/v1/setup/collection/cluster/${clusterUuid}`,
|
||||
{
|
||||
ccs: undefined,
|
||||
}
|
||||
);
|
||||
done();
|
||||
});
|
||||
await initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
toggleSetupMode(true);
|
||||
await waitForSetupModeData();
|
||||
|
||||
expect(injectorModulesMock.$http.post).toHaveBeenCalledWith(
|
||||
`../api/monitoring/v1/setup/collection/cluster/${clusterUuid}`,
|
||||
{
|
||||
ccs: undefined,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should fetch data for a single node', async () => {
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(true);
|
||||
await initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
toggleSetupMode(true);
|
||||
await waitForSetupModeData();
|
||||
|
||||
injectorModulesMock.$http.post.mockClear();
|
||||
await updateSetupModeData('45asd');
|
||||
expect(injectorModulesMock.$http.post).toHaveBeenCalledWith(
|
||||
|
|
|
@ -206,7 +206,7 @@ export const initSetupModeState = async ($scope: any, $injector: any, callback?:
|
|||
|
||||
const globalState = $injector.get('globalState');
|
||||
if (globalState.inSetupMode) {
|
||||
await toggleSetupMode(true);
|
||||
toggleSetupMode(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ describe('authorized_user_pre_routing', function () {
|
|||
).toMatchObject({ body: `Sorry, you don't have access to Reporting` });
|
||||
});
|
||||
|
||||
it('should return from handler when security is enabled and user has explicitly allowed role', async function (done) {
|
||||
it('should return from handler when security is enabled and user has explicitly allowed role', function (done) {
|
||||
mockCore.getPluginSetupDeps = () =>
|
||||
(({
|
||||
// @ts-ignore
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
} from '../../components';
|
||||
|
||||
jest.mock('../../../../kibana_services', () => {
|
||||
const services = require.requireActual('../../../../kibana_services');
|
||||
const services = jest.requireActual('../../../../kibana_services');
|
||||
return {
|
||||
...services,
|
||||
trackUiMetric: jest.fn(),
|
||||
|
|
|
@ -14,7 +14,7 @@ import { coreMock } from '../../../../../../../src/core/public/mocks';
|
|||
const startMock = coreMock.createStart();
|
||||
|
||||
jest.mock('../../services', () => {
|
||||
const services = require.requireActual('../../services');
|
||||
const services = jest.requireActual('../../services');
|
||||
return {
|
||||
...services,
|
||||
getRouterLinkProps: (link) => ({ href: link }),
|
||||
|
|
|
@ -12,7 +12,7 @@ import { rollupJobsStore } from '../../../store';
|
|||
import { JobTable } from './job_table';
|
||||
|
||||
jest.mock('../../../../kibana_services', () => {
|
||||
const services = require.requireActual('../../../../kibana_services');
|
||||
const services = jest.requireActual('../../../../kibana_services');
|
||||
return {
|
||||
...services,
|
||||
trackUiMetric: jest.fn(),
|
||||
|
|
|
@ -16,7 +16,7 @@ jest.mock('lodash', () => ({
|
|||
}));
|
||||
|
||||
jest.mock('../../kibana_services', () => {
|
||||
const services = require.requireActual('../../kibana_services');
|
||||
const services = jest.requireActual('../../kibana_services');
|
||||
return {
|
||||
...services,
|
||||
getUiStatsReporter: jest.fn(() => () => {}),
|
||||
|
|
|
@ -10,7 +10,7 @@ import { JOBS } from './helpers/constants';
|
|||
import { coreMock } from '../../../../../../src/core/public/mocks';
|
||||
|
||||
jest.mock('../../crud_app/services', () => {
|
||||
const services = require.requireActual('../../crud_app/services');
|
||||
const services = jest.requireActual('../../crud_app/services');
|
||||
return {
|
||||
...services,
|
||||
getRouterLinkProps: (link) => ({ href: link }),
|
||||
|
@ -18,7 +18,7 @@ jest.mock('../../crud_app/services', () => {
|
|||
});
|
||||
|
||||
jest.mock('../../kibana_services', () => {
|
||||
const services = require.requireActual('../../kibana_services');
|
||||
const services = jest.requireActual('../../kibana_services');
|
||||
return {
|
||||
...services,
|
||||
getUiStatsReporter: jest.fn(() => () => {}),
|
||||
|
|
|
@ -16,7 +16,7 @@ jest.mock('lodash', () => ({
|
|||
}));
|
||||
|
||||
jest.mock('../../kibana_services', () => {
|
||||
const services = require.requireActual('../../kibana_services');
|
||||
const services = jest.requireActual('../../kibana_services');
|
||||
return {
|
||||
...services,
|
||||
getUiStatsReporter: jest.fn(() => () => {}),
|
||||
|
|
|
@ -7,21 +7,7 @@ exports[`FlowTargetSelect Component rendering it renders the FlowTargetSelect 1`
|
|||
hasDividers={false}
|
||||
isInvalid={false}
|
||||
isLoading={false}
|
||||
onChange={
|
||||
[MockFunction] {
|
||||
"calls": Array [
|
||||
Array [
|
||||
"destination",
|
||||
],
|
||||
],
|
||||
"results": Array [
|
||||
Object {
|
||||
"type": "return",
|
||||
"value": undefined,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
onChange={[MockFunction]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
|
|
|
@ -38,6 +38,10 @@ describe('NewTemplateTimeline', () => {
|
|||
const mockTitle = 'NEW_TIMELINE';
|
||||
let wrapper: ReactWrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('render if CRUD', () => {
|
||||
beforeAll(() => {
|
||||
(useKibana as jest.Mock).mockReturnValue({
|
||||
|
@ -52,10 +56,6 @@ describe('NewTemplateTimeline', () => {
|
|||
},
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
(useKibana as jest.Mock).mockReset();
|
||||
});
|
||||
|
||||
wrapper = mount(
|
||||
<ReduxStoreProvider store={store}>
|
||||
<NewTemplateTimeline outline={true} closeGearMenu={mockClosePopover} title={mockTitle} />
|
||||
|
@ -100,10 +100,6 @@ describe('NewTemplateTimeline', () => {
|
|||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
(useKibana as jest.Mock).mockReset();
|
||||
});
|
||||
|
||||
test('no render', () => {
|
||||
expect(
|
||||
wrapper.find('[data-test-subj="template-timeline-new-with-border"]').exists()
|
||||
|
|
|
@ -161,7 +161,7 @@ describe('Bulk Operation Buffer', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('handles both resolutions and rejections at individual task level', async (done) => {
|
||||
test('handles both resolutions and rejections at individual task level', async () => {
|
||||
const bulkUpdate: jest.Mocked<BulkOperation<TaskInstance, Error>> = jest.fn(
|
||||
([task1, task2, task3]) => {
|
||||
return Promise.resolve([
|
||||
|
@ -178,7 +178,7 @@ describe('Bulk Operation Buffer', () => {
|
|||
const task2 = createTask();
|
||||
const task3 = createTask();
|
||||
|
||||
return Promise.all([
|
||||
await Promise.all([
|
||||
expect(bufferedUpdate(task1)).resolves.toMatchObject(incrementAttempts(task1)),
|
||||
expect(bufferedUpdate(task2)).rejects.toMatchObject(
|
||||
mapErr(
|
||||
|
@ -187,13 +187,12 @@ describe('Bulk Operation Buffer', () => {
|
|||
)
|
||||
),
|
||||
expect(bufferedUpdate(task3)).resolves.toMatchObject(incrementAttempts(task3)),
|
||||
]).then(() => {
|
||||
expect(bulkUpdate).toHaveBeenCalledTimes(1);
|
||||
done();
|
||||
});
|
||||
]);
|
||||
|
||||
expect(bulkUpdate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('handles bulkUpdate failure', async (done) => {
|
||||
test('handles bulkUpdate failure', async () => {
|
||||
const bulkUpdate: jest.Mocked<BulkOperation<TaskInstance, Error>> = jest.fn(() => {
|
||||
return Promise.reject(new Error('bulkUpdate is an illusion'));
|
||||
});
|
||||
|
@ -204,7 +203,7 @@ describe('Bulk Operation Buffer', () => {
|
|||
const task2 = createTask();
|
||||
const task3 = createTask();
|
||||
|
||||
return Promise.all([
|
||||
await Promise.all([
|
||||
expect(bufferedUpdate(task1)).rejects.toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"error": [Error: bulkUpdate is an illusion],
|
||||
|
@ -223,13 +222,12 @@ describe('Bulk Operation Buffer', () => {
|
|||
"tag": "err",
|
||||
}
|
||||
`),
|
||||
]).then(() => {
|
||||
expect(bulkUpdate).toHaveBeenCalledTimes(1);
|
||||
done();
|
||||
});
|
||||
]);
|
||||
|
||||
expect(bulkUpdate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('logs unknown bulk operation results', async (done) => {
|
||||
test('logs unknown bulk operation results', async () => {
|
||||
const bulkUpdate: jest.Mocked<BulkOperation<TaskInstance, Error>> = jest.fn(
|
||||
([task1, task2, task3]) => {
|
||||
return Promise.resolve([
|
||||
|
@ -248,7 +246,7 @@ describe('Bulk Operation Buffer', () => {
|
|||
const task2 = createTask();
|
||||
const task3 = createTask();
|
||||
|
||||
return Promise.all([
|
||||
await Promise.all([
|
||||
expect(bufferedUpdate(task1)).resolves.toMatchObject(incrementAttempts(task1)),
|
||||
expect(bufferedUpdate(task2)).rejects.toMatchObject(
|
||||
asErr(new Error(`Unhandled buffered operation for entity: ${task2.id}`))
|
||||
|
@ -256,10 +254,9 @@ describe('Bulk Operation Buffer', () => {
|
|||
expect(bufferedUpdate(task3)).rejects.toMatchObject(
|
||||
asErr(new Error(`Unhandled buffered operation for entity: ${task3.id}`))
|
||||
),
|
||||
]).then(() => {
|
||||
expect(logger.warn).toHaveBeenCalledTimes(2);
|
||||
done();
|
||||
});
|
||||
]);
|
||||
|
||||
expect(logger.warn).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'sinon';
|
||||
import uuid from 'uuid';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { Option, some, none } from 'fp-ts/lib/Option';
|
||||
|
||||
import {
|
||||
|
@ -1242,7 +1242,7 @@ if (doc['task.runAt'].size()!=0) {
|
|||
return { taskManagerId, runAt, tasks };
|
||||
}
|
||||
|
||||
test('emits an event when a task is succesfully claimed by id', async (done) => {
|
||||
test('emits an event when a task is succesfully claimed by id', async () => {
|
||||
const { taskManagerId, runAt, tasks } = generateTasks();
|
||||
const callCluster = sinon.spy(async (name: string, params?: unknown) =>
|
||||
name === 'updateByQuery'
|
||||
|
@ -1262,49 +1262,47 @@ if (doc['task.runAt'].size()!=0) {
|
|||
index: '',
|
||||
});
|
||||
|
||||
const sub = store.events
|
||||
const promise = store.events
|
||||
.pipe(
|
||||
filter(
|
||||
(event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) =>
|
||||
event.id === 'claimed-by-id'
|
||||
)
|
||||
),
|
||||
take(1)
|
||||
)
|
||||
.subscribe({
|
||||
next: (event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) => {
|
||||
expect(event).toMatchObject(
|
||||
asTaskClaimEvent(
|
||||
'claimed-by-id',
|
||||
asOk({
|
||||
id: 'claimed-by-id',
|
||||
runAt,
|
||||
taskType: 'foo',
|
||||
schedule: undefined,
|
||||
attempts: 0,
|
||||
status: 'claiming' as TaskStatus,
|
||||
params: { hello: 'world' },
|
||||
state: { baby: 'Henhen' },
|
||||
user: 'jimbo',
|
||||
scope: ['reporting'],
|
||||
ownerId: taskManagerId,
|
||||
startedAt: null,
|
||||
retryAt: null,
|
||||
scheduledAt: new Date(),
|
||||
})
|
||||
)
|
||||
);
|
||||
sub.unsubscribe();
|
||||
done();
|
||||
},
|
||||
});
|
||||
.toPromise();
|
||||
|
||||
await store.claimAvailableTasks({
|
||||
claimTasksById: ['claimed-by-id'],
|
||||
claimOwnershipUntil: new Date(),
|
||||
size: 10,
|
||||
});
|
||||
|
||||
const event = await promise;
|
||||
expect(event).toMatchObject(
|
||||
asTaskClaimEvent(
|
||||
'claimed-by-id',
|
||||
asOk({
|
||||
id: 'claimed-by-id',
|
||||
runAt,
|
||||
taskType: 'foo',
|
||||
schedule: undefined,
|
||||
attempts: 0,
|
||||
status: 'claiming' as TaskStatus,
|
||||
params: { hello: 'world' },
|
||||
state: { baby: 'Henhen' },
|
||||
user: 'jimbo',
|
||||
scope: ['reporting'],
|
||||
ownerId: taskManagerId,
|
||||
startedAt: null,
|
||||
retryAt: null,
|
||||
scheduledAt: new Date(),
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test('emits an event when a task is succesfully by scheduling', async (done) => {
|
||||
test('emits an event when a task is succesfully by scheduling', async () => {
|
||||
const { taskManagerId, runAt, tasks } = generateTasks();
|
||||
const callCluster = sinon.spy(async (name: string, params?: unknown) =>
|
||||
name === 'updateByQuery'
|
||||
|
@ -1324,49 +1322,47 @@ if (doc['task.runAt'].size()!=0) {
|
|||
index: '',
|
||||
});
|
||||
|
||||
const sub = store.events
|
||||
const promise = store.events
|
||||
.pipe(
|
||||
filter(
|
||||
(event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) =>
|
||||
event.id === 'claimed-by-schedule'
|
||||
)
|
||||
),
|
||||
take(1)
|
||||
)
|
||||
.subscribe({
|
||||
next: (event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) => {
|
||||
expect(event).toMatchObject(
|
||||
asTaskClaimEvent(
|
||||
'claimed-by-schedule',
|
||||
asOk({
|
||||
id: 'claimed-by-schedule',
|
||||
runAt,
|
||||
taskType: 'bar',
|
||||
schedule: { interval: '5m' },
|
||||
attempts: 2,
|
||||
status: 'claiming' as TaskStatus,
|
||||
params: { shazm: 1 },
|
||||
state: { henry: 'The 8th' },
|
||||
user: 'dabo',
|
||||
scope: ['reporting', 'ceo'],
|
||||
ownerId: taskManagerId,
|
||||
startedAt: null,
|
||||
retryAt: null,
|
||||
scheduledAt: new Date(),
|
||||
})
|
||||
)
|
||||
);
|
||||
sub.unsubscribe();
|
||||
done();
|
||||
},
|
||||
});
|
||||
.toPromise();
|
||||
|
||||
await store.claimAvailableTasks({
|
||||
claimTasksById: ['claimed-by-id'],
|
||||
claimOwnershipUntil: new Date(),
|
||||
size: 10,
|
||||
});
|
||||
|
||||
const event = await promise;
|
||||
expect(event).toMatchObject(
|
||||
asTaskClaimEvent(
|
||||
'claimed-by-schedule',
|
||||
asOk({
|
||||
id: 'claimed-by-schedule',
|
||||
runAt,
|
||||
taskType: 'bar',
|
||||
schedule: { interval: '5m' },
|
||||
attempts: 2,
|
||||
status: 'claiming' as TaskStatus,
|
||||
params: { shazm: 1 },
|
||||
state: { henry: 'The 8th' },
|
||||
user: 'dabo',
|
||||
scope: ['reporting', 'ceo'],
|
||||
ownerId: taskManagerId,
|
||||
startedAt: null,
|
||||
retryAt: null,
|
||||
scheduledAt: new Date(),
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test('emits an event when the store fails to claim a required task by id', async (done) => {
|
||||
test('emits an event when the store fails to claim a required task by id', async () => {
|
||||
const { taskManagerId, runAt, tasks } = generateTasks();
|
||||
const callCluster = sinon.spy(async (name: string, params?: unknown) =>
|
||||
name === 'updateByQuery'
|
||||
|
@ -1386,51 +1382,49 @@ if (doc['task.runAt'].size()!=0) {
|
|||
index: '',
|
||||
});
|
||||
|
||||
const sub = store.events
|
||||
const promise = store.events
|
||||
.pipe(
|
||||
filter(
|
||||
(event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) =>
|
||||
event.id === 'already-running'
|
||||
)
|
||||
),
|
||||
take(1)
|
||||
)
|
||||
.subscribe({
|
||||
next: (event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) => {
|
||||
expect(event).toMatchObject(
|
||||
asTaskClaimEvent(
|
||||
'already-running',
|
||||
asErr(
|
||||
some({
|
||||
id: 'already-running',
|
||||
runAt,
|
||||
taskType: 'bar',
|
||||
schedule: { interval: '5m' },
|
||||
attempts: 2,
|
||||
status: 'running' as TaskStatus,
|
||||
params: { shazm: 1 },
|
||||
state: { henry: 'The 8th' },
|
||||
user: 'dabo',
|
||||
scope: ['reporting', 'ceo'],
|
||||
ownerId: taskManagerId,
|
||||
startedAt: null,
|
||||
retryAt: null,
|
||||
scheduledAt: new Date(),
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
sub.unsubscribe();
|
||||
done();
|
||||
},
|
||||
});
|
||||
.toPromise();
|
||||
|
||||
await store.claimAvailableTasks({
|
||||
claimTasksById: ['already-running'],
|
||||
claimOwnershipUntil: new Date(),
|
||||
size: 10,
|
||||
});
|
||||
|
||||
const event = await promise;
|
||||
expect(event).toMatchObject(
|
||||
asTaskClaimEvent(
|
||||
'already-running',
|
||||
asErr(
|
||||
some({
|
||||
id: 'already-running',
|
||||
runAt,
|
||||
taskType: 'bar',
|
||||
schedule: { interval: '5m' },
|
||||
attempts: 2,
|
||||
status: 'running' as TaskStatus,
|
||||
params: { shazm: 1 },
|
||||
state: { henry: 'The 8th' },
|
||||
user: 'dabo',
|
||||
scope: ['reporting', 'ceo'],
|
||||
ownerId: taskManagerId,
|
||||
startedAt: null,
|
||||
retryAt: null,
|
||||
scheduledAt: new Date(),
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test('emits an event when the store fails to find a task which was required by id', async (done) => {
|
||||
test('emits an event when the store fails to find a task which was required by id', async () => {
|
||||
const { taskManagerId, tasks } = generateTasks();
|
||||
const callCluster = sinon.spy(async (name: string, params?: unknown) =>
|
||||
name === 'updateByQuery'
|
||||
|
@ -1450,26 +1444,24 @@ if (doc['task.runAt'].size()!=0) {
|
|||
index: '',
|
||||
});
|
||||
|
||||
const sub = store.events
|
||||
const promise = store.events
|
||||
.pipe(
|
||||
filter(
|
||||
(event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) =>
|
||||
event.id === 'unknown-task'
|
||||
)
|
||||
),
|
||||
take(1)
|
||||
)
|
||||
.subscribe({
|
||||
next: (event: TaskEvent<ConcreteTaskInstance, Option<ConcreteTaskInstance>>) => {
|
||||
expect(event).toMatchObject(asTaskClaimEvent('unknown-task', asErr(none)));
|
||||
sub.unsubscribe();
|
||||
done();
|
||||
},
|
||||
});
|
||||
.toPromise();
|
||||
|
||||
await store.claimAvailableTasks({
|
||||
claimTasksById: ['unknown-task'],
|
||||
claimOwnershipUntil: new Date(),
|
||||
size: 10,
|
||||
});
|
||||
|
||||
const event = await promise;
|
||||
expect(event).toMatchObject(asTaskClaimEvent('unknown-task', asErr(none)));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import React, { FC } from 'react';
|
||||
|
||||
import { render, wait } from '@testing-library/react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { renderHook } from '@testing-library/react-hooks';
|
||||
|
||||
import { CoreSetup } from 'src/core/public';
|
||||
|
@ -33,7 +33,7 @@ const query: SimpleQuery = {
|
|||
};
|
||||
|
||||
describe('Transform: useIndexData()', () => {
|
||||
test('indexPattern set triggers loading', async (done) => {
|
||||
test('indexPattern set triggers loading', async () => {
|
||||
const mlShared = await getMlSharedImports();
|
||||
const wrapper: FC = ({ children }) => (
|
||||
<MlSharedContext.Provider value={mlShared}>{children}</MlSharedContext.Provider>
|
||||
|
@ -58,13 +58,11 @@ describe('Transform: useIndexData()', () => {
|
|||
expect(IndexObj.errorMessage).toBe('');
|
||||
expect(IndexObj.status).toBe(1);
|
||||
expect(IndexObj.tableItems).toEqual([]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Transform: <DataGrid /> with useIndexData()', () => {
|
||||
// Using the async/await wait()/done() pattern to avoid act() errors.
|
||||
test('Minimal initialization', async (done) => {
|
||||
test('Minimal initialization', async () => {
|
||||
// Arrange
|
||||
const indexPattern = {
|
||||
title: 'the-index-pattern-title',
|
||||
|
@ -97,7 +95,5 @@ describe('Transform: <DataGrid /> with useIndexData()', () => {
|
|||
// Act
|
||||
// Assert
|
||||
expect(getByText('the-index-preview-title')).toBeInTheDocument();
|
||||
await wait();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { render, wait } from '@testing-library/react';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
|
||||
|
@ -51,8 +51,7 @@ const createMockStorage = () => ({
|
|||
});
|
||||
|
||||
describe('Transform: <DefinePivotForm />', () => {
|
||||
// Using the async/await wait()/done() pattern to avoid act() errors.
|
||||
test('Minimal initialization', async (done) => {
|
||||
test('Minimal initialization', async () => {
|
||||
// Arrange
|
||||
const mlSharedImports = await getMlSharedImports();
|
||||
|
||||
|
@ -85,8 +84,6 @@ describe('Transform: <DefinePivotForm />', () => {
|
|||
// Assert
|
||||
expect(getByText('Index pattern')).toBeInTheDocument();
|
||||
expect(getByText(searchItems.indexPattern.title)).toBeInTheDocument();
|
||||
await wait();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import { getMlSharedImports } from '../../../../../shared_imports';
|
|||
|
||||
describe('Transform: <DefinePivotSummary />', () => {
|
||||
// Using the async/await wait()/done() pattern to avoid act() errors.
|
||||
test('Minimal initialization', async (done) => {
|
||||
test('Minimal initialization', async () => {
|
||||
// Arrange
|
||||
const mlSharedImports = await getMlSharedImports();
|
||||
|
||||
|
@ -72,6 +72,5 @@ describe('Transform: <DefinePivotSummary />', () => {
|
|||
expect(getByText('Group by')).toBeInTheDocument();
|
||||
expect(getByText('Aggregations')).toBeInTheDocument();
|
||||
await wait();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { findTestSubject } from '@elastic/eui/lib/test';
|
||||
import { skip } from 'rxjs/operators';
|
||||
import { skip, take } from 'rxjs/operators';
|
||||
import * as Rx from 'rxjs';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
|
@ -27,7 +27,7 @@ const createOpenModalMock = () => {
|
|||
return mock;
|
||||
};
|
||||
|
||||
test('Custom time range action prevents embeddable from using container time', async (done) => {
|
||||
test('Custom time range action prevents embeddable from using container time', async () => {
|
||||
const container = new TimeRangeContainer(
|
||||
{
|
||||
timeRange: { from: 'now-15m', to: 'now' },
|
||||
|
@ -79,19 +79,19 @@ test('Custom time range action prevents embeddable from using container time', a
|
|||
|
||||
findTestSubject(wrapper, 'addPerPanelTimeRangeButton').simulate('click');
|
||||
|
||||
const subscription = Rx.merge(container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(2))
|
||||
.subscribe(() => {
|
||||
expect(child1.getInput().timeRange).toEqual({ from: 'now-30days', to: 'now-29days' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-30m', to: 'now-1m' });
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
});
|
||||
const promise = Rx.merge(container.getOutput$(), container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(2), take(1))
|
||||
.toPromise();
|
||||
|
||||
container.updateInput({ timeRange: { from: 'now-30m', to: 'now-1m' } });
|
||||
|
||||
await promise;
|
||||
|
||||
expect(child1.getInput().timeRange).toEqual({ from: 'now-30days', to: 'now-29days' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-30m', to: 'now-1m' });
|
||||
});
|
||||
|
||||
test('Removing custom time range action resets embeddable back to container time', async (done) => {
|
||||
test('Removing custom time range action resets embeddable back to container time', async () => {
|
||||
const container = new TimeRangeContainer(
|
||||
{
|
||||
timeRange: { from: 'now-15m', to: 'now' },
|
||||
|
@ -153,19 +153,19 @@ test('Removing custom time range action resets embeddable back to container time
|
|||
const wrapper2 = mount(openModal2);
|
||||
findTestSubject(wrapper2, 'removePerPanelTimeRangeButton').simulate('click');
|
||||
|
||||
const subscription = Rx.merge(container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(2))
|
||||
.subscribe(() => {
|
||||
expect(child1.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
});
|
||||
const promise = Rx.merge(container.getOutput$(), container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(2), take(1))
|
||||
.toPromise();
|
||||
|
||||
container.updateInput({ timeRange: { from: 'now-10m', to: 'now-5m' } });
|
||||
|
||||
await promise;
|
||||
|
||||
expect(child1.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
});
|
||||
|
||||
test('Cancelling custom time range action leaves state alone', async (done) => {
|
||||
test('Cancelling custom time range action leaves state alone', async () => {
|
||||
const container = new TimeRangeContainer(
|
||||
{
|
||||
timeRange: { from: 'now-15m', to: 'now' },
|
||||
|
@ -212,16 +212,16 @@ test('Cancelling custom time range action leaves state alone', async (done) => {
|
|||
|
||||
findTestSubject(wrapper, 'cancelPerPanelTimeRangeButton').simulate('click');
|
||||
|
||||
const subscription = Rx.merge(container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(2))
|
||||
.subscribe(() => {
|
||||
expect(child1.getInput().timeRange).toEqual({ from: '1', to: '2' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-30m', to: 'now-1m' });
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
});
|
||||
const promise = Rx.merge(container.getOutput$(), container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(2), take(1))
|
||||
.toPromise();
|
||||
|
||||
container.updateInput({ timeRange: { from: 'now-30m', to: 'now-1m' } });
|
||||
|
||||
await promise;
|
||||
|
||||
expect(child1.getInput().timeRange).toEqual({ from: '1', to: '2' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-30m', to: 'now-1m' });
|
||||
});
|
||||
|
||||
test(`badge is compatible with embeddable that inherits from parent`, async () => {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { findTestSubject } from '@elastic/eui/lib/test';
|
||||
import { skip } from 'rxjs/operators';
|
||||
import { skip, take } from 'rxjs/operators';
|
||||
import * as Rx from 'rxjs';
|
||||
import { mount } from 'enzyme';
|
||||
import { TimeRangeEmbeddable, TimeRangeContainer, TIME_RANGE_EMBEDDABLE } from './test_helpers';
|
||||
|
@ -13,7 +13,7 @@ import { CustomTimeRangeBadge } from './custom_time_range_badge';
|
|||
import { ReactElement } from 'react';
|
||||
import { nextTick } from 'test_utils/enzyme_helpers';
|
||||
|
||||
test('Removing custom time range from badge resets embeddable back to container time', async (done) => {
|
||||
test('Removing custom time range from badge resets embeddable back to container time', async () => {
|
||||
const container = new TimeRangeContainer(
|
||||
{
|
||||
timeRange: { from: 'now-15m', to: 'now' },
|
||||
|
@ -60,16 +60,16 @@ test('Removing custom time range from badge resets embeddable back to container
|
|||
const wrapper = mount(openModal);
|
||||
findTestSubject(wrapper, 'removePerPanelTimeRangeButton').simulate('click');
|
||||
|
||||
const subscription = Rx.merge(child1.getInput$(), container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(4))
|
||||
.subscribe(() => {
|
||||
expect(child1.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
subscription.unsubscribe();
|
||||
done();
|
||||
});
|
||||
const promise = Rx.merge(child1.getInput$(), container.getOutput$(), container.getInput$())
|
||||
.pipe(skip(4), take(1))
|
||||
.toPromise();
|
||||
|
||||
container.updateInput({ timeRange: { from: 'now-10m', to: 'now-5m' } });
|
||||
|
||||
await promise;
|
||||
|
||||
expect(child1.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
expect(child2.getInput().timeRange).toEqual({ from: 'now-10m', to: 'now-5m' });
|
||||
});
|
||||
|
||||
test(`badge is not compatible with embeddable that inherits from parent`, async () => {
|
||||
|
|
Loading…
Reference in a new issue