diff --git a/.cypress/integration/3_panels.spec.ts b/.cypress/integration/3_panels.spec.ts index 87a4ed902b..d8a6c91518 100644 --- a/.cypress/integration/3_panels.spec.ts +++ b/.cypress/integration/3_panels.spec.ts @@ -5,583 +5,589 @@ /// +import { newName } from '../utils/app_constants'; import { suppressResizeObserverIssue } from '../utils/constants'; +import { updatePanel } from '../../public/components/custom_panels/redux/panel_slice'; import { delay, NEW_VISUALIZATION_NAME, PPL_FILTER, + PPL_VISUALIZATION_CONFIGS, PPL_VISUALIZATIONS, PPL_VISUALIZATIONS_NAMES, TEST_PANEL, } from '../utils/panel_constants'; -describe('Adding sample data and visualization', () => { - it('Adds sample flights data for visualization paragraph', () => { +describe('Panels testing with Sample Data', () => { + before(() => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`); cy.get('div[data-test-subj="sampleDataSetCardflights"]') .contains(/(Add|View) data/) .trigger('mouseover') .click(); - cy.wait(delay * 3); - }); -}); - -describe('Creating visualizations', () => { - beforeEach(() => { - moveToEventsHome(); }); - it('Create first visualization in event analytics', () => { - cy.get('[id^=autocomplete-textarea]').focus().type(PPL_VISUALIZATIONS[0], { - delay: 50, + describe('Creating visualizations', () => { + beforeEach(() => { + moveToEventsHome(); }); - cy.get('.euiButton__text').contains('Refresh').trigger('mouseover').click(); - cy.wait(delay); - suppressResizeObserverIssue(); - cy.get('button[id="main-content-vis"]').contains('Visualizations').trigger('mouseover').click(); - cy.wait(delay * 2); - cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').trigger('mouseover').click(); - cy.wait(1000); - cy.get('[data-test-subj="eventExplorer__querySaveName"]') - .focus() - .type(PPL_VISUALIZATIONS_NAMES[0], { + + it('Create first visualization in event analytics', () => { + cy.get('[id^=autocomplete-textarea]').focus().type(PPL_VISUALIZATIONS[0], { delay: 50, }); - cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); - cy.wait(delay); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - }); + cy.get('.euiButton__text').contains('Refresh').trigger('mouseover').click(); + cy.wait(delay); //occationaly refresh wont work without this + cy.get('button[id="main-content-vis"]') + .contains('Visualizations') + .trigger('mouseover') + .click(); + cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]') + .trigger('mouseover') + .click(); + cy.wait(delay * 5); //Wont save as correct name without wait + cy.get('[data-test-subj="eventExplorer__querySaveName"]') + .focus() + .type(PPL_VISUALIZATIONS_NAMES[0]); - it('Create second visualization in event analytics', () => { - cy.get('[id^=autocomplete-textarea]').focus().type(PPL_VISUALIZATIONS[1], { - delay: 50, + cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); }); - cy.get('.euiButton__text').contains('Refresh').trigger('mouseover').click(); - cy.wait(delay); - suppressResizeObserverIssue(); - cy.get('button[id="main-content-vis"]').contains('Visualizations').trigger('mouseover').click(); - cy.wait(delay); - cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').trigger('mouseover').click(); - cy.wait(1000); - cy.get('[data-test-subj="eventExplorer__querySaveName"]') - .focus() - .type(PPL_VISUALIZATIONS_NAMES[1], { - delay: 50, - }); - cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); - cy.wait(delay); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - }); -}); -describe('Testing panels table', () => { - beforeEach(() => { - eraseTestPanels(); - moveToPanelHome(); + it('Create second visualization in event analytics', () => { + cy.get('[id^=autocomplete-textarea]').focus().type(PPL_VISUALIZATIONS[1]); + cy.get('.euiButton__text').contains('Refresh').trigger('mouseover').click(); + cy.get('button[id="main-content-vis"]') + .contains('Visualizations') + .trigger('mouseover') + .click({ force: true }); + cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]') + .trigger('mouseover') + .click(); + cy.wait(delay * 5); //Wont save as correct name without wait + cy.get('[data-test-subj="eventExplorer__querySaveName"]') + .focus() + .type(PPL_VISUALIZATIONS_NAMES[1]); + + cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + }); }); - describe('Without Any Panels', () => { + describe('Testing panels table', () => { beforeEach(() => { + eraseTestPanels(); moveToPanelHome(); }); - it.skip('Displays error toast for invalid panel name', () => { - clickCreatePanelButton(); - confirmModal(); - expectToastWith('Invalid Dashboard name'); - }); + describe('Without Any Panels', () => { + beforeEach(() => { + moveToPanelHome(); + }); - it('Creates a panel and redirects to the panel', () => { - clickCreatePanelButton(); - cy.get('input.euiFieldText').focus().type(TEST_PANEL, { - delay: 50, + it('Displays error toast for invalid panel name', () => { + clickCreatePanelButton(); + confirmModal(); + expectToastWith('Invalid Dashboard name'); }); - cy.get('button[data-test-subj="runModalButton"]').click(); - cy.contains(TEST_PANEL).should('exist'); - }); - }); - describe('with a Legacy Panel', () => { - beforeEach(() => { - createLegacyPanel(); - moveToPanelHome(); + it('Creates a panel and redirects to the panel', () => { + clickCreatePanelButton(); + cy.get('input.euiFieldText').focus().type(TEST_PANEL); + cy.get('button[data-test-subj="runModalButton"]').click(); + cy.contains(TEST_PANEL).should('exist'); + }); }); - it('Duplicates a legacy panel', () => { - cy.get('.euiTableRow').should('have.length', 1); - selectThePanel(); - openActionsDropdown(); - cy.get('button[data-test-subj="duplicateContextMenuItem"]').click(); - cy.get('button[data-test-subj="runModalButton"]').click(); - cy.get('.euiTableRow').should('have.length', 2); - const duplicateName = TEST_PANEL + ' (copy)'; - cy.contains(duplicateName).should('exist'); - const duplicate = cy.get('.euiLink').contains(duplicateName); - expectUuid(duplicate); - }); + describe('with a Legacy Panel', () => { + beforeEach(() => { + createLegacyPanel(); + moveToPanelHome(); + }); - it('Renames the panel', () => { - createLegacyPanel(); - cy.reload(); - const cell = cy.get('.euiTableCellContent'); - expectLegacyId(cell); - selectThePanel(); - openActionsDropdown(); - cy.get('button[data-test-subj="renameContextMenuItem"]').click(); - cy.get('input.euiFieldText').focus().type(' (rename)'); - cy.get('button[data-test-subj="runModalButton"]').click(); - const renamed = testPanelTableCell(); - expectUuid(renamed); - }); + it('Duplicates a legacy panel', () => { + cy.get('.euiTableRow').should('have.length', 1); + selectThePanel(); + openActionsDropdown(); + cy.get('button[data-test-subj="duplicateContextMenuItem"]').click(); + cy.get('button[data-test-subj="runModalButton"]').click(); + cy.get('[data-test-subj="breadcrumb"]').click({ force: true }); //Duplicate opens the panel, need to return + cy.get('.euiTableRow').should('have.length', 2); + const duplicateName = TEST_PANEL + ' (copy)'; + cy.contains(duplicateName).should('exist'); + const duplicate = cy.get('.euiLink').contains(duplicateName); + expectUuid(duplicate); + }); - it('Deletes the panel', () => { - cy.get('input[data-test-subj="checkboxSelectAll"]').click(); - openActionsDropdown(); - cy.get('button[data-test-subj="deleteContextMenuItem"]').click(); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('be.disabled'); + it('Renames the panel', () => { + createLegacyPanel(); + cy.reload(); + const cell = cy.get('.euiTableCellContent'); + expectLegacyId(cell); + cy.get('.euiCheckbox__input[title="Select this row"]').first().click(); + openActionsDropdown(); + cy.get('button[data-test-subj="renameContextMenuItem"]').click(); + cy.get('input.euiFieldText').focus().type(' (rename)'); + cy.get('button[data-test-subj="runModalButton"]').click(); + const renamed = testPanelTableCell(); + expectLegacyId(renamed); + }); - cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', { - delay: 50, + it('Deletes the panel', () => { + cy.get('input[data-test-subj="checkboxSelectAll"]').click(); + openActionsDropdown(); + cy.get('button[data-test-subj="deleteContextMenuItem"]').click(); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('be.disabled'); + + cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete'); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('not.be.disabled'); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); + cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist'); + }); + + it('Searches panels', () => { + createLegacyPanel('Legacy Named'); + createSavedObjectPanel('Saved Object'); + cy.reload(); + cy.get('input[data-test-subj="operationalPanelSearchBar"]') + .focus() + .type('this panel should not exist', { + delay: 50, + }); + + cy.get('.euiTableCellContent__text').contains('No items found').should('exist'); + + // Search for oriignal Legacy Panel + cy.get('[aria-label="Clear input"]').click(); + cy.get('input[data-test-subj="operationalPanelSearchBar"]').focus().type(TEST_PANEL); + + cy.get('a.euiLink').contains(TEST_PANEL).should('exist'); + cy.get('.euiTableRow').should('have.length', 1); + + // Search for teh Saved Object panel + cy.get('[aria-label="Clear input"]').click(); + cy.get('input[data-test-subj="operationalPanelSearchBar"]').focus().type('Saved Object'); + + cy.get('a.euiLink').contains('Saved Object').should('exist'); + cy.get('.euiTableRow').should('have.length', 1); }); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('not.be.disabled'); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); - cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist'); }); - it('Searches panels', () => { - createLegacyPanel('Legacy Named'); - createSavedObjectPanel('Saved Object'); - cy.reload(); - cy.get('input[data-test-subj="operationalPanelSearchBar"]') - .focus() - .type('this panel should not exist', { - delay: 50, - }); + describe('with a SavedObjects Panel', () => { + beforeEach(() => { + createSavedObjectPanel(); + moveToPanelHome(); + cy.get('[data-test-subj="breadcrumb last"]').click({ force: true }); //reload page + cy.get('.euiTableRow').should('have.length', 1); + }); - cy.get('.euiTableCellContent__text').contains('No items found').should('exist'); + it('Duplicates the panel', () => { + selectThePanel(); + openActionsDropdown(); + cy.get('button[data-test-subj="duplicateContextMenuItem"]').click(); + cy.get('button[data-test-subj="runModalButton"]').click(); + const duplicateName = TEST_PANEL + ' (copy)'; + cy.get('[data-test-subj="breadcrumb"]').click({ force: true }); //reload page + cy.get('.euiTableRow').should('have.length', 2); + cy.contains(duplicateName).should('exist'); + const duplicate = cy.get('.euiLink').contains(duplicateName); + expectUuid(duplicate); + }); - // Search for oriignal Legacy Panel - cy.get('[aria-label="Clear input"]').click(); - cy.get('input[data-test-subj="operationalPanelSearchBar"]').focus().type(TEST_PANEL, { - delay: 50, + it('Renames a saved-objects panel', () => { + selectThePanel(); + openActionsDropdown(); + cy.get('button[data-test-subj="renameContextMenuItem"]').click(); + cy.get('input.euiFieldText').focus().type(' (rename)'); + cy.get('button[data-test-subj="runModalButton"]').click(); }); - cy.get('a.euiLink').contains(TEST_PANEL).should('exist'); - cy.get('.euiTableRow').should('have.length', 1); + it('Deletes the panel', () => { + createSavedObjectPanel(); + cy.get('input[data-test-subj="checkboxSelectAll"]').click(); + openActionsDropdown(); + cy.get('button[data-test-subj="deleteContextMenuItem"]').click(); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('be.disabled'); + + cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete'); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('not.be.disabled'); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); + cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist'); + }); - // Search for teh Saved Object panel - cy.get('[aria-label="Clear input"]').click(); - cy.get('input[data-test-subj="operationalPanelSearchBar"]').focus().type('Saved Object', { - delay: 50, + it('Redirects to observability dashboard from OSD dashboards', () => { + moveToOsdDashboards(); + cy.location('pathname').should('eq', '/app/dashboards'); + cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]').click(); + cy.location('pathname').should('eq', '/app/observability-dashboards'); + }); + + it('Redirects to observability dashboard from OSD dashboards with edit', () => { + moveToOsdDashboards(); + cy.location('pathname').should('eq', '/app/dashboards'); + cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]') + .closest('tr') + .get('span.euiToolTipAnchor > button.euiButtonIcon') + .eq(0) + .click(); + cy.location('pathname').should('eq', '/app/observability-dashboards'); + cy.location('hash').should('include', '/edit'); }); - cy.get('a.euiLink').contains('Saved Object').should('exist'); - cy.get('.euiTableRow').should('have.length', 1); + it('Redirects to observability dashboard from OSD dashboards with create', () => { + moveToOsdDashboards(); + cy.location('pathname') + .should('eq', '/app/dashboards') + .then(() => { + cy.get('div#createMenuPopover').click(); + }); + cy.get('[data-test-subj="contextMenuItem-observability-panel"]').click(); + cy.location('pathname').should('eq', '/app/observability-dashboards'); + cy.location('hash').should('include', '/create'); + }); }); }); - describe('with a SavedObjects Panel', () => { + describe('Testing a panel', () => { beforeEach(() => { - createSavedObjectPanel(); - moveToPanelHome(); - cy.get('.euiTableRow').should('have.length', 1); + // moveToPanelHome(); + // moveToTestPanel(); }); - it('Duplicates the panel', () => { - selectThePanel(); - openActionsDropdown(); - cy.get('button[data-test-subj="duplicateContextMenuItem"]').click(); - cy.get('button[data-test-subj="runModalButton"]').click(); - const duplicateName = TEST_PANEL + ' (copy)'; - cy.get('.euiTableRow').should('have.length', 2); - cy.contains(duplicateName).should('exist'); - const duplicate = cy.get('.euiLink').contains(duplicateName); - expectUuid(duplicate); + it('Opens visualization flyout from empty panel', () => { + cy.get('a[data-test-subj="breadcrumb last"]').click(); + cy.get('button[data-test-subj="addVisualizationButton"]').eq(1).click(); + cy.get('button[data-test-subj="selectExistingVizContextMenuItem"]').click(); + cy.get('button[data-test-subj="closeFlyoutButton"]').click(); }); - it('Renames a saved-objects panel', () => { - selectThePanel(); - openActionsDropdown(); - cy.get('button[data-test-subj="renameContextMenuItem"]').click(); - cy.get('input.euiFieldText').focus().type(' (rename)', { - delay: 50, - }); - cy.get('button[data-test-subj="runModalButton"]').click(); - }); + it('Redirects to correct page on breadcrumb click', () => { + cy.get('a[data-test-subj="breadcrumb last"]').click(); - it('Deletes the panel', () => { - createSavedObjectPanel(); - cy.get('input[data-test-subj="checkboxSelectAll"]').click(); - openActionsDropdown(); - cy.get('button[data-test-subj="deleteContextMenuItem"]').click(); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('be.disabled'); + cy.get('h1[data-test-subj="panelNameHeader"]').contains(TEST_PANEL).should('exist'); + cy.get('a[data-test-subj="breadcrumb first"]').contains('Observability').click(); - cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', { - delay: 50, - }); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').should('not.be.disabled'); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); - cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist'); + cy.get('a[data-test-subj="breadcrumb"]').contains('Logs').should('exist'); }); - it('Redirects to observability dashboard from OSD dashboards', () => { - moveToOsdDashboards(); - cy.location('pathname').should('eq', '/app/dashboards'); - cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]').click(); - cy.location('pathname').should('eq', '/app/observability-dashboards'); + it('Duplicate the open panel', () => { + cy.get('button[data-test-subj="panelActionContextMenu"]').click(); + + cy.get('button[data-test-subj="duplicatePanelContextMenuItem"]').click(); + + cy.get(`input.euiFieldText[value="${TEST_PANEL} (copy)"]`).should('exist'); + cy.get('button[data-test-subj="runModalButton"]').click(); + cy.get('h1[data-test-subj="panelNameHeader"]') + .contains(TEST_PANEL + ' (copy)') + .should('exist'); }); - it('Redirects to observability dashboard from OSD dashboards with edit', () => { - moveToOsdDashboards(); - cy.location('pathname').should('eq', '/app/dashboards'); - cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]') - .closest('tr') - .get('span.euiToolTipAnchor > button.euiButtonIcon') - .eq(0) - .click(); - cy.location('pathname').should('eq', '/app/observability-dashboards'); - cy.location('hash').should('include', '/edit'); + it('Rename the open panel', () => { + cy.get('button[data-test-subj="panelActionContextMenu"]').click(); + + cy.get('button[data-test-subj="renamePanelContextMenuItem"]').click(); + + cy.get(`input.euiFieldText[value="${TEST_PANEL} (copy)"]`) + .focus() + .clear({ force: true }) + .focus() + .type('Renamed Panel'); + cy.get('button[data-test-subj="runModalButton"]').click(); + cy.get('h1[data-test-subj="panelNameHeader"]').contains('Renamed Panel').should('exist'); }); - it('Redirects to observability dashboard from OSD dashboards with create', () => { - moveToOsdDashboards(); - cy.location('pathname').should('eq', '/app/dashboards'); - cy.get('div#createMenuPopover').click(); - cy.get('[data-test-subj="contextMenuItem-observability-panel"]').click(); - cy.location('pathname').should('eq', '/app/observability-dashboards'); - cy.location('hash').should('include', '/create'); + it('Change date filter of the panel', () => { + cy.get('.euiButtonEmpty[data-test-subj="superDatePickerToggleQuickMenuButton"]').click({ + force: true, + }); + cy.get('button[data-test-subj="superDatePickerCommonlyUsed_This_year"]').click(); + cy.get('button[data-test-subj="superDatePickerShowDatesButton"]') + .contains('This year') + .should('exist'); }); - }); -}); -describe('Testing a panel', () => { - it('Move to test panel', () => { - moveToTestPanel(); - }); + it('Add existing visualization #1', () => { + cy.get('button[data-test-subj="addVisualizationButton"]').eq(0).click(); - it('Opens visualization flyout from empty panel', () => { - cy.get('button[data-test-subj="addVisualizationButton"]').eq(1).click(); - cy.get('button[data-test-subj="selectExistingVizContextMenuItem"]').click(); - cy.get('button[data-test-subj="closeFlyoutButton"]').click(); - }); + cy.get('button[data-test-subj="selectExistingVizContextMenuItem"]') + .click() + .then(() => { + cy.get('select').select(PPL_VISUALIZATIONS_NAMES[0]); + }); + cy.get('button[aria-label="refreshPreview"]').trigger('mouseover').click(); + cy.get('.plot-container').should('exist'); + cy.get('button[data-test-subj="addFlyoutButton"]').click(); - it('Redirects to correct page on breadcrumb click', () => { - moveToTestPanel(); - cy.get('a[data-test-subj="breadcrumb last"]').click(); + //cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + }); - cy.get('h1[data-test-subj="panelNameHeader"]').contains(TEST_PANEL).should('exist'); - cy.get('a[data-test-subj="breadcrumb"]').contains('Operational panels').click(); + it('Add existing visualization #2', () => { + cy.get('button[data-test-subj="addVisualizationButton"]').eq(0).click(); - cy.get('a[data-test-subj="breadcrumb last"]').contains('Operational panels').should('exist'); - cy.get('a[data-test-subj="breadcrumb first"]').contains('Observability').click(); + cy.get('button[data-test-subj="selectExistingVizContextMenuItem"]').click(); - cy.get('a[data-test-subj="breadcrumb"]').contains('Event analytics').should('exist'); - }); + cy.get('select').select(PPL_VISUALIZATIONS_NAMES[1]); + cy.get('button[aria-label="refreshPreview"]').trigger('mouseover').click(); + cy.get('.plot-container').should('exist'); + cy.get('button[data-test-subj="addFlyoutButton"]').click(); - it('Duplicate the open panel', () => { - moveToTestPanel(); - cy.get('button[data-test-subj="panelActionContextMenu"]').click(); + //cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + }); - cy.get('button[data-test-subj="duplicatePanelContextMenuItem"]').click(); + it.only('Add ppl filter to panel', () => { + console.log('Add PPL Test'); + createSavedObjectPanel().as('thePanel'); - cy.get(`input.euiFieldText[value="${TEST_PANEL} (copy)"]`).should('exist'); - cy.get('button[data-test-subj="runModalButton"]').click(); - cy.get('h1[data-test-subj="panelNameHeader"]') - .contains(TEST_PANEL + ' (copy)') - .should('exist'); - }); + createVisualization( + PPL_VISUALIZATIONS_NAMES[2], + PPL_VISUALIZATIONS[2], + PPL_VISUALIZATION_CONFIGS[2] + ).as('vis1'); - it('Rename the open panel', () => { - cy.get('button[data-test-subj="panelActionContextMenu"]').click(); + cy.then(function () { + addVisualizationsToPanel(this.thePanel, [this.vis1.id]); - cy.get('button[data-test-subj="renamePanelContextMenuItem"]').click(); - - cy.get(`input.euiFieldText[value="${TEST_PANEL} (copy)"]`) - .focus() - .clear({ force: true }) - .focus() - .type('Renamed Panel', { - delay: 200, + moveToThePanel(this.thePanel.id); }); - cy.get('button[data-test-subj="runModalButton"]').click(); - cy.get('h1[data-test-subj="panelNameHeader"]').contains('Renamed Panel').should('exist'); - }); - it('Change date filter of the panel', () => { - moveToTestPanel(); - cy.get('.euiButtonEmpty[data-test-subj="superDatePickerToggleQuickMenuButton"]').click({ - force: true, - }); - cy.get('button[data-test-subj="superDatePickerCommonlyUsed_This_year"]').click(); - cy.get('button[data-test-subj="superDatePickerShowDatesButton"]') - .contains('This year') - .should('exist'); - }); + cy.get('button[data-test-subj="addVisualizationButton"]').eq(0).click(); - it('Add existing visualization #1', () => { - cy.get('button[data-test-subj="addVisualizationButton"]').eq(0).click(); + cy.get('.euiButtonEmpty[data-test-subj="superDatePickerToggleQuickMenuButton"]').click({ + force: true, + }); - cy.get('button[data-test-subj="selectExistingVizContextMenuItem"]').click(); + cy.get('[data-test-subj="superDatePickerQuickMenu"') + .first() + .within(() => { + cy.get('input[aria-label="Time value"]').type('2', { force: true }); + cy.get('select[aria-label="Time unit"]').select('years'); + cy.get('button').contains('Apply').click(); + }); - cy.get('select').select(PPL_VISUALIZATIONS_NAMES[0]); - cy.get('button[aria-label="refreshPreview"]').trigger('mouseover').click(); - cy.wait(delay * 2); - cy.get('.plot-container').should('exist'); - cy.get('button[data-test-subj="addFlyoutButton"]').click(); + const delay = 500; + cy.get('[data-test-subj="searchAutocompleteTextArea"]') + .trigger('mouseover') + .click() + .wait(delay) + .focus() + .type(PPL_FILTER); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - }); + cy.get('button[data-test-subj="superDatePickerApplyTimeButton"]').click(); - it('Add existing visualization #2', () => { - cy.get('button[data-test-subj="addVisualizationButton"]').eq(0).click(); + cy.get('.xtick').should('contain', 'OpenSearch-Air'); + cy.get('.xtick').should('contain', 'Munich Airport'); + cy.get('.xtick').contains('Zurich Airport').should('not.exist'); + cy.get('.xtick').contains('BeatsWest').should('not.exist'); + cy.get('.xtick').contains('Logstash Airways').should('not.exist'); + cy.get('.xtick').contains('OpenSearch Dashboards Airlines').should('not.exist'); + }); - cy.get('button[data-test-subj="selectExistingVizContextMenuItem"]').click(); + it('Drag and drop a visualization', () => { + cy.get('button[data-test-subj="editPanelButton"]').click(); - cy.get('select').select(PPL_VISUALIZATIONS_NAMES[1]); - cy.get('button[aria-label="refreshPreview"]').trigger('mouseover').click(); - cy.wait(delay * 2); - cy.get('.plot-container').should('exist'); - cy.get('button[data-test-subj="addFlyoutButton"]').click(); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[1]) + .trigger('mousedown', { which: 1 }) + .trigger('mousemove', { clientX: 1100, clientY: 0 }) + .trigger('mouseup', { force: true }); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - }); + cy.get('button[data-test-subj="savePanelButton"]').click(); + cy.get('div.react-grid-layout>div') + .eq(1) + .invoke('attr', 'style') + .should('match', new RegExp('(.*)transform: translate((.*)10px)(.*)')); + }); - it('Add ppl filter to panel', () => { - cy.get('[data-test-subj="searchAutocompleteTextArea"]') - .trigger('mouseover') - .click() - .wait(3000) - .focus() - .type(PPL_FILTER, { - delay: 500, - }); + it('Resize a visualization', () => { + cy.get('button[data-test-subj="editPanelButton"]').click(); - cy.get('button[data-test-subj="superDatePickerApplyTimeButton"]').click(); - cy.wait(delay * 3); - cy.get('.xtick').should('contain', 'OpenSearch-Air'); - cy.get('.xtick').should('contain', 'Munich Airport'); - cy.get('.xtick').contains('Zurich Airport').should('not.exist'); - cy.get('.xtick').contains('BeatsWest').should('not.exist'); - cy.get('.xtick').contains('Logstash Airways').should('not.exist'); - cy.get('.xtick').contains('OpenSearch Dashboards Airlines').should('not.exist'); - }); + cy.get('.react-resizable-handle') + .eq(1) + .trigger('mousedown', { which: 1 }) + .trigger('mousemove', { clientX: 2000, clientY: 800 }) + .trigger('mouseup', { force: true }); - it('Drag and drop a visualization', () => { - cy.get('button[data-test-subj="editPanelButton"]').click(); - - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[1]) - .trigger('mousedown', { which: 1 }) - .trigger('mousemove', { clientX: 1100, clientY: 0 }) - .trigger('mouseup', { force: true }); - - cy.get('button[data-test-subj="savePanelButton"]').click(); - cy.wait(delay * 3); - cy.get('div.react-grid-layout>div') - .eq(1) - .invoke('attr', 'style') - .should('match', new RegExp('(.*)transform: translate((.*)10px)(.*)')); - }); + cy.get('button[data-test-subj="savePanelButton"]').click(); + cy.get('div.react-grid-layout>div').eq(1).invoke('height').should('match', new RegExp('470')); + }); - it('Resize a visualization', () => { - cy.get('button[data-test-subj="editPanelButton"]').click(); + it('Delete a visualization', () => { + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[1]) + .should('exist'); + cy.get('button[data-test-subj="editPanelButton"]').click(); - cy.get('.react-resizable-handle') - .eq(1) - .trigger('mousedown', { which: 1 }) - .trigger('mousemove', { clientX: 2000, clientY: 800 }) - .trigger('mouseup', { force: true }); + cy.get('.visualization-action-button > .euiIcon').eq(1).trigger('mouseover').click(); - cy.get('button[data-test-subj="savePanelButton"]').click(); - cy.wait(delay * 3); - cy.get('div.react-grid-layout>div').eq(1).invoke('height').should('match', new RegExp('470')); - }); + cy.get('button[data-test-subj="savePanelButton"]').click(); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[1]) + .should('not.exist'); + }); - it('Delete a visualization', () => { - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[1]) - .should('exist'); - cy.get('button[data-test-subj="editPanelButton"]').click(); + it('Duplicate a visualization', () => { + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[0]) + .should('exist'); + cy.get('button[aria-label="actionMenuButton"]').trigger('mouseover').click(); + cy.get('button[data-test-subj="duplicateVizContextMenuItem"]').click(); + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - cy.get('.visualization-action-button > .euiIcon').eq(1).trigger('mouseover').click(); + cy.get('h5[data-test-subj="visualizationHeader"]') + .eq(0) + .contains(PPL_VISUALIZATIONS_NAMES[0]) + .should('exist'); + cy.get('h5[data-test-subj="visualizationHeader"]') + .eq(1) + .contains(PPL_VISUALIZATIONS_NAMES[0]) + .should('exist'); + }); - cy.get('button[data-test-subj="savePanelButton"]').click(); - cy.wait(delay * 3); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[1]) - .should('not.exist'); - }); + it('Replace a visualization', () => { + cy.get('button[aria-label="actionMenuButton"]').eq(1).click(); + cy.get('button[data-test-subj="replaceVizContextMenuItem"]').click(); + cy.get('select').select(PPL_VISUALIZATIONS_NAMES[1]); + cy.get('button[aria-label="refreshPreview"]').trigger('mouseover').click(); + cy.get('.plot-container').should('exist'); + cy.get('button[data-test-subj="addFlyoutButton"]').click(); + + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[0]) + .should('exist'); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[1]) + .should('exist'); + }); - it('Duplicate a visualization', () => { - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[0]) - .should('exist'); - cy.get('button[aria-label="actionMenuButton"]').trigger('mouseover').click(); - cy.get('button[data-test-subj="duplicateVizContextMenuItem"]').click(); - cy.wait(delay * 2); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - - cy.get('h5[data-test-subj="visualizationHeader"]') - .eq(0) - .contains(PPL_VISUALIZATIONS_NAMES[0]) - .should('exist'); - cy.get('h5[data-test-subj="visualizationHeader"]') - .eq(1) - .contains(PPL_VISUALIZATIONS_NAMES[0]) - .should('exist'); - }); + it('add new visualization to panel', () => { + cy.get('button[data-test-subj="addVisualizationButton"]').eq(0).click(); + cy.get('button[data-test-subj="createNewVizContextMenuItem"]').click(); - it('Replace a visualization', () => { - cy.get('button[aria-label="actionMenuButton"]').eq(1).click(); - cy.get('button[data-test-subj="replaceVizContextMenuItem"]').click(); - cy.get('select').select(PPL_VISUALIZATIONS_NAMES[1]); - cy.get('button[aria-label="refreshPreview"]').trigger('mouseover').click(); - cy.wait(delay * 3); - cy.get('.plot-container').should('exist'); - cy.get('button[data-test-subj="addFlyoutButton"]').click(); - - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - cy.wait(delay); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[0]) - .should('exist'); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[1]) - .should('exist'); - }); + cy.url().should('match', new RegExp('(.*)#/explorer')); + cy.get('a[data-test-subj="eventExplorer__addNewTab"]').click({ force: true }); + cy.get('[id^=autocomplete-textarea]').focus().type(PPL_VISUALIZATIONS[2]); + cy.get('button[data-test-subj="superDatePickerApplyTimeButton"]').click({ force: true }); - it('add new visualization to panel', () => { - cy.get('button[data-test-subj="addVisualizationButton"]').eq(0).click(); - cy.get('button[data-test-subj="createNewVizContextMenuItem"]').click(); - cy.url().should('match', new RegExp('(.*)#/event_analytics/explorer')); - cy.get('a[data-test-subj="eventExplorer__addNewTab"]').click(); - cy.get('[id^=autocomplete-textarea]').focus().type(PPL_VISUALIZATIONS[2], { - delay: 50, + cy.get('button[id="main-content-vis"]') + .contains('Visualizations') + .trigger('mouseover') + .click(); + cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]') + .trigger('mouseover') + .click(); + cy.get('[data-test-subj="eventExplorer__querySaveComboBox"]').type(TEST_PANEL); + cy.get(`input[value="${TEST_PANEL}"]`).trigger('mouseover').click(); + cy.get('[data-test-subj="eventExplorer__querySaveName"]') + .focus() + .type(PPL_VISUALIZATIONS_NAMES[2]); + cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); + + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + moveToTestPanel(); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[0]) + .should('exist'); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[1]) + .should('exist'); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[2]) + .should('exist'); }); - cy.get('button[data-test-subj="superDatePickerApplyTimeButton"]').click(); - - suppressResizeObserverIssue(); - cy.get('button[id="main-content-vis"]').contains('Visualizations').trigger('mouseover').click(); - cy.wait(delay * 2); - cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').trigger('mouseover').click(); - cy.wait(1000); - cy.get('[data-test-subj="eventExplorer__querySaveComboBox"]').type(TEST_PANEL, { - delay: 50, + + it('Check visualization edit button', () => { + moveToTestPanel(); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[0]) + .should('exist'); + cy.get('button[aria-label="actionMenuButton"]').eq(0).trigger('mouseover').click(); + suppressResizeObserverIssue(); + cy.get('button[data-test-subj="editVizContextMenuItem"]').click(); + cy.url().should('match', new RegExp('(.*)#/explorer')); + + cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]') + .trigger('mouseover') + .click(); + cy.get('[data-test-subj="eventExplorer__querySaveName"]') + .clear({ force: true }) + .type(NEW_VISUALIZATION_NAME); + cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); + + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + moveToTestPanel(); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(NEW_VISUALIZATION_NAME) + .should('exist'); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[1]) + .should('exist'); + cy.get('h5[data-test-subj="visualizationHeader"]') + .contains(PPL_VISUALIZATIONS_NAMES[2]) + .should('exist'); }); - cy.wait(1000); - cy.get(`input[value="${TEST_PANEL}"]`).trigger('mouseover').click(); - cy.get('[data-test-subj="eventExplorer__querySaveName"]') - .focus() - .type(PPL_VISUALIZATIONS_NAMES[2], { - delay: 50, - }); - cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); - - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - moveToTestPanel(); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[0]) - .should('exist'); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[1]) - .should('exist'); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[2]) - .should('exist'); }); - it('Check visualization edit button', () => { - moveToTestPanel(); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[0]) - .should('exist'); - cy.get('button[aria-label="actionMenuButton"]').eq(0).trigger('mouseover').click(); - suppressResizeObserverIssue(); - cy.get('button[data-test-subj="editVizContextMenuItem"]').click(); - cy.wait(delay * 3); - cy.url().should('match', new RegExp('(.*)#/event_analytics/explorer')); - cy.wait(delay); - - cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').trigger('mouseover').click(); - cy.wait(1000); - cy.get('[data-test-subj="eventExplorer__querySaveName"]') - .clear({ force: true }) - .type(NEW_VISUALIZATION_NAME, { - delay: 200, - }); - cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').trigger('mouseover').click(); - - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); - moveToTestPanel(); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(NEW_VISUALIZATION_NAME) - .should('exist'); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[1]) - .should('exist'); - cy.get('h5[data-test-subj="visualizationHeader"]') - .contains(PPL_VISUALIZATIONS_NAMES[2]) - .should('exist'); - }); -}); + describe('Clean up all test data', () => { + it('Delete visualizations from event analytics', () => { + moveToEventsHome(); + cy.get('[data-test-subj="tablePaginationPopoverButton"]').trigger('mouseover').click(); + cy.get('button[data-test-subj="tablePagination-50-rows"]').click(); + cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]') + .trigger('mouseover') + .click(); + cy.get('button[data-test-subj="eventHomeAction"]').click(); -describe('Clean up all test data', () => { - it('Delete visualizations from event analytics', () => { - moveToEventsHome(); - cy.get('[data-test-subj="tablePaginationPopoverButton"]').trigger('mouseover').click(); - cy.get('button[data-test-subj="tablePagination-50-rows"]').click(); - cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]').trigger('mouseover').click(); - cy.get('button[data-test-subj="eventHomeAction"]').click(); - - cy.get('button[data-test-subj="eventHomeAction__delete"]').click(); - cy.get('button.euiButton--danger').should('be.disabled'); - cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', { - delay: 50, + cy.get('button[data-test-subj="eventHomeAction__delete"]').click(); + cy.get('button.euiButton--danger').should('be.disabled'); + cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete'); + cy.get('button.euiButton--danger').should('not.be.disabled'); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); + cy.get('.euiTextAlign').contains('No Queries or Visualizations').should('exist'); }); - cy.get('button.euiButton--danger').should('not.be.disabled'); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); - cy.get('.euiTextAlign').contains('No Queries or Visualizations').should('exist'); - }); - it('Deletes test panel', () => { - moveToPanelHome(); - cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]').trigger('mouseover').click(); - openActionsDropdown(); - clickDeleteAction(); - cy.get('button.euiButton--danger').should('be.disabled'); - cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', { - delay: 50, - }); - cy.get('button.euiButton--danger').should('not.be.disabled'); - cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); + it('Deletes test panel', () => { + moveToPanelHome(); + cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]') + .trigger('mouseover') + .click(); + openActionsDropdown(); + clickDeleteAction(); + cy.get('button.euiButton--danger').should('be.disabled'); + cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete'); + cy.get('button.euiButton--danger').should('not.be.disabled'); + cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); - cy.get('.euiTextAlign').contains('No Operational Panels').should('exist'); + cy.get('.euiTextAlign').contains('No Observability Dashboards').should('exist'); + }); }); }); const moveToOsdDashboards = () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#/`); - cy.wait(delay * 3); }; const moveToEventsHome = () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/`); - cy.wait(6000); }; const moveToPanelHome = () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/`, { timeout: 3000, }); - cy.wait(delay * 3); }; const testPanelTableCell = (name = TEST_PANEL) => cy.get('.euiTableCellContent').contains(name); +const moveToThePanel = (panelId) => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/${panelId}`, { + timeout: 3000, + }); +}; + const moveToTestPanel = () => { moveToPanelHome(); testPanelTableCell().trigger('mouseover').click(); - cy.wait(delay * 3); cy.get('h1').contains(TEST_PANEL).should('exist'); }; @@ -614,7 +620,7 @@ const eraseLegacyPanels = () => { }); }; -const eraseSavedObjectPaenls = () => { +const eraseSavedObjectPanels = () => { return cy .request({ method: 'get', @@ -642,15 +648,28 @@ const eraseSavedObjectPaenls = () => { const eraseTestPanels = () => { eraseLegacyPanels(); - eraseSavedObjectPaenls(); + eraseSavedObjectPanels(); }; const uuidRx = /[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/; const clickCreatePanelButton = () => cy.get('a[data-test-subj="customPanels__createNewPanels"]').click(); +const getSavedObjectsPanel = (panelId) => { + return cy + .request({ + method: 'GET', + failOnStatusCode: false, + url: `api/saved_objects/observability-panel/${panelId}`, + headers: { + 'content-type': 'application/json;charset=UTF-8', + 'osd-xsrf': true, + }, + }) + .then((response) => response.body); +}; const createSavedObjectPanel = (newName = TEST_PANEL) => { - const result = cy + return cy .request({ method: 'POST', failOnStatusCode: false, @@ -678,7 +697,82 @@ const createSavedObjectPanel = (newName = TEST_PANEL) => { }, }, }) - .then((response) => console.log(response)); + .then((response) => response.body); +}; + +const addVisualizationsToPanel = (panel, additionalVisualizationIds: string[]) => { + console.log('addVisualizationsToPanel', additionalVisualizationIds); + const additionalVisualizations = additionalVisualizationIds.map((id, idx) => { + return { + savedVisualizationId: `observability-visualization:${id}`, + w: 6, + x: 0, + h: 4, + y: idx, + id: `panel_viz_${id}`, + }; + }); + + panel.attributes.visualizations = [ + ...panel.attributes.visualizations, + ...additionalVisualizations, + ]; + console.log(panel.attributes); + cy.request({ + method: 'PUT', + failOnStatusCode: false, + url: `api/saved_objects/observability-panel/${panel.id}`, + headers: { + 'content-type': 'application/json;charset=UTF-8', + 'osd-xsrf': true, + }, + body: { + attributes: panel.attributes, + }, + }); +}; + +const createVisualization = (newName, query, vizConfig) => { + return cy + .request({ + method: 'POST', + failOnStatusCode: false, + url: 'api/saved_objects/observability-visualization', + headers: { + 'content-type': 'application/json;charset=UTF-8', + 'osd-xsrf': true, + }, + body: { + attributes: { + title: newName, + description: '', + version: 1, + createdTimeMs: new Date().getTime(), + savedVisualization: { + query: query, + selected_date_range: { + start: 'now-2y', + end: 'now', + text: '', + }, + selected_timestamp: { + name: 'timestamp', + type: 'timestamp', + }, + selected_fields: { + tokens: [], + text: '', + }, + name: newName, + description: '', + type: 'bar', + user_configs: vizConfig, + sub_type: 'visualization', + }, + }, + }, + }) + .then((response) => response.body); }; const createLegacyPanel = (newName = TEST_PANEL) => { diff --git a/.cypress/integration/4_trace_analytics_dashboard.spec.js b/.cypress/integration/4_trace_analytics_dashboard.spec.js index 284a642bad..656ac7e982 100644 --- a/.cypress/integration/4_trace_analytics_dashboard.spec.js +++ b/.cypress/integration/4_trace_analytics_dashboard.spec.js @@ -72,7 +72,6 @@ describe('Testing dashboard table empty state', () => { win.sessionStorage.clear(); }, }); - cy.wait(delay * 3); }); it('Renders empty state', () => { @@ -104,23 +103,19 @@ describe('Testing dashboard table', () => { cy.get('.euiBreadcrumb').contains('Trace analytics').click(); cy.get('.euiTitle').contains('Dashboard').should('exist'); cy.get('.euiBreadcrumb').contains('Observability').click(); - cy.get('.euiTitle').contains('Event analytics').should('exist'); + cy.get('.euiTitle').contains('Logs').should('exist'); }); it('Adds the percentile filters', () => { cy.contains(' >= 95 percentile').click({ force: true }); - cy.wait(delay); cy.contains(' >= 95 percentile').click({ force: true }); - cy.wait(delay); cy.contains('Latency percentile within trace group: >= 95th').should('exist'); cy.contains(' (7)').should('exist'); cy.contains('318.69').should('exist'); cy.contains(' < 95 percentile').click({ force: true }); - cy.wait(delay); cy.contains(' < 95 percentile').click({ force: true }); - cy.wait(delay); cy.contains('Latency percentile within trace group: < 95th').should('exist'); cy.contains(' (8)').should('exist'); @@ -134,16 +129,13 @@ describe('Testing dashboard table', () => { }); it('Redirects to traces table with filter', () => { - cy.wait(delay); cy.get('.euiLink').contains('13').click(); - cy.wait(delay); cy.get('h2.euiTitle').contains('Traces').should('exist'); cy.contains(' (13)').should('exist'); cy.contains('client_create_order').should('exist'); cy.get('.euiSideNavItemButton__label').contains('Trace analytics').click(); - cy.wait(delay); cy.contains('client_create_order').should('exist'); }); @@ -211,7 +203,6 @@ describe('Latency by trace group table', () =>{ it('Sorts the Latency by trace group table', () => { cy.get('span[title*="Trace group name"]').click(); cy.get('[data-test-subj="dashboard-table-trace-group-name-button"]').eq(0).contains('/**').should('exist'); - cy.wait(delay); }); it('Verify tooltips in Latency by trace group table', () => { @@ -232,7 +223,7 @@ describe('Latency by trace group table', () =>{ it('Verify Search engine on Trace dashboard', () => { cy.get('.euiFieldSearch.euiFieldSearch--fullWidth').click().type('client_pay_order'); cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); - cy.wait(delay); + cy.wait(delay);//Fails without cy.get('.euiTableCellContent.euiTableCellContent--alignRight.euiTableCellContent--overflowingContent').contains('211.04').should('exist'); cy.get('button[data-test-subj="dashboard-table-trace-group-name-button"]').click(); cy.get('.euiBadge.euiBadge--hollow.euiBadge--iconRight.globalFilterItem').click(); @@ -264,6 +255,7 @@ describe('Testing filters on trace analytics page', { scrollBehavior: false }, ( }); it('Verify Change all filters', () =>{ + cy.wait(delay);//Needed after removing waits from setTimeFilter() cy.get('[data-test-subj="global-filter-button"]').click(); cy.get('.euiContextMenuPanelTitle').contains('Change all filters').should('exist'); cy.get('.euiContextMenuItem__text').eq(0).contains('Enable all'); @@ -274,8 +266,10 @@ describe('Testing filters on trace analytics page', { scrollBehavior: false }, ( }) it('Verify Add filter section', () => { + cy.wait(delay);//Needed after removing waits from setTimeFilter() cy.get('[data-test-subj="addfilter"]').contains('+ Add filter').click(); cy.get('.euiPopoverTitle').contains('Add filter').should('exist'); + cy.wait(delay);//drop down won't open without cy.get('.euiComboBox__inputWrap.euiComboBox__inputWrap--noWrap').eq(0).trigger('mouseover').click(); cy.get('.euiComboBoxOption__content').eq(1).click(); cy.get('.euiComboBox__inputWrap.euiComboBox__inputWrap--noWrap').eq(1).trigger('mouseover').click(); @@ -370,9 +364,7 @@ describe('Testing switch mode to jaeger', () => { }); it('Verifies traces links to traces page', () => { - cy.wait(delay); cy.get('.euiLink').contains('7').click(); - cy.wait(delay); cy.get('h2.euiTitle').contains('Traces').should('exist'); cy.contains(' (7)').should('exist'); @@ -391,4 +383,4 @@ describe('Testing switch mode to jaeger', () => { cy.contains('Error rate').should('exist'); cy.contains('Traces').should('exist'); }); -}); +}); \ No newline at end of file diff --git a/.cypress/integration/5_trace_analytics_services.spec.js b/.cypress/integration/5_trace_analytics_services.spec.js index f5da59a1eb..7e02966617 100644 --- a/.cypress/integration/5_trace_analytics_services.spec.js +++ b/.cypress/integration/5_trace_analytics_services.spec.js @@ -14,7 +14,6 @@ describe('Testing services table empty state', () => { win.sessionStorage.clear(); }, }); - cy.wait(delay * 3); }); it('Renders empty state', () => { @@ -72,11 +71,6 @@ describe('Testing services table', () => { describe('Testing service view empty state', () => { beforeEach(() => { - // exception is thrown on loading EuiDataGrid in cypress only, ignore for now - cy.on('uncaught:exception', (err, runnable) => { - if (err.message.includes('ResizeObserver loop')) - return false; - }); cy.visit(`app/observability-traces#/services/${SERVICE_NAME}`, { onBeforeLoad: (win) => { win.sessionStorage.clear(); @@ -93,11 +87,6 @@ describe('Testing service view empty state', () => { describe('Testing service view', () => { beforeEach(() => { - // exception is thrown on loading EuiDataGrid in cypress only, ignore for now - cy.on('uncaught:exception', (err, runnable) => { - if (err.message.includes('ResizeObserver loop')) - return false; - }); cy.visit(`app/observability-traces#/services`, { onBeforeLoad: (win) => { win.sessionStorage.clear(); @@ -106,7 +95,7 @@ describe('Testing service view', () => { setTimeFilter(); cy.get('input[type="search"]').first().focus().type(`${SERVICE_NAME}`); cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); - cy.wait(delay); + cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait cy.get('[data-test-subj="service-link"]').eq(0).click(); }); @@ -119,28 +108,22 @@ describe('Testing service view', () => { it('Has working breadcrumbs', () => { cy.get('.euiBreadcrumb').contains(SERVICE_NAME).click(); - cy.wait(delay); cy.get('h2.euiTitle').contains(SERVICE_NAME).should('exist'); cy.get('.euiBreadcrumb').contains('Services').click(); - cy.wait(delay); cy.get('.euiTitle').contains('Services').should('exist'); cy.get('.euiBreadcrumb').contains('Trace analytics').click(); - cy.wait(delay); cy.get('.euiTitle').contains('Dashboard').should('exist'); cy.get('.euiBreadcrumb').contains('Observability').click(); - cy.wait(delay); - cy.get('.euiTitle').contains('Event analytics').should('exist'); + cy.get('.euiTitle').contains('Logs').should('exist'); }); it('Renders spans data grid, flyout, filters', () => { cy.get("[data-test-subj='spanId-link']").contains(SERVICE_SPAN_ID).trigger('mouseover', { force: true }); cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true }); - cy.wait(delay); cy.contains('Span detail').should('exist'); cy.contains('Span attributes').should('exist'); cy.get('.euiTextColor').contains('Span ID').trigger('mouseover'); cy.get('.euiButtonIcon[aria-label="span-flyout-filter-icon"').click({ force: true }); - cy.wait(delay); cy.get('.euiBadge__text').contains('spanId: ').should('exist'); cy.get('[data-test-subj="euiFlyoutCloseButton"]').click({ force: true }); cy.contains('Spans (1)').should('exist'); @@ -172,10 +155,6 @@ describe('Testing Service map', () => { describe('Testing traces Spans table verify table headers functionality', () => { beforeEach(() => { - cy.on('uncaught:exception', (err, runnable) => { - if (err.message.includes('ResizeObserver loop')) - return false; - }); cy.visit('app/observability-traces#/services', { onBeforeLoad: (win) => { win.sessionStorage.clear(); @@ -211,6 +190,7 @@ describe('Testing traces Spans table verify table headers functionality', () => it('Hide all button Spans table', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('.euiTableRow').should('have.length.lessThan', 2);//Replace wait cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click(); cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(1).should('have.text', 'Hide all').click(); cy.get('.euiDataGrid__focusWrap').click().should('exist'); @@ -268,10 +248,8 @@ describe('Testing traces Spans table and verify columns functionality', () => { cy.get('[aria-label="span-flyout-filter-icon"]').click(); cy.get('.euiFlyout__closeButton.euiFlyout__closeButton--inside').click(); cy.get('.euiBadge__content .euiBadge__text').contains('spanId: 277a5934acf55dcf').should('exist'); - cy.wait(delay); count_table_row(1); cy.get('[aria-label="remove current filter"]').click(); - cy.wait(delay); count_table_row(8); }); @@ -298,6 +276,7 @@ describe('Testing switch mode to jaeger', () => { setTimeFilter(); cy.get("[data-test-subj='indexPattern-switch-link']").click(); cy.get("[data-test-subj='jaeger-mode']").click(); + //cy.get('.euiButtonEmpty__text').should('contain', 'Jaeger'); }); it('Verifies columns and data', () => { @@ -312,10 +291,8 @@ describe('Testing switch mode to jaeger', () => { }); it('Verifies traces links to traces page with filter applied', () => { - cy.wait(delay); + cy.get('.euiTableRow').should('have.length.lessThan', 7);//Replaces Wait cy.get('.euiLink').contains('7').click(); - cy.wait(delay); - cy.get('h2.euiTitle').contains('Traces').should('exist'); cy.contains(' (7)').should('exist'); cy.get("[data-test-subj='filterBadge']").eq(0).contains('process.serviceName: customer') diff --git a/.cypress/integration/6_trace_analytics_traces.spec.js b/.cypress/integration/6_trace_analytics_traces.spec.js index 333f84ee31..c3ca6f3398 100644 --- a/.cypress/integration/6_trace_analytics_traces.spec.js +++ b/.cypress/integration/6_trace_analytics_traces.spec.js @@ -14,7 +14,6 @@ describe('Testing traces table empty state', () => { win.sessionStorage.clear(); }, }); - cy.wait(delay * 3); }); it('Renders empty state', () => { @@ -69,7 +68,7 @@ describe('Testing trace view', () => { setTimeFilter(); cy.get('input[type="search"]').focus().type(`${TRACE_ID}`); cy.get('.euiButton__text').contains('Refresh').click(); - cy.wait(delay); + cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait cy.get('[data-test-subj="trace-link"]').eq(0).click(); }); @@ -86,33 +85,27 @@ describe('Testing trace view', () => { it('Has working breadcrumbs', () => { cy.get(`.euiBreadcrumb[href="#/traces/${TRACE_ID}"]`).click(); - cy.wait(delay); cy.get('h2.euiTitle').contains(TRACE_ID).should('exist'); cy.get('.euiBreadcrumb[href="#/traces"]').click(); - cy.wait(delay); cy.get('.euiTitle').contains('Traces').should('exist'); cy.get('.euiBreadcrumb[href="#/"]').click(); - cy.wait(delay); cy.get('.euiTitle').contains('Dashboard').should('exist'); cy.get('.euiBreadcrumb[href="observability-logs#/"]').click(); - cy.wait(delay); - cy.get('.euiTitle').contains('Event analytics').should('exist'); + cy.get('.euiTitle').contains('Logs').should('exist'); }); it('Renders data grid, flyout and filters', () => { cy.get('.euiButton__text[title="Span list"]').click({ force: true }); cy.contains('2 columns hidden').should('exist'); - cy.wait(delay); cy.get('.euiLink').contains(SPAN_ID).trigger('mouseover', { force: true }); cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true }); cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true }); // first click doesn't go through eui data grid - cy.wait(delay); + cy.contains('Span detail').should('exist'); cy.contains('Span attributes').should('exist'); cy.get('.euiTextColor').contains('Span ID').trigger('mouseover'); cy.get('.euiButtonIcon[aria-label="span-flyout-filter-icon"').click({ force: true }); - cy.wait(delay); cy.get('.euiBadge__text').contains('spanId: ').should('exist'); cy.contains('Spans (1)').should('exist'); @@ -146,7 +139,6 @@ describe('Testing traces table', () => { cy.contains('client_create_order').should('exist'); cy.get('path[style*="rgb(116, 146, 231)"]').should('exist'); cy.go('back'); - cy.wait(delay); cy.get('.euiButtonEmpty__text').contains('Rows per page').click(); cy.get('.euiContextMenuItem__text').contains('15 rows').click(); let expected_row_count=15; diff --git a/.cypress/integration/8_metrics_analytics.spec.js b/.cypress/integration/8_metrics_analytics.spec.js new file mode 100644 index 0000000000..511d65a667 --- /dev/null +++ b/.cypress/integration/8_metrics_analytics.spec.js @@ -0,0 +1,260 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +/// + +import { + delay, + PPL_METRICS, + PPL_METRICS_NAMES, + VIS_TYPE_LINE, + TESTING_PANEL, +} from '../utils/metrics_constants'; +import { suppressResizeObserverIssue, COMMAND_TIMEOUT_LONG } from '../utils/constants'; +import { clearQuerySearchBoxText } from '../utils/event_analytics/helpers'; +import { landOnPanels } from '../utils/event_analytics/constants'; + +const moveToMetricsHome = () => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-metrics#/`); + cy.wait(delay * 3); +}; + +const moveToEventsExplorer = () => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/explorer`); + cy.wait(delay * 3); +}; + +const moveToEventsHome = () => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/`); + cy.wait(delay * 3); +}; + +describe('Creating custom metrics', () => { + beforeEach(() => { + moveToEventsExplorer(); + clearQuerySearchBoxText('searchAutocompleteTextArea'); + suppressResizeObserverIssue(); + }); + + it('Create custom metric in event analytics and check it in events home', () => { + cy.get('[id^=autocomplete-textarea]').focus().type(PPL_METRICS[0], { + delay: 50, + }); + cy.get('.euiButton__text').contains('Refresh').trigger('mouseover').click(); + cy.wait(delay); + suppressResizeObserverIssue(); + cy.get('button[id="main-content-vis"]').contains('Visualizations').trigger('mouseover').click(); + cy.wait(delay * 2); + cy.get('[data-test-subj="comboBoxToggleListButton"]').click(); + cy.get('[data-test-subj="comboBoxSearchInput"]').focus().type(VIS_TYPE_LINE, { force: true }); + cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').click({ force: true }); + cy.get('[data-test-subj="eventExplorer__querySaveName"]') + .focus() + .type(PPL_METRICS_NAMES[0], { force: true }); + cy.get('[data-test-subj="eventExplorer__metricSaveName"]').click({ force: true }); + cy.wait(1000); + cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]', { + timeout: COMMAND_TIMEOUT_LONG, + }).click(); + cy.wait(delay); + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + moveToEventsHome(); + cy.get('[data-test-subj="eventHome__savedQueryTableName"]') + .first() + .contains(PPL_METRICS_NAMES[0]); + }); + + it('Check for new metrics under recently created netrics', () => { + cy.get('[id^=autocomplete-textarea]').focus().type(PPL_METRICS[1], { + delay: 50, + }); + cy.get('.euiButton__text').contains('Refresh').trigger('mouseover').click(); + cy.wait(delay); + suppressResizeObserverIssue(); + cy.get('button[id="main-content-vis"]').contains('Visualizations').trigger('mouseover').click(); + cy.wait(delay * 2); + cy.get('[data-test-subj="comboBoxInput"]').click(); + cy.get('.euiComboBoxOption__content').contains('Time series').click({ force: true }); + + cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').click({ force: true }); + cy.get('[data-test-subj="eventExplorer__querySaveName"]') + .focus() + .type(PPL_METRICS_NAMES[1], { force: true }); + cy.get('[data-test-subj="eventExplorer__metricSaveName"]').click({ force: true }); + cy.wait(1000); + cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]', { + timeout: COMMAND_TIMEOUT_LONG, + }).click(); + cy.wait(delay); + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + moveToMetricsHome(); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[1]) + .should('exist'); + }); +}); + +describe('Search for metrics in search bar', () => { + beforeEach(() => { + moveToMetricsHome(); + suppressResizeObserverIssue(); + }); + + it('Search for metrics in search bar from available metrics', () => { + cy.get('[data-test-subj="metricsSearch"]').type('metric', { + delay: 50, + }); + cy.wait(delay); + + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[0]) + .should('exist'); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[1]) + .should('exist'); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains('go_memstats_alloc_bytes') + .should('not.exist'); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains('go_threads') + .should('not.exist'); + }); +}); + +describe('Select and unselect metrics in sidebar', () => { + it('Select and unselect metrics in sidebar', () => { + moveToMetricsHome(); + suppressResizeObserverIssue(); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[0]) + .trigger('mouseover') + .click(); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[1]) + .trigger('mouseover') + .click(); + cy.wait(50); + cy.get('[data-test-subj="metricsListItems_selectedMetrics"]') + .contains(PPL_METRICS_NAMES[0]) + .should('exist'); + cy.get('[data-test-subj="metricsListItems_selectedMetrics"]') + .contains(PPL_METRICS_NAMES[1]) + .should('exist'); + cy.get('[data-test-subj="metricsListItems_selectedMetrics"]') + .contains(PPL_METRICS_NAMES[0]) + .trigger('mouseover') + .click(); + cy.get('[data-test-subj="metricsListItems_selectedMetrics"]') + .contains(PPL_METRICS_NAMES[1]) + .trigger('mouseover') + .click(); + cy.wait(50); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[0]) + .trigger('mouseover') + .should('exist'); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[1]) + .trigger('mouseover') + .should('exist'); + }); +}); + +describe('Test Metric Visualizations', () => { + beforeEach(() => { + moveToMetricsHome(); + suppressResizeObserverIssue(); + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[0]) + .trigger('mouseover') + .click(); + }); + + it('Resize a Metric visualization in edit mode', () => { + cy.get('[data-test-subj="metrics__editView"]') + .contains('Edit view') + .trigger('mouseover') + .click(); + cy.wait(delay); + cy.get('.react-resizable-handle-se') + // .eq(1) + .trigger('mousedown', { which: 1 }) + .trigger('mousemove', { clientX: 2000, clientY: 800 }) + .trigger('mouseup', { force: true }); + cy.wait(delay); + cy.get('[data-test-subj="metrics__saveView"]').trigger('mouseover').click(); + cy.wait(delay * 3); + cy.get('div.react-grid-layout>div').invoke('height').should('match', new RegExp('630')); + cy.wait(delay); + }); + + it('Drag and drop a Metric visualization in edit mode', () => { + cy.get('[data-test-subj="metricsListItems_recentlyCreated"]') + .contains(PPL_METRICS_NAMES[1]) + .trigger('mouseover') + .click(); + cy.get('[data-test-subj="metrics__editView"]') + .contains('Edit view') + .trigger('mouseover') + .click(); + cy.wait(delay); + cy.get('h5') + .contains(PPL_METRICS_NAMES[0]) + .trigger('mousedown', { which: 1, force: true }) + .trigger('mousemove', { clientX: 415, clientY: 500 }) + .trigger('mouseup', { force: true }); + cy.wait(delay); + cy.get('[data-test-subj="metrics__saveView"]') + .trigger('mouseover') + .click({ force: true }) + .then(() => { + cy.wait(delay * 3); + cy.get('div.react-grid-layout>div') + .eq(1) + .invoke('attr', 'style') + .should('match', new RegExp('(.*)transform: translate((.*)10px)(.*)')); + cy.wait(delay); + }); + }); + + it('Change date filter of the Metrics home page', () => { + cy.get('.euiButtonEmpty[data-test-subj="superDatePickerToggleQuickMenuButton"]').click({ + force: true, + }); + cy.get('.euiLink').contains('This year').trigger('mouseover').click(); + cy.wait(delay * 2); + cy.get('.euiSuperDatePicker__prettyFormat[data-test-subj="superDatePickerShowDatesButton"]') + .contains('This year') + .should('exist'); + cy.wait(delay); + }); + + it('Saves metrics to an existing panel', () => { + landOnPanels(); + cy.get('[data-test-subj="customPanels__createNewPanels"]').click(); + cy.get('input.euiFieldText').type(TESTING_PANEL); + cy.get('.euiButton__text', { timeout: COMMAND_TIMEOUT_LONG }) + .contains(/^Create$/) + .click(); + cy.wait(delay * 3); + moveToMetricsHome(); + cy.get('[data-test-subj="metrics__saveManagementPopover"]').trigger('mouseover').click(); + cy.get('[data-test-subj="comboBoxSearchInput"]').focus().type(TESTING_PANEL, { force: true }); + cy.get('[data-test-subj="metrics__SaveConfirm"]').click({ force: true }); + cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + }); +}); + +describe('Has working breadcrumbs', () => { + it('Redirect to correct page on breadcrumb click', () => { + moveToMetricsHome(); + suppressResizeObserverIssue(); + cy.get('[data-test-subj="metricsSearch"]').should('exist'); + cy.get('.euiTitle').contains('Metrics').should('exist'); + cy.get('.euiBreadcrumb[href="observability-logs#/"]').click(), + { timeout: COMMAND_TIMEOUT_LONG }; + cy.get('.euiTitle').contains('Logs').should('exist'); + }); +}); diff --git a/.cypress/utils/constants.js b/.cypress/utils/constants.js index d7b296dd64..194fe0e971 100644 --- a/.cypress/utils/constants.js +++ b/.cypress/utils/constants.js @@ -57,18 +57,16 @@ export const setTimeFilter = (setEndTime = false, refresh = true) => { .focus() .type('{selectall}' + startTime, { force: true }); if (setEndTime) { - cy.wait(delay); cy.get( 'button.euiDatePopoverButton--end[data-test-subj="superDatePickerendDatePopoverButton"]' ).click(); - cy.wait(delay); cy.get('.euiTab__content').contains('Absolute').click(); cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]') .focus() .type('{selectall}' + endTime, { force: true }); } if (refresh) cy.get('.euiButton__text').contains('Refresh').click(); - cy.wait(delay); + cy.get('.euiTableRow').should('have.length.greaterThan', 3);//Replaces Wait }; // notebooks diff --git a/.cypress/utils/metrics_constants.js b/.cypress/utils/metrics_constants.js new file mode 100644 index 0000000000..63c5c18955 --- /dev/null +++ b/.cypress/utils/metrics_constants.js @@ -0,0 +1,23 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export const delay = 100; + +export const PPL_METRICS_NAMES = [ + '[Metric] Average ram usage per day by windows os', + '[Metric] Daily count for error response codes', + '[Metric] Average ram usage per day by apple os', + 'Average value by memstats stat bytes', + 'Average value by memstats heap allocation bytes', +]; + +export const PPL_METRICS = [ + "source = opensearch_dashboards_sample_data_logs | where match(machine.os,'win') | stats avg(machine.ram) by span(timestamp,1d)", + "source = opensearch_dashboards_sample_data_logs | where response='503' or response='404' | stats count() by span(timestamp,1d)", + "source = opensearch_dashboards_sample_data_logs | where machine.os='osx' or machine.os='ios' | stats avg(machine.ram) by span(timestamp,1d)", +]; + +export const VIS_TYPE_LINE = 'Time Series'; +export const TESTING_PANEL = 'Mock Testing Panels for Metrics'; diff --git a/.cypress/utils/panel_constants.js b/.cypress/utils/panel_constants.js index cc173d8076..de009ccf9d 100644 --- a/.cypress/utils/panel_constants.js +++ b/.cypress/utils/panel_constants.js @@ -20,9 +20,9 @@ export const SAMPLE_VISUALIZATIONS_NAMES = [ ]; export const PPL_VISUALIZATIONS = [ - 'source = opensearch_dashboards_sample_data_flights | stats count() by Dest', + 'source = opensearch_dashboards_sample_data_flights | stats count(Dest) by Dest', 'source = opensearch_dashboards_sample_data_flights | stats avg(FlightDelayMin) by Carrier', - 'source = opensearch_dashboards_sample_data_flights | stats max( DistanceKilometers ) by DestCityName', + 'source = opensearch_dashboards_sample_data_flights | stats max( DistanceKilometers ) by Dest', ]; export const PPL_VISUALIZATIONS_NAMES = [ @@ -31,6 +31,12 @@ export const PPL_VISUALIZATIONS_NAMES = [ 'Max distance by destination city', ]; +export const PPL_VISUALIZATION_CONFIGS = [ + '{"dataConfig":{"series":[{"customLabel":"","label":"Dest","name":"Dest","aggregation":"count"}],"dimensions":[{"label":"Dest","name":"Dest"}],"breakdowns":[]}}', + '{"dataConfig":{"series":[{"customLabel":"","label":"FlightDelayMin","name":"FlightDelayMin","aggregation":"avg"}],"dimensions":[{"label":"Dest","name":"Dest"}],"breakdowns":[]}}', + '{"dataConfig":{"series":[{"label":"DistanceKilometers","name":"DistanceKilometers","aggregation":"max","customLabel":""}],"dimensions":[{"label":"Dest","name":"Dest"}]}}', +]; + export const NEW_VISUALIZATION_NAME = 'Flight count by destination airport'; export const PPL_FILTER = "where Carrier = 'OpenSearch-Air' | where Dest = 'Munich Airport'"; diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d3de625893..2108cc1859 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,2 @@ # This should match the owning team set up in https://github.com/orgs/opensearch-project/teams -* @pjfitzgibbons @ps48 @kavithacm @derek-ho @joshuali925 @dai-chen @YANG-DB @rupal-bq @mengweieric @vamsi-amazon @swiddis @penghuo @seankao-az @anirudha \ No newline at end of file +* @pjfitzgibbons @ps48 @kavithacm @derek-ho @joshuali925 @dai-chen @YANG-DB @rupal-bq @mengweieric @vamsi-amazon @swiddis @penghuo @seankao-az @anirudha @TackAdam diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 68e4e8ed06..dd45e0f197 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -19,9 +19,9 @@ This document contains a list of maintainers in this repo. See [opensearch-proje | Vamsi Manohar | [vamsi-amazon](https://github.com/vamsi-amazon) | Amazon | | Peng Huo | [penghuo](https://github.com/penghuo) | Amazon | | Sean Kao | [seankao-az](https://github.com/seankao-az) | Amazon | +| Adam Tackett | [TackAdam](https://github.com/TackAdam) | Amazon | | Anirudha Jadhav | [anirudha](https://github.com/anirudha) | Amazon | - ## Emeritus Maintainers | Maintainer | GitHub ID | Affiliation | diff --git a/public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx b/public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx index 986411c236..e74e485089 100644 --- a/public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx +++ b/public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx @@ -25,6 +25,7 @@ import { EuiToolTip, } from '@elastic/eui'; import React, { useEffect, useMemo, useState } from 'react'; +import _ from 'lodash'; import { CoreStart } from '../../../../../../../src/core/public'; import PPLService from '../../../../services/requests/ppl'; import { @@ -34,7 +35,6 @@ import { } from '../../helpers/utils'; import './visualization_container.scss'; import { VizContainerError } from '../../../../../common/types/custom_panels'; -import _ from 'lodash'; /* * Visualization container - This module is a placeholder to add visualizations in react-grid-layout @@ -329,7 +329,10 @@ export const VisualizationContainer = ({ closePopover={closeActionsMenu} anchorPosition="downLeft" > - + )} diff --git a/public/components/event_analytics/explorer/explorer.scss b/public/components/event_analytics/explorer/explorer.scss index 33acd6b449..9d73808d27 100644 --- a/public/components/event_analytics/explorer/explorer.scss +++ b/public/components/event_analytics/explorer/explorer.scss @@ -3,10 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#opensearch-dashboards-body { - overflow-y: hidden; -} - .liveStream { margin : 8px; height: 40px; diff --git a/public/components/event_analytics/explorer/save_panel/__tests__/__snapshots__/save_panel.test.tsx.snap b/public/components/event_analytics/explorer/save_panel/__tests__/__snapshots__/save_panel.test.tsx.snap index cbc6c696c2..8729ce92b2 100644 --- a/public/components/event_analytics/explorer/save_panel/__tests__/__snapshots__/save_panel.test.tsx.snap +++ b/public/components/event_analytics/explorer/save_panel/__tests__/__snapshots__/save_panel.test.tsx.snap @@ -112,7 +112,11 @@ exports[`Saved query table component Renders saved query table 1`] = ` }, ] } - singleSelection={false} + singleSelection={ + Object { + "asPlainText": true, + } + } sortMatchesBy="none" >
- - - - - - - [Logs] Web traffic Panel - - - - - - - + [Logs] Web traffic Panel + - - - - - - - [Logs] Web traffic Panel 2 - - - - - - - + [Logs] Web traffic Panel 2 + @@ -121,6 +122,7 @@ export const SavePanel = ({ onChange={onToggleChange} compressed disabled={!isSaveAsMetricEnabled} + data-test-subj="eventExplorer__metricSaveName" /> diff --git a/public/components/metrics/index.scss b/public/components/metrics/index.scss index 1b96965459..9f2d601982 100644 --- a/public/components/metrics/index.scss +++ b/public/components/metrics/index.scss @@ -3,10 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#opensearch-dashboards-body { - overflow-y: hidden; -} - .liveStream { margin : 8px; height: 40px; diff --git a/public/components/metrics/index.tsx b/public/components/metrics/index.tsx index 7d7eef327f..a6ff425146 100644 --- a/public/components/metrics/index.tsx +++ b/public/components/metrics/index.tsx @@ -83,8 +83,7 @@ export const Home = ({ setToasts([...toasts, { id: new Date().toISOString(), title, text, color } as Toast]); }; - const onRefreshFilters = (startTime: ShortDate, endTime: ShortDate) => { - // eslint-disable-line + const onRefreshFilters = (startTimeFilter: ShortDate, endTimeFilter: ShortDate) => { if (spanValue < 1) { setToast('Please add a valid span interval', 'danger'); return; @@ -222,6 +221,7 @@ export const Home = ({ moveToEvents={onEditClick} onRefresh={onRefresh} editActionType={editActionType} + setEditActionType={setEditActionType} spanParam={spanValue + resolutionValue} /> ) : ( diff --git a/public/components/metrics/redux/slices/metrics_slice.ts b/public/components/metrics/redux/slices/metrics_slice.ts index 3054b25b90..943675db12 100644 --- a/public/components/metrics/redux/slices/metrics_slice.ts +++ b/public/components/metrics/redux/slices/metrics_slice.ts @@ -56,14 +56,16 @@ const fetchRemoteMetrics = async (pplService: any) => { pplService, `source = ${dataSource.DATASOURCE_NAME}.information_schema.tables` ); - const normalizedData = catalogData.jsonData.map((obj: any) => ({ - id: `${obj.TABLE_CATALOG}.${obj.TABLE_NAME}`, - name: `${obj.TABLE_CATALOG}.${obj.TABLE_NAME}`, - catalog: `${dataSource.DATASOURCE_NAME}`, - type: obj.TABLE_TYPE, - recentlyCreated: false, - })); - dataSet.push(normalizedData); + if (catalogData !== undefined) { + const normalizedData = catalogData.jsonData.map((obj: any) => ({ + id: `${obj.TABLE_CATALOG}.${obj.TABLE_NAME}`, + name: `${obj.TABLE_CATALOG}.${obj.TABLE_NAME}`, + catalog: `${dataSource.DATASOURCE_NAME}`, + type: obj.TABLE_TYPE, + recentlyCreated: false, + })); + dataSet.push(normalizedData); + } } return dataSet; }; diff --git a/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap b/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap index 9232c58180..cbf7f59758 100644 --- a/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap +++ b/public/components/metrics/sidebar/__tests__/__snapshots__/searchbar.test.tsx.snap @@ -17,6 +17,7 @@ exports[`Search Bar Component Search Side Bar Component with available metrics 1 >
void; + dataTestSubj: string; } export const MetricsAccordion = (props: IMetricNameProps) => { - const { metricsList, headerName, handleClick } = props; + const { metricsList, headerName, handleClick, dataTestSubj } = props; return ( { >
    {metricsList.slice(0, 100).map((metric: any) => ( -
  • +
  • ))} diff --git a/public/components/metrics/sidebar/search_bar.tsx b/public/components/metrics/sidebar/search_bar.tsx index 26c564b4df..3843381a8b 100644 --- a/public/components/metrics/sidebar/search_bar.tsx +++ b/public/components/metrics/sidebar/search_bar.tsx @@ -28,7 +28,7 @@ export const SearchBar = (props: ISearchBarProps) => { }; return ( -
    +
    { metricsList={recentlyCreatedMetrics} headerName="Recently Created Metrics" handleClick={handleAddMetric} + dataTestSubj="metricsListItems_recentlyCreated" /> diff --git a/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap b/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap index 3e603d391b..070dfcd797 100644 --- a/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap +++ b/public/components/metrics/top_menu/__tests__/__snapshots__/top_menu.test.tsx.snap @@ -81,6 +81,7 @@ exports[`Metrics Top Menu Component renders Top Menu Component when disabled in