diff --git a/x-pack/plugins/canvas/public/components/element_content/element_content.js b/x-pack/plugins/canvas/public/components/element_content/element_content.js index 4a62f219b2ba5..4f9ee400940a4 100644 --- a/x-pack/plugins/canvas/public/components/element_content/element_content.js +++ b/x-pack/plugins/canvas/public/components/element_content/element_content.js @@ -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" > diff --git a/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js b/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js index fc46820aca56f..35ec5db959d76 100644 --- a/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js +++ b/x-pack/plugins/canvas/public/components/workpad_page/workpad_page.js @@ -72,6 +72,7 @@ export class WorkpadPage extends PureComponent {
{ + 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); + }); + }); + }); +} diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 73f48d1f369c1..3c396fc7c2c97 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -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'), @@ -174,6 +175,10 @@ export default async function ({ readConfigFile }) { }, infraOps: { pathname: '/app/infra' + }, + canvas: { + pathname: '/app/canvas', + hash: '/', } }, diff --git a/x-pack/test/functional/es_archives/canvas/default/data.json.gz b/x-pack/test/functional/es_archives/canvas/default/data.json.gz new file mode 100644 index 0000000000000..444125d376cfc Binary files /dev/null and b/x-pack/test/functional/es_archives/canvas/default/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/canvas/default/mappings.json b/x-pack/test/functional/es_archives/canvas/default/mappings.json new file mode 100644 index 0000000000000..a9fe069e4f920 --- /dev/null +++ b/x-pack/test/functional/es_archives/canvas/default/mappings.json @@ -0,0 +1,387 @@ +{ + "type": "index", + "value": { + "index": ".kibana", + "settings": { + "index": { + "number_of_shards": "1", + "auto_expand_replicas": "0-1", + "number_of_replicas": "0" + } + }, + "mappings": { + "doc": { + "dynamic": "strict", + "properties": { + "apm-telemetry": { + "properties": { + "has_any_services": { + "type": "boolean" + }, + "services_per_agent": { + "properties": { + "go": { + "type": "long", + "null_value": 0 + }, + "java": { + "type": "long", + "null_value": 0 + }, + "js-base": { + "type": "long", + "null_value": 0 + }, + "nodejs": { + "type": "long", + "null_value": 0 + }, + "python": { + "type": "long", + "null_value": 0 + }, + "ruby": { + "type": "long", + "null_value": 0 + } + } + } + } + }, + "canvas-workpad": { + "dynamic": "false", + "properties": { + "@created": { + "type": "date" + }, + "@timestamp": { + "type": "date" + }, + "id": { + "type": "text", + "index": false + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + } + } + }, + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + } + } + }, + "dashboard": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { + "type": "text" + }, + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "graph-workspace": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "numLinks": { + "type": "integer" + }, + "numVertices": { + "type": "integer" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "wsState": { + "type": "text" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { + "type": "keyword" + }, + "notExpandable": { + "type": "boolean" + }, + "sourceFilters": { + "type": "text" + }, + "timeFieldName": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "type": { + "type": "keyword" + }, + "typeMeta": { + "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" + }, + "optOutCount": { + "type": "long" + } + } + }, + "migrationVersion": { + "type": "object", + "dynamic": "true" + }, + "namespace": { + "type": "keyword" + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "space": { + "properties": { + "_reserved": { + "type": "boolean" + }, + "color": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "initials": { + "type": "keyword" + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "telemetry": { + "properties": { + "enabled": { + "type": "boolean" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchId": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" + } + } + } + } + } + }, + "aliases": {} + } +} \ No newline at end of file