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
a034b0d7
Commit
a034b0d7
authored
Jul 12, 2015
by
Arthur Verschaeve
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1371 from samccone/sjs/flake-2
⚡
️ Fixing the flake
⚡
️
parents
b3c6cd62
4176377a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
46 deletions
+73
-46
tests/allTests.js
tests/allTests.js
+1
-1
tests/package.json
tests/package.json
+0
-1
tests/page.js
tests/page.js
+69
-9
tests/testOperations.js
tests/testOperations.js
+3
-35
No files found.
tests/allTests.js
View file @
a034b0d7
...
...
@@ -41,7 +41,7 @@ var exceptions = [
{
name
:
'
dart
'
,
path
:
'
examples/vanilladart/build/
'
},
{
name
:
'
canjs_require
'
,
path
:
'
examples/canjs_require/
'
},
{
name
:
'
troopjs
'
,
path
:
'
examples/troopjs_require/
'
},
{
name
:
'
thorax_lumbar
'
,
path
:
'
examples/thorax_lumbar/public
'
}
,
{
name
:
'
thorax_lumbar
'
,
path
:
'
examples/thorax_lumbar/public
'
}
];
list
=
list
.
map
(
function
(
framework
)
{
var
exception
=
exceptions
.
filter
(
function
(
exFramework
)
{
...
...
tests/package.json
View file @
a034b0d7
...
...
@@ -8,7 +8,6 @@
"mocha"
:
"*"
,
"mocha-known-issues-reporter"
:
"git+https://github.com/ColinEberhardt/mocha-known-issues-reporter.git#v0.0.0"
,
"optimist"
:
"^0.6.1"
,
"q"
:
"^1.0.1"
,
"selenium-webdriver"
:
"^2.45.1"
},
"scripts"
:
{
...
...
tests/page.js
View file @
a034b0d7
...
...
@@ -99,11 +99,11 @@ module.exports = function Page(browser) {
this
.
tryGetToggleForItemAtIndex
=
function
(
index
)
{
var
xpath
=
this
.
xPathForItemAtIndex
(
index
)
+
'
//input[contains(@class,"toggle")]
'
;
return
this
.
tryF
indByXpath
(
xpath
);
return
this
.
f
indByXpath
(
xpath
);
};
this
.
tryGetItemLabelAtIndex
=
function
(
index
)
{
return
this
.
tryF
indByXpath
(
this
.
xPathForItemAtIndex
(
index
)
+
'
//label
'
);
return
this
.
f
indByXpath
(
this
.
xPathForItemAtIndex
(
index
)
+
'
//label
'
);
};
// ----------------- DOM element access methods
...
...
@@ -146,6 +146,55 @@ module.exports = function Page(browser) {
return
this
.
tryFindByXpath
(
xpath
);
};
this
.
getVisibleLabelText
=
function
()
{
var
self
=
this
;
return
this
.
getVisibleItemLabels
()
.
then
(
function
(
indicies
)
{
return
webdriver
.
promise
.
map
(
indicies
,
function
(
elmIndex
)
{
var
ret
;
return
browser
.
wait
(
function
()
{
return
self
.
tryGetItemLabelAtIndex
(
elmIndex
).
getText
()
.
then
(
function
(
v
)
{
ret
=
v
;
return
true
;
})
.
thenCatch
(
function
()
{
return
false
;
});
},
5000
)
.
then
(
function
()
{
return
ret
;
});
});
});
};
this
.
getVisibleItemLabels
=
function
()
{
var
self
=
this
;
var
ret
;
return
this
.
getItemLabels
()
.
then
(
function
(
elms
)
{
return
elms
.
map
(
function
(
elm
,
i
)
{
return
i
;
});
})
.
then
(
function
(
elms
)
{
return
webdriver
.
promise
.
filter
(
elms
,
function
(
elmIndex
)
{
return
browser
.
wait
(
function
()
{
return
self
.
tryGetItemLabelAtIndex
(
elmIndex
).
isDisplayed
()
.
then
(
function
(
v
)
{
ret
=
v
;
return
true
;
})
.
thenCatch
(
function
()
{
return
false
;
});
},
5000
)
.
then
(
function
()
{
return
ret
;
});
});
});
};
// ----------------- page actions
this
.
ensureAppIsVisible
=
function
()
{
return
browser
.
findElements
(
webdriver
.
By
.
css
(
'
#todoapp
'
))
...
...
@@ -190,10 +239,7 @@ module.exports = function Page(browser) {
};
this
.
toggleItemAtIndex
=
function
(
index
)
{
return
this
.
tryGetToggleForItemAtIndex
(
index
).
then
(
function
(
elements
)
{
var
toggleElement
=
elements
[
0
];
toggleElement
.
click
();
});
return
this
.
tryGetToggleForItemAtIndex
(
index
).
click
();
};
this
.
editItemAtIndex
=
function
(
index
,
itemText
)
{
...
...
@@ -226,15 +272,29 @@ module.exports = function Page(browser) {
});
};
this
.
filterBy
=
function
(
selectorFn
)
{
var
self
=
this
;
return
browser
.
wait
(
function
()
{
return
self
.
findByXpath
(
selectorFn
()).
click
()
.
then
(
function
()
{
return
self
.
findByXpath
(
selectorFn
()).
getAttribute
(
'
class
'
);
})
.
then
(
function
(
klass
)
{
return
klass
.
indexOf
(
'
selected
'
)
!==
-
1
;
});
},
5000
);
};
this
.
filterByActiveItems
=
function
()
{
return
this
.
fi
ndByXpath
(
this
.
getFilterActiveXpath
()).
click
(
);
return
this
.
fi
lterBy
(
this
.
getFilterActiveXpath
.
bind
(
this
)
);
};
this
.
filterByCompletedItems
=
function
()
{
return
this
.
fi
ndByXpath
(
this
.
getFilterCompletedXpath
()).
click
(
);
return
this
.
fi
lterBy
(
this
.
getFilterCompletedXpath
.
bind
(
this
)
);
};
this
.
filterByAllItems
=
function
()
{
return
this
.
fi
ndByXpath
(
this
.
getFilterAllXpath
()).
click
(
);
return
this
.
fi
lterBy
(
this
.
getFilterAllXpath
.
bind
(
this
)
);
};
};
tests/testOperations.js
View file @
a034b0d7
'
use strict
'
;
var
assert
=
require
(
'
assert
'
);
var
Q
=
require
(
'
q
'
);
function
TestOperations
(
page
)
{
// unfortunately webdriver does not have a decent API for determining if an
...
...
@@ -109,40 +108,9 @@ function TestOperations(page) {
// tests that the list contains the following items, independant of order
this
.
assertItems
=
function
(
textArray
)
{
page
.
getItemLabels
().
then
(
function
(
labels
)
{
// obtain all the visible items
var
visibleLabels
=
[];
var
tests
=
labels
.
map
(
function
(
label
)
{
return
label
.
isDisplayed
().
then
(
function
(
isDisplayed
)
{
if
(
isDisplayed
)
{
visibleLabels
.
push
(
label
);
}
});
});
// check that they match the supplied text
return
Q
.
all
(
tests
).
then
(
function
()
{
assert
.
equal
(
textArray
.
length
,
visibleLabels
.
length
,
textArray
.
length
+
'
items expected in the todo list,
'
+
visibleLabels
.
length
+
'
items observed
'
);
// create an array of promises which check the presence of the
// label text within the 'textArray'
tests
=
[];
for
(
var
i
=
0
;
i
<
visibleLabels
.
length
;
i
++
)
{
// suppressing JSHint - the loop variable is not being used in the function.
/* jshint -W083 */
tests
.
push
(
visibleLabels
[
i
].
getText
().
then
(
function
(
text
)
{
var
index
=
textArray
.
indexOf
(
text
);
assert
(
index
!==
-
1
,
'
A todo item with text
\'
'
+
text
+
'
\'
was not expected
'
);
// remove this item when found
textArray
.
splice
(
index
,
1
);
}));
}
// execute all the tests
return
Q
.
all
(
tests
);
});
return
page
.
getVisibleLabelText
()
.
then
(
function
(
visibleText
)
{
assert
.
deepEqual
(
textArray
.
sort
(),
visibleText
.
sort
());
});
};
...
...
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