/
login-form.test.js
90 lines (79 loc) · 2.2 KB
/
login-form.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
import {
webpackHelper
} from 'macaca-wd';
import assert from 'assert';
const {
driver,
BASE_URL
} = webpackHelper;
describe('test/antd-sample/login-form.test.js', () => {
before(() => {
return driver
.initWindow({
width: 800,
height: 600,
deviceScaleFactor: 2
});
});
beforeEach(() => {
return driver
.switchAllScenes({
hub: 'antd-sample',
scene: 'default',
});
});
afterEach(function () {
return driver
.coverage()
.saveScreenshots(this);
});
after(() => {
return driver
.openReporter(false)
.quit();
});
describe('login form render', () => {
it('render should be ok', () => {
return driver
.getUrl(`${BASE_URL}/antd-sample#login`)
.elementByCss('[accessbilityId="login"]')
.text()
.then(text => assert.equal(text, 'Log in'));
});
});
describe('login form submit', () => {
it.skip('validator logic should be correct', () => {
return driver
.getUrl(`${BASE_URL}/antd-sample#login`)
.elementByCss('[accessbilityId="login"]')
.click()
.sleep(1000)
.elementByCss('#app > form > div:nth-child(1) .ant-form-explain')
.text()
.then(text => assert.equal(text, 'Please input your username!'));
});
it('input should be correct', () => {
return driver
.getUrl(`${BASE_URL}/antd-sample#login`)
.elementByCss('[accessbilityId="username"]')
.formInput('username')
.elementByCss('[accessbilityId="login"]')
.click()
.elementByCssOrNull('#app > form > div:nth-child(1) .ant-form-explain')
.then(res => assert.deepEqual(res, null));
});
it('submit should be ok', () => {
return driver
.getUrl(`${BASE_URL}/antd-sample#login`)
.elementByCss('[accessbilityId="username"]')
.formInput('username')
.elementByCss('[accessbilityId="password"]')
.formInput('password')
.elementByCss('[accessbilityId="login"]')
.click()
.elementByCssOrNull('#app > form > div:nth-child(1) .ant-form-explain')
.then(res => assert.deepEqual(res, null));
});
});
});