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

Prepare OSS unit tests for jest-circus #82280

Closed
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c3e8026
Use jest-circus in OSS
patrykkopycinski Nov 2, 2020
7d6a6b2
cleanup done
patrykkopycinski Nov 2, 2020
6b73115
done
patrykkopycinski Nov 2, 2020
9cf98f2
done
patrykkopycinski Nov 2, 2020
99145d4
window
patrykkopycinski Nov 2, 2020
150916f
Merge branch 'master' of github.com:elastic/kibana into chore/jest-ci…
patrykkopycinski Nov 6, 2020
efe5ebd
Merge branch 'master' of github.com:elastic/kibana into feat/timeline…
patrykkopycinski Nov 6, 2020
3d232b9
Update saved_objects_service.test.ts
patrykkopycinski Nov 6, 2020
cf932b8
fix lint
patrykkopycinski Nov 7, 2020
a7df3f5
cleanup
patrykkopycinski Nov 7, 2020
0a7b433
increase timeout
patrykkopycinski Nov 7, 2020
91df75a
timeout
patrykkopycinski Nov 7, 2020
a8bae2b
bump jest
patrykkopycinski Nov 8, 2020
551d1ab
Merge branch 'master' of github.com:elastic/kibana into chore/jest-ci…
patrykkopycinski Nov 12, 2020
016ad9a
dist
patrykkopycinski Nov 12, 2020
f704ade
deps
patrykkopycinski Nov 12, 2020
1141f23
Merge remote-tracking branch 'upstream/master' into chore/jest-circus…
Nov 14, 2020
3a0965c
Merge pull request #2 from tylersmalley/chore/jest-circus-oss_cr
patrykkopycinski Nov 14, 2020
ab91378
Merge branch 'master' of github.com:elastic/kibana into chore/jest-ci…
patrykkopycinski Nov 14, 2020
994eaf2
Fixes integration tests
Nov 14, 2020
096e844
Merge branch 'master' into chore/jest-circus-oss
kibanamachine Nov 14, 2020
a63a0a9
observables to promises
patrykkopycinski Nov 16, 2020
a8fb412
refactor async observables tests to promises
patrykkopycinski Nov 16, 2020
15c3b7e
lint
patrykkopycinski Nov 16, 2020
d68dfdf
Merge branch 'master' into chore/jest-circus-oss
kibanamachine Nov 17, 2020
b323f7d
Merge branch 'master' of github.com:elastic/kibana into chore/jest-ci…
patrykkopycinski Nov 24, 2020
f4971a1
Update integration.test.js
patrykkopycinski Nov 25, 2020
d63d36f
Merge branch 'master' of github.com:elastic/kibana into chore/jest-ci…
patrykkopycinski Nov 27, 2020
24a2134
use promise
patrykkopycinski Nov 27, 2020
5ea7ff3
Merge branch 'master' into chore/jest-circus-oss
kibanamachine Nov 30, 2020
2609644
Merge branch 'master' into chore/jest-circus-oss
patrykkopycinski Dec 1, 2020
dfc9fa7
Merge remote-tracking branch 'upstream/master' into chore/jest-circus…
Dec 3, 2020
266dc8e
Updates for multi-project runner
Dec 3, 2020
6892d82
Merge branch 'master' into chore/jest-circus-oss
kibanamachine Dec 5, 2020
23a8433
Merge branch 'master' of github.com:elastic/kibana into chore/jest-ci…
patrykkopycinski Dec 6, 2020
225cd7e
PR comments
patrykkopycinski Dec 6, 2020
42a662d
Merge branch 'master' into chore/jest-circus-oss
kibanamachine Dec 9, 2020
f509e42
Merge branch 'master' into chore/jest-circus-oss
kibanamachine Dec 20, 2020
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -354,7 +354,7 @@
"@elastic/maki": "6.3.0",
"@elastic/ui-ace": "0.2.3",
"@istanbuljs/schema": "^0.1.2",
"@jest/reporters": "^26.5.2",
"@jest/reporters": "^26.6.2",
"@kbn/babel-code-parser": "link:packages/kbn-babel-code-parser",
"@kbn/babel-preset": "link:packages/kbn-babel-preset",
"@kbn/dev-utils": "link:packages/kbn-dev-utils",
@@ -580,7 +580,7 @@
"autoprefixer": "^9.7.4",
"axe-core": "^4.0.2",
"babel-eslint": "^10.0.3",
"babel-jest": "^26.3.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.0.6",
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-istanbul": "^6.0.0",
1 change: 0 additions & 1 deletion src/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -21,5 +21,4 @@ module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/src/core'],
testRunner: 'jasmine2',
};
Original file line number Diff line number Diff line change
@@ -406,7 +406,7 @@ describe('ClusterClient', () => {
expect(scopedClient.close).toHaveBeenCalledTimes(1);
});

