]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add E2E for login
authorTiago Melo <tmelo@suse.com>
Thu, 30 Apr 2020 21:06:51 +0000 (21:06 +0000)
committerTiago Melo <tmelo@suse.com>
Tue, 7 Jul 2020 18:28:30 +0000 (18:28 +0000)
Fixes: https://tracker.ceph.com/issues/45376
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.e2e-spec.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/cypress/integration/ui/login.po.ts [new file with mode: 0644]

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 (file)
index 0000000..29c9e9e
--- /dev/null
@@ -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 (file)
index 0000000..d536f18
--- /dev/null
@@ -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');
+  }
+}