Skip to content

Commit 76c8eb8

Browse files
committed
Fixed all tests to run in testcafe; Removed unused code; Added circleci config
1 parent 9ec2300 commit 76c8eb8

19 files changed

+347
-307
lines changed

.circleci/config.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/node:7.10-browsers
11+
12+
# Specify service dependencies here if necessary
13+
# CircleCI maintains a library of pre-built images
14+
# documented at https://circleci.com/docs/2.0/circleci-images/
15+
# - image: circleci/mongo:3.4.4
16+
17+
working_directory: ~/repo
18+
19+
steps:
20+
- checkout
21+
22+
# Download and cache dependencies
23+
- restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "package.json" }}
26+
# fallback to using the latest cache if no exact match is found
27+
- v1-dependencies-
28+
29+
- run: yarn install
30+
- run: yarn test:setup
31+
32+
- save_cache:
33+
paths:
34+
- node_modules
35+
key: v1-dependencies-{{ checksum "package.json" }}
36+
37+
# run tests!
38+
- run: yarn test
39+
40+
- store_test_results:
41+
path: /tmp/test-results

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ before_install:
2020
- fluxbox >/dev/null 2>&1 &
2121

2222
before_script:
23-
- npm run test:setup
23+
- yarn test:setup

e2e/async.spec.js

-20
This file was deleted.

e2e/async.testcafe.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Selector } from 'testcafe';
2+
import { TreeDriver } from './helpers/tree.driver';
3+
4+
fixture `Async`
5+
.page `http://localhost:4200/#/async`
6+
.beforeEach( async t => {
7+
t.ctx.tree = new TreeDriver('tree-root');
8+
t.ctx.root2 = t.ctx.tree.getNode('root2');
9+
});
10+
11+
test('should show the tree', async t => {
12+
await t.expect(t.ctx.tree.isPresent()).ok();
13+
});
14+
15+
test('should have 3 nodes', async t => {
16+
await t.expect(t.ctx.tree.getNodes().count).eql(3);
17+
});
18+
19+
test('should not show loading before expanding', async t => {
20+
await t.expect(t.ctx.root2.getLoading().exists).notOk();
21+
});
22+
23+
test('should show loading', async t => {
24+
await t.ctx.root2.clickExpander(t)
25+
.expect(t.ctx.root2.getLoading().exists).ok();
26+
});
27+
28+
test('should show children and then loading disappears', async t => {
29+
await t.ctx.root2.clickExpander(t)
30+
.expect(t.ctx.root2.getNode('child1').isPresent()).ok()
31+
.expect(t.ctx.root2.getLoading().exists).notOk();
32+
});
33+
34+
test('should show not show loading the second time we expand the node', async t => {
35+
await t.ctx.root2.clickExpander(t)
36+
.expect(t.ctx.root2.getNode('child1').isPresent()).ok();
37+
38+
await t.ctx.root2.clickExpander(t);
39+
await t.ctx.root2.clickExpander(t)
40+
.expect(t.ctx.root2.getLoading().exists).notOk();
41+
});

e2e/basic.testcafe.js

+44-44
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Selector } from 'testcafe';
22
import { TreeDriver } from './helpers/tree.driver';
33

4-
fixture.skip `Basic`
4+
fixture `Basic`
55
.page `http://localhost:4200/#/basic`
66
.beforeEach( async t => {
77
t.ctx.tree = new TreeDriver('tree-root');
@@ -13,121 +13,121 @@ fixture.skip `Basic`
1313
});
1414

1515
test('should show the tree', async t => {
16-
await t.expect(t.ctx.tree.isPresent()).toBe(true);
16+
await t.expect(t.ctx.tree.isPresent()).eql(true);
1717
});
1818

1919
test('should have 5 nodes', async t => {
20-
await t.expect(t.ctx.tree.getNodes().count).toEqual(5);
20+
await t.expect(t.ctx.tree.getNodes().count).eql(5);
2121
});
2222

2323
test('should have a node named root1', async t => {
24-
await t.expect(t.ctx.root1.isPresent()).toBe(true);
24+
await t.expect(t.ctx.root1.isPresent()).eql(true);
2525
});
2626

2727
test('roots with children should have an expander icon', async t => {
28-
await t.expect(t.ctx.root1.getExpander().isPresent()).toBe(true)
29-
.expect(t.ctx.root2.getExpander().isPresent()).toBe(true);
28+
await t.expect(t.ctx.root1.getExpander().exists).eql(true)
29+
.expect(t.ctx.root2.getExpander().exists).eql(true);
3030
});
3131

