|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import expect from '@kbn/expect'; |
| 21 | +import { WebElementWrapper } from 'test/functional/services/lib/web_element_wrapper'; |
| 22 | +import { FtrProviderContext } from '../../ftr_provider_context'; |
| 23 | + |
| 24 | +export default function ({ getService, getPageObjects }: FtrProviderContext) { |
| 25 | + const { common, dashboard, settings, timePicker, visChart } = getPageObjects([ |
| 26 | + 'common', |
| 27 | + 'dashboard', |
| 28 | + 'settings', |
| 29 | + 'timePicker', |
| 30 | + 'visChart', |
| 31 | + ]); |
| 32 | + const esArchiver = getService('esArchiver'); |
| 33 | + const kibanaServer = getService('kibanaServer'); |
| 34 | + const testSubjects = getService('testSubjects'); |
| 35 | + const browser = getService('browser'); |
| 36 | + const fieldName = 'clientip'; |
| 37 | + |
| 38 | + const clickFieldAndCheckUrl = async (fieldLink: WebElementWrapper) => { |
| 39 | + const fieldValue = await fieldLink.getVisibleText(); |
| 40 | + await fieldLink.click(); |
| 41 | + const windowHandlers = await browser.getAllWindowHandles(); |
| 42 | + expect(windowHandlers.length).to.equal(2); |
| 43 | + await browser.switchToWindow(windowHandlers[1]); |
| 44 | + const currentUrl = await browser.getCurrentUrl(); |
| 45 | + const fieldUrl = common.getHostPort() + '/app/' + fieldValue; |
| 46 | + expect(currentUrl).to.equal(fieldUrl); |
| 47 | + }; |
| 48 | + |
| 49 | + describe('Changing field formatter to Url', () => { |
| 50 | + before(async function () { |
| 51 | + await esArchiver.load('dashboard/current/kibana'); |
| 52 | + await kibanaServer.uiSettings.replace({ |
| 53 | + defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', |
| 54 | + }); |
| 55 | + await common.navigateToApp('settings'); |
| 56 | + await settings.clickKibanaIndexPatterns(); |
| 57 | + await settings.clickIndexPatternLogstash(); |
| 58 | + await settings.filterField(fieldName); |
| 59 | + await settings.openControlsByName(fieldName); |
| 60 | + await settings.setFieldFormat('url'); |
| 61 | + await settings.controlChangeSave(); |
| 62 | + }); |
| 63 | + |
| 64 | + it('applied on dashboard', async () => { |
| 65 | + await common.navigateToApp('dashboard'); |
| 66 | + await dashboard.loadSavedDashboard('dashboard with everything'); |
| 67 | + await dashboard.waitForRenderComplete(); |
| 68 | + const fieldLink = await visChart.getFieldLinkInVisTable(`${fieldName}: Descending`, 1); |
| 69 | + await clickFieldAndCheckUrl(fieldLink); |
| 70 | + }); |
| 71 | + |
| 72 | + it('applied on discover', async () => { |
| 73 | + await common.navigateToApp('discover'); |
| 74 | + await timePicker.setAbsoluteRange( |
| 75 | + 'Sep 19, 2017 @ 06:31:44.000', |
| 76 | + 'Sep 23, 2018 @ 18:31:44.000' |
| 77 | + ); |
| 78 | + await testSubjects.click('docTableExpandToggleColumn'); |
| 79 | + const fieldLink = await testSubjects.find(`tableDocViewRow-${fieldName}-value`); |
| 80 | + await clickFieldAndCheckUrl(fieldLink); |
| 81 | + }); |
| 82 | + |
| 83 | + afterEach(async function () { |
| 84 | + const windowHandlers = await browser.getAllWindowHandles(); |
| 85 | + if (windowHandlers.length > 1) { |
| 86 | + await browser.closeCurrentWindow(); |
| 87 | + await browser.switchToWindow(windowHandlers[0]); |
| 88 | + } |
| 89 | + }); |
| 90 | + }); |
| 91 | +} |
0 commit comments