Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.5] Test: canvas functional smoke test (#25262) #26037

Merged
merged 2 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const ElementContent = compose(
// TODO: 'canvas__element' was added for BWC, It can be removed after a while
className={'canvas__element canvasElement'}
style={{ ...renderable.containerStyle, ...size }}
data-test-subj="canvasWorkpadPageElementContent"
>
<ElementShareContainer
className="canvasElement__content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export class WorkpadLoader extends React.PureComponent {

return (
<Link
data-test-subj="canvasWorkpadLoaderWorkpad"
name="loadWorkpad"
params={{ id: workpad.id }}
aria-label={`Load workpad ${workpadName}`}
Expand Down Expand Up @@ -246,6 +247,7 @@ export class WorkpadLoader extends React.PureComponent {
isSelectable
selection={selection}
className="canvasWorkpad__dropzoneTable"
data-test-subj="canvasWorkpadLoaderTable"
/>
<EuiSpacer />
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class WorkpadPage extends PureComponent {
<div
key={page.id}
id={page.id}
data-test-subj="canvasWorkpadPage"
className={`canvasPage ${className} ${isEditable ? 'canvasPage--isEditable' : ''}`}
data-shared-items-container
style={{
Expand Down
11 changes: 11 additions & 0 deletions x-pack/test/functional/apps/canvas/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export default function canvasApp({ loadTestFile }) {
describe('Canvas app', function canvasAppTestSuite() {
loadTestFile(require.resolve('./smoke_test'));
});
}
81 changes: 81 additions & 0 deletions x-pack/test/functional/apps/canvas/smoke_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from 'expect.js';
import { parse } from 'url';

export default function canvasSmokeTest({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const testSubjects = getService('testSubjects');
const remote = getService('remote');
const retry = getService('retry');
const PageObjects = getPageObjects(['common']);

describe('smoke test', async () => {
const workpadListSelector = 'canvasWorkpadLoaderTable canvasWorkpadLoaderWorkpad';
const testWorkpadId = 'workpad-1705f884-6224-47de-ba49-ca224fe6ec31';

before(async () => {
// init data
await Promise.all([
esArchiver.loadIfNeeded('logstash_functional'),
esArchiver.load('canvas/default'),
]);

// load canvas
// see also navigateToUrl(app, hash)
await PageObjects.common.navigateToApp('canvas');
});

it('loads workpad list', async () => {
await retry.try(async () => {
const workpadRows = await testSubjects.findAll(workpadListSelector);
expect(workpadRows).to.have.length(1);
expect(await workpadRows[0].getVisibleText()).to.equal('Test Workpad');
});
});

it('loads workpage when clicked', async () => {
// click the first workpad in the list to load it
await testSubjects.click(workpadListSelector);

// wait for the workpad page to load
await retry.waitFor('workpad page', () => testSubjects.exists('canvasWorkpadPage'));

// check that workpad loaded in url
const url = await remote.getCurrentUrl();
expect(parse(url).hash).to.equal(`#/workpad/${testWorkpadId}/page/1`);
});

it('renders elements on workpad', async () => {
await retry.try(async () => {
// check for elements on the page
const elements = await testSubjects.findAll(
'canvasWorkpadPage canvasWorkpadPageElementContent'
);
expect(elements).to.have.length(4);

// check that the elements are what we expect

// first is a markdown element
const md = await elements[0].findByCssSelector('.canvasMarkdown');
expect(await md.getVisibleText()).to.contain('Welcome to Canvas');

// second element is a datatable that uses essql
const serverRows = await elements[1].findAllByCssSelector('.canvasDataTable tbody tr');
expect(serverRows).to.have.length(10);

// third is a datatable that uses csv
const commonRows = await elements[2].findAllByCssSelector('.canvasDataTable tbody tr');
expect(commonRows).to.have.length(2);

// fourth is a datatable that uses timelion
const timelionRows = await elements[3].findAllByCssSelector('.canvasDataTable tbody tr');
expect(timelionRows).to.have.length(12);
});
});
});
}
5 changes: 5 additions & 0 deletions x-pack/test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default async function ({ readConfigFile }) {
return {
// list paths to the files that contain your plugins tests
testFiles: [
resolve(__dirname, './apps/canvas'),
resolve(__dirname, './apps/graph'),
resolve(__dirname, './apps/monitoring'),
resolve(__dirname, './apps/watcher'),
Expand Down Expand Up @@ -174,6 +175,10 @@ export default async function ({ readConfigFile }) {
},
infraOps: {
pathname: '/app/infra'
},
canvas: {
pathname: '/app/canvas',
hash: '/',
}
},

Expand Down
Binary file not shown.
Loading