Skip to content

Commit 777df14

Browse files
committed
WIP: add e2e tests
1 parent 023edfa commit 777df14

File tree

3 files changed

+140
-116
lines changed

3 files changed

+140
-116
lines changed

test/e2e/local-datasource.js

Lines changed: 0 additions & 116 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Selector } from 'testcafe';
2+
3+
export default class Page {
4+
constructor () {
5+
this.laolao = Selector('#n1');
6+
this.bomiao = Selector('#n2');
7+
this.sumiao = Selector('#n3');
8+
this.hongmiao = Selector('#n4');
9+
this.tiehua = Selector('#n5');
10+
this.heihei = Selector('#n6');
11+
this.pangpang = Selector('#n7');
12+
this.dandan = Selector('#n8');
13+
}
14+
}

test/e2e/local-datasource/test.js

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import Page from './page-model';
2+
3+
fixture `Local Datasource`
4+
.page `127.0.0.1:3000/local-datasource.html`;
5+
6+
const page = new Page();
7+
const laolao = page.laolao;
8+
const bomiao = page.bomiao;
9+
const sumiao = page.sumiao;
10+
const hongmiao = page.hongmiao;
11+
const tiehua = page.tiehua;
12+
const heihei = page.heihei;
13+
const pangpang = page.pangpang;
14+
const dandan = page.dandan;
15+
16+
test('bottomEdge of root node works well', async t => {
17+
await t
18+
.hover(laolao)
19+
.click(laolao.find('.bottomEdge'))
20+
.expect(bomiao.visible).notOk()
21+
.expect(sumiao.visible).notOk()
22+
.expect(hongmiao.visible).notOk()
23+
.hover(laolao)
24+
.click(laolao.find('.bottomEdge'))
25+
.expect(bomiao.visible).ok()
26+
.expect(sumiao.visible).ok()
27+
.expect(hongmiao.visible).ok();
28+
});
29+
30+
test('topEdge of sumiao node works well', async t => {
31+
await t
32+
.hover(sumiao)
33+
.click(sumiao.find('.topEdge'))
34+
.expect(laolao.visible).notOk()
35+
.expect(bomiao.visible).notOk()
36+
.expect(hongmiao.visible).notOk()
37+
.hover(sumiao)
38+
.click(sumiao.find('.topEdge'))
39+
.expect(laolao.visible).ok()
40+
.expect(bomiao.visible).notOk()
41+
.expect(hongmiao.visible).notOk();
42+
});
43+
44+
test('leftEdge of sumiao node works well', async t => {
45+
await t
46+
.hover(sumiao)
47+
.click(sumiao.find('.leftEdge'))
48+
.expect(bomiao.visible).notOk()
49+
.expect(hongmiao.visible).notOk()
50+
.hover(sumiao)
51+
.click(sumiao.find('.leftEdge'))
52+
.expect(bomiao.visible).ok()
53+
.expect(hongmiao.visible).ok();
54+
});
55+
56+
test('rightEdge of sumiao node works well', async t => {
57+
await t
58+
.hover(sumiao)
59+
.click(sumiao.find('.rightEdge'))
60+
.expect(hongmiao.visible).notOk()
61+
.expect(hongmiao.visible).notOk()
62+
.hover(sumiao)
63+
.click(sumiao.find('.rightEdge'))
64+
.expect(bomiao.visible).ok()
65+
.expect(hongmiao.visible).ok();
66+
});
67+
68+
test('bottomEdge of sumiao node works well', async t => {
69+
await t
70+
.hover(sumiao)
71+
.click(sumiao.find('.bottomEdge'))
72+
.expect(tiehua.visible).notOk()
73+
.expect(heihei.visible).notOk()
74+
.expect(pangpang.visible).notOk()
75+
.expect(dandan.visible).notOk()
76+
.hover(sumiao)
77+
.click(sumiao.find('.bottomEdge'))
78+
.expect(tiehua.visible).ok()
79+
.expect(heihei.visible).ok()
80+
.expect(pangpang.visible).ok();
81+
});
82+
83+
test('topEdge of heihei node works well', async t => {
84+
await t
85+
.hover(heihei)
86+
.click(heihei.find('.topEdge'))
87+
.expect(laolao.visible).notOk()
88+
.expect(bomiao.visible).notOk()
89+
.expect(sumiao.visible).notOk()
90+
.expect(hongmiao.visible).notOk()
91+
.expect(tiehua.visible).notOk()
92+
.expect(pangpang.visible).notOk()
93+
.hover(heihei)
94+
.click(heihei.find('.topEdge'))
95+
.expect(sumiao.visible).ok()
96+
.expect(laolao.visible).notOk();
97+
});
98+
99+
test('horizontalEdge of heihei node works well', async t => {
100+
await t
101+
.hover(heihei)
102+
.click(heihei.find('.topEdge'))
103+
/* take into account the transition settings in jquery.orgchart.css
104+
* .orgchart .node {
105+
* transition: transform 0.3s, opacity 0.3s;
106+
* }
107+
*/
108+
.wait(500)
109+
.click(heihei.find('.leftEdge'))
110+
.expect(sumiao.visible).ok()
111+
.expect(tiehua.visible).ok()
112+
.expect(pangpang.visible).ok()
113+
.expect(laolao.visible).notOk();
114+
});
115+
116+
test('horizontalEdge of pangpang node works well', async t => {
117+
await t
118+
.hover(pangpang)
119+
.click(pangpang.find('.leftEdge'))
120+
.expect(tiehua.visible).notOk()
121+
.expect(heihei.visible).notOk()
122+
.expect(dandan.visible).notOk()
123+
.click(pangpang.find('.leftEdge'))
124+
.expect(tiehua.visible).ok()
125+
.expect(heihei.visible).ok()
126+
});

0 commit comments

Comments
 (0)