From a7b3210c0e1310d45fea1ca36e1348dbe1b320d4 Mon Sep 17 00:00:00 2001 From: k3yi0 Date: Wed, 29 Jun 2022 10:13:26 +0200 Subject: [PATCH 1/2] chore(cypress): adjust Reader log in, improve Reader test --- ui/cypress/integration/dashboard.test.ts | 61 +++++++++++++++--------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/ui/cypress/integration/dashboard.test.ts b/ui/cypress/integration/dashboard.test.ts index c9bc2209d..705bd3135 100644 --- a/ui/cypress/integration/dashboard.test.ts +++ b/ui/cypress/integration/dashboard.test.ts @@ -5,50 +5,45 @@ describe('Use Dashboards', () => { beforeEach(() => { cy.toInitialState() - cy.createInfluxDBConnection() - .then((src: Source) => { - source = src - cy.visit(`/sources/${source.id}/dashboards`) - cy.createDashboard('Reader Dashboard') - }) + cy.createInfluxDBConnection().then((src: Source) => { + source = src + cy.visit(`/sources/${source.id}/dashboards`) + }) }) it('create, rename and delete a dashboard', () => { - // create a dashboard - cy.get('button').contains('Create Dashboard').click() - const newName = 'DashboardQA' - // rename the dashboard + cy.get('button').contains('Create Dashboard').click() cy.get('.rename-dashboard') .should('have.text', 'Name This Dashboard') .type(`${newName}{enter}`) .should('have.text', newName) - // delete the dashboard cy.visit(`/sources/${source.id}/dashboards`) - // DOM Element where the dashboard resides cy.get('.panel-body > table > tbody') .should('exist') .within(() => { // delete button - cy.get('.confirm-button--confirmation').eq(1).click({force: true}) + cy.get('.confirm-button--confirmation').click({force: true}) }) }) describe('Use Dashboards as reader', () => { beforeEach(() => { - cy.getByTestID('sidebar') - .should('be.visible') - .then(() => { - cy.createChronografUser('Reader', 'oauth-mock', 'oauth2').then(() => { - cy.OAuthLoginAsDiffUser('Reader') - }) + cy.createDashboard('Reader Dashboard').then(() => { + cy.createChronografUser('Reader', 'oauth-mock', 'oauth2').then(() => { + cy.getByTestID('dashboard-panel') + .should('be.visible') + .then(() => { + cy.OAuthLoginAsDiffUser('Reader') + }) }) + }) }) - it('ensure that all elements used to edit Chronograf are not visible', () => { + it.only('ensure that all elements used to edit Chronograf are not visible', () => { cy.getByTestID('sidebar').should('not.exist') cy.getByTestID('import-dashboard--button').should('not.exist') cy.getByTestID('create-dashboard-button').should('not.exist') @@ -65,11 +60,33 @@ describe('Use Dashboards', () => { cy.get('.dashboard-empty--menu').should('not.exist') cy.getByTestID('add-cell').should('not.exist') + cy.get('.template-control-bar').should('not.exist') cy.getByTestID('show-variables--button').should('be.visible').click() + cy.get('.template-control-bar').should('exist').and('be.visible') + cy.get('.annotation-control-bar').should('not.exist') + cy.getByTestID('show-annotations--button').should('be.visible').click() + cy.get('.annotation-control-bar').should('exist').and('be.visible') cy.getByTestID('add-template-variable').should('not.exist') - cy.getByTestID('show-annotations--button').click() cy.getByTestID('add-annotation--button').should('not.exist') - cy.getByTestID('add-annotation-filter--button').should('not.exist') + cy.window() + .its('localStorage') + .then(({state}) => { + cy.wrap(state).should( + 'contain', + '"showTemplateVariableControlBar":true' + ) + cy.wrap(state).should('contain', '"showAnnotationControls":true') + }) + + cy.reload().then(() => { + cy.get('.page-header--title') + .should('exist') + .and('be.visible') + .then(() => { + cy.get('.template-control-bar').should('exist').and('be.visible') + cy.get('.annotation-control-bar').should('exist').and('be.visible') + }) + }) }) }) }) From 655e4366dd3e540e1838fdd7f81d36a8fed6fca0 Mon Sep 17 00:00:00 2001 From: k3yi0 Date: Wed, 29 Jun 2022 10:45:02 +0200 Subject: [PATCH 2/2] chore(cypress): remove .only, remove assertion of local storage --- ui/cypress/integration/dashboard.test.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/ui/cypress/integration/dashboard.test.ts b/ui/cypress/integration/dashboard.test.ts index 705bd3135..9e2231ef3 100644 --- a/ui/cypress/integration/dashboard.test.ts +++ b/ui/cypress/integration/dashboard.test.ts @@ -43,7 +43,7 @@ describe('Use Dashboards', () => { }) }) - it.only('ensure that all elements used to edit Chronograf are not visible', () => { + it('ensure that all elements used to edit Chronograf are not visible', () => { cy.getByTestID('sidebar').should('not.exist') cy.getByTestID('import-dashboard--button').should('not.exist') cy.getByTestID('create-dashboard-button').should('not.exist') @@ -65,19 +65,14 @@ describe('Use Dashboards', () => { cy.get('.template-control-bar').should('exist').and('be.visible') cy.get('.annotation-control-bar').should('not.exist') cy.getByTestID('show-annotations--button').should('be.visible').click() - cy.get('.annotation-control-bar').should('exist').and('be.visible') - cy.getByTestID('add-template-variable').should('not.exist') - cy.getByTestID('add-annotation--button').should('not.exist') - cy.window() - .its('localStorage') - .then(({state}) => { - cy.wrap(state).should( - 'contain', - '"showTemplateVariableControlBar":true' - ) - cy.wrap(state).should('contain', '"showAnnotationControls":true') - }) - + cy.get('.annotation-control-bar').should('exist').and('be.visible').within(() => { + cy.getByTestID('add-template-variable').should('not.exist') + cy.getByTestID('add-annotation--button').should('not.exist') + cy.getByTestID('wizard-bucket-selected').click() + cy.getByTestID('dropdown--item').contains('Filter Annotations By Tags').click() + cy.getByTestID('add-annotation-filter--button').should('exist').and('be.visible') + }) + cy.reload().then(() => { cy.get('.page-header--title') .should('exist')