Skip to content

Commit

Permalink
more backported test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Drengenberg committed Apr 5, 2022
1 parent f4e4942 commit d3614cd
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 74 deletions.
57 changes: 19 additions & 38 deletions test/functional/apps/dashboard/embeddable_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const find = getService('find');
const browser = getService('browser');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const pieChart = getService('pieChart');
const elasticChart = getService('elasticChart');
const security = getService('security');
const dashboardExpect = getService('dashboardExpect');
const dashboardAddPanel = getService('dashboardAddPanel');
Expand All @@ -32,7 +32,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'dashboard',
'header',
'visualize',
'visChart',
'discover',
'timePicker',
]);
Expand All @@ -41,31 +40,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const expectAllDataRenders = async () => {
await pieChart.expectPieSliceCount(16);
await dashboardExpect.metricValuesExist(['7,544']);
await dashboardExpect.seriesElementCount(14);
await dashboardExpect.seriesElementCount(19);
const tsvbGuageExists = await find.existsByCssSelector('.tvbVisHalfGauge');
expect(tsvbGuageExists).to.be(true);
await dashboardExpect.timelionLegendCount(0);
await dashboardExpect.timelionLegendCount(5);
await dashboardExpect.markdownWithValuesExists(["I'm a markdown!"]);
await dashboardExpect.vegaTextsExist(['5,000']);
await dashboardExpect.goalAndGuageLabelsExist(['62.925%', '55.625%', '11.915 GB']);
await dashboardExpect.dataTableRowCount(5);
await dashboardExpect.tagCloudWithValuesFound(['CN', 'IN', 'US', 'BR', 'ID']);
// TODO add test for 'region map viz'
// TODO add test for 'tsvb gauge' viz
// TODO add test for 'geo map' viz
// This tests the presence of the two input control embeddables
await dashboardExpect.inputControlItemCount(5);
await dashboardExpect.tsvbTableCellCount(20);
await dashboardExpect.tsvbMarkdownWithValuesExists(['Hi Avg last bytes: 6286.674715909091']);
await dashboardExpect.tsvbTopNValuesExist(['5,734.79', '6,286.675']);
await dashboardExpect.tsvbMetricValuesExist(['210,007,889,606']);
// TODO add test for 'animal sound pie' viz

// This tests line charts that do not use timeseries data
const dogData = await elasticChart.getChartDebugData('visTypeXyChart', 2);
const pointCount = dogData?.areas?.reduce((acc, a) => {
return acc + a.lines.y1.points.length;
}, 0);
expect(pointCount).to.equal(6);

// This tests the area chart and non timebased line chart points
await dashboardExpect.lineChartPointsCount(5);
// TODO add test for 'scripted filter and query' viz
// TODO add test for 'animal weight linked to search' viz
// TODO add test for the last vega viz
Expand All @@ -76,36 +71,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await pieChart.expectPieSliceCount(0);
await dashboardExpect.seriesElementCount(0);
await dashboardExpect.dataTableNoResult();
await dashboardExpect.savedSearchNoResult();
await dashboardExpect.savedSearchRowCount(0);
await dashboardExpect.inputControlItemCount(5);
await dashboardExpect.metricValuesExist(['0']);
await dashboardExpect.markdownWithValuesExists(["I'm a markdown!"]);

// Three instead of 0 because there is a visualization based off a non time based index that
// should still show data.
const dogData = await elasticChart.getChartDebugData('visTypeXyChart');
const pointCount = dogData?.areas?.reduce((acc, a) => {
return acc + a.lines.y1.points.length;
}, 0);
expect(pointCount).to.equal(6);
await dashboardExpect.lineChartPointsCount(3);

await dashboardExpect.timelionLegendCount(0);
const tsvbGuageExists = await find.existsByCssSelector('.tvbVisHalfGauge');
expect(tsvbGuageExists).to.be(true);
await dashboardExpect.tsvbMetricValuesExist(['-']);
await dashboardExpect.tsvbMarkdownWithValuesExists(['Hi Avg last bytes:']);
await dashboardExpect.tsvbMetricValuesExist(['0']);
await dashboardExpect.tsvbMarkdownWithValuesExists(['Hi Avg last bytes: 0']);
await dashboardExpect.tsvbTableCellCount(0);
await dashboardExpect.tsvbTopNValuesExist(['-']);
await dashboardExpect.tsvbTopNValuesExist(['0']);
await dashboardExpect.vegaTextsDoNotExist(['5,000']);
};

