You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by su...@apache.org on 2021/05/17 01:34:27 UTC

[apisix-dashboard] branch master updated: chore: refactored test login.spec.js (#1881)

This is an automated email from the ASF dual-hosted git repository.

sunyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new eb7bd29  chore: refactored test login.spec.js (#1881)
eb7bd29 is described below

commit eb7bd29d63e49d258e3ccac651642d1a4179233c
Author: Ayush das <ay...@gmail.com>
AuthorDate: Mon May 17 07:04:20 2021 +0530

    chore: refactored test login.spec.js (#1881)
---
 web/cypress/integration/user/login.spec.js | 40 +++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/web/cypress/integration/user/login.spec.js b/web/cypress/integration/user/login.spec.js
index f3b01c4..7afbce5 100644
--- a/web/cypress/integration/user/login.spec.js
+++ b/web/cypress/integration/user/login.spec.js
@@ -17,39 +17,55 @@
 /* eslint-disable no-undef */
 
 context('Login Test', () => {
+  const selector = {
+    errorExplain: '.ant-form-item-explain',
+    usernameInput: '#control-ref_username',
+    passwordInput: '#control-ref_password',
+    notification: '.ant-notification-notice-message',
+  };
+
+  const data = {
+    usernamePlaceholder: 'Please input username',
+    passwordPlaceholder: 'Please input password',
+    username: 'user',
+    password: 'user',
+    invalidPassword: 'invalidPassword',
+    errorCode: 'Request Error Code: 10000',
+    successMessage: 'Successfully',
+  };
+
   beforeEach(() => {
     // set default language
     localStorage.setItem('umi_locale', 'en-US');
-    cy.fixture('selector.json').as('domSelector');
   });
 
   it('login failed with empty username and password', function () {
     cy.visit('/user/Login');
     cy.contains('Login').click();
-    cy.get(this.domSelector.errorExplain).should('contain', 'Please input username');
-    cy.get(this.domSelector.errorExplain).should('contain', 'Please input password');
+    cy.get(selector.errorExplain).should('contain', data.usernamePlaceholder);
+    cy.get(selector.errorExplain).should('contain', data.passwordPlaceholder);
   });
 
   it('login with invalid credentials', function () {
     cy.visit('/user/Login');
-    cy.get(this.domSelector.usernameInput).type('user');
-    cy.get(this.domSelector.passwordInput).type('invalidPassword');
+    cy.get(selector.usernameInput).type(data.username);
+    cy.get(selector.passwordInput).type(data.invalidPassword);
     cy.contains('Login').click();
-    cy.get(this.domSelector.notification).should('contain', 'Request Error Code: 10000');
+    cy.get(selector.notification).should('contain', data.errorCode);
   });
 
   it('login success', function () {
     cy.visit('/user/Login');
-    cy.get(this.domSelector.usernameInput).type('user');
-    cy.get(this.domSelector.passwordInput).type('user');
+    cy.get(selector.usernameInput).type(data.username);
+    cy.get(selector.passwordInput).type(data.password);
     cy.contains('Login').click();
-    cy.get(this.domSelector.notification).should('contain', 'Successfully');
+    cy.get(selector.notification).should('contain', data.successMessage);
   });
 
   it('should press Enter to login successfully', function () {
     cy.visit('/user/Login');
-    cy.get(this.domSelector.usernameInput).type('user');
-    cy.get(this.domSelector.passwordInput).type('user{enter}');
-    cy.get(this.domSelector.notification).should('contain', 'Successfully');
+    cy.get(selector.usernameInput).type(data.username);
+    cy.get(selector.passwordInput).type(data.password).type('{enter}');
+    cy.get(selector.notification).should('contain', data.successMessage);
   });
 });