login.e2e.js 792 B

123456789101112131415161718192021222324252627
  1. import Nightmare from 'nightmare';
  2. describe('Login', () => {
  3. let page;
  4. beforeEach(() => {
  5. page = Nightmare();
  6. page.goto('http://localhost:8000/#/user/login');
  7. });
  8. it('should login with failure', async () => {
  9. await page.type('#userName', 'mockuser')
  10. .type('#password', 'wrong_password')
  11. .click('button[type="submit"]')
  12. .wait('.ant-alert-error') // should display error
  13. .end();
  14. });
  15. it('should login successfully', async () => {
  16. const text = await page.type('#userName', 'admin')
  17. .type('#password', '888888')
  18. .click('button[type="submit"]')
  19. .wait('.ant-layout-sider h1') // should display error
  20. .evaluate(() => document.body.innerHTML)
  21. .end();
  22. expect(text).toContain('<h1>Ant Design Pro</h1>');
  23. });
  24. });