| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- /**
- * 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.
- */
- import { CHART_LIST } from 'cypress/utils/urls';
- import { interceptGet as interceptDashboardGet } from 'cypress/e2e/dashboard/utils';
- import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
- import {
- interceptFiltering,
- interceptV1ChartData,
- saveChartToDashboard,
- visitSampleChartFromList,
- } from './utils';
- // SEARCH_THRESHOLD is 10. We need to add at least 11 dashboards to show search
- const SAMPLE_DASHBOARDS_INDEXES = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- function openDashboardsAddedTo() {
- cy.getBySel('actions-trigger').should('be.visible').click();
- cy.get('.ant-dropdown-menu-submenu-title')
- .contains('On dashboards')
- .trigger('mouseover', { force: true });
- }
- function closeDashboardsAddedTo() {
- cy.get('.ant-dropdown-menu-submenu-title')
- .contains('On dashboards')
- .trigger('mouseout', { force: true });
- cy.getBySel('actions-trigger').click();
- }
- function verifyDashboardsSubmenuItem(dashboardName) {
- cy.get('.ant-dropdown-menu-submenu-popup').contains(dashboardName);
- closeDashboardsAddedTo();
- }
- function verifyDashboardSearch() {
- openDashboardsAddedTo();
- cy.get('.ant-dropdown-menu-submenu-popup').trigger('mouseover');
- cy.get('.ant-dropdown-menu-submenu-popup')
- .find('input[placeholder="Search"]')
- .type('1');
- cy.get('.ant-dropdown-menu-submenu-popup').contains('1 - Sample dashboard');
- cy.get('.ant-dropdown-menu-submenu-popup')
- .find('input[placeholder="Search"]')
- .type('Blahblah');
- cy.get('.ant-dropdown-menu-submenu-popup').contains('No results found');
- cy.get('.ant-dropdown-menu-submenu-popup')
- .find('[aria-label="close-circle"]')
- .click();
- closeDashboardsAddedTo();
- }
- function verifyDashboardLink() {
- interceptDashboardGet();
- openDashboardsAddedTo();
- cy.get('.ant-dropdown-menu-submenu-popup').trigger('mouseover', {
- force: true,
- });
- cy.get('.ant-dropdown-menu-submenu-popup a')
- .first()
- .invoke('removeAttr', 'target')
- .click({ force: true });
- cy.wait('@get');
- }
- function verifyMetabar(text) {
- cy.getBySel('metadata-bar').contains(text);
- }
- function saveAndVerifyDashboard(chartName, number) {
- saveChartToDashboard(chartName, `${number} - Sample dashboard`);
- verifyMetabar(
- number > 1 ? `Added to ${number} dashboards` : 'Added to 1 dashboard',
- );
- openDashboardsAddedTo();
- verifyDashboardsSubmenuItem(`${number} - Sample dashboard`);
- }
- describe('Cross-referenced dashboards', () => {
- beforeEach(() => {
- interceptFiltering();
- cy.createSampleDashboards(SAMPLE_DASHBOARDS_INDEXES);
- cy.createSampleCharts([0]);
- cy.visit(CHART_LIST);
- cy.wait('@filtering');
- });
- it('should show the cross-referenced dashboards', () => {
- visitSampleChartFromList('1 - Sample chart');
- cy.getBySel('metadata-bar').contains('Not added to any dashboard');
- openDashboardsAddedTo();
- verifyDashboardsSubmenuItem('None');
- saveAndVerifyDashboard('1 - Sample chart', '1');
- saveAndVerifyDashboard('1 - Sample chart', '2');
- saveAndVerifyDashboard('1 - Sample chart', '3');
- saveAndVerifyDashboard('1 - Sample chart', '4');
- saveAndVerifyDashboard('1 - Sample chart', '5');
- saveAndVerifyDashboard('1 - Sample chart', '6');
- saveAndVerifyDashboard('1 - Sample chart', '7');
- saveAndVerifyDashboard('1 - Sample chart', '8');
- saveAndVerifyDashboard('1 - Sample chart', '9');
- saveAndVerifyDashboard('1 - Sample chart', '10');
- saveAndVerifyDashboard('1 - Sample chart', '11');
- verifyDashboardSearch();
- verifyDashboardLink();
- });
- });
- describe('No Results', () => {
- beforeEach(() => {
- interceptV1ChartData();
- });
- it('No results message shows up', () => {
- const formData = {
- ...FORM_DATA_DEFAULTS,
- metrics: [NUM_METRIC],
- viz_type: 'echarts_timeseries_line',
- adhoc_filters: [
- {
- expressionType: 'SIMPLE',
- subject: 'state',
- operator: 'IN',
- comparator: ['Fake State'],
- clause: 'WHERE',
- sqlExpression: null,
- },
- ],
- };
- cy.visitChartByParams(formData);
- cy.wait('@v1Data').its('response.statusCode').should('eq', 200);
- cy.get('div.chart-container').contains(
- 'No results were returned for this query',
- );
- });
- });
|