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

[ts] migrate x-pack/test to composite ts project #101441

Merged
merged 6 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion src/plugins/telemetry/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
"declarationMap": true,
"isolatedModules": true
},
"include": ["public/**/**/*", "server/**/**/*", "common/**/*", "../../../typings/**/*"],
"include": [
"public/**/**/*",
"server/**/**/*",
"common/**/*",
"../../../typings/**/*",
"schema/oss_plugins.json",
"schema/oss_root.json",
],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../../plugins/kibana_react/tsconfig.json" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@
* Side Public License, v 1.
*/

const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded', 'unload', 'emptyKibanaIndex'];
import type { ProvidedType } from '@kbn/test';

import type { EsArchiverProvider } from '../es_archiver';
import type { RetryService } from '../retry';
import type { KibanaServerProvider } from './kibana_server';

const ES_ARCHIVER_LOAD_METHODS = ['load', 'loadIfNeeded', 'unload', 'emptyKibanaIndex'] as const;
const KIBANA_INDEX = '.kibana';

export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults }) {
interface Options {
esArchiver: ProvidedType<typeof EsArchiverProvider>;
kibanaServer: ProvidedType<typeof KibanaServerProvider>;
retry: RetryService;
defaults: Record<string, any>;
}

export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults }: Options) {
// only extend the esArchiver if there are default uiSettings to restore
if (!defaults) {
return;
Expand All @@ -18,9 +31,9 @@ export function extendEsArchiver({ esArchiver, kibanaServer, retry, defaults })
ES_ARCHIVER_LOAD_METHODS.forEach((method) => {
const originalMethod = esArchiver[method];

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

const statsKeys = Object.keys(stats);
const kibanaKeys = statsKeys.filter(
Expand Down
1 change: 0 additions & 1 deletion test/common/services/kibana_server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/

export { KibanaServerProvider } from './kibana_server';
// @ts-ignore
export { extendEsArchiver } from './extend_es_archiver';
6 changes: 5 additions & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"include": [
"**/*",
"../typings/**/*",
"../packages/kbn-test/types/ftr_globals/**/*"
"../packages/kbn-test/types/ftr_globals/**/*",
"api_integration/apis/logstash/pipeline/fixtures/*.json",
"api_integration/apis/logstash/pipelines/fixtures/*.json",
"api_integration/apis/telemetry/fixtures/*.json",
"api_integration/apis/telemetry/fixtures/*.json",
],
"exclude": ["target/**/*", "plugin_functional/plugins/**/*", "interpreter_functional/plugins/**/*"],
"references": [
Expand Down
1 change: 1 addition & 0 deletions tsconfig.refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@
{ "path": "./x-pack/plugins/index_lifecycle_management/tsconfig.json" },
{ "path": "./x-pack/plugins/uptime/tsconfig.json" },
{ "path": "./x-pack/plugins/xpack_legacy/tsconfig.json" },
{ "path": "./x-pack/test/tsconfig.json" },
]
}
5 changes: 4 additions & 1 deletion x-pack/plugins/telemetry_collection_xpack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"include": [
"common/**/*",
"server/**/*",
"../../../typings/*"
"../../../typings/*",
"schema/xpack_monitoring.json",
"schema/xpack_plugins.json",
"schema/xpack_root.json",
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
Expand Down
43 changes: 20 additions & 23 deletions x-pack/test/functional/page_objects/account_settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,30 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';
import { FtrService } from '../ftr_provider_context';

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

class AccountSettingsPage {
async verifyAccountSettings(expectedEmail: string, expectedUserName: string) {
await userMenu.clickProvileLink();
async verifyAccountSettings(expectedEmail: string, expectedUserName: string) {
await this.userMenu.clickProvileLink();

const usernameField = await testSubjects.find('username');
const userName = await usernameField.getVisibleText();
expect(userName).to.be(expectedUserName);
const usernameField = await this.testSubjects.find('username');
const userName = await usernameField.getVisibleText();
expect(userName).to.be(expectedUserName);

const emailIdField = await testSubjects.find('email');
const emailField = await emailIdField.getVisibleText();
expect(emailField).to.be(expectedEmail);
await userMenu.closeMenu();
}
const emailIdField = await this.testSubjects.find('email');
const emailField = await emailIdField.getVisibleText();
expect(emailField).to.be(expectedEmail);
await this.userMenu.closeMenu();
}

async changePassword(currentPassword: string, newPassword: string) {
await testSubjects.setValue('currentPassword', currentPassword);
await testSubjects.setValue('newPassword', newPassword);
await testSubjects.setValue('confirmNewPassword', newPassword);
await testSubjects.click('changePasswordButton');
await testSubjects.existOrFail('passwordUpdateSuccess');
}
async changePassword(currentPassword: string, newPassword: string) {
await this.testSubjects.setValue('currentPassword', currentPassword);
await this.testSubjects.setValue('newPassword', newPassword);
await this.testSubjects.setValue('confirmNewPassword', newPassword);
await this.testSubjects.click('changePasswordButton');
await this.testSubjects.existOrFail('passwordUpdateSuccess');
}
return new AccountSettingsPage();
}
30 changes: 13 additions & 17 deletions x-pack/test/functional/page_objects/banners_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@
* 2.0.
*/

import { FtrProviderContext } from '../ftr_provider_context';
import { FtrService } from '../ftr_provider_context';

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

class BannersPage {
isTopBannerVisible() {
return find.existsByCssSelector('.header__topBanner .kbnUserBanner__container');
}
isTopBannerVisible() {
return this.find.existsByCssSelector('.header__topBanner .kbnUserBanner__container');
}

async getTopBannerText() {
if (!(await this.isTopBannerVisible())) {
return '';
}
const bannerContainer = await find.byCssSelector(
'.header__topBanner .kbnUserBanner__container'
);
return bannerContainer.getVisibleText();
async getTopBannerText() {
if (!(await this.isTopBannerVisible())) {
return '';
}
const bannerContainer = await this.find.byCssSelector(
'.header__topBanner .kbnUserBanner__container'
);
return bannerContainer.getVisibleText();
}

return new BannersPage();
}
Loading