diff --git a/.cypress/integration/02-edit.spec.ts b/.cypress/integration/02-edit.spec.ts index 23a48b56..f7f76e91 100644 --- a/.cypress/integration/02-edit.spec.ts +++ b/.cypress/integration/02-edit.spec.ts @@ -4,25 +4,34 @@ */ describe('Cypress', () => { - it('Visit edit page, update name and description', () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); + beforeEach(() => { + // Wait before visiting to allow index refresh after previous test's save + cy.wait(5000); + cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`, { + timeout: 60000, + }); cy.location('pathname', { timeout: 60000 }).should( 'include', '/reports-dashboards' ); + // Retry: if the list doesn't load, reload the page + cy.get('body').then(($body) => { + if ($body.find('#reportDefinitionDetailsLink').length === 0) { + cy.wait(5000); + cy.reload(); + } + }); + cy.get('#reportDefinitionDetailsLink', { timeout: 60000 }).should('exist'); + }); - cy.wait(12500); - + it('Visit edit page, update name and description', () => { cy.get('#reportDefinitionDetailsLink').first().click(); cy.get('#editReportDefinitionButton').should('exist'); - cy.get('#editReportDefinitionButton').click(); cy.url().should('include', 'edit'); - cy.wait(1000); - // update the report name cy.get('#reportSettingsName').type(' update name', { force: true }); @@ -31,67 +40,44 @@ describe('Cypress', () => { cy.get('#editReportDefinitionButton').click({ force: true }); - cy.wait(12500); - // check that re-direct to home page - cy.get('#reportDefinitionDetailsLink').should('exist'); + cy.get('#reportDefinitionDetailsLink', { timeout: 60000 }).should('exist'); }); it('Visit edit page, change report trigger', () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); - cy.location('pathname', { timeout: 60000 }).should( - 'include', - '/reports-dashboards' - ); - - cy.wait(12500); - cy.get('#reportDefinitionDetailsLink').first().click(); cy.get('#editReportDefinitionButton').should('exist'); - cy.get('#editReportDefinitionButton').click(); cy.url().should('include', 'edit'); - cy.wait(1000); - cy.get('#reportDefinitionTriggerTypes > div:nth-child(2)').click({ force: true }); + cy.get('#reportDefinitionTriggerTypes > div:nth-child(2)').click({ + force: true, + }); cy.get('#Schedule').check({ force: true }); cy.get('#editReportDefinitionButton').click({ force: true }); - cy.wait(12500); - // check that re-direct to home page - cy.get('#reportDefinitionDetailsLink').should('exist'); + cy.get('#reportDefinitionDetailsLink', { timeout: 60000 }).should('exist'); }); it('Visit edit page, change report trigger back', () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`); - cy.location('pathname', { timeout: 60000 }).should( - 'include', - '/reports-dashboards' - ); - - cy.wait(12500); - cy.get('#reportDefinitionDetailsLink').first().click(); cy.get('#editReportDefinitionButton').should('exist'); - cy.get('#editReportDefinitionButton').click(); cy.url().should('include', 'edit'); - cy.wait(1000); - - cy.get('#reportDefinitionTriggerTypes > div:nth-child(1)').click({ force: true }); + cy.get('#reportDefinitionTriggerTypes > div:nth-child(1)').click({ + force: true, + }); cy.get('#editReportDefinitionButton').click({ force: true }); - cy.wait(12500); - // check that re-direct to home page - cy.get('#reportDefinitionDetailsLink').should('exist'); + cy.get('#reportDefinitionDetailsLink', { timeout: 60000 }).should('exist'); }); }); diff --git a/package.json b/package.json index 36e01007..a4e9c8dc 100644 --- a/package.json +++ b/package.json @@ -82,4 +82,4 @@ "qs": "^6.14.1", "uuid": "^11.1.1" } -} \ No newline at end of file +}