diff --git a/dashboards-reports/.cypress/integration/01-create.spec.ts b/dashboards-reports/.cypress/integration/01-create.spec.ts index 65b4999d..d047aeff 100644 --- a/dashboards-reports/.cypress/integration/01-create.spec.ts +++ b/dashboards-reports/.cypress/integration/01-create.spec.ts @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { visitReportingLandingPage } from "../support/utils"; + describe('Adding sample data', () => { it('Adds sample data', () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`); @@ -195,14 +197,6 @@ describe('Cypress', () => { }); }); -function visitReportingLandingPage() { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); - cy.location('pathname', { timeout: 60000 }).should( - 'include', - '/reports-dashboards' - ); -} - function visitCreateReportDefinitionPage() { cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); cy.location('pathname', { timeout: 60000 }).should( diff --git a/dashboards-reports/.cypress/integration/03-details.spec.ts b/dashboards-reports/.cypress/integration/03-details.spec.ts index dfcb0f51..166da435 100644 --- a/dashboards-reports/.cypress/integration/03-details.spec.ts +++ b/dashboards-reports/.cypress/integration/03-details.spec.ts @@ -3,45 +3,109 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { visitReportingLandingPage } from "../support/utils"; + describe('Cypress', () => { it('Visit report definition details page', () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); - cy.location('pathname', { timeout: 60000 }).should( - 'include', - '/reports-dashboards' - ); + visitReportingLandingPage(); + cy.wait(5000); + visitReportDefinitionDetailsPage(); + verifyReportDefinitionDetailsURL(); + verifyDeleteDefinitionButtonExists(); + verifyGenerateReportFromFileFormatExists(); + }); - cy.wait(12500); + it('Go to edit report definition from report definition details', () => { + visitReportingLandingPage(); + cy.wait(5000); + visitReportDefinitionDetailsPage(); + verifyEditDefinitionButtonExists(); + clickEditReportDefinitionButton(); + verifyEditReportDefinitionURL(); + }); - cy.get('#reportDefinitionDetailsLink').first().click(); + it('Verify report source URL on report definition details', () => { + visitReportingLandingPage(); + cy.wait(5000); + visitReportDefinitionDetailsPage(); + verifyReportDefinitionSourceURLExists(); + + }); - cy.url().should('include', 'report_definition_details'); + it('Delete report definition from details page', () => { + visitReportingLandingPage(); + cy.wait(5000); + visitReportDefinitionDetailsPage(); + verifyDeleteDefinitionButtonExists(); + deleteReportDefinition(); + verifyDeleteSuccess(); + }); - cy.get('#deleteReportDefinitionButton').should('exist'); + it('Visit report details page', () => { + visitReportingLandingPage(); + cy.wait(5000); + visitReportDetailsPage(); + verifyReportDetailsURL(); + }); - cy.get('#editReportDefinitionButton').should('exist'); + it('Verify report source URL on report details', () => { + visitReportingLandingPage(); + cy.wait(5000); + visitReportDetailsPage(); + verifyReportDetailsSourceURLExists(); + }); +}); - if (cy.get('body').contains('Schedule details')) { - cy.wait(1000); - cy.get('#changeStatusFromDetailsButton').click(); - } else { - cy.wait(1000); - cy.get('#generateReportFromDetailsButton').click(); - } +function visitReportDefinitionDetailsPage() { + cy.get('#reportDefinitionDetailsLink').first().click(); +} - cy.get('#deleteReportDefinitionButton').click(); - }); +function verifyReportDefinitionDetailsURL() { + cy.url().should('include', 'report_definition_details'); +} - it('Visit report details page', () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); - cy.location('pathname', { timeout: 60000 }).should( - 'include', - '/reports-dashboards' - ); +function verifyDeleteDefinitionButtonExists() { + cy.get('#deleteReportDefinitionButton').should('exist'); +} - cy.wait(12500); - cy.get('#reportDetailsLink').first().click(); +function verifyEditDefinitionButtonExists() { + cy.get('#editReportDefinitionButton').should('exist'); +} - cy.url().should('include', 'report_details'); - }); -}); +function clickEditReportDefinitionButton() { + cy.get('#editReportDefinitionButton').click({ force: true }); +} + +function verifyEditReportDefinitionURL() { + cy.url().should('include', 'edit'); +} + +function verifyReportDefinitionSourceURLExists() { + cy.get('#reportDefinitionSourceURL').should('exist'); +} + +function verifyReportDetailsSourceURLExists() { + cy.get('#reportDetailsSourceURL').should('exist'); +} + +function verifyGenerateReportFromFileFormatExists() { + cy.get('#generateReportFromDetailsFileFormat').should('exist'); +} + +function deleteReportDefinition() { + cy.get('#deleteReportDefinitionButton').click(); + cy.wait(500); + cy.get('button.euiButton:nth-child(2)').click({ force: true }); +} + +function verifyDeleteSuccess() { + cy.get('#deleteReportDefinitionSuccessToast').should('exist'); +} + +function visitReportDetailsPage() { + cy.get('#reportDetailsLink').first().click(); +} + +function verifyReportDetailsURL() { + cy.url().should('include', 'report_details'); +} diff --git a/dashboards-reports/.cypress/support/constants.js b/dashboards-reports/.cypress/support/constants.js index 4f2416b5..1001fd49 100644 --- a/dashboards-reports/.cypress/support/constants.js +++ b/dashboards-reports/.cypress/support/constants.js @@ -6,4 +6,4 @@ export const ADMIN_AUTH = { username: 'admin', password: 'admin', -}; \ No newline at end of file +}; diff --git a/dashboards-reports/.cypress/support/utils.js b/dashboards-reports/.cypress/support/utils.js new file mode 100644 index 00000000..a534be13 --- /dev/null +++ b/dashboards-reports/.cypress/support/utils.js @@ -0,0 +1,12 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export function visitReportingLandingPage() { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); + cy.location('pathname', { timeout: 60000 }).should( + 'include', + '/reports-dashboards' + ); + } \ No newline at end of file diff --git a/dashboards-reports/public/components/main/report_definition_details/__tests__/__snapshots__/report_definition_details.test.tsx.snap b/dashboards-reports/public/components/main/report_definition_details/__tests__/__snapshots__/report_definition_details.test.tsx.snap index f5cbdec9..21653179 100644 --- a/dashboards-reports/public/components/main/report_definition_details/__tests__/__snapshots__/report_definition_details.test.tsx.snap +++ b/dashboards-reports/public/components/main/report_definition_details/__tests__/__snapshots__/report_definition_details.test.tsx.snap @@ -200,6 +200,7 @@ exports[` panel render 5 hours recurring definition d @@ -242,7 +243,7 @@ exports[` panel render 5 hours recurring definition d >