Skip to content

Commit b20b4c8

Browse files
author
Stacey Gammon
committed
Merge branch 'master' of github.com:elastic/kibana into 2020-02-11-url-service
2 parents 129906b + 464f907 commit b20b4c8

File tree

73 files changed

+5195
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+5195
-730
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
export function foo() {}

packages/kbn-optimizer/src/__fixtures__/mock_repo/plugins/foo/public/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@
1919

2020
export * from './lib';
2121
export * from './ext';
22+
23+
export async function getFoo() {
24+
return await import('./async_import');
25+
}

packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,21 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
128128
Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, 'plugins/foo/target/public/foo.plugin.js'), 'utf8')
129129
).toMatchSnapshot('foo bundle');
130130

131+
expect(
132+
Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, 'plugins/foo/target/public/1.plugin.js'), 'utf8')
133+
).toMatchSnapshot('1 async bundle');
134+
131135
expect(
132136
Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, 'plugins/bar/target/public/bar.plugin.js'), 'utf8')
133137
).toMatchSnapshot('bar bundle');
134138

135139
const foo = config.bundles.find(b => b.id === 'foo')!;
136140
expect(foo).toBeTruthy();
137141
foo.cache.refresh();
138-
expect(foo.cache.getModuleCount()).toBe(3);
142+
expect(foo.cache.getModuleCount()).toBe(4);
139143
expect(foo.cache.getReferencedFiles()).toMatchInlineSnapshot(`
140144
Array [
145+
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts,
141146
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts,
142147
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/index.ts,
143148
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/lib.ts,
@@ -148,8 +153,8 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
148153
expect(bar).toBeTruthy();
149154
bar.cache.refresh();
150155
expect(bar.cache.getModuleCount()).toBe(
151-
// code + styles + style/css-loader runtime
152-
14
156+
// code + styles + style/css-loader runtimes
157+
15
153158
);
154159

155160
expect(bar.cache.getReferencedFiles()).toMatchInlineSnapshot(`
@@ -159,6 +164,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
159164
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.ts,
160165
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/legacy/styles.scss,
161166
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/lib.ts,
167+
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts,
162168
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts,
163169
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/index.ts,
164170
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/lib.ts,

packages/kbn-optimizer/src/worker/run_compilers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const observeCompiler = (
127127
);
128128
}
129129

