Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
todomvc
Commits
4beba8b5
Commit
4beba8b5
authored
Jan 30, 2014
by
Colin Eberhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved test failure reporting
parent
1127b0a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
36 deletions
+50
-36
browser-tests/test.js
browser-tests/test.js
+2
-2
browser-tests/testOperations.js
browser-tests/testOperations.js
+48
-34
No files found.
browser-tests/test.js
View file @
4beba8b5
...
...
@@ -194,8 +194,8 @@ module.exports.todoMVCTest = function (frameworkName, baseUrl, speedMode, laxMod
createStandardItems
();
page
.
doubleClickItemAtIndex
(
1
);
testOps
.
assertItemToggleIsHidden
();
testOps
.
assertItemLabelIsHidden
();
testOps
.
assertItemToggleIsHidden
(
1
);
testOps
.
assertItemLabelIsHidden
(
1
);
});
test
.
it
(
'
should save edits on enter
'
,
function
()
{
...
...
browser-tests/testOperations.js
View file @
4beba8b5
...
...
@@ -9,36 +9,37 @@ function TestOperations(page) {
// element exists. The standard approach is to obtain an array of elements
// and test that the length is zero. In this case the item is hidden if
// it is either not in the DOM, or is in the DOM but not visible.
function
testIsHidden
(
elements
)
{
function
testIsHidden
(
elements
,
name
)
{
if
(
elements
.
length
===
1
)
{
elements
[
0
].
isDisplayed
().
then
(
function
(
isDisplayed
)
{
assert
(
!
isDisplayed
);
assert
(
!
isDisplayed
,
'
the
'
+
name
+
'
element should be hidden
'
);
});
}
}
function
testIsVisible
(
elements
)
{
function
testIsVisible
(
elements
,
name
)
{
assert
.
equal
(
1
,
elements
.
length
);
elements
[
0
].
isDisplayed
().
then
(
function
(
isDisplayed
)
{
assert
(
isDisplayed
);
assert
(
isDisplayed
,
'
the
'
+
name
+
'
element should be displayed
'
);
});
}
this
.
assertClearCompleteButtonIsHidden
=
function
()
{
page
.
tryGetClearCompleteButton
().
then
(
function
(
element
)
{
testIsHidden
(
element
);
testIsHidden
(
element
,
'
clear completed items button
'
);
});
};
this
.
assertClearCompleteButtonIsVisible
=
function
()
{
page
.
tryGetClearCompleteButton
().
then
(
function
(
element
)
{
testIsVisible
(
element
);
testIsVisible
(
element
,
'
clear completed items button
'
);
});
};
this
.
assertItemCount
=
function
(
itemCount
)
{
page
.
getItemElements
().
then
(
function
(
toDoItems
)
{
assert
.
equal
(
itemCount
,
toDoItems
.
length
);
assert
.
equal
(
itemCount
,
toDoItems
.
length
,
itemCount
+
'
items expected in the todo list,
'
+
toDoItems
.
length
+
'
items observed
'
);
});
};
...
...
@@ -53,37 +54,38 @@ function TestOperations(page) {
this
.
assertMainSectionIsHidden
=
function
()
{
page
.
tryGetMainSectionElement
().
then
(
function
(
mainSection
)
{
testIsHidden
(
mainSection
);
testIsHidden
(
mainSection
,
'
main
'
);
});
};
this
.
assertFooterIsHidden
=
function
()
{
page
.
tryGetFooterElement
().
then
(
function
(
footer
)
{
testIsHidden
(
footer
);
testIsHidden
(
footer
,
'
footer
'
);
});
};
this
.
assertMainSectionIsVisible
=
function
()
{
page
.
tryGetMainSectionElement
().
then
(
function
(
mainSection
)
{
testIsVisible
(
mainSection
);
testIsVisible
(
mainSection
,
'
main
'
);
});
};
this
.
assertItemToggleIsHidden
=
function
()
{
page
.
tryGetToggleForItemAtIndex
().
then
(
function
(
toggleItem
)
{
testIsHidden
(
toggleItem
);
//TODO: fishy!
this
.
assertItemToggleIsHidden
=
function
(
index
)
{
page
.
tryGetToggleForItemAtIndex
(
index
).
then
(
function
(
toggleItem
)
{
testIsHidden
(
toggleItem
,
'
item-toggle
'
);
});
};
this
.
assertItemLabelIsHidden
=
function
()
{
page
.
tryGetItemLabelAtIndex
().
then
(
function
(
toggleItem
)
{
testIsHidden
(
toggleItem
);
this
.
assertItemLabelIsHidden
=
function
(
index
)
{
page
.
tryGetItemLabelAtIndex
(
index
).
then
(
function
(
toggleItem
)
{
testIsHidden
(
toggleItem
,
'
item-label
'
);
});
};
this
.
assertFooterIsVisible
=
function
()
{
page
.
tryGetFooterElement
().
then
(
function
(
footer
)
{
testIsVisible
(
footer
);
testIsVisible
(
footer
,
'
footer
'
);
});
};
...
...
@@ -95,14 +97,17 @@ function TestOperations(page) {
this
.
assertItemText
=
function
(
itemIndex
,
textToAssert
)
{
page
.
getItemLabelAtIndex
(
itemIndex
).
getText
().
then
(
function
(
text
)
{
assert
.
equal
(
textToAssert
,
text
.
trim
());
assert
.
equal
(
textToAssert
,
text
,
'
A todo item with text
\'
'
+
textToAssert
+
'
\'
was expected at index
'
+
itemIndex
+
'
, the text
\'
'
+
text
+
'
\'
was observed
'
);
});
};
// tests that the list contains the following items, independant of order
this
.
assertItems
=
function
(
textArray
)
{
page
.
getItemLabels
().
then
(
function
(
labels
)
{
assert
.
equal
(
textArray
.
length
,
labels
.
length
);
assert
.
equal
(
textArray
.
length
,
labels
.
length
,
textArray
.
length
,
+
'
items expected in the todo list,
'
+
labels
.
length
+
'
items observed
'
);
// create an array of promises which check the presence of the
// label text within the 'textArray'
var
tests
=
[];
...
...
@@ -121,7 +126,7 @@ function TestOperations(page) {
this
.
assertItemCountText
=
function
(
textToAssert
)
{
page
.
getItemsCountElement
().
getText
().
then
(
function
(
text
)
{
assert
.
equal
(
textToAssert
,
text
.
trim
());
assert
.
equal
(
textToAssert
,
text
.
trim
()
,
'
the item count text was incorrect
'
);
});
};
...
...
@@ -129,7 +134,8 @@ function TestOperations(page) {
this
.
assertItemAtIndexIsCompleted
=
function
(
index
)
{
page
.
getItemElements
().
then
(
function
(
toDoItems
)
{
toDoItems
[
index
].
getAttribute
(
'
class
'
).
then
(
function
(
cssClass
)
{
assert
(
cssClass
.
indexOf
(
'
completed
'
)
!==
-
1
);
assert
(
cssClass
.
indexOf
(
'
completed
'
)
!==
-
1
,
'
the item at index
'
+
index
+
'
should have been marked as completed
'
);
});
});
};
...
...
@@ -139,7 +145,8 @@ function TestOperations(page) {
toDoItems
[
index
].
getAttribute
(
'
class
'
).
then
(
function
(
cssClass
)
{
// the maria implementation uses an 'incompleted' CSS class which is redundant
// TODO: this should really be moved into the pageLaxMode
assert
(
cssClass
.
indexOf
(
'
completed
'
)
===
-
1
||
cssClass
.
indexOf
(
'
incompleted
'
)
!==
-
1
);
assert
(
cssClass
.
indexOf
(
'
completed
'
)
===
-
1
||
cssClass
.
indexOf
(
'
incompleted
'
)
!==
-
1
,
'
the item at index
'
+
index
+
'
should not have been marked as completed
'
);
});
});
};
...
...
@@ -148,26 +155,33 @@ function TestOperations(page) {
return
cssClass
.
indexOf
(
'
selected
'
)
!==
-
1
;
}
this
.
assertFilterAtIndexIsSelected
=
function
(
i
ndex
)
{
this
.
assertFilterAtIndexIsSelected
=
function
(
selectedI
ndex
)
{
page
.
getFilterElements
().
then
(
function
(
filterElements
)
{
filterElements
[
0
].
getAttribute
(
'
class
'
).
then
(
function
(
cssClass
)
{
assert
(
index
===
0
?
isSelected
(
cssClass
)
:
!
isSelected
(
cssClass
));
});
filterElements
[
1
].
getAttribute
(
'
class
'
).
then
(
function
(
cssClass
)
{
assert
(
index
===
1
?
isSelected
(
cssClass
)
:
!
isSelected
(
cssClass
));
});
// create an array of promises, each one holding a test
var
tests
=
[];
filterElements
[
2
].
getAttribute
(
'
class
'
).
then
(
function
(
cssClass
)
{
assert
(
index
===
2
?
isSelected
(
cssClass
)
:
!
isSelected
(
cssClass
));
});
// push a test into the array, avoiding the classic JS for loops + closures issue!
function
pushTest
(
itemIndex
)
{
tests
.
push
(
filterElements
[
itemIndex
].
getAttribute
(
'
class
'
).
then
(
function
(
cssClass
)
{
assert
(
selectedIndex
===
itemIndex
?
isSelected
(
cssClass
)
:
!
isSelected
(
cssClass
),
'
the filter / route at index
'
+
selectedIndex
+
'
should have been selected
'
);
}));
}
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
pushTest
(
i
);
};
// execute all the tests
return
Q
.
all
(
tests
);
});
};
this
.
assertCompleteAllIsClear
=
function
()
{
page
.
getMarkAllCompletedCheckBox
().
then
(
function
(
markAllCompleted
)
{
markAllCompleted
.
isSelected
().
then
(
function
(
isSelected
)
{
assert
(
!
isSelected
);
assert
(
!
isSelected
,
'
the mark-all-completed checkbox should be clear
'
);
});
});
};
...
...
@@ -175,7 +189,7 @@ function TestOperations(page) {
this
.
assertCompleteAllIsChecked
=
function
()
{
page
.
getMarkAllCompletedCheckBox
().
then
(
function
(
markAllCompleted
)
{
markAllCompleted
.
isSelected
().
then
(
function
(
isSelected
)
{
assert
(
isSelected
);
assert
(
isSelected
,
'
the mark-all-completed checkbox should be checked
'
);
});
});
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment