Browse Source

Cleanup some cypress tests, more tests for pages

Vova Tkach 6 years ago
parent
commit
31318060d3

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

@@ -9,11 +9,9 @@ context('Install MySQL, create first user and login', () => {
 
   it('should configure mysql config', () => {
     cy.actionStart();
-
     cy.get('.form-signin input[type=text]').should('have.length', 4);
     cy.get('.form-signin input[type=password]').should('have.length', 1);
     cy.get('.form-signin button').should('have.length', 1);
-
     cy.get('.form-signin input[name=name]').type('fave');
     cy.get('.form-signin input[name=user]').type('root');
     cy.get('.form-signin input[name=password]').type('root');
@@ -23,12 +21,10 @@ context('Install MySQL, create first user and login', () => {
 
   it('should create first user', () => {
     cy.actionStart();
-
     cy.get('.form-signin input[type=text]').should('have.length', 2);
     cy.get('.form-signin input[type=email]').should('have.length', 1);
     cy.get('.form-signin input[type=password]').should('have.length', 1);
     cy.get('.form-signin button').should('have.length', 1);
-
     cy.get('.form-signin input[name=first_name]').type('First');
     cy.get('.form-signin input[name=last_name]').type('Last');
     cy.get('.form-signin input[name=email]').type('example@example.com');
@@ -39,16 +35,13 @@ context('Install MySQL, create first user and login', () => {
 
   it('should login to control panel', () => {
     cy.actionStart();
-
     cy.get('.form-signin input[type=email]').should('have.length', 1);
     cy.get('.form-signin input[type=password]').should('have.length', 1);
     cy.get('.form-signin button').should('have.length', 1);
-
     cy.get('.form-signin input[name=email]').type('example@example.com');
     cy.get('.form-signin input[name=password]').type('example@example.com');
     cy.get('.form-signin button').click();
     cy.actionWait();
-
     cy.logoutCMS();
   });
 });

+ 12 - 9
cypress/integration/control-panel/001_module_index/002_top_nav_bar.js

@@ -30,30 +30,33 @@ context('Top navigation bar', () => {
     cy.loginCMS();
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) a.nav-link:first-child').click();
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) div.dropdown-menu a.dropdown-item:nth-child(1)').click();
-
     cy.get('#sys-modal-user-settings').should('exist');
     cy.get('#sys-modal-user-settings form input[type=text]').should('have.length', 2);
     cy.get('#sys-modal-user-settings form input[type=email]').should('have.length', 1);
     cy.get('#sys-modal-user-settings form input[type=password]').should('have.length', 1);
+    cy.logoutCMS();
+  });
 
+  it('should change user profile data in modal dialog', () => {
+    cy.loginCMS();
+    cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) a.nav-link:first-child').click();
+    cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) div.dropdown-menu a.dropdown-item:nth-child(1)').click();
+    cy.get('#sys-modal-user-settings').should('exist');
     cy.get('#sys-modal-user-settings form input[name=first_name]').clear().type('FirstNew');
     cy.get('#sys-modal-user-settings form input[name=last_name]').clear().type('LastNew');
-
     cy.get('#sys-modal-user-settings form button[type=submit].btn').click();
     cy.actionWait();
+    cy.logoutCMS();
+  });
 
+  it('should render saved user profile data in modal dialog', () => {
+    cy.loginCMS();
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) a.nav-link:first-child').click();
     cy.get('#navbarCollapse ul.navbar-nav:nth-child(2) li.nav-item:nth-child(1) div.dropdown-menu a.dropdown-item:nth-child(1)').click();
-
     cy.get('#sys-modal-user-settings').should('exist');
     cy.get('#sys-modal-user-settings form input[name=first_name]').should('have.value', 'FirstNew');
     cy.get('#sys-modal-user-settings form input[name=last_name]').should('have.value', 'LastNew');
-
-    cy.get('#sys-modal-user-settings form input[name=first_name]').clear().type('First');
-    cy.get('#sys-modal-user-settings form input[name=last_name]').clear().type('Last');
-
-    cy.get('#sys-modal-user-settings form button[type=submit].btn').click();
-    cy.actionWait();
+    cy.get('#sys-modal-user-settings form button[type=button].btn').click();
     cy.logoutCMS();
   });
 });

+ 15 - 4
cypress/integration/control-panel/001_module_index/003_pages.js

@@ -18,7 +18,6 @@ context('Module pages', () => {
   it('should render data form', () => {
     cy.loginCMS();
     cy.visit('http://localhost:8080/cp/index/add/');
-    
     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);
@@ -30,7 +29,6 @@ context('Module pages', () => {
     cy.visit('http://localhost:8080/cp/index/add/');
     cy.get('#add-edit-button').click();
     cy.actionWait();
-
     cy.get('.data-form.index-add div.sys-messages').should('exist');
     cy.logoutCMS();
   });
@@ -38,7 +36,6 @@ context('Module pages', () => {
   it('should add new page', () => {
     cy.loginCMS();
     cy.visit('http://localhost:8080/cp/index/add/');
-    
     cy.get('.data-form.index-add input[name=name]').clear().type('Some test page');
     cy.get('.data-form.index-add textarea[name=content]').clear().type('Some test content');
     cy.get('.data-form.index-add input[name=meta_title]').clear().type('Page meta title');
@@ -50,7 +47,7 @@ context('Module pages', () => {
     cy.logoutCMS();
   });
 
-  it('should render added page', () => {
+  it('should render added page in list', () => {
     cy.loginCMS();
     cy.visit('http://localhost:8080/cp/');
     cy.get('table#cp-table-pages tbody tr').should('have.length', 4);
@@ -59,6 +56,20 @@ context('Module pages', () => {
     cy.logoutCMS();
   });
 
+  it('should render added page in edit form', () => {
+    cy.loginCMS();
+    cy.visit('http://localhost:8080/cp/');
+    cy.contains('table#cp-table-pages tbody tr:nth-child(1) td a', 'Some test page').click();
+    cy.get('.data-form.index-modify input[name=name]').should('have.value', 'Some test page');
+    cy.get('.data-form.index-modify input[name=alias]').should('have.value', '/some-test-page/');
+    cy.get('.data-form.index-modify textarea[name=content]').should('have.value', 'Some test content');
+    cy.get('.data-form.index-modify input[name=meta_title]').should('have.value', 'Page meta title');
+    cy.get('.data-form.index-modify input[name=meta_keywords]').should('have.value', 'Page meta keywords');
+    cy.get('.data-form.index-modify textarea[name=meta_description]').should('have.value', 'Page meta description');
+    cy.get('.data-form.index-modify input[name=active]').should('be.checked');
+    cy.logoutCMS();
+  });
+
   it('should delete added page', () => {
     cy.loginCMS();
     cy.visit('http://localhost:8080/cp/');