-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: canvas functional smoke test (#25262)
~~Blocked by #23046 (pending #25828 merged Adds functional smoke tests for Canvas. - Loads and checks the list of workpads - Loads the first workpad and checks that elements render This is the simple workpad it's testing 
- Loading branch information
Showing
8 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.