login.cy.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {loginIntercept, loginSetup, menuIntercept} from './utils';
  2. describe('登录页面', function() {
  3. beforeEach(function() {
  4. loginIntercept();
  5. menuIntercept();
  6. loginSetup();
  7. });
  8. it('登录', function() {
  9. cy.getTestId('user_name').should('contain.text', '超级管理员');
  10. });
  11. it('退出', function() {
  12. cy.get('.ant-dropdown-trigger').trigger('mouseover');
  13. cy.get('.ant-dropdown').should('be.visible');
  14. cy.get('.ant-dropdown-menu').children().first().click();
  15. cy.get('.ant-modal-confirm-btns').children().last().click();
  16. cy.url().should('contain', '/login');
  17. });
  18. it.only('菜单', function() {
  19. cy.getTestId('menu').children().should('have.length', 4);
  20. cy.getTestId('menu').children().first().should('include.text', '首页');
  21. cy.getTestId('menu').children().each(function(el, idx) {
  22. if (idx === 1) {
  23. el.find('.ant-menu-submenu-title').trigger('click');
  24. expect(el.children()).to.length(2);
  25. expect(el.find('ul.ant-menu').children()).to.length(3);
  26. expect(
  27. el.find('ul.ant-menu').children()[0].getAttribute('title'),
  28. ).to.be.equal('用户管理');
  29. }
  30. });
  31. });
  32. });