3232
test('roots with children should not have an expander icon', async t => {
33-
await t.expect(t.ctx.root3.getExpander().isPresent()).toBe(false)
34-
.expect(t.ctx.root4.getExpander().isPresent()).toBe(false)
35-
.expect(t.ctx.root5.getExpander().isPresent()).toBe(false);
33+
await t.expect(t.ctx.root3.getExpander().exists).eql(false)
34+
.expect(t.ctx.root4.getExpander().exists).eql(false)
35+
.expect(t.ctx.root5.getExpander().exists).eql(false);
3636
});
3737

3838
test('roots with children should start collapsed', async t => {
39-
await t.expect(t.ctx.root1.getChildren().isPresent()).toBe(false)
40-
.expect(t.ctx.root1.isExpanded()).toBe(false);
39+
await t.expect(t.ctx.root1.getChildren().exists).eql(false)
40+
.expect(t.ctx.root1.isExpanded()).eql(false);
4141
});
4242

4343
test('should expand & collapse children on click expander', async t => {
4444
await t.ctx.root1.clickExpander(t);
45-
await t.expect(t.ctx.root1.getChildren().isPresent()).toBe(true)
46-
.expect(t.ctx.root1.isExpanded()).toBe(true);
45+
await t.expect(t.ctx.root1.getChildren().exists).eql(true)
46+
.expect(t.ctx.root1.isExpanded()).eql(true);
4747
await t.ctx.root1.clickExpander(t);
48-
await t.expect(t.ctx.root1.getChildren().isPresent()).toBe(false)
49-
.expect(t.ctx.root1.isExpanded()).toBe(false);
48+
await t.expect(t.ctx.root1.getChildren().exists).eql(false)
49+
.expect(t.ctx.root1.isExpanded()).eql(false);
5050
});
5151

5252
test('should start inactive', async t => {
53-
await t.expect(t.ctx.root1.isActive()).toBe(false);
53+
await t.expect(t.ctx.root1.isActive()).eql(false);
5454
});
5555

5656
test('should activate & deactivate nodes on click', async t => {
5757
await t.ctx.root1.click(t);
58-
await t.expect(t.ctx.root1.isActive()).toBe(true)
59-
.expect(t.ctx.root2.isActive()).toBe(false);
58+
await t.expect(t.ctx.root1.isActive()).eql(true)
59+
.expect(t.ctx.root2.isActive()).eql(false);
6060
await t.ctx.root2.click(t);
61-
await t.expect(t.ctx.root1.isActive()).toBe(false)
62-
.expect(t.ctx.root2.isActive()).toBe(true);
61+
await t.expect(t.ctx.root1.isActive()).eql(false)
62+
.expect(t.ctx.root2.isActive()).eql(true);
6363
});
6464

6565
test('should start without focus', async t => {
66-
await t.expect(t.ctx.root1.isFocused()).toBe(false);
66+
await t.expect(t.ctx.root1.isFocused()).eql(false);
6767
});
6868

6969
test('should focus on a node on click', async t => {
7070
await t.ctx.root1.click(t);
71-
await t.expect(t.ctx.root1.isFocused()).toBe(true)
72-
.expect(t.ctx.root2.isFocused()).toBe(false);
71+
await t.expect(t.ctx.root1.isFocused()).eql(true)
72+
.expect(t.ctx.root2.isFocused()).eql(false);
7373
await t.ctx.root2.click(t);
74-
await t.expect(t.ctx.root1.isFocused()).toBe(false)
75-
expect(t.ctx.root2.isFocused()).toBe(true);
74+
await t.expect(t.ctx.root1.isFocused()).eql(false)
75+
.expect(t.ctx.root2.isFocused()).eql(true);
7676
});
7777

7878
test('should navigate with keys', async t => {
7979
await t.ctx.tree.keyDown(t);
80-
await t.expect(t.ctx.root1.isFocused()).toBe(true);
80+
await t.expect(t.ctx.root1.isFocused()).eql(true);
8181
await t.ctx.tree.keyRight(t);
82-
await t.expect(t.ctx.root1.isExpanded()).toBe(true);
82+
await t.expect(t.ctx.root1.isExpanded()).eql(true);
8383
await t.ctx.tree.keyRight(t);
8484

8585
const child1 = t.ctx.tree.getNode('child1');
8686
const child2 = t.ctx.tree.getNode('child2');
8787

88-
await t.expect(child1.isFocused()).toBe(true);
88+
await t.expect(child1.isFocused()).eql(true);
8989
await t.ctx.tree.keyRight(t);
90-
await t.expect(child1.isFocused()).toBe(true);
90+
await t.expect(child1.isFocused()).eql(true);
9191
await t.ctx.tree.keyDown(t);
9292
await t.ctx.tree.keyDown(t);
93-
await t.expect(t.ctx.root2.isFocused()).toBe(true);
93+
await t.expect(t.ctx.root2.isFocused()).eql(true);
9494
await t.ctx.tree.keyUp(t);
95-
await t.expect(child2.isFocused()).toBe(true);
95+
await t.expect(child2.isFocused()).eql(true);
9696
await t.ctx.tree.keyLeft(t);
97-
await t.expect(t.ctx.root1.isFocused()).toBe(true);
97+
await t.expect(t.ctx.root1.isFocused()).eql(true);
9898
await t.ctx.tree.keyLeft(t);
99-
await t.expect(t.ctx.root1.isExpanded()).toBe(false);
99+
await t.expect(t.ctx.root1.isExpanded()).eql(false);
100100
await t.ctx.tree.keyDown(t);
101-
await t.expect(t.ctx.root2.isFocused()).toBe(true);
101+
await t.expect(t.ctx.root2.isFocused()).eql(true);
102102
await t.ctx.tree.keyUp(t);
103-
await t.expect(t.ctx.root1.isFocused()).toBe(true);
103+
await t.expect(t.ctx.root1.isFocused()).eql(true);
104104
});
105105

