* [Reporting/PDF] Custom layout option for Canvas * fix snapshots * --wip-- [skip ci] * check pdf data * add test * functional tests work * add fixme comment * read strings from pdf for test * Update reports.ts * function name / comment improvment * Add Canvas toggle to choose pdf layout type * Fix Canvas pdf panel storybook test * Update style for new Canvas report type switch * Update canvas share menu snapshot * Fix tests for validating Canvas PDF using inline snapshots Run test server with: node scripts/functional_tests_server.js --config x-pack/test/functional/config.js Run test suite with: node scripts/functional_test_runner.js --config x-pack/test/functional/config.js --grep 'Canvas PDF Report' * Fix i18n and typo * Add a test for removing borders * Fix i18n * Update snapshot Co-authored-by: Timothy Sullivan <tsullivan@elastic.co> Co-authored-by: Tim Sullivan <tsullivan@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
118 lines
4 KiB
TypeScript
118 lines
4 KiB
TypeScript
/*
|
|
* 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 '@kbn/expect';
|
|
|
|
import { FtrProviderContext } from '../ftr_provider_context';
|
|
|
|
export function CanvasPageProvider({ getService, getPageObjects }: FtrProviderContext) {
|
|
const testSubjects = getService('testSubjects');
|
|
const find = getService('find');
|
|
const browser = getService('browser');
|
|
const PageObjects = getPageObjects(['common']);
|
|
|
|
return {
|
|
async enterFullscreen() {
|
|
const elem = await find.byCssSelector('[aria-label="View fullscreen"]', 20000);
|
|
await elem.click();
|
|
},
|
|
|
|
async exitFullscreen() {
|
|
await browser.pressKeys(browser.keys.ESCAPE);
|
|
},
|
|
|
|
async openExpressionEditor() {
|
|
await testSubjects.click('canvasExpressionEditorButton');
|
|
},
|
|
|
|
async waitForWorkpadElements() {
|
|
await testSubjects.findAll('canvasWorkpadPage > canvasWorkpadPageElementContent');
|
|
},
|
|
|
|
/*
|
|
* Finds the first workpad in the loader (uses find, not findAll) and
|
|
* ensures the expected name is the actual name. Then it clicks the element
|
|
* to load the workpad. Resolves once the workpad is in the DOM
|
|
*/
|
|
async loadFirstWorkpad(workpadName: string) {
|
|
const elem = await testSubjects.find('canvasWorkpadLoaderWorkpad');
|
|
const text = await elem.getVisibleText();
|
|
expect(text).to.be(workpadName);
|
|
await elem.click();
|
|
await testSubjects.existOrFail('canvasWorkpadPage');
|
|
},
|
|
|
|
async fillOutCustomElementForm(name: string, description: string) {
|
|
// Fill out the custom element form and submit it
|
|
await testSubjects.setValue('canvasCustomElementForm-name', name, {
|
|
clearWithKeyboard: true,
|
|
});
|
|
await testSubjects.setValue('canvasCustomElementForm-description', description, {
|
|
clearWithKeyboard: true,
|
|
});
|
|
|
|
await testSubjects.click('canvasCustomElementForm-submit');
|
|
},
|
|
|
|
async expectCreateWorkpadButtonEnabled() {
|
|
const button = await testSubjects.find('create-workpad-button', 20000);
|
|
const disabledAttr = await button.getAttribute('disabled');
|
|
expect(disabledAttr).to.be(null);
|
|
},
|
|
|
|
async expectCreateWorkpadButtonDisabled() {
|
|
const button = await testSubjects.find('create-workpad-button', 20000);
|
|
const disabledAttr = await button.getAttribute('disabled');
|
|
expect(disabledAttr).to.be('true');
|
|
},
|
|
|
|
async openSavedElementsModal() {
|
|
await testSubjects.click('add-element-button');
|
|
await testSubjects.click('saved-elements-menu-option');
|
|
|
|
await PageObjects.common.sleep(1000); // give time for modal animation to complete
|
|
},
|
|
async closeSavedElementsModal() {
|
|
await testSubjects.click('saved-elements-modal-close-button');
|
|
},
|
|
|
|
async expectAddElementButton() {
|
|
await testSubjects.existOrFail('add-element-button');
|
|
},
|
|
|
|
async expectNoAddElementButton() {
|
|
// Ensure page is fully loaded first by waiting for the refresh button
|
|
const refreshPopoverExists = await testSubjects.exists('canvas-refresh-control', {
|
|
timeout: 20000,
|
|
});
|
|
expect(refreshPopoverExists).to.be(true);
|
|
|
|
await testSubjects.missingOrFail('add-element-button');
|
|
},
|
|
|
|
async getTimeFiltersFromDebug() {
|
|
await testSubjects.existOrFail('canvasDebug__content');
|
|
|
|
const contentElem = await testSubjects.find('canvasDebug__content');
|
|
const content = await contentElem.getVisibleText();
|
|
|
|
const filters = JSON.parse(content);
|
|
|
|
return filters.and.filter((f: any) => f.filterType === 'time');
|
|
},
|
|
|
|
async getMatchFiltersFromDebug() {
|
|
await testSubjects.existOrFail('canvasDebug__content');
|
|
|
|
const contentElem = await testSubjects.find('canvasDebug__content');
|
|
const content = await contentElem.getVisibleText();
|
|
|
|
const filters = JSON.parse(content);
|
|
|
|
return filters.and.filter((f: any) => f.filterType === 'exactly');
|
|
},
|
|
};
|
|
}
|