kibana/test/functional/page_objects/home_page.ts

159 lines
5.2 KiB
TypeScript
Raw Normal View History

/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { FtrService } from '../ftr_provider_context';
export class HomePageObject extends FtrService {
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly retry = this.ctx.getService('retry');
private readonly find = this.ctx.getService('find');
private readonly common = this.ctx.getPageObject('common');
private readonly log = this.ctx.getService('log');
Kibana Home page - phase two (#14749) * add tutorial directory and home promo section * tutorial components * use KuiCodeEditor for displaying instruction code * move spec files to server so joi can be used. Fetch via rest API * Adding more tutorials (#4) * More edits on the Apache logs tutorial * Added nginx, mysql, and sytem modules for FB * Moved apache to apacheLogs and added an apacheMetrics tutorial * Added mysqlMetrics, nginxMetrics, systemMetrics tutorials * Reduce duplication in the tutorials This uses common objects for the install and start steps for Filebeat. Same can be done for MB. * fix windows path for config file * add markdown parsing * use mustache to replace config.kibana.version with kibana version * add image preview to tutorial introduction * fix css class name * add param types constants * add docs variables * [WIP] Logstash Netflow module tutorial (#5) * First draft of Logstash Netflow module tutorial * Incorporated writing style suggestions * pass params to template replace logic * parameter inputs * use isReadOnly flag from ui-framework for KuiCodeEditor * dedemorton commits on netflow * remove trailing slash from base links * add config.docs.logstash and fix vertical spacing between Content component and commands * Use logstash docs config variable * Starting to add Deb instructions * Fix Logstash documentation link * Make commands optional * Refactor: extract common LS instructions * Edits for the existing tutorials * change schema to support three instruction types * [Netflow tutorial] Simplify OSX instructions * replace axios with fetch * pass credentials to tutorial fetch * display cloud instructions when cloud set * RadioButtonGroup component * update copy * add tutorial component jest tests * content component test * load isCloudEnabled in home_app * add functional test ensuring add data tutorials are fetch and displayed * rename card btns to 'Add data', fix type in tutorial directory tab, remove 'Set up index pattern from tutorial directory' * move parameters form to right of instruction set title * add copy snippet button, remove line numbers from command block * add breadcrumb to tutorial view * update tutorial jest snapshot * use componentDidMount and ignore async results if componenent has been unmounted * define shape of prop for instructionVariants and params. Create NumberParameter and StringParameter components * add bread crumb to add data directory page * Add cloud version of the apache_logs tutorial (#16) * Add cloud version of the apache_logs tutorial * Added onprem-cloud version as well * fix styling broken by EUI rebase * add artifacts to tutorial schema * fix styling for code block * [Tutorials] Netflow: instructions for onPremCloud (#18) * Extract common on-prem cloud instructions so LS and Beats can share them * Extracting common instructions; adding onPremCloud instructions * fix copy bug where copy would only contain previously selected text * make string parameter input type be text * Implementing Elastic Cloud tutorial for Netflow module (#19) * More tutorial edits (#20) * More tutorial edits This updates the on prem instructions with a step that installs the GeoIP and UA plugins in ES. It also makes the on-prem steps more consistent with the cloud instructions which results in less redundancy in the code. * Show config step for all variants * More DRY in the tutorial content * Updated screenshot for apache_logs * wrap markdown content in markdown-body class * use EuiFlexGroup to remove wasted space with 'copy snippet' button and instruction text * change OSX to macOS, use Computed property names for instruction_variant DISPLAY_MAP, replace /app/kibana with kbnBaseUrl, remove unneeded if check in copy_to_clippboard, put getTutorials mixin on server instead of request * capitilize 'C' in Elastic Cloud * remove try/catch from copy_to_clipboard * Removing unrelated instructions * Copy editing fixes * Multiply edits to the Beats tutorials (#21) * Updated Nginx module * Updated MySQL logs module * Updated system logs module * Correct the on_prem_cloud enable steps * Updated the Nginx metrics tutorial and added screenshot * Updated the Apache metrics module + screenshot * Updated the MySQL metrics module + screenshot * Updated the system metrics module + screenshot * prevent 'Copy snippet' button text from wrapping * [Netflow tutorial] Windows instructions (#22) * [Netflow tutorial] Adding onPrem instructions for Windows * Removing unrelated/superfluous instructions * Adding Windows instructions for onPremElasticCloud and elasticCloud * use EuiImage so tutorial images are clickable to view in full screen * fix jest tests * set fullScreenIconColor and alt options for EuiImage, add space between command block and instruction text
2018-01-10 15:20:38 +01:00
async clickSynopsis(title: string) {
await this.testSubjects.click(`homeSynopsisLink${title}`);
}
async doesSynopsisExist(title: string) {
return await this.testSubjects.exists(`homeSynopsisLink${title}`);
}
Sample data (#17807) * register list, install, and uninstall endpoints * decorate server with methods needed to register data sets * implement list endpoint, add flights sample data set * stream data file * create sample data index with mappings * bulk insert into elsaticsearch * more loadBulk work * advance time stamp * change http method back to post * delete index on uninstall * last 15 minutes example * add option to preserver day of week and time of day * import saved objects on install and delete saved objects on delete * update uiSetting defaultIndex on install and uninstall * use correct format for saved object json * Adding example sample data, mappings and dashboards * add sample data tab to Add Data page * add launch button * add sample data link to empy index pattern create state * fix jest tests * add toast nofication on success and fail install/uninstall * move uiSettings of defaultIndex to client, clear index patterns get id cache * put link to sample data sets on home page * updated saved objects and data set * add card for sample data * add preview image * updated dashboards and data set * update button text * woops, forgot vega * compress data json file * move flights data file to same folder as saved objects file * add functional tests * updates from chrisdavies review * fix install API call - broken on last commit * fix mistake in create_index_pattern * updates from Stacey-Gammon review * remove delete from install API * add more tests to ensure dashboard renders as expected * better error message on install and uninstall failure * remove checks that may change from run to run to keep functional tests stable * update scripted field to reflect changes in ES * change saved object install/uninstall error code from 500 to 403 * add more logic to check if dataset is installed and display a disabled add button when there is a problem checking status * make add data links be side-by-side on home page * propery handle savedObjectClient bulkCreate errors. Ensure launch dashboard exists in test if dataset is installed * ignore saved object delete 404s since users could have deleted some of the saved objects via the UI * show response error in toast, delete index before trying to create, log create index error
2018-05-24 22:39:07 +02:00
async doesSampleDataSetExist(id: string) {
return await this.testSubjects.exists(`sampleDataSetCard${id}`);
}
Sample data (#17807) * register list, install, and uninstall endpoints * decorate server with methods needed to register data sets * implement list endpoint, add flights sample data set * stream data file * create sample data index with mappings * bulk insert into elsaticsearch * more loadBulk work * advance time stamp * change http method back to post * delete index on uninstall * last 15 minutes example * add option to preserver day of week and time of day * import saved objects on install and delete saved objects on delete * update uiSetting defaultIndex on install and uninstall * use correct format for saved object json * Adding example sample data, mappings and dashboards * add sample data tab to Add Data page * add launch button * add sample data link to empy index pattern create state * fix jest tests * add toast nofication on success and fail install/uninstall * move uiSettings of defaultIndex to client, clear index patterns get id cache * put link to sample data sets on home page * updated saved objects and data set * add card for sample data * add preview image * updated dashboards and data set * update button text * woops, forgot vega * compress data json file * move flights data file to same folder as saved objects file * add functional tests * updates from chrisdavies review * fix install API call - broken on last commit * fix mistake in create_index_pattern * updates from Stacey-Gammon review * remove delete from install API * add more tests to ensure dashboard renders as expected * better error message on install and uninstall failure * remove checks that may change from run to run to keep functional tests stable * update scripted field to reflect changes in ES * change saved object install/uninstall error code from 500 to 403 * add more logic to check if dataset is installed and display a disabled add button when there is a problem checking status * make add data links be side-by-side on home page * propery handle savedObjectClient bulkCreate errors. Ensure launch dashboard exists in test if dataset is installed * ignore saved object delete 404s since users could have deleted some of the saved objects via the UI * show response error in toast, delete index before trying to create, log create index error
2018-05-24 22:39:07 +02:00
async isSampleDataSetInstalled(id: string) {
const sampleDataCard = await this.testSubjects.find(`sampleDataSetCard${id}`);
const sampleDataCardInnerHTML = await sampleDataCard.getAttribute('innerHTML');
this.log.debug(sampleDataCardInnerHTML);
return sampleDataCardInnerHTML.includes('removeSampleDataSet');
}
async isWelcomeInterstitialDisplayed() {
return await this.testSubjects.isDisplayed('homeWelcomeInterstitial');
}
async getVisibileSolutions() {
const solutionPanels = await this.testSubjects.findAll('~homSolutionPanel', 2000);
const panelAttributes = await Promise.all(
solutionPanels.map((panel) => panel.getAttribute('data-test-subj'))
);
return panelAttributes.map((attributeValue) => attributeValue.split('homSolutionPanel_')[1]);
}
Sample data (#17807) * register list, install, and uninstall endpoints * decorate server with methods needed to register data sets * implement list endpoint, add flights sample data set * stream data file * create sample data index with mappings * bulk insert into elsaticsearch * more loadBulk work * advance time stamp * change http method back to post * delete index on uninstall * last 15 minutes example * add option to preserver day of week and time of day * import saved objects on install and delete saved objects on delete * update uiSetting defaultIndex on install and uninstall * use correct format for saved object json * Adding example sample data, mappings and dashboards * add sample data tab to Add Data page * add launch button * add sample data link to empy index pattern create state * fix jest tests * add toast nofication on success and fail install/uninstall * move uiSettings of defaultIndex to client, clear index patterns get id cache * put link to sample data sets on home page * updated saved objects and data set * add card for sample data * add preview image * updated dashboards and data set * update button text * woops, forgot vega * compress data json file * move flights data file to same folder as saved objects file * add functional tests * updates from chrisdavies review * fix install API call - broken on last commit * fix mistake in create_index_pattern * updates from Stacey-Gammon review * remove delete from install API * add more tests to ensure dashboard renders as expected * better error message on install and uninstall failure * remove checks that may change from run to run to keep functional tests stable * update scripted field to reflect changes in ES * change saved object install/uninstall error code from 500 to 403 * add more logic to check if dataset is installed and display a disabled add button when there is a problem checking status * make add data links be side-by-side on home page * propery handle savedObjectClient bulkCreate errors. Ensure launch dashboard exists in test if dataset is installed * ignore saved object delete 404s since users could have deleted some of the saved objects via the UI * show response error in toast, delete index before trying to create, log create index error
2018-05-24 22:39:07 +02:00
async addSampleDataSet(id: string) {
const isInstalled = await this.isSampleDataSetInstalled(id);
if (!isInstalled) {
await this.retry.waitFor('wait until sample data is installed', async () => {
await this.testSubjects.click(`addSampleDataSet${id}`);
await this._waitForSampleDataLoadingAction(id);
return await this.isSampleDataSetInstalled(id);
});
}
}
async removeSampleDataSet(id: string) {
// looks like overkill but we're hitting flaky cases where we click but it doesn't remove
await this.testSubjects.waitForEnabled(`removeSampleDataSet${id}`);
// https://github.com/elastic/kibana/issues/65949
// Even after waiting for the "Remove" button to be enabled we still have failures
// where it appears the click just didn't work.
await this.common.sleep(1010);
await this.testSubjects.click(`removeSampleDataSet${id}`);
await this._waitForSampleDataLoadingAction(id);
}
Sample data (#17807) * register list, install, and uninstall endpoints * decorate server with methods needed to register data sets * implement list endpoint, add flights sample data set * stream data file * create sample data index with mappings * bulk insert into elsaticsearch * more loadBulk work * advance time stamp * change http method back to post * delete index on uninstall * last 15 minutes example * add option to preserver day of week and time of day * import saved objects on install and delete saved objects on delete * update uiSetting defaultIndex on install and uninstall * use correct format for saved object json * Adding example sample data, mappings and dashboards * add sample data tab to Add Data page * add launch button * add sample data link to empy index pattern create state * fix jest tests * add toast nofication on success and fail install/uninstall * move uiSettings of defaultIndex to client, clear index patterns get id cache * put link to sample data sets on home page * updated saved objects and data set * add card for sample data * add preview image * updated dashboards and data set * update button text * woops, forgot vega * compress data json file * move flights data file to same folder as saved objects file * add functional tests * updates from chrisdavies review * fix install API call - broken on last commit * fix mistake in create_index_pattern * updates from Stacey-Gammon review * remove delete from install API * add more tests to ensure dashboard renders as expected * better error message on install and uninstall failure * remove checks that may change from run to run to keep functional tests stable * update scripted field to reflect changes in ES * change saved object install/uninstall error code from 500 to 403 * add more logic to check if dataset is installed and display a disabled add button when there is a problem checking status * make add data links be side-by-side on home page * propery handle savedObjectClient bulkCreate errors. Ensure launch dashboard exists in test if dataset is installed * ignore saved object delete 404s since users could have deleted some of the saved objects via the UI * show response error in toast, delete index before trying to create, log create index error
2018-05-24 22:39:07 +02:00
// loading action is either uninstall and install
async _waitForSampleDataLoadingAction(id: string) {
const sampleDataCard = await this.testSubjects.find(`sampleDataSetCard${id}`);
await this.retry.try(async () => {
// waitForDeletedByCssSelector needs to be inside retry because it will timeout at least once
// before action is complete
await sampleDataCard.waitForDeletedByCssSelector('.euiLoadingSpinner');
});
}
async launchSampleDashboard(id: string) {
await this.launchSampleDataSet(id);
await this.find.clickByLinkText('Dashboard');
}
Sample data (#17807) * register list, install, and uninstall endpoints * decorate server with methods needed to register data sets * implement list endpoint, add flights sample data set * stream data file * create sample data index with mappings * bulk insert into elsaticsearch * more loadBulk work * advance time stamp * change http method back to post * delete index on uninstall * last 15 minutes example * add option to preserver day of week and time of day * import saved objects on install and delete saved objects on delete * update uiSetting defaultIndex on install and uninstall * use correct format for saved object json * Adding example sample data, mappings and dashboards * add sample data tab to Add Data page * add launch button * add sample data link to empy index pattern create state * fix jest tests * add toast nofication on success and fail install/uninstall * move uiSettings of defaultIndex to client, clear index patterns get id cache * put link to sample data sets on home page * updated saved objects and data set * add card for sample data * add preview image * updated dashboards and data set * update button text * woops, forgot vega * compress data json file * move flights data file to same folder as saved objects file * add functional tests * updates from chrisdavies review * fix install API call - broken on last commit * fix mistake in create_index_pattern * updates from Stacey-Gammon review * remove delete from install API * add more tests to ensure dashboard renders as expected * better error message on install and uninstall failure * remove checks that may change from run to run to keep functional tests stable * update scripted field to reflect changes in ES * change saved object install/uninstall error code from 500 to 403 * add more logic to check if dataset is installed and display a disabled add button when there is a problem checking status * make add data links be side-by-side on home page * propery handle savedObjectClient bulkCreate errors. Ensure launch dashboard exists in test if dataset is installed * ignore saved object delete 404s since users could have deleted some of the saved objects via the UI * show response error in toast, delete index before trying to create, log create index error
2018-05-24 22:39:07 +02:00
async launchSampleDataSet(id: string) {
await this.addSampleDataSet(id);
await this.common.closeToastIfExists();
await this.testSubjects.click(`launchSampleDataSet${id}`);
}
async clickAllKibanaPlugins() {
await this.testSubjects.click('allPlugins');
}
async clickVisualizeExplorePlugins() {
await this.testSubjects.click('tab-data');
}
async clickAdminPlugin() {
await this.testSubjects.click('tab-admin');
}
async clickOnConsole() {
await this.clickSynopsis('console');
}
async clickOnLogo() {
await this.testSubjects.click('logo');
}
async clickOnAddData() {
await this.clickSynopsis('home_tutorial_directory');
}
// clicks on Active MQ logs
async clickOnLogsTutorial() {
await this.clickSynopsis('activemqlogs');
}
// clicks on cloud tutorial link
async clickOnCloudTutorial() {
await this.testSubjects.click('onCloudTutorial');
}
// click on global nav toggle button
async clickToggleGlobalNav() {
await this.testSubjects.click('toggleNavButton');
}
async clickGoHome() {
await this.openCollapsibleNav();
await this.testSubjects.click('homeLink');
}
// open global nav if it's closed
async openCollapsibleNav() {
if (!(await this.testSubjects.exists('collapsibleNav'))) {
await this.clickToggleGlobalNav();
}
}
// collapse the observability side nav details
async collapseObservabibilitySideNav() {
await this.testSubjects.click('collapsibleNavGroup-observability');
}
async loadSavedObjects() {
await this.retry.try(async () => {
await this.testSubjects.click('loadSavedObjects');
const successMsgExists = await this.testSubjects.exists('loadSavedObjects_success', {
timeout: 5000,
});
if (!successMsgExists) {
throw new Error('Failed to load saved objects');
}
});
}
}