Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
ecommerce-ui
Commits
619f51a0
Commit
619f51a0
authored
Apr 01, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: added multiple start/stop to wait for async requests
parent
283886f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
12 deletions
+47
-12
test/index.html
test/index.html
+47
-12
No files found.
test/index.html
View file @
619f51a0
...
...
@@ -168,6 +168,8 @@
d
=
el
.
contentDocument
;
j
=
el
.
contentWindow
.
$
;
helper
=
$
.
testHelper
;
// unbind onload handler
frame
.
onload
=
undefined
;
// ======================= start here ===========================
trigger
=
function
(
window
,
d
,
$
,
testHelper
)
{
...
...
@@ -215,21 +217,37 @@
'
<td>//div[@id="global-panel"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-popup-popup"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Login"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//div[@id="global-popup-popup"]</td>
'
+
'
<td>verifyAttribute</td>
'
+
'
<td>//div[@id="global-popup-popup"]@class</td>
'
+
'
<td>ui-popup-active</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[@data-reference="google"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyAttribute</td>
'
+
'
<td>//div[@id="global-popup-popup"]@class</td>
'
+
'
<td>ui-popup-
active
</td>
'
+
'
<td>ui-popup-
hidden
</td>
'
+
'
</tr>
'
+
'
</tbody>
'
+
'
</table>
'
;
...
...
@@ -304,6 +322,7 @@
// set reference, because what we do is not working
madeJS
=
'
var frame = document.getElementsByTagName("iframe")[0];
'
+
'
var $frame = $(frame);
'
+
'
var d = frame.contentDocument;
'
+
'
var w = frame.contentWindow;
'
+
'
var $i = w.$( d );
'
+
...
...
@@ -311,26 +330,28 @@
'
var $body = w.$("body");
'
;
// dump all testmethods here, because they need to be available
// inside the iFrame...
madeJS
+=
'
$.testHelper.eventTarget = $
body
;
'
+
madeJS
+=
'
$.testHelper.eventTarget = $
frame
;
'
+
'
$.testHelper.stepSequence = function (fns) {
'
+
'
$.testHelper.eventSequence( "step", fns );
'
+
'
};
'
+
'
$.testHelper.runTest = function (command, condition, arr) {
'
+
'
var message = command + " - CRITERIA - " + arr[0] + "|" + arr[1] + "|" + arr[2];
'
+
'
ok(condition, message);
'
+
'
$
body
.trigger("step");
'
+
'
$
body
.trigger("test_runner");
'
+
'
$
frame
.trigger("step");
'
+
'
$
frame
.trigger("test_runner");
'
+
'
};
'
+
'
$.testHelper.countDown = function (arr, command) {
'
+
'
var condition, is_done;
'
+
'
var ticker = 0;
'
+
'
var el;
'
+
'
var skip_test;
'
+
'
var source;
'
+
'
var i = w.setInterval(function() {
'
+
'
switch (command) {
'
+
'
case "verifyAttribute":
'
+
'
el = $.find(arr[0]);
'
+
'
el = $
i
.find(arr[0]);
'
+
'
if (el.length > 0) {
'
+
'
con
sole.log("OI");console.log(arr);condition = $i.find(arr[0])
.eq(0).attr(arr[1]).indexOf(arr[2]) > -1;
'
+
'
con
dition = el
.eq(0).attr(arr[1]).indexOf(arr[2]) > -1;
'
+
'
} else {
'
+
'
condition = false;
'
+
'
}
'
+
...
...
@@ -380,13 +401,13 @@
count
=
0
;
madeJS
+=
'
asyncTest( "
'
+
instruction
.
selector
+
'
", function() { expect( __number__ );
'
;
madeJS
+=
'
$.testHelper.stepSequence([ function () {
'
;
madeJS
+=
'
$
body
.on("test_runner", function (e) {
'
+
madeJS
+=
'
$
frame
.on("test_runner", function (e) {
'
+
'
test_log += 1;
'
+
'
if (test_log === __number__) {
'
+
'
start();
'
+
'
start(
0
);
'
+
'
}
'
+
'
});
'
+
'
}, function () {
'
;
'
$frame.trigger("step");
}, function () {
'
;
break
;
case
"
select
"
:
...
...
@@ -409,7 +430,20 @@
ins
=
instruction
.
selector
;
wrap
=
selector
(
ins
);
find
=
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
nth
(
ins
)
+
wrap
[
1
];
source
=
find
.
indexOf
(
"
google
"
)
!==
-
1
;
if
(
source
)
{
madeJS
+=
'
stop(0);frame.onload = function () {
'
+
'
frame.onload=undefined;
'
+
'
$i = frame.contentWindow.$(frame.contentDocument);
'
+
'
window.setTimeout(function() {
'
+
'
$frame.trigger("step");start(1);
'
+
'
},5000);
'
+
'
};
'
+
'
frame.src = $i.find("
'
+
find
+
'
")[0].href;
'
+
'
}, function() {
'
;
}
else
{
madeJS
+=
'
$i.find("
'
+
find
+
'
").trigger("click");
'
;
}
break
;
case
"
verifyText
"
:
...
...
@@ -486,6 +520,7 @@
<div
id=
"playground"
>
<iframe
id=
"testbed"
src=
"../index.html"
>
Your browser doesn't support Iframes
</iframe>
</div>
</body>
</html>
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