[pageObjects/welcome] automatically disable on navigation (#28792)
* [pageObjects/welcome] automatically disable on navigation * [pageObjects/welcome] disable on beforeTests to not slow down navigation * [ftr/services/welcome] also disable welcome after logout * [ftr/services/welcome] revist home after disabling welcome
This commit is contained in:
parent
31cd2bc370
commit
3bea7a31d5
7 changed files with 58 additions and 34 deletions
|
@ -32,7 +32,7 @@ import {
|
|||
PointSeriesPageProvider,
|
||||
VisualBuilderPageProvider,
|
||||
TimelionPageProvider,
|
||||
SharePageProvider
|
||||
SharePageProvider,
|
||||
} from './page_objects';
|
||||
|
||||
import {
|
||||
|
@ -57,6 +57,7 @@ import {
|
|||
BrowserProvider,
|
||||
InspectorProvider,
|
||||
PieChartProvider,
|
||||
WelcomeProvider,
|
||||
} from './services';
|
||||
|
||||
export default async function ({ readConfigFile }) {
|
||||
|
@ -119,6 +120,7 @@ export default async function ({ readConfigFile }) {
|
|||
browser: BrowserProvider,
|
||||
pieChart: PieChartProvider,
|
||||
inspector: InspectorProvider,
|
||||
welcome: WelcomeProvider,
|
||||
},
|
||||
servers: commonConfig.get('servers'),
|
||||
|
||||
|
|
|
@ -75,18 +75,6 @@ export function HomePageProvider({ getService }) {
|
|||
await testSubjects.click(`launchSampleDataSet${id}`);
|
||||
}
|
||||
|
||||
// When logging into a brand new Kibana instance, the welcome screen
|
||||
// may pop up. It may not, depending on the speed of the test, so it
|
||||
// pays to check for the welcome screen and hide it in any test that
|
||||
// hits the Kibana home page.
|
||||
isWelcomeShowing() {
|
||||
return testSubjects.exists('skipWelcomeScreen');
|
||||
}
|
||||
|
||||
async hideWelcomeScreen() {
|
||||
await testSubjects.click('skipWelcomeScreen');
|
||||
}
|
||||
|
||||
async loadSavedObjects() {
|
||||
await retry.try(async () => {
|
||||
await testSubjects.click('loadSavedObjects');
|
||||
|
|
|
@ -230,6 +230,18 @@ export function BrowserProvider({ getService }) {
|
|||
return await leadfoot.getAllWindowHandles(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value in local storage for the focused window/frame.
|
||||
* https://theintern.io/leadfoot/module-leadfoot_Session.html#setLocalStorageItem
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {string} value
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async setLocalStorageItem(key, value) {
|
||||
await leadfoot.setLocalStorageItem(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the currently focused window. In most environments, after the window has been
|
||||
* closed, it is necessary to explicitly switch to whatever window is now focused.
|
||||
|
|
|
@ -33,6 +33,7 @@ export { RenderableProvider } from './renderable';
|
|||
export { TableProvider } from './table';
|
||||
export { BrowserProvider } from './browser';
|
||||
export { InspectorProvider } from './inspector';
|
||||
export { WelcomeProvider } from './welcome';
|
||||
|
||||
export * from './visualizations';
|
||||
export * from './dashboard';
|
||||
|
|
38
test/functional/services/welcome.js
Normal file
38
test/functional/services/welcome.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export async function WelcomeProvider({ getService, getPageObjects }) {
|
||||
const browser = getService('browser');
|
||||
const lifecycle = getService('lifecycle');
|
||||
const PageObjects = getPageObjects(['common']);
|
||||
|
||||
const welcome = new class Welcome {
|
||||
async disable() {
|
||||
await browser.setLocalStorageItem('home:welcome:show', 'false');
|
||||
}
|
||||
};
|
||||
|
||||
lifecycle.on('beforeTests', async () => {
|
||||
await PageObjects.common.navigateToApp('home');
|
||||
await welcome.disable();
|
||||
await PageObjects.common.navigateToApp('home');
|
||||
});
|
||||
|
||||
return welcome;
|
||||
}
|
|
@ -15,6 +15,7 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
|
|||
const kibanaServer = getService('kibanaServer');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const welcome = getService('welcome');
|
||||
const PageObjects = getPageObjects(['common', 'header', 'settings', 'home']);
|
||||
|
||||
class LoginPage {
|
||||
|
@ -87,25 +88,12 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
|
|||
async logout() {
|
||||
log.debug('SecurityPage.logout');
|
||||
|
||||
const [isWelcomeShowing, logoutLinkExists] = await Promise.all([
|
||||
PageObjects.home.isWelcomeShowing(),
|
||||
find.existsByLinkText('Logout'),
|
||||
]);
|
||||
|
||||
const logoutLinkExists = await find.existsByLinkText('Logout');
|
||||
if (!logoutLinkExists) {
|
||||
log.debug('Logout not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// This sometimes happens when hitting the home screen on a brand new / empty
|
||||
// Kibana instance. It may not *always* happen, depending on how
|
||||
// long it takes the home screen to query Elastic to see if it's a
|
||||
// new Kibana instance.
|
||||
if (isWelcomeShowing) {
|
||||
log.debug('welcome screen showing when attempting logout');
|
||||
await PageObjects.home.hideWelcomeScreen();
|
||||
}
|
||||
|
||||
await find.clickByLinkText('Logout');
|
||||
|
||||
await retry.try(async () => {
|
||||
|
@ -120,6 +108,8 @@ export function SecurityPageProvider({ getService, getPageObjects }) {
|
|||
throw new Error('Logout is not completed yet');
|
||||
}
|
||||
});
|
||||
|
||||
await welcome.disable();
|
||||
}
|
||||
|
||||
async clickRolesSection() {
|
||||
|
|
|
@ -30,7 +30,6 @@ export function SpaceSelectorPageProvider({ getService, getPageObjects }) {
|
|||
async expectHomePage(spaceId) {
|
||||
return await retry.try(async () => {
|
||||
log.debug(`expectHomePage(${spaceId})`);
|
||||
await this.dismissWelcomeScreen();
|
||||
await find.byCssSelector('[data-test-subj="kibanaChrome"] nav:not(.ng-hide) ', 20000);
|
||||
const url = await browser.getCurrentUrl();
|
||||
if (spaceId === 'default') {
|
||||
|
@ -41,12 +40,6 @@ export function SpaceSelectorPageProvider({ getService, getPageObjects }) {
|
|||
});
|
||||
}
|
||||
|
||||
async dismissWelcomeScreen() {
|
||||
if (await PageObjects.home.isWelcomeShowing()) {
|
||||
await PageObjects.home.hideWelcomeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
async openSpacesNav() {
|
||||
log.debug('openSpacesNav()');
|
||||
return await testSubjects.click('spacesNavSelector');
|
||||
|
|
Loading…
Reference in a new issue