106106
test('should toggle active on space', async t => {
107-
await t.expect(t.ctx.root1.isActive()).toBe(false);
107+
await t.expect(t.ctx.root1.isActive()).eql(false);
108108
await t.ctx.tree.keyDown(t);
109109
await t.ctx.tree.keySpace(t);
110-
await t.expect(t.ctx.root1.isActive()).toBe(true);
110+
await t.expect(t.ctx.root1.isActive()).eql(true);
111111
await t.ctx.tree.keyDown(t);
112112
await t.ctx.tree.keySpace(t);
113-
await t.expect(t.ctx.root2.isActive()).toBe(true);
113+
await t.expect(t.ctx.root2.isActive()).eql(true);
114114
await t.ctx.tree.keySpace(t);
115-
await t.expect(t.ctx.root2.isActive()).toBe(false);
115+
await t.expect(t.ctx.root2.isActive()).eql(false);
116116
});
117117

118118
test('should toggle active on enter', async t => {
119-
await t.expect(t.ctx.root1.isActive()).toBe(false);
119+
await t.expect(t.ctx.root1.isActive()).eql(false);
120120
await t.ctx.tree.keyDown(t);
121121
await t.ctx.tree.keyEnter(t);
122-
await t.expect(t.ctx.root1.isActive()).toBe(true);
122+
await t.expect(t.ctx.root1.isActive()).eql(true);
123123
await t.ctx.tree.keyDown(t);
124124
await t.ctx.tree.keyEnter(t);
125-
await t.expect(t.ctx.root2.isActive()).toBe(true);
125+
await t.expect(t.ctx.root2.isActive()).eql(true);
126126
await t.ctx.tree.keyEnter(t);
127-
await t.expect(t.ctx.root2.isActive()).toBe(false);
127+
await t.expect(t.ctx.root2.isActive()).eql(false);
128128
});
129129

130130
test('should not show checkboxes', async t => {
131-
expect(t.ctx.root1.getCheckbox().isPresent()).toBe(false);
131+
await t.expect(t.ctx.root1.getCheckbox().exists).eql(false);
132132
});
133133

e2e/drag.spec.js

-38
This file was deleted.

e2e/drag.testcafe.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const { browser, element, by, $ } = require('protractor');
2+
const { TreeDriver } = require('./helpers/tree.driver');
3+
4+
fixture `Drag and Drop`
5+
.page `http://localhost:4200/#/drag`
6+
.beforeEach( async t => {
7+
t.ctx.tree = new TreeDriver('tree-root');
8+
t.ctx.root1 = t.ctx.tree.getNode('root1');
9+
t.ctx.child1 = t.ctx.root1.getNode('child1');
10+
t.ctx.root2 = t.ctx.tree.getNode('root2');
11+
t.ctx.child21 = t.ctx.root2.getNode('child2.1');
12+
});
13+
14+
test('should show the tree', async t => {
15+
await t.expect(t.ctx.tree.isPresent()).ok();
16+
});
17+
18+
test('should have expected children', async t => {
19+
await t.expect(t.ctx.root1.getNodes().count).eql(2)
20+
.expect(t.ctx.root2.getNodes().count).eql(2)
21+
.expect(t.ctx.child21.getNodes().count).eql(0);
22+
});
23+
24+
test('should allow to drag leaf', async t => {
25+
await t.ctx.child1.dragToNode(t, t.ctx.child21);
26+
await t.ctx.child21.clickExpander(t)
27+
.expect(t.ctx.root1.getNodes().count).eql(1)
28+
.expect(t.ctx.child21.getNodes().count).eql(1);
29+
});
30+
31+
test('should allow to drag to drop slot', async t => {
32+
await t.ctx.child1.dragToDropSlot(t, t.ctx.child21)
33+
.expect(t.ctx.root1.getNodes().count).eql(1)
34+
.expect(t.ctx.root2.getNodes().count).eql(3);
35+
});

e2e/empty.spec.js

-35
This file was deleted.

0 commit comments

Comments
 (0)