From 1ef00a83b1172a9f30f85defb3fc575217d8d49a Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Thu, 30 Apr 2020 21:06:51 +0000 Subject: [PATCH] mgr/dashboard: Add E2E for login Fixes: https://tracker.ceph.com/issues/45376 Signed-off-by: Tiago Melo --- .../cypress/integration/ui/login.e2e-spec.ts | 17 ++++++++++++++ .../cypress/integration/ui/login.po.ts | 22 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.e2e-spec.ts create mode 100644 src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.po.ts diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.e2e-spec.ts new file mode 100644 index 00000000000..29c9e9e10bb --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.e2e-spec.ts @@ -0,0 +1,17 @@ +import { LoginPageHelper } from './login.po'; + +describe('Login page', () => { + const login = new LoginPageHelper(); + + it('should login and navigate to dashboard page', () => { + login.navigateTo(); + login.doLogin(); + }); + + it('should logout when clicking the button', () => { + login.navigateTo(); + login.doLogin(); + + login.doLogout(); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.po.ts new file mode 100644 index 00000000000..d536f188a8a --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.po.ts @@ -0,0 +1,22 @@ +import { PageHelper } from '../page-helper.po'; + +export class LoginPageHelper extends PageHelper { + pages = { + index: { url: '#/login', id: 'cd-login' }, + dashboard: { url: '#/dashboard', id: 'cd-dashboard' } + }; + + doLogin() { + cy.get('[name=username]').type('admin'); + cy.get('#password').type('admin'); + cy.contains('input', 'Login').click(); + cy.get('cd-dashboard').should('exist'); + } + + doLogout() { + cy.get('cd-identity a').click(); + cy.contains('cd-identity span', 'Sign out').click(); + cy.get('cd-login').should('exist'); + cy.location('hash').should('be', '#login'); + } +}