it('waits for both clients to close', async (done) => {
it('waits for both clients to close', (done) => {
expect.assertions(4);

const clusterClient = new ClusterClient(createConfig(), logger, getAuthHeaders);
38 changes: 18 additions & 20 deletions src/core/server/elasticsearch/elasticsearch_service.test.ts
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ describe('#setup', () => {
});
});

it('esNodeVersionCompatibility$ only starts polling when subscribed to', async (done) => {
it('esNodeVersionCompatibility$ only starts polling when subscribed to', async () => {
const mockedClient = mockClusterClientInstance.asInternalUser;
mockedClient.nodes.info.mockImplementation(() =>
elasticsearchClientMock.createErrorTransportRequestPromise(new Error())
@@ -231,13 +231,13 @@ describe('#setup', () => {
await delay(10);

expect(mockedClient.nodes.info).toHaveBeenCalledTimes(0);
setupContract.esNodesCompatibility$.subscribe(() => {
expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);
done();
});

await setupContract.esNodesCompatibility$.pipe(first()).toPromise();

expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);
});

it('esNodeVersionCompatibility$ stops polling when unsubscribed from', async (done) => {
it('esNodeVersionCompatibility$ stops polling when unsubscribed from', async () => {
const mockedClient = mockClusterClientInstance.asInternalUser;
mockedClient.nodes.info.mockImplementation(() =>
elasticsearchClientMock.createErrorTransportRequestPromise(new Error())
@@ -246,12 +246,11 @@ describe('#setup', () => {
const setupContract = await elasticsearchService.setup(setupDeps);

expect(mockedClient.nodes.info).toHaveBeenCalledTimes(0);
const sub = setupContract.esNodesCompatibility$.subscribe(async () => {
sub.unsubscribe();
await delay(100);
expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);
done();
});

await setupContract.esNodesCompatibility$.pipe(first()).toPromise();

await delay(100);
expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);
});
});

@@ -351,7 +350,7 @@ describe('#stop', () => {
expect(mockClusterClientInstance.close).toHaveBeenCalledTimes(1);
});

it('stops pollEsNodeVersions even if there are active subscriptions', async (done) => {
it('stops pollEsNodeVersions even if there are active subscriptions', async () => {
expect.assertions(2);

const mockedClient = mockClusterClientInstance.asInternalUser;
@@ -361,13 +360,12 @@ describe('#stop', () => {

const setupContract = await elasticsearchService.setup(setupDeps);

setupContract.esNodesCompatibility$.subscribe(async () => {
expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);
await setupContract.esNodesCompatibility$.pipe(first()).toPromise();

await elasticsearchService.stop();
await delay(100);
expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);
done();
tylersmalley marked this conversation as resolved.
Show resolved Hide resolved
});
expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);

await elasticsearchService.stop();
await delay(100);
expect(mockedClient.nodes.info).toHaveBeenCalledTimes(1);
});
});
8 changes: 4 additions & 4 deletions src/core/server/http/integration_tests/request.test.ts
Original file line number Diff line number Diff line change
@@ -174,7 +174,7 @@ describe('KibanaRequest', () => {

describe('events', () => {
describe('aborted$', () => {
it('emits once and completes when request aborted', async (done) => {
it('emits once and completes when request aborted', async () => {
expect.assertions(1);
const { server: innerServer, createRouter } = await server.setup(setupDeps);
const router = createRouter('/');
@@ -185,7 +185,6 @@ describe('KibanaRequest', () => {
next: nextSpy,
complete: () => {
expect(nextSpy).toHaveBeenCalledTimes(1);
done();
},
});

@@ -202,6 +201,7 @@ describe('KibanaRequest', () => {
.end();

setTimeout(() => incomingRequest.abort(), 50);
await delay(100);
});

it('completes & does not emit when request handled', async () => {
@@ -310,7 +310,7 @@ describe('KibanaRequest', () => {
expect(completeSpy).toHaveBeenCalledTimes(1);
});

it('emits once and completes when response is aborted', async (done) => {
it('emits once and completes when response is aborted', async () => {
expect.assertions(2);
const { server: innerServer, createRouter } = await server.setup(setupDeps);
const router = createRouter('/');
@@ -322,7 +322,6 @@ describe('KibanaRequest', () => {
next: nextSpy,
complete: () => {
expect(nextSpy).toHaveBeenCalledTimes(1);
done();
},
});

@@ -338,6 +337,7 @@ describe('KibanaRequest', () => {
// end required to send request
.end();
setTimeout(() => incomingRequest.abort(), 50);
await delay(100);
});
});
});
10 changes: 4 additions & 6 deletions src/core/server/saved_objects/saved_objects_service.test.ts
Original file line number Diff line number Diff line change
@@ -177,7 +177,7 @@ describe('SavedObjectsService', () => {
expect(migratorInstanceMock.runMigrations).not.toHaveBeenCalled();
});

it('waits for all es nodes to be compatible before running migrations', async (done) => {
it('waits for all es nodes to be compatible before running migrations', async () => {
expect.assertions(2);
const coreContext = createCoreContext({ skipMigration: false });
const soService = new SavedObjectsService(coreContext);
@@ -191,7 +191,7 @@ describe('SavedObjectsService', () => {
kibanaVersion: '8.0.0',
});
await soService.setup(setupDeps);
soService.start(createStartDeps());
const promise = soService.start(createStartDeps());
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(0);
((setupDeps.elasticsearch
.esNodesCompatibility$ as any) as BehaviorSubject<NodesVersionCompatibility>).next({
@@ -200,10 +200,8 @@ describe('SavedObjectsService', () => {
warningNodes: [],
kibanaVersion: '8.0.0',
});
setImmediate(() => {
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(1);
done();
});
await promise;
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(1);
});

it('resolves with KibanaMigrator after waiting for migrations to complete', async () => {
1 change: 0 additions & 1 deletion src/plugins/console/jest.config.js
Original file line number Diff line number Diff line change
@@ -21,5 +21,4 @@ module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/src/plugins/console'],
testRunner: 'jasmine2',
};
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ describe('Output Tokenization', () => {
data = JSON.stringify(data, null, 3);
}

test('Token test ' + testCount++, async function (done) {
test('Token test ' + testCount++, function (done) {
output.update(data, function () {
const tokens = tokensAsList();
const normTokenList = [];
Loading