Skip to content

Commit bdafd27

Browse files
Spencerspalger
andauthored
[ts] migrate x-pack/test to composite ts project (#101441)
Co-authored-by: spalger <spalger@users.noreply.github.com>
1 parent a9e64ab commit bdafd27

File tree

33 files changed

+2842
-2807
lines changed

33 files changed

+2842
-2807
lines changed

src/plugins/telemetry/tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
"declarationMap": true,
99
"isolatedModules": true
1010
},
11-
"include": ["public/**/**/*", "server/**/**/*", "common/**/*", "../../../typings/**/*"],
11+
"include": [
12+
"public/**/**/*",
13+
"server/**/**/*",
14+
"common/**/*",
15+
"../../../typings/**/*",
16+
"schema/oss_plugins.json",
17+
"schema/oss_root.json",
18+
],
1219
"references": [
1320
{ "path": "../../core/tsconfig.json" },
1421
{ "path": "../../plugins/kibana_react/tsconfig.json" },

test/common/services/kibana_server/extend_es_archiver.js renamed to test/common/services/kibana_server/extend_es_archiver.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,23 @@
66
* Side Public License, v 1.
77
*/
88

9-
const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded', 'unload', 'emptyKibanaIndex'];
9+
import type { ProvidedType } from '@kbn/test';
10+
11+
import type { EsArchiverProvider } from '../es_archiver';
12+
import type { RetryService } from '../retry';
13+
import type { KibanaServerProvider } from './kibana_server';
14+
15+
const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded', 'unload', 'emptyKibanaIndex'] as const;
1016
const KIBANA_INDEX = '.kibana';
1117

12-
export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults }) {
18+
interface Options {
19+
esArchiver: ProvidedType<typeof EsArchiverProvider>;
20+
kibanaServer: ProvidedType<typeof KibanaServerProvider>;
21+
retry: RetryService;
22+
defaults: Record<string, any>;
23+
}
24+
25+
export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults }: Options) {
1326
// only extend the esArchiver if there are default uiSettings to restore
1427
if (!defaults) {
1528
return;
@@ -18,9 +31,9 @@ export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults })
1831
ES_ARCHIVER_LOAD_METHODS.forEach((method) => {
1932
const originalMethod = esArchiver[method];
2033

21-
esArchiver[method] = async (...args) => {
34+
esArchiver[method] = async (...args: unknown[]) => {
2235
// esArchiver methods return a stats object, with information about the indexes created
23-
const stats = await originalMethod.apply(esArchiver, args);
36+
const stats = await originalMethod.apply(esArchiver, args as any);
2437

2538
const statsKeys = Object.keys(stats);
2639
const kibanaKeys = statsKeys.filter(

test/common/services/kibana_server/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
*/
88

99
export { KibanaServerProvider } from './kibana_server';
10-
// @ts-ignore
1110
export { extendEsArchiver } from './extend_es_archiver';

test/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
"include": [
1212
"**/*",
1313
"../typings/**/*",
14-
"../packages/kbn-test/types/ftr_globals/**/*"
14+
"../packages/kbn-test/types/ftr_globals/**/*",
15+
"api_integration/apis/logstash/pipeline/fixtures/*.json",
16+
"api_integration/apis/logstash/pipelines/fixtures/*.json",
17+
"api_integration/apis/telemetry/fixtures/*.json",
18+
"api_integration/apis/telemetry/fixtures/*.json",
1519
],
1620
"exclude": ["target/**/*", "plugin_functional/plugins/**/*", "interpreter_functional/plugins/**/*"],
1721
"references": [

tsconfig.refs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,6 @@
119119
{ "path": "./x-pack/plugins/index_lifecycle_management/tsconfig.json" },
120120
{ "path": "./x-pack/plugins/uptime/tsconfig.json" },
121121
{ "path": "./x-pack/plugins/xpack_legacy/tsconfig.json" },
122+
{ "path": "./x-pack/test/tsconfig.json" },
122123
]
123124
}

x-pack/plugins/telemetry_collection_xpack/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"include": [
1212
"common/**/*",
1313
"server/**/*",
14-
"../../../typings/*"
14+
"../../../typings/*",
15+
"schema/xpack_monitoring.json",
16+
"schema/xpack_plugins.json",
17+
"schema/xpack_root.json",
1518
],
1619
"references": [
1720
{ "path": "../../../src/core/tsconfig.json" },

x-pack/test/functional/page_objects/account_settings_page.ts

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,30 @@
66
*/
77

88
import expect from '@kbn/expect';
9-
import { FtrProviderContext } from '../ftr_provider_context';
9+
import { FtrService } from '../ftr_provider_context';
1010

11-
export function AccountSettingProvider({ getService }: FtrProviderContext) {
12-
const testSubjects = getService('testSubjects');
13-
const userMenu = getService('userMenu');
11+
export class AccountSettingsPageObject extends FtrService {
12+
private readonly testSubjects = this.ctx.getService('testSubjects');
13+
private readonly userMenu = this.ctx.getService('userMenu');
1414

15-
class AccountSettingsPage {
16-
async verifyAccountSettings(expectedEmail: string, expectedUserName: string) {
17-
await userMenu.clickProvileLink();
15+
async verifyAccountSettings(expectedEmail: string, expectedUserName: string) {
16+
await this.userMenu.clickProvileLink();
1817

19-
const usernameField = await testSubjects.find('username');
20-
const userName = await usernameField.getVisibleText();
21-
expect(userName).to.be(expectedUserName);
18+
const usernameField = await this.testSubjects.find('username');
19+
const userName = await usernameField.getVisibleText();
20+
expect(userName).to.be(expectedUserName);
2221

23-
const emailIdField = await testSubjects.find('email');
24-
const emailField = await emailIdField.getVisibleText();
25-
expect(emailField).to.be(expectedEmail);
26-
await userMenu.closeMenu();
27-
}
22+
const emailIdField = await this.testSubjects.find('email');
23+
const emailField = await emailIdField.getVisibleText();
24+
expect(emailField).to.be(expectedEmail);
25+
await this.userMenu.closeMenu();
26+
}
2827

29-
async changePassword(currentPassword: string, newPassword: string) {
30-
await testSubjects.setValue('currentPassword', currentPassword);
31-
await testSubjects.setValue('newPassword', newPassword);
32-
await testSubjects.setValue('confirmNewPassword', newPassword);
33-
await testSubjects.click('changePasswordButton');
34-
await testSubjects.existOrFail('passwordUpdateSuccess');
35-
}
28+
async changePassword(currentPassword: string, newPassword: string) {
29+
await this.testSubjects.setValue('currentPassword', currentPassword);
30+
await this.testSubjects.setValue('newPassword', newPassword);
31+
await this.testSubjects.setValue('confirmNewPassword', newPassword);
32+
await this.testSubjects.click('changePasswordButton');
33+
await this.testSubjects.existOrFail('passwordUpdateSuccess');
3634
}
37-
return new AccountSettingsPage();
3835
}

x-pack/test/functional/page_objects/banners_page.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,22 @@
55
* 2.0.
66
*/
77

8-
import { FtrProviderContext } from '../ftr_provider_context';
8+
import { FtrService } from '../ftr_provider_context';
99

10-
export function BannersPageProvider({ getService }: FtrProviderContext) {
11-
const find = getService('find');
10+
export class BannersPageObject extends FtrService {
11+
private readonly find = this.ctx.getService('find');
1212

13-
class BannersPage {
14-
isTopBannerVisible() {
15-
return find.existsByCssSelector('.header__topBanner .kbnUserBanner__container');
16-
}
13+
isTopBannerVisible() {
14+
return this.find.existsByCssSelector('.header__topBanner .kbnUserBanner__container');
15+
}
1716

18-
async getTopBannerText() {
19-
if (!(await this.isTopBannerVisible())) {
20-
return '';
21-
}
22-
const bannerContainer = await find.byCssSelector(
23-
'.header__topBanner .kbnUserBanner__container'
24-
);
25-
return bannerContainer.getVisibleText();
17+
async getTopBannerText() {
18+
if (!(await this.isTopBannerVisible())) {
19+
return '';
2620
}
21+
const bannerContainer = await this.find.byCssSelector(
22+
'.header__topBanner .kbnUserBanner__container'
23+
);
24+
return bannerContainer.getVisibleText();
2725
}
28-
29-
return new BannersPage();
3026
}

0 commit comments

Comments
 (0)