130-
const files = Array.from(referencedFiles);
130+
const files = Array.from(referencedFiles).sort(ascending(p => p));
131131
const mtimes = new Map(
132132
files.map((path): [string, number | undefined] => {
133133
try {
@@ -146,7 +146,7 @@ const observeCompiler = (
146146
optimizerCacheKey: workerConfig.optimizerCacheKey,
147147
cacheKey: bundle.createCacheKey(files, mtimes),
148148
moduleCount: normalModules.length,
149-
files: files.sort(ascending(f => f)),
149+
files,
150150
});
151151

152152
return compilerMsgs.compilerSuccess({

packages/kbn-test/src/failed_tests_reporter/github_api.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ export interface GithubIssue {
3333
body: string;
3434
}
3535

36+
/**
37+
* Minimal GithubIssue type that can be easily replicated by dry-run helpers
38+
*/
39+
export interface GithubIssueMini {
40+
number: GithubIssue['number'];
41+
body: GithubIssue['body'];
42+
html_url: GithubIssue['html_url'];
43+
}
44+
3645
type RequestOptions = AxiosRequestConfig & {
3746
safeForDryRun?: boolean;
3847
maxAttempts?: number;
@@ -162,7 +171,7 @@ export class GithubApi {
162171
}
163172

164173
async createIssue(title: string, body: string, labels?: string[]) {
165-
const resp = await this.request(
174+
const resp = await this.request<GithubIssueMini>(
166175
{
167176
method: 'POST',
168177
url: Url.resolve(BASE_URL, 'issues'),
@@ -173,11 +182,13 @@ export class GithubApi {
173182
},
174183
},
175184
{
185+
body,
186+
number: 999,
176187
html_url: 'https://dryrun',
177188
}
178189
);
179190

180-
return resp.data.html_url;
191+
return resp.data;
181192
}
182193

183194
private async request<T>(

packages/kbn-test/src/failed_tests_reporter/report_failure.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ describe('updateFailureIssue()', () => {
7878
'https://build-url',
7979
{
8080
html_url: 'https://github.com/issues/1234',
81-
labels: ['some-label'],
8281
number: 1234,
83-
title: 'issue title',
8482
body: dedent`
8583
# existing issue body
8684

packages/kbn-test/src/failed_tests_reporter/report_failure.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import { TestFailure } from './get_failures';
21-
import { GithubIssue, GithubApi } from './github_api';
21+
import { GithubIssueMini, GithubApi } from './github_api';
2222
import { getIssueMetadata, updateIssueMetadata } from './issue_metadata';
2323

2424
export async function createFailureIssue(buildUrl: string, failure: TestFailure, api: GithubApi) {
@@ -44,7 +44,7 @@ export async function createFailureIssue(buildUrl: string, failure: TestFailure,
4444
return await api.createIssue(title, body, ['failed-test']);
4545
}
4646

47-
export async function updateFailureIssue(buildUrl: string, issue: GithubIssue, api: GithubApi) {
47+
export async function updateFailureIssue(buildUrl: string, issue: GithubIssueMini, api: GithubApi) {
4848
// Increment failCount
4949
const newCount = getIssueMetadata(issue.body, 'test.failCount', 0) + 1;
5050
const newBody = updateIssueMetadata(issue.body, {

packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import { REPO_ROOT, run, createFailError, createFlagError } from '@kbn/dev-utils';
2121
import globby from 'globby';
2222

23-
import { getFailures } from './get_failures';
24-
import { GithubApi } from './github_api';
23+
import { getFailures, TestFailure } from './get_failures';
24+
import { GithubApi, GithubIssueMini } from './github_api';
2525
import { updateFailureIssue, createFailureIssue } from './report_failure';
2626
import { getIssueMetadata } from './issue_metadata';
2727
import { readTestReport } from './test_report';
@@ -73,6 +73,11 @@ export function runFailedTestsReporterCli() {
7373
absolute: true,
7474
});
7575

76+
const newlyCreatedIssues: Array<{
77+
failure: TestFailure;
78+
newIssue: GithubIssueMini;
79+
}> = [];
80+
7681
for (const reportPath of reportPaths) {
7782
const report = await readTestReport(reportPath);
7883
const messages = Array.from(getReportMessageIter(report));
@@ -94,12 +99,22 @@ export function runFailedTestsReporterCli() {
9499
continue;
95100
}
96101

97-
const existingIssue = await githubApi.findFailedTestIssue(
102+
let existingIssue: GithubIssueMini | undefined = await githubApi.findFailedTestIssue(
98103
i =>
99104
getIssueMetadata(i.body, 'test.class') === failure.classname &&
100105
getIssueMetadata(i.body, 'test.name') === failure.name
101106
);
102107

108+
if (!existingIssue) {
109+
const newlyCreated = newlyCreatedIssues.find(
110+
({ failure: f }) => f.classname === failure.classname && f.name === failure.name
111+
);
112+
113+
if (newlyCreated) {
114+
existingIssue = newlyCreated.newIssue;
115+
}
116+
}
117+
103118
if (existingIssue) {
104119
const newFailureCount = await updateFailureIssue(buildUrl, existingIssue, githubApi);
105120
const url = existingIssue.html_url;
@@ -110,11 +125,12 @@ export function runFailedTestsReporterCli() {
110125
continue;
111126
}
112127

113-
const newIssueUrl = await createFailureIssue(buildUrl, failure, githubApi);
128+
const newIssue = await createFailureIssue(buildUrl, failure, githubApi);
114129
pushMessage('Test has not failed recently on tracked branches');
115130
if (updateGithub) {
116-
pushMessage(`Created new issue: ${newIssueUrl}`);
131+
pushMessage(`Created new issue: ${newIssue.html_url}`);
117132
}
133+
newlyCreatedIssues.push({ failure, newIssue });
118134
}
119135

120136
// mutates report to include messages and writes updated report to disk

src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.test.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { I18nProvider } from '@kbn/i18n/react';
2525
import { act } from 'react-dom/test-utils';
2626
import * as sinon from 'sinon';
2727

28-
import { notificationServiceMock } from '../../../../../../../../core/public/mocks';
28+
import { serviceContextMock } from '../../../../contexts/services_context.mock';
2929

3030
import { nextTick } from 'test_utils/enzyme_helpers';
3131
import {
@@ -61,21 +61,7 @@ describe('Legacy (Ace) Console Editor Component Smoke Test', () => {
6161

6262
beforeEach(() => {
6363
document.queryCommandSupported = sinon.fake(() => true);
64-
mockedAppContextValue = {
65-
elasticsearchUrl: 'test',
66-
services: {
67-
trackUiMetric: { count: () => {}, load: () => {} },
68-
settings: {} as any,
69-
storage: {} as any,
70-
history: {
71-
getSavedEditorState: () => ({} as any),
72-
updateCurrentState: jest.fn(),
73-
} as any,
74-
notifications: notificationServiceMock.createSetupContract(),
75-
objectStorageClient: {} as any,
76-
},
77-
docLinkVersion: 'NA',
78-
};
64+
mockedAppContextValue = serviceContextMock.create();
7965
});
8066

8167
afterEach(() => {

0 commit comments

Comments
 (0)