Skip to content

Commit

Permalink
fix(explore): Small changes in metadata bar copy and tooltip placement (
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje authored and AAfghahi committed Dec 1, 2022
1 parent 17e932c commit e3c099d
Show file tree
Hide file tree
Showing 5 changed files with 730 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,109 @@
* under the License.
*/
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
import {
interceptFiltering,
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').click();
cy.get('.ant-dropdown-menu-submenu-title')
.contains('Dashboards added to')
.trigger('mouseover');
}

function closeDashboardsAddedTo() {
cy.get('.ant-dropdown-menu-submenu-title')
.contains('Dashboards added to')
.trigger('mouseout');
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');
cy.get('.ant-dropdown-menu-submenu-popup a')
.first()
.invoke('removeAttr', 'target')
.click();
cy.wait('@get');
}

function verifyMetabar(text) {
cy.getBySel('metadata-bar').contains(text);
}

function saveAndVerifyDashboard(number) {
saveChartToDashboard(`${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.preserveLogin();
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');
saveAndVerifyDashboard('2');
saveAndVerifyDashboard('3');
saveAndVerifyDashboard('4');
saveAndVerifyDashboard('5');
saveAndVerifyDashboard('6');
saveAndVerifyDashboard('7');
saveAndVerifyDashboard('8');
saveAndVerifyDashboard('9');
saveAndVerifyDashboard('10');
saveAndVerifyDashboard('11');

verifyDashboardSearch();
verifyDashboardLink();
});
});

describe('No Results', () => {
beforeEach(() => {
Expand Down
Loading

0 comments on commit e3c099d

Please sign in to comment.