Skip to content

Commit

Permalink
update nav, unskip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Sep 26, 2023
1 parent a228bf9 commit 9b8651f
Show file tree
Hide file tree
Showing 24 changed files with 156 additions and 40 deletions.
104 changes: 104 additions & 0 deletions x-pack/test_serverless/functional/page_objects/svl_common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { getUrl } from '@kbn/test';
import { FtrProviderContext } from '../ftr_provider_context';

export function SvlCommonPageProvider({ getService, getPageObjects }: FtrProviderContext) {
Expand All @@ -22,6 +23,105 @@ export function SvlCommonPageProvider({ getService, getPageObjects }: FtrProvide
});

return {
async navigateToApp(
appName: string,
{
basePath = '',
shouldLoginIfPrompted = true,
path = '',
hash = '',
search = '',
disableWelcomePrompt = true,
insertTimestamp = true,
retryOnFatalError = true,
} = {}
) {
let appUrl: string;

if (config.has(['apps', appName])) {
// Legacy applications
const appConfig = config.get(['apps', appName]);
appUrl = getUrl.noAuth(config.get('servers.kibana'), {
pathname: `${basePath}${appConfig.pathname}`,
hash: hash || appConfig.hash,
search,
});
} else {
appUrl = getUrl.noAuth(config.get('servers.kibana'), {
pathname: `${basePath}/app/${appName}` + (path ? `/${path}` : ''),
hash,
search,
});
}

log.debug('navigating to ' + appName + ' url: ' + appUrl);

await retry.tryForTime(60_000 * 2, async () => {
let lastUrl = await retry.try(async () => {
// since we're using hash URLs, always reload first to force re-render
log.debug('navigate to: ' + appUrl);
await browser.get(appUrl, insertTimestamp);
// accept alert if it pops up
const alert = await browser.getAlert();
await alert?.accept();
await delay(700);
let currentUrl = await browser.getCurrentUrl();

if (currentUrl.includes('app/kibana')) {
await testSubjects.find('kibanaChrome');
}

// If navigating to the `home` app, and we want to skip the Welcome page, but the chrome is still hidden,
// set the relevant localStorage key to skip the Welcome page and throw an error to try to navigate again.
// if (
// appName === 'home' &&
// currentUrl.includes('app/home') &&
// disableWelcomePrompt &&
// (await this.isWelcomeScreen())
// ) {
// await this.browser.setLocalStorageItem('home:welcome:show', 'false');
// const msg = `Failed to skip the Welcome page when navigating the app ${appName}`;
// this.log.debug(msg);
// throw new Error(msg);
// }

currentUrl = (await browser.getCurrentUrl()).replace(/\/\/\w+:\w+@/, '//');

const navSuccessful = currentUrl
.replace(':80/', '/')
.replace(':443/', '/')
.startsWith(appUrl.replace(':80/', '/').replace(':443/', '/'));

if (!navSuccessful) {
const msg = `App failed to load: ${appName} in 60000 ms appUrl=${appUrl} currentUrl=${currentUrl}`;
log.debug(msg);
throw new Error(msg);
}

if (retryOnFatalError && (await pageObjects.common.isFatalErrorScreen())) {
const msg = `Fatal error screen shown. Let's try refreshing the page once more.`;
log.debug(msg);
throw new Error(msg);
}

if (appName === 'discover') {
await browser.setLocalStorageItem('data.autocompleteFtuePopover', 'true');
}
return currentUrl;
});

await retry.tryForTime(60_000, async () => {
await delay(501);
const currentUrl = await browser.getCurrentUrl();
log.debug('in navigateTo url = ' + currentUrl);
if (lastUrl !== currentUrl) {
lastUrl = currentUrl;
throw new Error('URL changed, waiting for it to settle');
}
});
});
},

async navigateToLoginForm() {
const url = deployment.getHostPort() + '/login';
await browser.get(url);
Expand Down Expand Up @@ -53,6 +153,10 @@ export function SvlCommonPageProvider({ getService, getPageObjects }: FtrProvide
await testSubjects.click('loginSubmit');
}

await testSubjects.existOrFail('userMenuButton', { timeout: 10_000 });
await delay(2000);
await browser.refresh();

if (await testSubjects.exists('userMenuButton', { timeout: 10_000 })) {
log.debug('userMenuButton is found, logged in passed');
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export function SvlCommonNavigationServiceProvider({
}: FtrProviderContext) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
const PageObjects = getPageObjects(['common', 'svlCommonPage']);

return {
async navigateToKibanaHome() {
await retry.tryForTime(60 * 1000, async () => {
await PageObjects.common.navigateToApp('home');
await PageObjects.svlCommonPage.navigateToApp('home');
await testSubjects.existOrFail('homeApp', { timeout: 2000 });
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export function SvlObltNavigationServiceProvider({
}: FtrProviderContext) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
const PageObjects = getPageObjects(['svlCommonPage']);

return {
async navigateToLandingPage() {
await retry.tryForTime(60 * 1000, async () => {
await PageObjects.common.navigateToApp('landingPage');
await PageObjects.svlCommonPage.navigateToApp('landingPage');
await testSubjects.existOrFail('obltOnboardingHomeTitle', { timeout: 2000 });
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export function SvlSearchNavigationServiceProvider({
getPageObjects,
}: FtrProviderContext) {
const retry = getService('retry');
const PageObjects = getPageObjects(['common']);
const PageObjects = getPageObjects(['svlCommonPage']);

return {
async navigateToLandingPage() {
await retry.tryForTime(60 * 1000, async () => {
await PageObjects.common.navigateToApp('landingPage');
await PageObjects.svlCommonPage.navigateToApp('landingPage');
// The getting started page is currently empty, so there's nothing we could
// assert on. Once something exists here, we should add back a check.
// await testSubjects.existOrFail('svlSearchOverviewPage', { timeout: 2000 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export function SvlSecNavigationServiceProvider({
}: FtrProviderContext) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
const PageObjects = getPageObjects(['svlCommonPage']);

return {
async navigateToLandingPage() {
await retry.tryForTime(60 * 1000, async () => {
await PageObjects.common.navigateToApp('landingPage');
await PageObjects.svlCommonPage.navigateToApp('landingPage');
// Currently, the security landing page app is not loading correctly.
// Replace '~kbnAppWrapper' with a proper test subject of the landing
// page once it loads successfully.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const testSubjects = getService('testSubjects');
const pageObjects = getPageObjects(['common']);
const pageObjects = getPageObjects(['svlCommonPage']);
const browser = getService('browser');
const retry = getService('retry');

// Skip until we enable the Advanced settings app in serverless
describe.skip('Common advanced settings', function () {
before(async () => {
await pageObjects.common.navigateToApp('advancedSettings');
await pageObjects.svlCommonPage.navigateToApp('advancedSettings');
});

it('renders the page', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid
);

// TODO: Navigation to Data View Management is different in Serverless
await PageObjects.common.navigateToApp('management');
await PageObjects.svlCommonPage.navigateToApp('management');
await retry.waitFor('data views link', async () => {
if (await testSubjects.exists('app-card-dataViews')) {
await testSubjects.click('app-card-dataViews');
Expand All @@ -56,7 +56,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid
return false;
});
await PageObjects.settings.createIndexPattern('blogs', null);
await PageObjects.common.navigateToApp('dataViewFieldEditorExample');
await PageObjects.svlCommonPage.navigateToApp('dataViewFieldEditorExample');
});

loadTestFile(require.resolve('./data_view_field_editor_example'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
await kibanaServer.uiSettings.replace(defaultSettings);
await PageObjects.common.navigateToApp('home');
await PageObjects.svlCommonPage.navigateToApp('home');
const currentUrl = await browser.getCurrentUrl();
const customizationUrl =
currentUrl.substring(0, currentUrl.indexOf('/app/home')) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
before(async () => {
// TODO: Serverless tests require login first
await PageObjects.svlCommonPage.login();
await PageObjects.common.navigateToApp('fieldFormatsExample');
await PageObjects.svlCommonPage.navigateToApp('fieldFormatsExample');
});

it('renders field formats example 1', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
before(async () => {
// TODO: Serverless tests require login first
await PageObjects.svlCommonPage.login();
await PageObjects.common.navigateToApp('partialResultsExample');
await PageObjects.svlCommonPage.navigateToApp('partialResultsExample');

const element = await testSubjects.find('example-help');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'timepicker:timeDefaults': '{ "from": "now-1y", "to": "now" }',
});

await PageObjects.common.navigateToApp('searchExamples');
await PageObjects.svlCommonPage.navigateToApp('searchExamples');
});

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import type { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
const PageObjects = getPageObjects(['svlCommonPage']);
const retry = getService('retry');

// FLAKY: https://github.com/elastic/kibana/issues/165763
describe.skip('Partial results example', () => {
describe('Partial results example', () => {
before(async () => {
await PageObjects.common.navigateToApp('searchExamples');
await PageObjects.svlCommonPage.navigateToApp('searchExamples');
await testSubjects.click('/search');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

function testSearchExample() {
before(async function () {
await PageObjects.common.navigateToApp(appId, { insertTimestamp: false });
await PageObjects.svlCommonPage.navigateToApp(appId, { insertTimestamp: false });
await comboBox.setCustom('dataViewSelector', 'logstash-*');
await comboBox.set('searchBucketField', 'geo.src');
await comboBox.set('searchMetricField', 'memory');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const monacoEditor = getService('monacoEditor');
const PageObjects = getPageObjects(['common', 'timePicker', 'header', 'unifiedFieldList']);
const PageObjects = getPageObjects([
'common',
'timePicker',
'header',
'unifiedFieldList',
'svlCommonPage',
]);
const dataViewTitle = 'existence_index_*';

async function addDSLFilter(value: string) {
Expand All @@ -53,15 +59,15 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {

// Failing: See https://github.com/elastic/kibana/issues/165938
// Failing: See https://github.com/elastic/kibana/issues/165927
describe.skip('Fields existence info', () => {
describe('Fields existence info', () => {
before(async () => {
await esArchiver.load(
'test/api_integration/fixtures/es_archiver/index_patterns/constant_keyword'
);
await kibanaServer.importExport.load(
'test/api_integration/fixtures/kbn_archiver/index_patterns/constant_keyword.json'
);
await PageObjects.common.navigateToApp('unifiedFieldListExamples');
await PageObjects.svlCommonPage.navigateToApp('unifiedFieldListExamples');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.waitFor('combobox is ready', async () => {
return await testSubjects.exists('dataViewSelector');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ const TEST_START_TIME = 'Sep 19, 2015 @ 06:31:44.000';
const TEST_END_TIME = 'Sep 23, 2015 @ 18:31:44.000';

export default ({ getService, getPageObjects }: FtrProviderContext) => {
const PageObjects = getPageObjects(['common', 'timePicker', 'header', 'unifiedFieldList']);
const PageObjects = getPageObjects([
'common',
'timePicker',
'header',
'unifiedFieldList',
'svlCommonPage',
]);
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const comboBox = getService('comboBox');
Expand All @@ -22,7 +28,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
const dataViewTitle = 'logstash-2015.09.22';

// FLAKY: https://github.com/elastic/kibana/issues/165882
describe.skip('Field stats', () => {
describe('Field stats', () => {
before(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
Expand All @@ -34,7 +40,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
await esArchiver.loadIfNeeded(
'x-pack/test_serverless/functional/es_archives/pre_calculated_histogram'
);
await PageObjects.common.navigateToApp('unifiedFieldListExamples');
await PageObjects.svlCommonPage.navigateToApp('unifiedFieldListExamples');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.waitFor('combobox is ready', async () => {
return await testSubjects.exists('dataViewSelector');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await log.debug('Navigating to the enrich policies tab');
await pageObjects.svlCommonPage.login();
await security.testUser.setRoles(['index_management_user']);
await pageObjects.common.navigateToApp('indexManagement');
await pageObjects.svlCommonPage.navigateToApp('indexManagement');

// Navigate to the enrich policies tab
await pageObjects.indexManagement.changeTabs('enrich_policiesTab');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await security.testUser.setRoles(['index_management_user']);
// Navigate to the index management page
await pageObjects.svlCommonPage.login();
await pageObjects.common.navigateToApp('indexManagement');
await pageObjects.svlCommonPage.navigateToApp('indexManagement');
// Navigate to the index templates tab
await pageObjects.indexManagement.changeTabs('templatesTab');
await pageObjects.header.waitUntilLoadingHasFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await security.testUser.setRoles(['index_management_user']);
// Navigate to the index management page
await pageObjects.svlCommonPage.login();
await pageObjects.common.navigateToApp('indexManagement');
await pageObjects.svlCommonPage.navigateToApp('indexManagement');
// Navigate to the indices tab
await pageObjects.indexManagement.changeTabs('indicesTab');
await pageObjects.header.waitUntilLoadingHasFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const testSubjects = getService('testSubjects');
const pageObjects = getPageObjects(['common']);
const pageObjects = getPageObjects(['common', 'svlCommonPage']);
const browser = getService('browser');
const retry = getService('retry');

// Skip until we enable the Advanced settings app in serverless
describe.skip('Observability advanced settings', function () {
before(async () => {
await pageObjects.common.navigateToApp('advancedSettings');
await pageObjects.svlCommonPage.navigateToApp('advancedSettings');
});

it('renders the page', async () => {
Expand Down
Loading

0 comments on commit 9b8651f

Please sign in to comment.