Skip to content

Commit

Permalink
fixup! [Kibana Overview] Shift SCSS import and lazy-load main compone…
Browse files Browse the repository at this point in the history
…nt (#204661)
  • Loading branch information
mykolaharmash committed Jan 3, 2025
1 parent 5930917 commit 12b2204
Show file tree
Hide file tree
Showing 6 changed files with 473 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import {
test as base,
PageObjects,
createLazyPageObject,
ScoutTestFixtures,
ScoutWorkerFixtures,
KibanaUrl,
KbnClient,
} from '@kbn/scout';
import { OnboardingHomePage } from './page_objects';
import { CustomLogsPage } from './page_objects/custom_logs';

export interface ExtendedScoutTestFixtures extends ScoutTestFixtures {
pageObjects: PageObjects & {
onboardingHomePage: OnboardingHomePage;
customLogsPage: CustomLogsPage;
};
}

export const test = base.extend<ExtendedScoutTestFixtures, ScoutWorkerFixtures>({
pageObjects: async (
{
pageObjects,
page,
kbnUrl,
kbnClient,
}: {
pageObjects: ExtendedScoutTestFixtures['pageObjects'];
page: ExtendedScoutTestFixtures['page'];
kbnUrl: KibanaUrl;
kbnClient: KbnClient;
},
use: (pageObjects: ExtendedScoutTestFixtures['pageObjects']) => Promise<void>
) => {
const extendedPageObjects = {
...pageObjects,
onboardingHomePage: createLazyPageObject(OnboardingHomePage, page),
customLogsPage: createLazyPageObject(CustomLogsPage, page, kbnUrl, kbnClient),
};

await use(extendedPageObjects);
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ScoutPage, KibanaUrl, KbnClient } from '@kbn/scout';

export class CustomLogsPage {
constructor(
private readonly page: ScoutPage,
private readonly kbnUrl: KibanaUrl,
private readonly kbnClient: KbnClient
) {}

async goto() {
this.page.goto(`${this.kbnUrl.app('observabilityOnboarding')}/customLogs`);
}

async clickBackButton() {
await this.page.testSubj.click('observabilityOnboardingFlowBackToSelectionButton');
}

logFilePathList() {
return this.page.locator(`[data-test-subj^=obltOnboardingLogFilePath-]`);
}

logFilePathInput(index: number) {
return this.page.testSubj.locator(`obltOnboardingLogFilePath-${index}`).getByRole('textbox');
}

continueButton() {
return this.page.testSubj.locator('obltOnboardingCustomLogsContinue');
}

addLogFilePathButton() {
return this.page.testSubj.locator('obltOnboardingCustomLogsAddFilePath');
}

logFilePathDeleteButton(index: number) {
return this.page.testSubj.locator(`obltOnboardingLogFilePathDelete-${index}`);
}

integrationNameInput() {
return this.page.testSubj.locator('obltOnboardingCustomLogsIntegrationsName');
}

datasetNameInput() {
return this.page.testSubj.locator('obltOnboardingCustomLogsDatasetName');
}

serviceNameInput() {
return this.page.testSubj.locator('obltOnboardingCustomLogsServiceName');
}

async clickAdvancedSettingsButton() {
return this.page.testSubj
.locator('obltOnboardingCustomLogsAdvancedSettings')
.getByRole('button')
.first()
.click();
}

namespaceInput() {
return this.page.testSubj.locator('obltOnboardingCustomLogsNamespace');
}

customConfigInput() {
return this.page.testSubj.locator('obltOnboardingCustomLogsCustomConfig');
}

async installCustomIntegration(name: string) {
await this.kbnClient.request({
method: 'POST',
path: `/api/fleet/epm/custom_integrations`,
body: {
force: true,
integrationName: name,
datasets: [
{ name: `${name}.access`, type: 'logs' },
{ name: `${name}.error`, type: 'metrics' },
{ name: `${name}.warning`, type: 'logs' },
],
},
});
}

async deleteIntegration(name: string) {
const packageInfo = await this.kbnClient.request<{ item: { status: string } }>({
method: 'GET',
path: `/api/fleet/epm/packages/${name}`,
ignoreErrors: [404],
});

if (packageInfo.data.item?.status === 'installed') {
await this.kbnClient.request({
method: 'DELETE',
path: `/api/fleet/epm/packages/${name}`,
});
}
}

customIntegrationErrorCallout() {
return this.page.testSubj.locator('obltOnboardingCustomIntegrationErrorCallout');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export { OnboardingHomePage } from './onboarding_home';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ScoutPage } from '@kbn/scout';

export class OnboardingHomePage {
constructor(private readonly page: ScoutPage) {}

async goto() {
this.page.gotoApp('observabilityOnboarding');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { createPlaywrightConfig } from '@kbn/scout';

// eslint-disable-next-line import/no-default-export
export default createPlaywrightConfig({
testDir: './tests',
});
Loading

0 comments on commit 12b2204

Please sign in to comment.