describe('dashboard embeddable rendering', function describeIndexTests() {
// Failing: See https://github.com/elastic/kibana/issues/76245
describe.skip('dashboard embeddable rendering', function describeIndexTests() {
before(async () => {
await security.testUser.setRoles(['kibana_admin', 'animals', 'test_logstash_reader']);
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
Expand All @@ -124,21 +113,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const newUrl = currentUrl.replace(/\?.*$/, '');
await browser.get(newUrl, false);
await security.testUser.restoreDefaults();
await kibanaServer.savedObjects.cleanStandardList();
});

it('adding visualizations', async () => {
await elasticChart.setNewChartUiDebugFlag(true);

visNames = await dashboardAddPanel.addEveryVisualization('"Rendering Test"');
expect(visNames.length).to.be.equal(24);
await dashboardExpect.visualizationsArePresent(visNames);

// This one is rendered via svg which lets us do better testing of what is being rendered.
visNames.push(await dashboardAddPanel.addVisualization('Filter Bytes Test: vega'));
await PageObjects.header.waitUntilLoadingHasFinished();
await dashboardExpect.visualizationsArePresent(visNames);
expect(visNames.length).to.be.equal(25);
expect(visNames.length).to.be.equal(27);
await PageObjects.dashboard.waitForRenderComplete();
});

Expand All @@ -149,7 +134,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboardAddPanel.closeAddPanel();
await PageObjects.header.waitUntilLoadingHasFinished();
await dashboardExpect.visualizationsArePresent(visAndSearchNames);
expect(visAndSearchNames.length).to.be.equal(26);
expect(visAndSearchNames.length).to.be.equal(28);
await PageObjects.dashboard.waitForRenderComplete();

await PageObjects.dashboard.saveDashboard('embeddable rendering test', {
Expand All @@ -174,12 +159,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('data rendered correctly when dashboard is hard refreshed', async () => {
await browser.refresh();
const alert = await browser.getAlert();
await alert?.accept();

await elasticChart.setNewChartUiDebugFlag(true);

const currentUrl = await browser.getCurrentUrl();
await browser.get(currentUrl, true);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();
await expectAllDataRenders();
Expand Down
26 changes: 2 additions & 24 deletions test/functional/apps/dashboard/full_screen_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const browser = getService('browser');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard', 'common']);
const filterBar = getService('filterBar');

describe('full screen mode', () => {
before(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
Expand All @@ -32,10 +29,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});

it('option not available in edit mode', async () => {
await PageObjects.dashboard.switchToEditMode();
const exists = await PageObjects.dashboard.fullScreenModeMenuItemExists();
Expand Down Expand Up @@ -100,20 +93,5 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
await filterBar.removeFilter('bytes');
});

it('exits full screen mode when back button pressed', async () => {
await PageObjects.dashboard.clickFullScreenMode();
await browser.goBack();
await retry.try(async () => {
const isChromeVisible = await PageObjects.common.isChromeVisible();
expect(isChromeVisible).to.be(true);
});

await browser.goForward();
await retry.try(async () => {
const isChromeVisible = await PageObjects.common.isChromeVisible();
expect(isChromeVisible).to.be(true);
});
});
});
}
7 changes: 5 additions & 2 deletions test/functional/apps/dashboard/legacy_urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const dashboardAddPanel = getService('dashboardAddPanel');
const listingTable = getService('listingTable');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const security = getService('security');

let kibanaLegacyBaseUrl: string;
Expand All @@ -33,7 +33,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('legacy urls', function describeIndexTests() {
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader', 'animals']);
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.clickNewDashboard();
await dashboardAddPanel.addVisualization('Rendering-Test:-animal-sounds-pie');
Expand Down
10 changes: 8 additions & 2 deletions test/functional/apps/dashboard/panel_expand_toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard', 'visualize', 'header', 'common']);

describe('expanding a panel', () => {
before(async () => {
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
Expand All @@ -28,6 +30,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});

it('hides other panels', async () => {
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
Expand Down
11 changes: 8 additions & 3 deletions test/functional/apps/dashboard/saved_search_embeddable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
before(async () => {
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data');
await esArchiver.loadIfNeeded(
'test/functional/fixtures/es_archiver/dashboard/current/kibana'
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
Expand All @@ -38,6 +39,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});

it('highlighting on filtering works', async function () {
await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search');
await filterBar.addFilter('agent', 'is', 'Mozilla');
Expand All @@ -48,7 +53,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const marks = $('mark')
.toArray()
.map((mark) => $(mark).text());
expect(marks.length).to.above(10);
expect(marks.length).to.above(0);
});

it('removing a filter removes highlights', async function () {
Expand Down
12 changes: 9 additions & 3 deletions test/functional/apps/dashboard/url_field_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'timePicker',
'visChart',
]);
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const browser = getService('browser');
Expand All @@ -38,7 +37,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('Changing field formatter to Url', () => {
before(async function () {
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
Expand All @@ -52,11 +54,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await settings.controlChangeSave();
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});

it('applied on dashboard', async () => {
await common.navigateToApp('dashboard');
await dashboard.loadSavedDashboard('dashboard with table');
await dashboard.waitForRenderComplete();
const fieldLink = await visChart.getFieldLinkInVisTable(`${fieldName}: Descending`, 1);
const fieldLink = await visChart.getFieldLinkInVisTable(`${fieldName}: Descending`);
await clickFieldAndCheckUrl(fieldLink);
});

Expand Down
7 changes: 5 additions & 2 deletions test/functional/apps/dashboard/view_edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const queryBar = getService('queryBar');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const dashboardAddPanel = getService('dashboardAddPanel');
const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize', 'timePicker']);
Expand All @@ -22,7 +21,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('dashboard view edit mode', function viewEditModeTests() {
before(async () => {
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader', 'animals']);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
Expand All @@ -33,6 +35,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

after(async () => {
await security.testUser.restoreDefaults();
await kibanaServer.savedObjects.cleanStandardList();
});

it('create new dashboard opens in edit mode', async function () {
Expand Down

0 comments on commit d3614cd

Please sign in to comment.