Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Jun 16, 2020
1 parent 51dc7bb commit 42b4ce4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
26 changes: 13 additions & 13 deletions packages/kbn-test/src/kbn/kbn_test_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import url from 'url';
import { kibanaTestUser } from './users';

interface UrlParts {
protocol: string;
hostname: string;
port: number;
auth: string;
username: string;
password: string;
protocol?: string;
hostname?: string;
port?: number;
auth?: string;
username?: string;
password?: string;
}

export const kbnTestConfig = new (class KbnTestConfig {
Expand All @@ -38,12 +38,12 @@ export const kbnTestConfig = new (class KbnTestConfig {
if (process.env.TEST_KIBANA_URL) {
const testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL);
return {
protocol: testKibanaUrl.protocol!.slice(0, -1),
hostname: testKibanaUrl.hostname!,
port: parseInt(testKibanaUrl.port!, 10),
auth: testKibanaUrl.auth!,
username: testKibanaUrl.auth!.split(':')[0],
password: testKibanaUrl.auth!.split(':')[1],
protocol: testKibanaUrl.protocol?.slice(0, -1),
hostname: testKibanaUrl.hostname,
port: testKibanaUrl.port ? parseInt(testKibanaUrl.port, 10) : undefined,
auth: testKibanaUrl.auth,
username: testKibanaUrl.auth?.split(':')[0],
password: testKibanaUrl.auth?.split(':')[1],
};
}

Expand All @@ -52,7 +52,7 @@ export const kbnTestConfig = new (class KbnTestConfig {
return {
protocol: process.env.TEST_KIBANA_PROTOCOL || 'http',
hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_KIBANA_PORT!, 10) || 5620,
port: process.env.TEST_KIBANA_PORT ? parseInt(process.env.TEST_KIBANA_PORT, 10) : 5620,
auth: `${username}:${password}`,
username,
password,
Expand Down
4 changes: 1 addition & 3 deletions test/common/services/security/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import util from 'util';
import { KbnClient, ToolingLog } from '@kbn/dev-utils';

export class Role {
constructor(private log: ToolingLog, private kibanaServer: KbnClient) {
this.log = log;
}
constructor(private log: ToolingLog, private kibanaServer: KbnClient) {}

public async create(name: string, role: any) {
this.log.debug(`creating role ${name}`);
Expand Down
5 changes: 5 additions & 0 deletions test/functional/services/common/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,5 +529,10 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
await driver.executeScript('document.body.scrollLeft = ' + scrollSize);
return this.getScrollLeft();
}

public async switchToFrame(idOrElement: number | WebElementWrapper) {
const _id = idOrElement instanceof WebElementWrapper ? idOrElement._webElement : idOrElement;
await driver.switchTo().frame(_id);
}
})();
}
10 changes: 2 additions & 8 deletions x-pack/test/functional_embedded/tests/iframe_embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
import Url from 'url';
import { By, until } from 'selenium-webdriver';
import testSubjSelector from '@kbn/test-subj-selector';

import { FtrProviderContext } from '../ftr_provider_context';

Expand All @@ -15,8 +13,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const config = getService('config');
const testSubjects = getService('testSubjects');

const WD = getService('__webdriver__');

describe('in iframe', () => {
it('should open Kibana for logged-in user', async () => {
await PageObjects.security.login();
Expand All @@ -33,11 +29,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await browser.navigateTo(url);

const iframe = await testSubjects.find('iframe_embedded');
WD.driver.switchTo().frame(iframe._webElement);
await browser.switchToFrame(iframe);

const selector = By.css(testSubjSelector('kibanaChrome'));
const minute = 60000;
await WD.driver.wait(until.elementLocated(selector), minute);
await testSubjects.find('kibanaChrome', 60000);
});
});
}
2 changes: 1 addition & 1 deletion x-pack/test/functional_embedded/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Kibana embedded', function () {
this.tags('ciGroup6');
this.tags('ciGroup2');
loadTestFile(require.resolve('./iframe_embedded'));
});
}

0 comments on commit 42b4ce4

Please sign in to comment.