mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
chore: Add new e2e tests for Explore (#21184)
* chore(explore): Add cypress test for creating chart from dataset list * Add cypress test for creating chart from sqllab query * Fix the test for editing dataset in exploer * Fix lint * Fix tests
This commit is contained in:
parent
994e1f6bdc
commit
17ad0d80de
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const DATASET_LIST_PATH = 'tablemodelview/list';
|
||||||
|
|
||||||
|
describe('Dataset list', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.login();
|
||||||
|
cy.visit(DATASET_LIST_PATH);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should open Explore on dataset name click', () => {
|
||||||
|
cy.intercept('**/api/v1/explore/**').as('explore');
|
||||||
|
cy.get('[data-test="listview-table"] [data-test="internal-link"]')
|
||||||
|
.contains('birth_names')
|
||||||
|
.click();
|
||||||
|
cy.wait('@explore');
|
||||||
|
cy.get('[data-test="datasource-control"] .title-select').contains(
|
||||||
|
'birth_names',
|
||||||
|
);
|
||||||
|
cy.get('.metric-option-label').first().contains('COUNT(*)');
|
||||||
|
cy.get('.column-option-label').first().contains('ds');
|
||||||
|
cy.get('[data-test="fast-viz-switcher"] > div:not([role="button"]')
|
||||||
|
.contains('Table')
|
||||||
|
.should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
@ -25,17 +25,15 @@ import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
|
|||||||
describe('Datasource control', () => {
|
describe('Datasource control', () => {
|
||||||
const newMetricName = `abc${Date.now()}`;
|
const newMetricName = `abc${Date.now()}`;
|
||||||
|
|
||||||
// TODO: uncomment when adding metrics from dataset is fixed
|
it('should allow edit dataset', () => {
|
||||||
xit('should allow edit dataset', () => {
|
|
||||||
let numScripts = 0;
|
let numScripts = 0;
|
||||||
|
|
||||||
cy.login();
|
cy.login();
|
||||||
interceptChart({ legacy: false }).as('chartData');
|
interceptChart({ legacy: true }).as('chartData');
|
||||||
|
|
||||||
cy.visitChartByName('Num Births Trend');
|
cy.visitChartByName('Num Births Trend');
|
||||||
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
cy.verifySliceSuccess({ waitAlias: '@chartData' });
|
||||||
|
|
||||||
cy.get('[data-test="open-datasource-tab').click({ force: true });
|
|
||||||
cy.get('[data-test="datasource-menu-trigger"]').click();
|
cy.get('[data-test="datasource-menu-trigger"]').click();
|
||||||
|
|
||||||
cy.get('script').then(nodes => {
|
cy.get('script').then(nodes => {
|
||||||
@ -53,21 +51,31 @@ describe('Datasource control', () => {
|
|||||||
});
|
});
|
||||||
// create new metric
|
// create new metric
|
||||||
cy.get('[data-test="crud-add-table-item"]', { timeout: 10000 }).click();
|
cy.get('[data-test="crud-add-table-item"]', { timeout: 10000 }).click();
|
||||||
cy.get('[data-test="table-content-rows"]')
|
cy.wait(1000);
|
||||||
.find('input[value="<new metric>"]')
|
cy.get(
|
||||||
|
'[data-test="table-content-rows"] [data-test="editable-title-input"]',
|
||||||
|
)
|
||||||
|
.first()
|
||||||
.click();
|
.click();
|
||||||
cy.get('[data-test="table-content-rows"]')
|
|
||||||
.find('input[value="<new metric>"]')
|
cy.get(
|
||||||
|
'[data-test="table-content-rows"] [data-test="editable-title-input"]',
|
||||||
|
)
|
||||||
|
.first()
|
||||||
.focus()
|
.focus()
|
||||||
.clear()
|
.clear()
|
||||||
.type(`${newMetricName}{enter}`);
|
.type(`${newMetricName}{enter}`);
|
||||||
|
|
||||||
cy.get('[data-test="datasource-modal-save"]').click();
|
cy.get('[data-test="datasource-modal-save"]').click();
|
||||||
cy.get('.ant-modal-confirm-btns button').contains('OK').click();
|
cy.get('.ant-modal-confirm-btns button').contains('OK').click();
|
||||||
// select new metric
|
// select new metric
|
||||||
cy.get('[data-test=metrics]')
|
cy.get('[data-test=metrics]')
|
||||||
.find('.Select__control input')
|
.contains('Drop columns/metrics here or click')
|
||||||
.focus()
|
.click();
|
||||||
.type(newMetricName, { force: true });
|
|
||||||
|
cy.get('input[aria-label="Select saved metrics"]').type(
|
||||||
|
`${newMetricName}{enter}`,
|
||||||
|
);
|
||||||
// delete metric
|
// delete metric
|
||||||
cy.get('[data-test="datasource-menu-trigger"]').click();
|
cy.get('[data-test="datasource-menu-trigger"]').click();
|
||||||
cy.get('[data-test="edit-dataset"]').click();
|
cy.get('[data-test="edit-dataset"]').click();
|
||||||
@ -78,13 +86,11 @@ describe('Datasource control', () => {
|
|||||||
});
|
});
|
||||||
cy.get(`input[value="${newMetricName}"]`)
|
cy.get(`input[value="${newMetricName}"]`)
|
||||||
.closest('tr')
|
.closest('tr')
|
||||||
.find('.fa-trash')
|
.find('[data-test="crud-delete-icon"]')
|
||||||
.click();
|
.click();
|
||||||
cy.get('[data-test="datasource-modal-save"]').click();
|
cy.get('[data-test="datasource-modal-save"]').click();
|
||||||
cy.get('.ant-modal-confirm-btns button').contains('OK').click();
|
cy.get('.ant-modal-confirm-btns button').contains('OK').click();
|
||||||
cy.get('.Select__multi-value__label')
|
cy.get('[data-test="metrics"]').contains(newMetricName).should('not.exist');
|
||||||
.contains(newMetricName)
|
|
||||||
.should('not.exist');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,19 +34,9 @@ describe('SqlLab query panel', () => {
|
|||||||
// are fetched below (because React _Virtualized_ does not render all rows)
|
// are fetched below (because React _Virtualized_ does not render all rows)
|
||||||
let clockTime = 0;
|
let clockTime = 0;
|
||||||
|
|
||||||
const sampleResponse = {
|
|
||||||
status: 'success',
|
|
||||||
data: [{ '?column?': 1 }],
|
|
||||||
columns: [{ name: '?column?', type: 'INT', is_dttm: false }],
|
|
||||||
selected_columns: [{ name: '?column?', type: 'INT', is_dttm: false }],
|
|
||||||
expanded_columns: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
cy.intercept({
|
cy.intercept({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/superset/sql_json/',
|
url: '/superset/sql_json/',
|
||||||
delay: 1000,
|
|
||||||
response: () => sampleResponse,
|
|
||||||
}).as('mockSQLResponse');
|
}).as('mockSQLResponse');
|
||||||
|
|
||||||
cy.get('.TableSelector .Select:eq(0)').click();
|
cy.get('.TableSelector .Select:eq(0)').click();
|
||||||
@ -157,4 +147,52 @@ describe('SqlLab query panel', () => {
|
|||||||
assertSQLLabResultsAreEqual(initialResultsTable, savedQueryResultsTable);
|
assertSQLLabResultsAreEqual(initialResultsTable, savedQueryResultsTable);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Create a chart from a query', () => {
|
||||||
|
cy.intercept('/superset/sql_json/').as('queryFinished');
|
||||||
|
cy.intercept('**/api/v1/explore/**').as('explore');
|
||||||
|
cy.intercept('**/api/v1/chart/**').as('chart');
|
||||||
|
|
||||||
|
// cypress doesn't handle opening a new tab, override window.open to open in the same tab
|
||||||
|
cy.window().then(win => {
|
||||||
|
cy.stub(win, 'open', url => {
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
win.location.href = url;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const query = 'SELECT gender, name FROM birth_names';
|
||||||
|
|
||||||
|
cy.get('.ace_text-input')
|
||||||
|
.focus()
|
||||||
|
.clear({ force: true })
|
||||||
|
.type(`{selectall}{backspace}${query}`, { force: true });
|
||||||
|
cy.get('.sql-toolbar button').contains('Run').click();
|
||||||
|
cy.wait('@queryFinished');
|
||||||
|
|
||||||
|
cy.get(
|
||||||
|
'.SouthPane .ant-tabs-content > .ant-tabs-tabpane-active > div button:first',
|
||||||
|
{ timeout: 10000 },
|
||||||
|
).click();
|
||||||
|
|
||||||
|
cy.wait('@explore');
|
||||||
|
cy.get('[data-test="datasource-control"] .title-select').contains(query);
|
||||||
|
cy.get('.column-option-label').first().contains('gender');
|
||||||
|
cy.get('.column-option-label').last().contains('name');
|
||||||
|
|
||||||
|
cy.get(
|
||||||
|
'[data-test="all_columns"] [data-test="dnd-labels-container"] > div:first-child',
|
||||||
|
).contains('gender');
|
||||||
|
cy.get(
|
||||||
|
'[data-test="all_columns"] [data-test="dnd-labels-container"] > div:nth-child(2)',
|
||||||
|
).contains('name');
|
||||||
|
|
||||||
|
cy.wait('@chart');
|
||||||
|
cy.get('[data-test="slice-container"] table > thead th')
|
||||||
|
.first()
|
||||||
|
.contains('gender');
|
||||||
|
cy.get('[data-test="slice-container"] table > thead th')
|
||||||
|
.last()
|
||||||
|
.contains('name');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user