Browse Source

Cypress logout to remove session files in tmp folder

Vova Tkach 6 years ago
parent
commit
09f8c3ff39

+ 2 - 0
cypress/integration/control-panel/001_module_index/001_install_mysql.spec.js

@@ -48,5 +48,7 @@ context('Install MySQL, create first user and login', () => {
     cy.get('.form-signin input[name=password]').type('example@example.com');
     cy.get('.form-signin button').click();
     cy.actionWait();
+
+    cy.logoutCMS();
   });
 });

+ 4 - 0
cypress/integration/control-panel/001_module_index/002_top_nav_bar.js

@@ -8,6 +8,7 @@ context('Top navigation bar', () => {
   it('should render top nav bar', () => {
     cy.loginCMS();
     cy.get('#navbarCollapse ul.navbar-nav').should('have.length', 2);
+    cy.logoutCMS();
   });
 
   it('should render modules menu', () => {
@@ -15,12 +16,14 @@ context('Top navigation bar', () => {
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(1) li.nav-item').should('have.length', 2);
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(1) li.nav-item:nth-child(1) a.nav-link').should('exist');
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(1) li.nav-item:nth-child(2) a.nav-link').should('exist');
+    cy.logoutCMS();
   });
 
   it('should render user menu', () => {
     cy.loginCMS();
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item').should('have.length', 1);
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) a.nav-link').should('contain', 'example@example.com');
+    cy.logoutCMS();
   });
 
   it('should render user profile modal dialog', () => {
@@ -51,5 +54,6 @@ context('Top navigation bar', () => {
 
     cy.get('#sys-modal-user-settings form button[type=submit].btn').click();
     cy.actionWait();
+    cy.logoutCMS();
   });
 });

+ 6 - 0
cypress/integration/control-panel/001_module_index/003_pages.js

@@ -12,6 +12,7 @@ context('Module pages', () => {
     cy.get('table#cp-table-pages thead tr th').should('have.length', 4);
     cy.get('table#cp-table-pages tbody tr').should('have.length', 3);
     cy.get('table#cp-table-pages tbody tr:nth-child(1) td').should('have.length', 4);
+    cy.logoutCMS();
   });
 
   it('should render data form', () => {
@@ -21,6 +22,7 @@ context('Module pages', () => {
     cy.get('.data-form.index-add input[type=text]').should('have.length', 4);
     cy.get('.data-form.index-add textarea').should('have.length', 2);
     cy.get('.data-form.index-add input[type=checkbox]').should('have.length', 1);
+    cy.logoutCMS();
   });
 
   it('should not add new page', () => {
@@ -30,6 +32,7 @@ context('Module pages', () => {
     cy.actionWait();
 
     cy.get('.data-form.index-add div.sys-messages').should('exist');
+    cy.logoutCMS();
   });
 
   it('should add new page', () => {
@@ -44,6 +47,7 @@ context('Module pages', () => {
     cy.get('.data-form.index-add label[for=lbl_active]').click();
     cy.get('#add-edit-button').click();
     cy.actionWait();
+    cy.logoutCMS();
   });
 
   it('should render added page', () => {
@@ -52,6 +56,7 @@ context('Module pages', () => {
     cy.get('table#cp-table-pages tbody tr').should('have.length', 4);
     cy.get('table#cp-table-pages tbody tr:nth-child(1) td:nth-child(1)').should('contain', 'Some test page');
     cy.get('table#cp-table-pages tbody tr:nth-child(1) td:nth-child(3) .svg-green').should('exist');
+    cy.logoutCMS();
   });
 
   it('should delete added page', () => {
@@ -60,5 +65,6 @@ context('Module pages', () => {
     cy.get('table#cp-table-pages tbody tr:nth-child(1) td:nth-child(4) a.ico.delete').click();
     cy.actionWait();
     cy.get('table#cp-table-pages tbody tr').should('have.length', 3);
+    cy.logoutCMS();
   });
 });

+ 8 - 0
cypress/support/commands.js

@@ -77,3 +77,11 @@ Cypress.Commands.add('loginCMS', () => {
   cy.get('.form-signin button').click();
   cy.actionWait();
 });
+
+Cypress.Commands.add('logoutCMS', () => {
+  cy.actionStart();
+  cy.visit('http://localhost:8080/cp/');
+  cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) a.nav-link').click();
+  cy.contains('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) div.dropdown-menu a', 'Logout').click();
+  cy.actionWait();
+});