diff --git a/test/functional/page_objects/vega_chart_page.ts b/test/functional/page_objects/vega_chart_page.ts index b9906911b00f1..019a5df0b1318 100644 --- a/test/functional/page_objects/vega_chart_page.ts +++ b/test/functional/page_objects/vega_chart_page.ts @@ -17,7 +17,6 @@ * under the License. */ -import { Key } from 'selenium-webdriver'; import { FtrProviderContext } from '../ftr_provider_context'; export function VegaChartPageProvider({ @@ -48,10 +47,10 @@ export function VegaChartPageProvider({ await textarea.click(); let repeats = 20; while (--repeats > 0) { - await browser.pressKeys(Key.ARROW_UP); + await browser.pressKeys(browser.keys.ARROW_UP); await common.sleep(50); } - await browser.pressKeys(Key.ARROW_RIGHT); + await browser.pressKeys(browser.keys.ARROW_RIGHT); await browser.pressKeys(text); } diff --git a/x-pack/test/functional/page_objects/accountsetting_page.js b/x-pack/test/functional/page_objects/account_settings_page.ts similarity index 80% rename from x-pack/test/functional/page_objects/accountsetting_page.js rename to x-pack/test/functional/page_objects/account_settings_page.ts index 283199a76a033..b7351b1e1cf22 100644 --- a/x-pack/test/functional/page_objects/accountsetting_page.js +++ b/x-pack/test/functional/page_objects/account_settings_page.ts @@ -4,15 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ -//import { map as mapAsync } from 'bluebird'; import expect from '@kbn/expect'; +import { FtrProviderContext } from '../ftr_provider_context'; -export function AccountSettingProvider({ getService }) { +export function AccountSettingProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const userMenu = getService('userMenu'); class AccountSettingsPage { - async verifyAccountSettings(expectedEmail, expectedUserName) { + async verifyAccountSettings(expectedEmail: string, expectedUserName: string) { await userMenu.clickProvileLink(); const usernameField = await testSubjects.find('username'); @@ -25,7 +25,7 @@ export function AccountSettingProvider({ getService }) { await userMenu.closeMenu(); } - async changePassword(currentPassword, newPassword) { + async changePassword(currentPassword: string, newPassword: string) { await testSubjects.setValue('currentPassword', currentPassword); await testSubjects.setValue('newPassword', newPassword); await testSubjects.setValue('confirmNewPassword', newPassword); diff --git a/x-pack/test/functional/page_objects/gis_page.js b/x-pack/test/functional/page_objects/gis_page.ts similarity index 90% rename from x-pack/test/functional/page_objects/gis_page.js rename to x-pack/test/functional/page_objects/gis_page.ts index dc941570e26d8..072767e57ab7e 100644 --- a/x-pack/test/functional/page_objects/gis_page.js +++ b/x-pack/test/functional/page_objects/gis_page.ts @@ -6,8 +6,9 @@ import _ from 'lodash'; import { APP_ID } from '../../../plugins/maps/common/constants'; +import { FtrProviderContext } from '../ftr_provider_context'; -export function GisPageProvider({ getService, getPageObjects }) { +export function GisPageProvider({ getService, getPageObjects }: FtrProviderContext) { const PageObjects = getPageObjects(['common', 'header', 'timePicker']); const log = getService('log'); @@ -19,25 +20,27 @@ export function GisPageProvider({ getService, getPageObjects }) { const comboBox = getService('comboBox'); const renderable = getService('renderable'); - function escapeLayerName(layerName) { + function escapeLayerName(layerName: string) { return layerName.split(' ').join('_'); } class GisPage { + basePath: string; + constructor() { this.basePath = ''; } - setBasePath(basePath) { + setBasePath(basePath: string) { this.basePath = basePath; } - async setAbsoluteRange(start, end) { + async setAbsoluteRange(start: string, end: string) { await PageObjects.timePicker.setAbsoluteRange(start, end); await this.waitForLayersToLoad(); } - async setAndSubmitQuery(query) { + async setAndSubmitQuery(query: string) { await queryBar.setQuery(query); await queryBar.submitQuery(); await this.waitForLayersToLoad(); @@ -70,7 +73,7 @@ export function GisPageProvider({ getService, getPageObjects }) { // this method waits until the map view has stabilized, signaling that the panning/zooming is complete. // Pass origView parameter when the new map view determinition is async // so method knows when panning/zooming has started. - async waitForMapPanAndZoom(origView) { + async waitForMapPanAndZoom(origView?: { lon: number; lat: number; zoom: number }) { await retry.try(async () => { log.debug('Waiting for map pan and zoom to complete'); const prevView = await this.getView(); @@ -94,7 +97,7 @@ export function GisPageProvider({ getService, getPageObjects }) { }); } - async waitForLayerDeleted(layerName) { + async waitForLayerDeleted(layerName: string) { log.debug('Wait for layer deleted'); await retry.waitFor('Layer to be deleted', async () => { const doesLayerExist = await this.doesLayerExist(layerName); @@ -104,7 +107,7 @@ export function GisPageProvider({ getService, getPageObjects }) { // use the search filter box to narrow the results down to a single // entry, or at least to a single page of results - async loadSavedMap(name) { + async loadSavedMap(name: string) { log.debug(`Load Saved Map ${name}`); await retry.try(async () => { @@ -121,7 +124,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await this.waitForLayersToLoad(); } - async deleteSavedMaps(search) { + async deleteSavedMaps(search: string) { await this.searchForMapWithName(search); await testSubjects.click('checkboxSelectAll'); await testSubjects.click('deleteSelectedItems'); @@ -139,7 +142,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await renderable.waitForRender(); } - async saveMap(name) { + async saveMap(name: string) { await testSubjects.click('mapSaveButton'); await testSubjects.setValue('savedObjectTitle', name); await testSubjects.clickWhenNotDisabled('confirmSaveSavedObjectButton'); @@ -167,7 +170,7 @@ export function GisPageProvider({ getService, getPageObjects }) { return exists; } - async searchForMapWithName(name) { + async searchForMapWithName(name: string) { log.debug(`searchForMapWithName: ${name}`); await this.gotoMapListingPage(); @@ -183,7 +186,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await PageObjects.header.waitUntilLoadingHasFinished(); } - async selectMap(name) { + async selectMap(name: string) { await testSubjects.click(`mapListingTitleLink-${name.split(' ').join('-')}`); } @@ -208,7 +211,7 @@ export function GisPageProvider({ getService, getPageObjects }) { } } - async getMapCountWithName(name) { + async getMapCountWithName(name: string) { await this.gotoMapListingPage(); log.debug(`getMapCountWithName: ${name}`); @@ -247,7 +250,7 @@ export function GisPageProvider({ getService, getPageObjects }) { } } - async setView(lat, lon, zoom) { + async setView(lat: number, lon: number, zoom: number) { log.debug( `Set view lat: ${lat.toString()}, lon: ${lon.toString()}, zoom: ${zoom.toString()}` ); @@ -273,7 +276,7 @@ export function GisPageProvider({ getService, getPageObjects }) { }; } - async toggleLayerVisibility(layerName) { + async toggleLayerVisibility(layerName: string) { log.debug(`Toggle layer visibility, layer: ${layerName}`); await this.openLayerTocActionsPanel(layerName); await testSubjects.click('layerVisibilityToggleButton'); @@ -287,7 +290,7 @@ export function GisPageProvider({ getService, getPageObjects }) { } } - async clickFitToBounds(layerName) { + async clickFitToBounds(layerName: string) { log.debug(`Fit to bounds, layer: ${layerName}`); const origView = await this.getView(); await this.openLayerTocActionsPanel(layerName); @@ -295,7 +298,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await this.waitForMapPanAndZoom(origView); } - async openLayerTocActionsPanel(layerName) { + async openLayerTocActionsPanel(layerName: string) { const escapedDisplayName = escapeLayerName(layerName); const isOpen = await testSubjects.exists(`layerTocActionsPanel${escapedDisplayName}`); if (!isOpen) { @@ -303,7 +306,7 @@ export function GisPageProvider({ getService, getPageObjects }) { } } - async openLayerPanel(layerName) { + async openLayerPanel(layerName: string) { log.debug(`Open layer panel, layer: ${layerName}`); await this.openLayerTocActionsPanel(layerName); await testSubjects.click('editLayerButton'); @@ -314,7 +317,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await this.waitForLayersToLoad(); } - async getLayerTOCDetails(layerName) { + async getLayerTOCDetails(layerName: string) { return await testSubjects.getVisibleText(`mapLayerTOCDetails${escapeLayerName(layerName)}`); } @@ -339,13 +342,13 @@ export function GisPageProvider({ getService, getPageObjects }) { } } - async doesLayerExist(layerName) { + async doesLayerExist(layerName: string) { return await testSubjects.exists( `layerTocActionsPanelToggleButton${escapeLayerName(layerName)}` ); } - async hasFilePickerLoadedFile(fileName) { + async hasFilePickerLoadedFile(fileName: string) { log.debug(`Has file picker loaded file ${fileName}`); const filePickerText = await find.byCssSelector('.euiFilePicker__promptText'); const filePickerTextContent = await filePickerText.getVisibleText(); @@ -380,7 +383,7 @@ export function GisPageProvider({ getService, getPageObjects }) { }); } - async cancelLayerAdd(layerName) { + async cancelLayerAdd(layerName: string) { log.debug(`Cancel layer add`); const cancelExists = await testSubjects.exists('layerAddCancelButton'); if (cancelExists) { @@ -392,7 +395,7 @@ export function GisPageProvider({ getService, getPageObjects }) { } } - async closeOrCancelLayer(layerName) { + async closeOrCancelLayer(layerName: string) { log.debug(`Close or cancel layer add`); const cancelExists = await testSubjects.exists('layerAddCancelButton'); const closeExists = await testSubjects.exists('layerPanelCancelButton'); @@ -436,24 +439,24 @@ export function GisPageProvider({ getService, getPageObjects }) { await testSubjects.click('importFileButton'); } - async setIndexName(indexName) { + async setIndexName(indexName: string) { log.debug(`Set index name to: ${indexName}`); await testSubjects.setValue('fileUploadIndexNameInput', indexName); } - async setIndexType(indexType) { + async setIndexType(indexType: string) { log.debug(`Set index type to: ${indexType}`); await testSubjects.selectValue('fileImportIndexSelect', indexType); } - async indexTypeOptionExists(indexType) { + async indexTypeOptionExists(indexType: string) { log.debug(`Check index type "${indexType}" available`); return await find.existsByCssSelector( `select[data-test-subj="fileImportIndexSelect"] > option[value="${indexType}"]` ); } - async getCodeBlockParsedJson(dataTestSubjName) { + async getCodeBlockParsedJson(dataTestSubjName: string) { log.debug(`Get parsed code block for ${dataTestSubjName}`); const indexRespCodeBlock = await testSubjects.find(`${dataTestSubjName}`); const indexRespJson = await indexRespCodeBlock.getAttribute('innerText'); @@ -470,7 +473,7 @@ export function GisPageProvider({ getService, getPageObjects }) { return await this.getCodeBlockParsedJson('indexPatternRespCodeBlock'); } - async setLayerQuery(layerName, query) { + async setLayerQuery(layerName: string, query: string) { await this.openLayerPanel(layerName); await testSubjects.click('mapLayerPanelOpenFilterEditorButton'); const filterEditorContainer = await testSubjects.find('mapFilterEditor'); @@ -492,7 +495,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await this.waitForLayersToLoad(); } - async setJoinWhereQuery(layerName, query) { + async setJoinWhereQuery(layerName: string, query: string) { await this.openLayerPanel(layerName); await testSubjects.click('mapJoinWhereExpressionButton'); const filterEditorContainer = await testSubjects.find('mapJoinWhereFilterEditor'); @@ -518,7 +521,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await testSubjects.click('uploadGeoJson'); } - async uploadJsonFileForIndexing(path) { + async uploadJsonFileForIndexing(path: string) { await PageObjects.common.setFileInputPath(path); log.debug(`File selected`); @@ -527,7 +530,7 @@ export function GisPageProvider({ getService, getPageObjects }) { } // Returns first layer by default - async selectVectorLayer(vectorLayerName) { + async selectVectorLayer(vectorLayerName: string) { log.debug(`Select EMS vector layer ${vectorLayerName}`); if (!vectorLayerName) { throw new Error(`You did not provide the EMS layer to select`); @@ -536,14 +539,14 @@ export function GisPageProvider({ getService, getPageObjects }) { await this.waitForLayersToLoad(); } - async removeLayer(layerName) { + async removeLayer(layerName: string) { log.debug(`Remove layer ${layerName}`); await this.openLayerPanel(layerName); await testSubjects.click(`mapRemoveLayerButton`); await this.waitForLayerDeleted(layerName); } - async getLayerErrorText(layerName) { + async getLayerErrorText(layerName: string) { log.debug(`Remove layer ${layerName}`); await this.openLayerPanel(layerName); return await testSubjects.getVisibleText(`layerErrorMessage`); @@ -576,7 +579,7 @@ export function GisPageProvider({ getService, getPageObjects }) { // Method should only be used when multiple requests are expected // RequestSelector will only display inspectorRequestChooser when there is more than one request - async openInspectorRequest(requestName) { + async openInspectorRequest(requestName: string) { await inspector.open(); await inspector.openInspectorRequestsView(); log.debug(`Open Inspector request ${requestName}`); @@ -607,12 +610,12 @@ export function GisPageProvider({ getService, getPageObjects }) { return mapboxStyle; } - getInspectorStatRowHit(stats, rowName) { + getInspectorStatRowHit(stats: string[][], rowName: string) { const STATS_ROW_NAME_INDEX = 0; const STATS_ROW_VALUE_INDEX = 1; - const statsRow = stats.find((statsRow) => { - return statsRow[STATS_ROW_NAME_INDEX] === rowName; + const statsRow = stats.find((row) => { + return row[STATS_ROW_NAME_INDEX] === rowName; }); if (!statsRow) { throw new Error(`Unable to find value for row ${rowName} in ${stats}`); @@ -621,7 +624,7 @@ export function GisPageProvider({ getService, getPageObjects }) { return statsRow[STATS_ROW_VALUE_INDEX]; } - async triggerSingleRefresh(refreshInterval) { + async triggerSingleRefresh(refreshInterval: number) { log.debug(`triggerSingleRefresh, refreshInterval: ${refreshInterval}`); await PageObjects.timePicker.resumeAutoRefresh(); log.debug('waiting to give time for refresh timer to fire'); @@ -630,7 +633,7 @@ export function GisPageProvider({ getService, getPageObjects }) { await this.waitForLayersToLoad(); } - async lockTooltipAtPosition(xOffset, yOffset) { + async lockTooltipAtPosition(xOffset: number, yOffset: number) { await retry.try(async () => { const mapContainerElement = await testSubjects.find('mapContainer'); await mapContainerElement.moveMouseTo({ xOffset, yOffset }); @@ -643,12 +646,12 @@ export function GisPageProvider({ getService, getPageObjects }) { }); } - async setStyleByValue(styleName, fieldName) { + async setStyleByValue(styleName: string, fieldName: string) { await testSubjects.selectValue(`staticDynamicSelect_${styleName}`, 'DYNAMIC'); await comboBox.set(`styleFieldSelect_${styleName}`, fieldName); } - async selectCustomColorRamp(styleName) { + async selectCustomColorRamp(styleName: string) { // open super select menu await testSubjects.click(`colorMapSelect_${styleName}`); // Click option diff --git a/x-pack/test/functional/page_objects/graph_page.ts b/x-pack/test/functional/page_objects/graph_page.ts index fe049327fe38b..5ebfbd2479272 100644 --- a/x-pack/test/functional/page_objects/graph_page.ts +++ b/x-pack/test/functional/page_objects/graph_page.ts @@ -23,7 +23,7 @@ export function GraphPageProvider({ getService, getPageObjects }: FtrProviderCon const find = getService('find'); const log = getService('log'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'header', 'settings']); + const PageObjects = getPageObjects(['common', 'header']); const retry = getService('retry'); class GraphPage { diff --git a/x-pack/test/functional/page_objects/grok_debugger_page.js b/x-pack/test/functional/page_objects/grok_debugger_page.ts similarity index 86% rename from x-pack/test/functional/page_objects/grok_debugger_page.js rename to x-pack/test/functional/page_objects/grok_debugger_page.ts index fec3e9de3c74b..d3edbe6c27e77 100644 --- a/x-pack/test/functional/page_objects/grok_debugger_page.js +++ b/x-pack/test/functional/page_objects/grok_debugger_page.ts @@ -4,7 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -export function GrokDebuggerPageProvider({ getPageObjects, getService }) { +import { FtrProviderContext } from '../ftr_provider_context'; + +export function GrokDebuggerPageProvider({ getPageObjects, getService }: FtrProviderContext) { const PageObjects = getPageObjects(['common']); const grokDebugger = getService('grokDebugger'); diff --git a/x-pack/test/functional/page_objects/index.ts b/x-pack/test/functional/page_objects/index.ts index a630582bbdcc2..c9c00dadd8549 100644 --- a/x-pack/test/functional/page_objects/index.ts +++ b/x-pack/test/functional/page_objects/index.ts @@ -7,30 +7,20 @@ import { pageObjects as kibanaFunctionalPageObjects } from '../../../../test/functional/page_objects'; import { CanvasPageProvider } from './canvas_page'; -// @ts-ignore not ts yet import { SecurityPageProvider } from './security_page'; -// @ts-ignore not ts yet import { MonitoringPageProvider } from './monitoring_page'; // @ts-ignore not ts yet import { LogstashPageProvider } from './logstash_page'; -// @ts-ignore not ts yet import { GraphPageProvider } from './graph_page'; -// @ts-ignore not ts yet import { GrokDebuggerPageProvider } from './grok_debugger_page'; -// @ts-ignore not ts yet import { WatcherPageProvider } from './watcher_page'; import { ReportingPageProvider } from './reporting_page'; -// @ts-ignore not ts yet -import { AccountSettingProvider } from './accountsetting_page'; +import { AccountSettingProvider } from './account_settings_page'; import { InfraHomePageProvider } from './infra_home_page'; import { InfraLogsPageProvider } from './infra_logs_page'; -// @ts-ignore not ts yet import { GisPageProvider } from './gis_page'; -// @ts-ignore not ts yet import { StatusPagePageProvider } from './status_page'; -// @ts-ignore not ts yet -import { UpgradeAssistantProvider } from './upgrade_assistant'; -// @ts-ignore not ts yet +import { UpgradeAssistantPageProvider } from './upgrade_assistant_page'; import { RollupPageProvider } from './rollup_page'; import { UptimePageProvider } from './uptime_page'; import { ApiKeysPageProvider } from './api_keys_page'; @@ -67,7 +57,7 @@ export const pageObjects = { infraLogs: InfraLogsPageProvider, maps: GisPageProvider, statusPage: StatusPagePageProvider, - upgradeAssistant: UpgradeAssistantProvider, + upgradeAssistant: UpgradeAssistantPageProvider, uptime: UptimePageProvider, rollup: RollupPageProvider, apiKeys: ApiKeysPageProvider, diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index 79548db0e2630..6291a9ec9a98b 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -13,14 +13,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont const retry = getService('retry'); const find = getService('find'); const comboBox = getService('comboBox'); - const PageObjects = getPageObjects([ - 'header', - 'common', - 'visualize', - 'dashboard', - 'header', - 'timePicker', - ]); + const PageObjects = getPageObjects(['header', 'header', 'timePicker']); return logWrapper('lensPage', log, { /** diff --git a/x-pack/test/functional/page_objects/monitoring_page.js b/x-pack/test/functional/page_objects/monitoring_page.ts similarity index 84% rename from x-pack/test/functional/page_objects/monitoring_page.js rename to x-pack/test/functional/page_objects/monitoring_page.ts index c3b9d20b3ac4a..bbfa884e71cda 100644 --- a/x-pack/test/functional/page_objects/monitoring_page.js +++ b/x-pack/test/functional/page_objects/monitoring_page.ts @@ -4,8 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -export function MonitoringPageProvider({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['common', 'header', 'security', 'login', 'spaceSelector']); +import { FtrProviderContext } from '../ftr_provider_context'; + +export function MonitoringPageProvider({ getPageObjects, getService }: FtrProviderContext) { + const PageObjects = getPageObjects(['common', 'header', 'security', 'login']); const testSubjects = getService('testSubjects'); const security = getService('security'); const find = getService('find'); @@ -35,34 +37,34 @@ export function MonitoringPageProvider({ getPageObjects, getService }) { return testSubjects.getVisibleText('accessDeniedTitle'); } - async clickBreadcrumb(subj) { + async clickBreadcrumb(subj: string) { return testSubjects.click(subj); } - async assertTableNoData(subj) { + async assertTableNoData(subj: string) { if (!(await testSubjects.exists(subj))) { throw new Error('Expected to find the no data message'); } } - async tableGetRows(subj) { + async tableGetRows(subj: string) { const table = await testSubjects.find(subj); return table.findAllByTagName('tr'); } - async tableGetRowsFromContainer(subj) { + async tableGetRowsFromContainer(subj: string) { const table = await testSubjects.find(subj); const tbody = await table.findByTagName('tbody'); return tbody.findAllByTagName('tr'); } - async tableSetFilter(subj, text) { + async tableSetFilter(subj: string, text: string) { await testSubjects.setValue(subj, text); await PageObjects.common.pressEnterKey(); await PageObjects.header.waitUntilLoadingHasFinished(); } - async tableClearFilter(subj) { + async tableClearFilter(subj: string) { return await testSubjects.setValue(subj, ' \uE003'); // space and backspace to trigger onChange event } })(); diff --git a/x-pack/test/functional/page_objects/reporting_page.ts b/x-pack/test/functional/page_objects/reporting_page.ts index 58ac50c26a01d..cb5cbe896887e 100644 --- a/x-pack/test/functional/page_objects/reporting_page.ts +++ b/x-pack/test/functional/page_objects/reporting_page.ts @@ -5,16 +5,15 @@ */ import http, { IncomingMessage } from 'http'; -import { FtrProviderContext } from 'test/functional/ftr_provider_context'; import { parse } from 'url'; +import { FtrProviderContext } from '../ftr_provider_context'; export function ReportingPageProvider({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const log = getService('log'); const retry = getService('retry'); const testSubjects = getService('testSubjects'); - - const PageObjects = getPageObjects(['common', 'security' as any, 'share', 'timePicker']); // FIXME: Security PageObject is not Typescript + const PageObjects = getPageObjects(['security', 'share', 'timePicker']); class ReportingPage { async forceSharedItemsContainerSize({ width }: { width: number }) { diff --git a/x-pack/test/functional/page_objects/rollup_page.js b/x-pack/test/functional/page_objects/rollup_page.ts similarity index 85% rename from x-pack/test/functional/page_objects/rollup_page.js rename to x-pack/test/functional/page_objects/rollup_page.ts index f974f60271746..fbeb6acd3ebf2 100644 --- a/x-pack/test/functional/page_objects/rollup_page.js +++ b/x-pack/test/functional/page_objects/rollup_page.ts @@ -6,8 +6,9 @@ import expect from '@kbn/expect'; import { map as mapAsync } from 'bluebird'; +import { FtrProviderContext } from '../ftr_provider_context'; -export function RollupPageProvider({ getService, getPageObjects }) { +export function RollupPageProvider({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const log = getService('log'); const find = getService('find'); @@ -15,16 +16,16 @@ export function RollupPageProvider({ getService, getPageObjects }) { class RollupJobPage { async createNewRollUpJob( - jobName, - indexPattern, - indexName, - interval, + jobName: string, + indexPattern: string, + indexName: string, + interval: string, delay = '1d', startImmediately = false, scheduledTime = { time: 'minute', cron: true } ) { let stepNum = 1; - //Step 1 + // Step 1 await testSubjects.click('createRollupJobButton'); await this.verifyStepIsActive(stepNum); await this.addRollupNameandIndexPattern(jobName, indexPattern); @@ -34,47 +35,47 @@ export function RollupPageProvider({ getService, getPageObjects }) { await this.setRollupDelay(delay); stepNum = await this.moveToNextStep(stepNum); - //Step 2: Histogram + // Step 2: Histogram await this.verifyStepIsActive(stepNum); await this.setJobInterval(interval); stepNum = await this.moveToNextStep(stepNum); - //Step 3: Terms (optional) + // Step 3: Terms (optional) await this.verifyStepIsActive(stepNum); stepNum = await this.moveToNextStep(); - //Step 4: Histogram(optional) + // Step 4: Histogram(optional) await this.verifyStepIsActive(stepNum); stepNum = await this.moveToNextStep(); - //Step 5: Metrics(optional) + // Step 5: Metrics(optional) await this.verifyStepIsActive(stepNum); stepNum = await this.moveToNextStep(); - //Step 6: saveJob and verify the name in the list + // Step 6: saveJob and verify the name in the list await this.verifyStepIsActive(stepNum); await this.saveJob(startImmediately); } - async verifyStepIsActive(stepNumber) { + async verifyStepIsActive(stepNumber = 0) { await testSubjects.exists(`createRollupStep${stepNumber}--active`); } - async setScheduleTime(time, cron) { - if (cron) { + async setScheduleTime(time: string, isCron: boolean) { + if (isCron) { await testSubjects.click('rollupShowAdvancedCronLink'); await testSubjects.setValue('rollupAdvancedCron', time); } // TODO: Add handling for if Cron is false to go through clicking options. } - async addRollupNameandIndexPattern(name, indexPattern) { + async addRollupNameandIndexPattern(name: string, indexPattern: string) { log.debug(`Adding name ${name} to form`); await testSubjects.setValue('rollupJobName', name); await testSubjects.setValue('rollupIndexPattern', indexPattern); } - async setRollupDelay(time) { + async setRollupDelay(time: string) { log.debug(`Setting rollup delay to "${time}"`); await testSubjects.setValue('rollupDelay', time); } @@ -86,20 +87,20 @@ export function RollupPageProvider({ getService, getPageObjects }) { expect(text).to.be.equal('Success! Index pattern has matching indices.'); } - async setIndexName(name) { + async setIndexName(name: string) { await testSubjects.setValue('rollupIndexName', name); } - async moveToNextStep(stepNum) { + async moveToNextStep(stepNum = 0) { await testSubjects.click('rollupJobNextButton'); return stepNum + 1; } - async setJobInterval(time) { + async setJobInterval(time: string) { await testSubjects.setValue('rollupJobInterval', time); } - async saveJob(startImmediately) { + async saveJob(startImmediately: boolean) { if (startImmediately) { const checkbox = await find.byCssSelector('.euiCheckbox'); await checkbox.click(); diff --git a/x-pack/test/functional/page_objects/security_page.ts b/x-pack/test/functional/page_objects/security_page.ts index e3efc8731e6b3..3ce8a0e681d69 100644 --- a/x-pack/test/functional/page_objects/security_page.ts +++ b/x-pack/test/functional/page_objects/security_page.ts @@ -17,7 +17,7 @@ export function SecurityPageProvider({ getService, getPageObjects }: FtrProvider const esArchiver = getService('esArchiver'); const userMenu = getService('userMenu'); const comboBox = getService('comboBox'); - const PageObjects = getPageObjects(['common', 'header', 'settings', 'home', 'error']); + const PageObjects = getPageObjects(['common', 'header', 'error']); interface LoginOptions { expectSpaceSelector?: boolean; diff --git a/x-pack/test/functional/page_objects/space_selector_page.ts b/x-pack/test/functional/page_objects/space_selector_page.ts index 90196c89170dd..e96d9f2296c90 100644 --- a/x-pack/test/functional/page_objects/space_selector_page.ts +++ b/x-pack/test/functional/page_objects/space_selector_page.ts @@ -13,7 +13,7 @@ export function SpaceSelectorPageProvider({ getService, getPageObjects }: FtrPro const testSubjects = getService('testSubjects'); const browser = getService('browser'); const find = getService('find'); - const PageObjects = getPageObjects(['common', 'header', 'security']); + const PageObjects = getPageObjects(['common']); class SpaceSelectorPage { async initTests() { diff --git a/x-pack/test/functional/page_objects/status_page.js b/x-pack/test/functional/page_objects/status_page.ts similarity index 81% rename from x-pack/test/functional/page_objects/status_page.js rename to x-pack/test/functional/page_objects/status_page.ts index 68fc931a9140f..3b12d65765a20 100644 --- a/x-pack/test/functional/page_objects/status_page.js +++ b/x-pack/test/functional/page_objects/status_page.ts @@ -5,13 +5,14 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../ftr_provider_context'; -export function StatusPagePageProvider({ getService, getPageObjects }) { +export function StatusPagePageProvider({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const log = getService('log'); const browser = getService('browser'); const find = getService('find'); - const PageObjects = getPageObjects(['common', 'home', 'security']); + const { common } = getPageObjects(['common']); class StatusPage { async initTests() { @@ -20,13 +21,13 @@ export function StatusPagePageProvider({ getService, getPageObjects }) { async navigateToPage() { return await retry.try(async () => { - const url = PageObjects.common.getHostPort() + '/status'; + const url = common.getHostPort() + '/status'; log.info(`StatusPage:navigateToPage(): ${url}`); await browser.get(url); }); } - async expectStatusPage() { + async expectStatusPage(): Promise { return await retry.try(async () => { log.debug(`expectStatusPage()`); await find.byCssSelector('[data-test-subj="kibanaChrome"] nav:not(.ng-hide) ', 20000); diff --git a/x-pack/test/functional/page_objects/upgrade_assistant.js b/x-pack/test/functional/page_objects/upgrade_assistant_page.ts similarity index 76% rename from x-pack/test/functional/page_objects/upgrade_assistant.js rename to x-pack/test/functional/page_objects/upgrade_assistant_page.ts index 72dbb2175abc9..3fe60747505a7 100644 --- a/x-pack/test/functional/page_objects/upgrade_assistant.js +++ b/x-pack/test/functional/page_objects/upgrade_assistant_page.ts @@ -5,14 +5,15 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../ftr_provider_context'; -export function UpgradeAssistantProvider({ getService, getPageObjects }) { +export function UpgradeAssistantPageProvider({ getPageObjects, getService }: FtrProviderContext) { const retry = getService('retry'); const log = getService('log'); const browser = getService('browser'); const find = getService('find'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'settings', 'security']); + const { common } = getPageObjects(['common']); class UpgradeAssistant { async initTests() { @@ -21,7 +22,7 @@ export function UpgradeAssistantProvider({ getService, getPageObjects }) { async navigateToPage() { return await retry.try(async () => { - await PageObjects.common.navigateToApp('settings'); + await common.navigateToApp('settings'); await testSubjects.click('upgrade_assistant'); }); } @@ -29,7 +30,7 @@ export function UpgradeAssistantProvider({ getService, getPageObjects }) { async expectUpgradeAssistant() { return await retry.try(async () => { log.debug(`expectUpgradeAssistant()`); - expect(testSubjects.exists('upgradeAssistantRoot')).to.be.true; + expect(await testSubjects.exists('upgradeAssistantRoot')).to.equal(true); const url = await browser.getCurrentUrl(); expect(url).to.contain(`/upgrade_assistant`); }); @@ -42,7 +43,7 @@ export function UpgradeAssistantProvider({ getService, getPageObjects }) { }); } - async expectDeprecationLoggingLabel(labelText) { + async expectDeprecationLoggingLabel(labelText: string) { return await retry.try(async () => { log.debug('expectDeprecationLoggingLabel()'); const label = await find.byCssSelector( @@ -53,19 +54,17 @@ export function UpgradeAssistantProvider({ getService, getPageObjects }) { }); } - async clickTab(tabId) { + async clickTab(tabId: string) { return await retry.try(async () => { log.debug('clickTab()'); - const tab = await find.byCssSelector(`.euiTabs .euiTab#${tabId}`); - await tab.click(); + await find.clickByCssSelector(`.euiTabs .euiTab#${tabId}`); }); } - async expectIssueSummary(summary) { + async expectIssueSummary(summary: string) { return await retry.try(async () => { log.debug('expectIssueSummary()'); - const summaryEl = await testSubjects.find('upgradeAssistantIssueSummary'); - const summaryElText = await summaryEl.getVisibleText(); + const summaryElText = await testSubjects.getVisibleText('upgradeAssistantIssueSummary'); expect(summaryElText).to.eql(summary); }); } diff --git a/x-pack/test/functional/page_objects/uptime_page.ts b/x-pack/test/functional/page_objects/uptime_page.ts index 074a2d598be8a..5c48415e2aa14 100644 --- a/x-pack/test/functional/page_objects/uptime_page.ts +++ b/x-pack/test/functional/page_objects/uptime_page.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../ftr_provider_context'; export function UptimePageProvider({ getPageObjects, getService }: FtrProviderContext) { - const pageObjects = getPageObjects(['common', 'timePicker']); + const pageObjects = getPageObjects(['timePicker']); const { common: commonService, monitor, navigation } = getService('uptime'); const retry = getService('retry'); diff --git a/x-pack/test/functional/page_objects/watcher_page.js b/x-pack/test/functional/page_objects/watcher_page.ts similarity index 89% rename from x-pack/test/functional/page_objects/watcher_page.js rename to x-pack/test/functional/page_objects/watcher_page.ts index dfc31a6ad5ed2..ce6d9edcb6cdb 100644 --- a/x-pack/test/functional/page_objects/watcher_page.js +++ b/x-pack/test/functional/page_objects/watcher_page.ts @@ -5,9 +5,10 @@ */ import { map as mapAsync } from 'bluebird'; +import { FtrProviderContext } from '../ftr_provider_context'; -export function WatcherPageProvider({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['common', 'header', 'settings']); +export function WatcherPageProvider({ getPageObjects, getService }: FtrProviderContext) { + const PageObjects = getPageObjects(['header']); const find = getService('find'); const testSubjects = getService('testSubjects'); @@ -22,7 +23,7 @@ export function WatcherPageProvider({ getPageObjects, getService }) { } } - async createWatch(watchName, name) { + async createWatch(watchName: string, name: string) { await testSubjects.click('createWatchButton'); await testSubjects.click('jsonWatchCreateLink'); await find.setValue('#id', watchName); @@ -31,7 +32,7 @@ export function WatcherPageProvider({ getPageObjects, getService }) { await PageObjects.header.waitUntilLoadingHasFinished(); } - async getWatch(watchID) { + async getWatch(watchID: string) { const watchIdColumn = await testSubjects.find(`watchIdColumn-${watchID}`); const watchNameColumn = await testSubjects.find(`watchNameColumn-${watchID}`); const id = await watchIdColumn.getVisibleText(); @@ -47,7 +48,7 @@ export function WatcherPageProvider({ getPageObjects, getService }) { await testSubjects.click('btnDeleteWatches'); } - //get all the watches in the list + // get all the watches in the list async getWatches() { const watches = await find.allByCssSelector('.euiTableRow'); return mapAsync(watches, async (watch) => { diff --git a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts index 8ee42d4026381..0135993c9e5f4 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts @@ -27,7 +27,7 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr */ async findFirstActionsButton() { await this.ensureIsOnPolicyPage(); - return (await testSubjects.findAll('policyActionsButton'))[0]; + return await testSubjects.find('policyActionsButton'); }, /** @@ -36,8 +36,7 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr async launchAndFindDeleteModal() { const actionsButton = await this.findFirstActionsButton(); await actionsButton.click(); - const deleteAction = await testSubjects.find('policyDeleteButton'); - await deleteAction.click(); + await testSubjects.click('policyDeleteButton'); return await testSubjects.find('policyListDeleteModal'); },