auth.cy.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {beforeSetup} from './utils';
  2. describe('登录测试', function () {
  3. beforeEach(function () {
  4. beforeSetup();
  5. });
  6. function inputLogin() {
  7. cy.get('input[name="accountName"]').clear().type('admin');
  8. cy.get('input[name="accountPassword"]').clear().type('tld123');
  9. cy.getTestId('login_form').submit();
  10. cy.get('.ant-message-notice-content').should('include.text', '登录成功');
  11. }
  12. function logOut() {
  13. cy.get('.ant-dropdown-trigger').trigger('mouseover');
  14. cy.get('.ant-dropdown-menu-item').eq(1).click();
  15. cy.get('.ant-modal-confirm-btns').find('.ant-btn-primary').click();
  16. cy.get('h2').should('include.text', '你特别,我来电');
  17. }
  18. it('登录测试', function () {
  19. cy.visit('/');
  20. inputLogin();
  21. logOut();
  22. cy.getTestId('memo_user_name').check();
  23. inputLogin();
  24. logOut();
  25. cy.getTestId('memo_user_name').should('be.checked');
  26. cy.getTestId('memo_all').should('not.be.checked');
  27. cy.get('input[name="accountName"]').should('have.value', 'admin');
  28. cy.get('input[name="accountPassword"]').should('have.value', '');
  29. cy.getTestId('memo_user_name').uncheck();
  30. cy.getTestId('memo_all').check();
  31. inputLogin();
  32. logOut();
  33. cy.getTestId('memo_all').should('be.checked');
  34. cy.getTestId('memo_user_name').should('not.be.checked');
  35. cy.get('input[name="accountName"]').should('have.value', 'admin');
  36. cy.get('input[name="accountPassword"]').should('have.value', 'tld123');
  37. });
  38. });