Skip to content

Commit 71e2f55

Browse files
committed
E2E tests
1 parent 7712b36 commit 71e2f55

File tree

11 files changed

+317
-75
lines changed

11 files changed

+317
-75
lines changed

.jshintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"esversion":5,
2+
"esversion":6,
33
"node": true,
44
"undef": true,
55
"unused": true,

Gruntfile.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@ var bundleFiles=[
55
"openNote/**/*.html"
66
];
77

8+
// Helper function
9+
var serverConfig = function(keepalive){
10+
if(keepalive==undefined)
11+
keepalive = true;
12+
return {
13+
options: {
14+
port: 8080,
15+
base: ".",
16+
keepalive: keepalive
17+
}
18+
};
19+
};
820

921
module.exports = function(grunt) {
1022
//Initializing the configuration object
1123
grunt.initConfig({
1224
connect: {
13-
server: {
14-
options: {
15-
port: 8080,
16-
base: ".",
17-
keepalive: true
18-
}
19-
}
25+
server: serverConfig(),
26+
serverNoAlive: serverConfig(false)
2027
},
2128
compress: {
2229
main: {
@@ -33,8 +40,10 @@ module.exports = function(grunt) {
3340
}
3441
},
3542
jshint: {
36-
options: {},
37-
all: ["**/*.js*", //Order matters
43+
options: {
44+
"esversion":6,
45+
},
46+
all: ["openNote/**/*.js*", //Order matters
3847
"!node_modules/**",
3948
"!OpenNote/node_moduless/**"
4049
]
@@ -100,6 +109,9 @@ module.exports = function(grunt) {
100109
"rm -rf dark light"
101110
].join("&&")
102111
},
112+
test: {
113+
command: ["npm run test"].join("&&")
114+
},
103115
dev: {
104116
command: ["npm run dev"].join("&&")
105117
},
@@ -148,5 +160,5 @@ module.exports = function(grunt) {
148160

149161
//testing
150162
grunt.registerTask("devmode", ["karma:unit", "watch"]);
151-
grunt.registerTask("ci", ["build", "jshint:all"]);
163+
grunt.registerTask("ci", "Build the app and runs tests on it", ["jshint:all", "buildProd", "connect:serverNoAlive", "shell:test" ]);
152164
};

docs/Build.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,20 @@ Then run
1212
this will start a webpack dev server.
1313

1414
To test production bundles run `grunt testDeploy`
15+
16+
//TODO new stuff and note in an ascii tree how the shared services are are expected to be neighbors of the cli and OpenNoteFolder
17+
18+
19+
//TODO grunt --help to get steps
20+
21+
Super important
22+
grunt default or grunt
23+
grunt ci
24+
grunt deploy //TODO
25+
26+
27+
To develop tests
28+
```
29+
grunt dev # in terminal A
30+
npm run testChrome # in terminal B. Iterate on this terminal
31+
```

openNote/controllers/folderController.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ openNote.controller("folderController", ["$scope",
2424
//add buttons
2525
if ($routeParams.id)
2626
$rootScope.buttons.push({
27+
id: "newNote",
2728
text: "New note",
2829
action: function() {
2930
$scope.fadeOutFoldersAndNotes(function() {
@@ -34,6 +35,7 @@ openNote.controller("folderController", ["$scope",
3435

3536
//Create a folder
3637
$rootScope.buttons.push({
38+
id: "newFolder",
3739
text: "New folder",
3840
action: function() {
3941
var prompt = "Please enter a name for the new folder";
@@ -244,10 +246,6 @@ openNote.controller("folderController", ["$scope",
244246
storageService.loadFolderContents($scope.currentFolder._id, function(results) {
245247
$scope.currentFolderContents = results.rows;
246248

247-
//Do they have anything to display?
248-
if (!$scope.currentFolder._id && !$scope.currentFolderContents.length)
249-
alertify.alert("It looks like you dont have any folders. You can create one using the \"New Folder\" button in the top right of the page. If you need to pull your remote notes <a href='#/settings/database'>click here</a>.");
250-
251249
$scope.$apply();
252250
});
253251
};

openNote/controllers/noteController.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ openNote.controller("noteController", ["$scope",
3535
*/
3636
var saveButton = function() {
3737
return {
38+
id: "save",
3839
text: "Save",
3940
action: function() {
4041
save();
@@ -44,6 +45,7 @@ openNote.controller("noteController", ["$scope",
4445

4546
var copyButton = function(note) {
4647
return {
48+
id: "cut",
4749
text: "Cut",
4850
action: function() {
4951
$rootScope.clipboard = note;
@@ -57,6 +59,7 @@ openNote.controller("noteController", ["$scope",
5759
*/
5860
var clearButton = function() {
5961
return {
62+
id: "clear",
6063
text: "Clear",
6164
action: function() {
6265
$scope.clear();
@@ -66,6 +69,7 @@ openNote.controller("noteController", ["$scope",
6669

6770
var editButton = function() {
6871
return {
72+
id: "edit",
6973
text: "Edit",
7074
action: function() {
7175
activateEditMode();
@@ -75,6 +79,7 @@ openNote.controller("noteController", ["$scope",
7579

7680
var upButton = function(folderID) {
7781
return {
82+
id: "goToParentFolder",
7883
text: "Go up a folder",
7984
action: function() {
8085
$location.url("/folder/" + folderID);

openNote/controllers/tagListController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ openNote.controller("tagListController", [
5050
//Confirm action
5151
alertify.confirm("Are you sure you want to move " + (request.moveObject.name || request.moveObject.title) + " into " + request.destFolder.name + "?", function(confirm) {
5252
if (confirm) {
53-
var origParrentFolderID = request.moveObject.parentFolderID;
53+
var origParentFolderID = request.moveObject.parentFolderID;
5454

5555
request.moveObject.parentFolderID = request.destFolder._id;
5656
storageService.database().put(request.moveObject).then(function() {
5757
$rootScope.$emit("changedFolder", { //fire off an event to tell everyone we just modified a folder
5858
folder: request.moveObject,
59-
oldParrentFolderID: origParrentFolderID
59+
oldParentFolderID: origParentFolderID
6060
});
6161
}).catch(function(error) {
6262
throw error;

openNote/partials/folderPartial.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<li id="parentFolder" ng-if="parentFolder!=null">
55
<a href="#/folder/{{parentFolder._id}}">{{parentFolder.name}}</a>
66
</li>
7-
<li class="active" ng-click="activateFolderEditMode();">
7+
<li id="currentFolder" class="active" ng-click="activateFolderEditMode();">
88
{{currentFolder.name}}
99
</li>
1010
</ol>
1111
<div ng-show="folderEditMode" class="ng-hide fadeIn">
1212
<button class="customButton ng-hide" ng-click="loadParentFolder();">Go up a folder</button>
13-
<button class="customButton" ng-click="renameFolder();">Rename</button>
14-
<button class="customButton" ng-click="removeFolder();">Delete</button>
13+
<button id="rename" class="customButton" ng-click="renameFolder();">Rename</button>
14+
<button id="delete" class="customButton" ng-click="removeFolder();">Delete</button>
1515
</div>
1616

1717
</div>
@@ -39,4 +39,9 @@ <h4>
3939
<span class="right">Note</span>
4040
</p>
4141
</div>
42+
43+
<div class="noFolderHelp startHidden randomFadeInDirective" ng-if="!currentFolderContents.length">
44+
<h4 ng-if="!currentFolder._id">It looks like you dont have any folders. You can create one using the "New Folder" button in the top right of the page. If you need to pull your remote notes <a href='#/settings/database'>click here</a>.</h4>
45+
<h4 ng-if="currentFolder._id">This folder is empty.</h4>
46+
</div>
4247
</div>

openNote/partials/navBarPartial.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<div class="navbar-collapse collapse noShadow">
1212
<ul class="nav navbar-nav navbar-right">
1313
<li ng-repeat="button in buttons">
14-
<button type="button" class="customButton" ng-click="button.action();">{{button.text}}</button>
14+
<button id="{{button.id}}" type="button" class="customButton" ng-click="button.action();">{{button.text}}</button>
1515
</li>
1616
<li>
17-
<button type="button" class="customButton" onclick="window.location='#/settings'">Settings</button>
17+
<button id="setting" type="button" class="customButton" onclick="window.location='#/settings'">Settings</button>
1818
</li>
1919
</ul>
2020
</div>

openNote/style/invert/style.less

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@treeHandleBackgroundColor: negation(#0b0908, @offset);
2020
@treeHandleBorderColor: negation(#231d17, @offset);
2121

22-
@copyRightColor: negation(#656565, @offset);
22+
@copyRightColor: negation(#777777, @offset);
2323
@loginInputColor: negation(#444, @offset);
2424

2525
body{
@@ -93,33 +93,6 @@ input:focus, select:focus, textarea:focus, button:focus {
9393
border-radius:4px;/*round the corners*/
9494
}
9595

96-
#folderTitleBar{
97-
padding: 0px 0px 15px 0px;
98-
overflow: hidden;
99-
font-size: 18px;
100-
101-
.breadcrumb{
102-
margin-bottom:0;
103-
padding: 0 15px 0 0;
104-
background: none;
105-
float:left;
106-
107-
>.active{
108-
color:inherit;
109-
}
110-
111-
li{
112-
font-size: 20px;
113-
}
114-
}
115-
}
116-
117-
#folderTitle{
118-
float:left;
119-
padding-right:15px;
120-
font-size: 20px;
121-
}
122-
12396
.customButton{ /*custom button class that removes all browser formating*/
12497
border: none;
12598
background:transparent;
@@ -146,21 +119,6 @@ img {
146119
float: right;
147120
}
148121

149-
#sideBar{
150-
background: @navBackground;
151-
152-
/*round the corners*/
153-
border-radius:4px ;
154-
margin-bottom: 15px;
155-
padding: 15px 15px 15px 30px;
156-
}
157-
158-
#sideBar ul{
159-
padding-left: 20px;
160-
}
161-
162-
163-
164122
.box{
165123
width: 250px;
166124
height: 150px;
@@ -193,7 +151,7 @@ img {
193151
resize:none;
194152

195153
/* copied from div.event */
196-
color: inherit; /*inherit from parrent*/
154+
color: inherit; /*inherit from parent*/
197155

198156
/*coped from body to prevent glitch*/
199157
font-family: inherit;
@@ -259,7 +217,7 @@ img {
259217
resize:none;
260218

261219
/* copied from div.event */
262-
color: inherit; /*inherit from parrent*/
220+
color: inherit; /*inherit from parent*/
263221

264222
/*coped from body to prevent glitch*/
265223
font-family: inherit;
@@ -295,13 +253,68 @@ img {
295253
box-shadow: none;
296254
}
297255

298-
#copyRight{
299-
color: @copyRightColor;
300-
padding-left: 50px;
301-
}
256+
257+
258+
// Main
259+
#copyRight{
260+
color: @copyRightColor;
261+
padding-left: 50px;
262+
}
263+
264+
#sideBar{
265+
background: @navBackground;
266+
267+
/*round the corners*/
268+
border-radius:4px ;
269+
margin-bottom: 15px;
270+
padding: 15px 15px 15px 30px;
271+
}
272+
273+
#sideBar ul{
274+
padding-left: 20px;
275+
}
302276

303277
// Note partial
304-
.notePartial .CodeMirror{
305-
border-radius:0 0 4px 4px;/*round the corners*/
306-
size: 75vh;
278+
.notePartial{
279+
.CodeMirror{
280+
border-radius:0 0 4px 4px;/*round the corners*/
281+
size: 75vh;
282+
}
283+
}
284+
285+
286+
// Folder partial
287+
.folderPartial{
288+
#folderTitleBar{
289+
padding: 0px 0px 15px 0px;
290+
overflow: hidden;
291+
font-size: 18px;
292+
293+
.breadcrumb{
294+
margin-bottom:0;
295+
padding: 0 15px 0 0;
296+
background: none;
297+
float:left;
298+
299+
>.active{
300+
color:inherit;
301+
}
302+
303+
li{
304+
font-size: 20px;
305+
}
306+
}
307+
}
308+
309+
#folderTitle{
310+
float:left;
311+
padding-right:15px;
312+
font-size: 20px;
313+
}
314+
315+
.noFolderHelp{
316+
margin-top: 25px;
317+
text-align: center;
318+
color: @copyRightColor
319+
}
307320
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@
3434
"grunt-shell": "^0.7.0",
3535
"script-loader": "^0.7.2",
3636
"style-loader": "^0.19.0",
37+
"testcafe": "^0.18.6",
3738
"url-loader": "^0.6.2",
3839
"webpack": "^3.8.1",
3940
"webpack-dev-server": "^2.9.5"
4041
},
4142
"scripts": {
42-
"test": "grunt ci",
43+
"test": "testcafe chrome ./test/e2e/test.js -e -c 3",
4344
"dev": "webpack-dev-server --open --hot --config ./build/webpack.dev.config.js",
4445
"build": "webpack --progress --hide-modules --config ./build/webpack.prod.config.js"
4546
}

0 commit comments

Comments
 (0)