Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ch-dashboards-functional-test into feature-anywhere

# Conflicts:
#	cypress/utils/dashboards/commands.js
  • Loading branch information
jovancacvetkovic committed May 26, 2023
2 parents 60e9647 + ddabc9e commit 5f6d02e
Show file tree
Hide file tree
Showing 23 changed files with 21,910 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"MANAGED_SERVICE_ENDPOINT": false,
"VISBUILDER_ENABLED": true,
"DATASOURCE_MANAGEMENT_ENABLED": false,
"ML_COMMONS_DASHBOARDS_ENABLED": false
"ML_COMMONS_DASHBOARDS_ENABLED": true
}
}
20,000 changes: 20,000 additions & 0 deletions cypress/fixtures/dashboard/opensearch_dashboards/vis_type_table/table.data.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"id":"index-pattern-vis-table","type":"index-pattern","namespaces":["default"],"updated_at":"2022-12-05T21:14:35.148Z","version":"WzUwLDFd","attributes":{"title":"vis-table","timeFieldName":"timestamp"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"}}
{"id":"f3f0a6f0-74de-11ed-9a2e-2509e8c9c014","type":"visualization","namespaces":["default"],"updated_at":"2022-12-05T20:54:04.254Z","version":"WzQ0LDFd","attributes":{"title":"TABLE: Basic","visState":"{\"title\":\"TABLE: Basic\",\"type\":\"table\",\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"params\":{},\"schema\":\"metric\"}],\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMetricsAtAllLevels\":false,\"showTotal\":false,\"totalFunc\":\"sum\",\"percentageCol\":\"\"}}","uiStateJSON":"{}","description":"A basic table visualization","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"}},"references":[{"name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern","id":"index-pattern-vis-table"}],"migrationVersion":{"visualization":"7.10.0"}}
{"exportedCount":1,"missingRefCount":0,"missingReferences":[]}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"password": "password"
"password": "testUserPassword123"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
TABLE_INDEX_ID,
TABLE_INDEX_PATTERN,
TABLE_PATH_INDEX_DATA,
TABLE_INDEX_START_TIME,
TABLE_INDEX_END_TIME,
TABLE_CREATE_URL,
TABLE_VIS_APP_PATH,
TABLE_VIS_TYPE,
} from '../../../../../utils/constants';

/**
* Basic test suite description:
* Create a new table visualization from index pattern.
* Set the time range and Histogram Aggregation.
* Test that global header and side bar function correctly.
* Test that table visualization can be saved.
* Test inspector is enabled and contains correct data.
*/

describe('table visualization basic functions', () => {
before(() => {
cy.deleteIndex(TABLE_INDEX_ID);
cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA);
cy.createIndexPattern(TABLE_INDEX_PATTERN, {
title: TABLE_INDEX_ID,
timeFieldName: 'timestamp',
});

cy.log('create a new table visualization: ', TABLE_CREATE_URL);
cy.visit(TABLE_CREATE_URL);
cy.url().should('contain', TABLE_VIS_APP_PATH);
// Select index pattern and load table visualization
cy.setTopNavDate(TABLE_INDEX_START_TIME, TABLE_INDEX_END_TIME);
// Wait for page to load
cy.waitForLoader();
});

it('Should apply changed params and allow to reset', () => {
// Set a Histogram Aggregation
cy.tbAddBucketsAggregation();
cy.tbSplitRows();
cy.tbSetupHistogramAggregation('age', '20', 2);
// Update Historgram interval
cy.tbSetHistogramInterval('201', 2);
cy.tbIsUpdateAggregationSettingsEnabled();
// Discard the updated interval
cy.tbDiscardAggregationSettings();
cy.tbIsHistogramIntervalSet('20', 2);
});

it('Should be able to save and load', () => {
const cleanupKey = Date.now();
const title = `table${cleanupKey}`;
// Save
cy.log('Save this table visualization with title ', title);
cy.getElementByTestId('visualizeSaveButton')
.should('not.be.disabled')
.click();
cy.getElementByTestId('savedObjectTitle').type(title);
cy.getElementByTestId('confirmSaveSavedObjectButton').click();
// Verify save
cy.getElementByTestId('breadcrumb last')
.invoke('attr', 'title')
.should('equal', title);
// Cleanup
cy.log('Remove saved table visualization with title ', title);
cy.deleteSavedObjectByType(TABLE_VIS_TYPE, title);
});

it('Should have inspector enabled', () => {
cy.getElementByTestId('openInspectorButton')
.invoke('attr', 'class')
.should(
'equal',
'euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiHeaderLink'
);
});

it('Should show correct data in inspector', () => {
const expectedData = [
'0',
'1,059',
'20',
'2,236',
'40',
'2,200',
'60',
'2,211',
'80',
'2,179',
'100',
'115',
];
cy.tbOpenInspector();
cy.tbGetTableDataFromInspectPanel().then((data) => {
expect(data).to.deep.eq(expectedData);
});
cy.tbCloseInspector();
});

after(() => {
cy.deleteIndex(TABLE_INDEX_ID);
cy.deleteIndexPattern(TABLE_INDEX_PATTERN);
});
});
Loading

0 comments on commit 5f6d02e

Please sign in to comment.