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
77aacf3f
Commit
77aacf3f
authored
Mar 31, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: finished test setup
parent
b5f638d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
145 deletions
+105
-145
test/index.html
test/index.html
+105
-145
No files found.
test/index.html
View file @
77aacf3f
...
...
@@ -164,7 +164,7 @@
// ======================= start here ===========================
trigger
=
function
(
window
,
d
,
$
,
testHelper
)
{
// oh lord
// oh lord
... please buy me another test code generator
var
another_string
=
'
<table cellspacing="1" cellpadding="1" border="1" name="SELENIUM-TEST">
'
+
'
<thead>
'
+
...
...
@@ -209,6 +209,21 @@
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Login"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>verifyAttribute</td>
'
+
'
<td>//div[@id="global-popup-popup"]@class</td>
'
+
'
<td>ui-popup-active</td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="Facebook"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//a[.="Menu"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
...
...
@@ -219,29 +234,35 @@
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//
h1[.="My Account
"]</td>
'
+
'
<td>//
a[.="Menu
"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//a[.="
Add network
"]</td>
'
+
'
<td>//a[.="
My Account
"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>click</td>
'
+
'
<td>//a[.="
Add network
"]</td>
'
+
'
<td>//a[.="
My Account
"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>waitForElementPresent</td>
'
+
'
<td>//
input[@id="network_new_title
"]</td>
'
+
'
<td>//
th[.="Email Address
"]</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>
type
</td>
'
+
'
<td>
id=network_new_title
</td>
'
+
'
<td>
Bazbam
</td>
'
+
'
<td>
click
</td>
'
+
'
<td>
//a[@class="table_link"][0]
</td>
'
+
'
<td></td>
'
+
'
</tr>
'
+
'
<tr>
'
+
'
<td>pause</td>
'
+
'
<td>5000</td>
'
+
...
...
@@ -829,7 +850,7 @@
// (7)
var
tableToParse
,
tag
,
selector
,
val
,
ins
,
find
,
close_async
,
i
,
instruction
,
madeJS
,
add
,
menu_button
,
testForElement
,
countDown
,
getParam
,
test_value
;
getParam
,
test_value
,
test_attr
,
test_log
,
wrap
,
iter
;
// parse table into objcet
...
...
@@ -847,12 +868,24 @@
// extract selector identifier (class, id, :contains...)
selector
=
function
(
str
)
{
var
base
=
str
.
split
(
"
[
"
)[
1
].
split
(
"
=
"
)[
0
].
replace
(
"
@
"
,
""
);
switch
(
base
)
{
case
"
class
"
:
return
[
"
.
"
,
""
];
case
"
id
"
:
return
[
"
#
"
,
""
];
case
"
.
"
:
return
[
"
:contains('
"
,
"
')
"
];
}
};
// which element
nth
=
function
(
str
)
{
if
(
str
.
split
(
"
][
"
).
length
>
1
)
{
return
"
:nth-child(
"
+
str
.
split
(
"
]
"
).
slice
(
-
2
).
shift
().
replace
(
"
[
"
,
""
)
+
"
)
"
;
}
return
""
};
// extract selector value
val
=
function
(
str
)
{
return
str
.
split
(
"
=
"
)[
1
]
...
...
@@ -868,113 +901,112 @@
madeJS
=
'
var frame = document.getElementsByTagName("iframe")[0];
'
+
'
var d = frame.contentDocument;
'
+
'
var w = frame.contentWindow;
'
+
'
var $i = $( d );
'
;
'
var $i = w.$( d );
'
+
'
var test_log = 0;
'
+
'
var $body = w.$("body");
'
;
// dump all testmethods here, because they need to be available
// inside the iFrame...
madeJS
+=
'
$.testHelper.countDown = function(test, iteration) {
'
+
'
var ticker = iteration || 0;
'
+
'
if (ticker > 10) {
'
+
'
return false;
'
+
'
}
'
+
'
window.setTimeout(function() {
'
+
'
if (test === true) {
'
+
'
return true;
'
+
madeJS
+=
'
$.testHelper.eventTarget = $body;
'
+
'
$.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");
'
+
'
};
'
+
'
$.testHelper.countDown = function (arr, command) {
'
+
'
var condition, is_done;
'
+
'
var ticker = 0;
'
+
'
var i = w.setInterval(function() {
'
+
'
switch (command) {
'
+
'
case "verifyAttribute":
'
+
'
condition = $i.find(arr[0]).eq(0).attr(arr[1]).indexOf(arr[2]) > -1;
'
+
'
break;
'
+
'
case "waitForElementPresent":
'
+
'
condition = $i.find(arr[0]).length > 0;
'
+
'
break;
'
+
'
}
'
+
'
if (condition) {
'
+
'
$.testHelper.runTest(command, condition, arr);
'
+
'
w.clearInterval(i);
'
+
'
}
'
+
'
ticker += 1;
'
+
'
$.testHelper.countDown(test, ticker);
'
+
'
if (ticker === 10) {
'
+
'
$.testHelper.runTest(command, condition, arr);
'
+
'
w.clearInterval(i);
'
+
'
}
'
+
'
}, 1000);
'
+
'
};
'
+
'
$.testHelper.testForAttribute = function(element, attr, value) {
'
+
'
var look = $i.find(element).eq(0).attr(attr);
'
+
'
return $.testHelper.countDown(
'
+
'
look.indexOf(value) > -1
'
+
'
);
'
+
'
};
'
+
'
$.testHelper.testForElement = function(element) {
'
+
'
return $.testHelper.countDown(
'
+
'
$i.find(element).length > 0
'
+
'
);
'
+
'
};
'
;
madeJS
+=
'
module("
'
+
'
SlapOS UI Basic Interaction
'
+
'
");
'
;
len
=
tableToParse
.
length
;
// loop table rows
for
(
i
=
0
;
i
<
9
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
17
;
i
+=
1
)
{
instruction
=
tableToParse
[
i
];
// parse instructions
console
.
log
(
instruction
.
command
)
switch
(
instruction
.
command
)
{
case
"
openAndWait
"
:
// close previous async block
if
(
close_async
)
{
madeJS
+=
'
function() {start();} ]) });
'
;
madeJS
=
madeJS
.
replace
(
/__number__/
,
count
.
toString
());
close_asyn
=
undefined
;
count
=
undefined
;
}
// start a new block
close_async
=
true
;
count
=
0
;
madeJS
+=
'
asyncTest( "
'
+
instruction
.
selector
+
'
", function() { expect( __number__ );
'
;
madeJS
+=
'
$.testHelper.pageSequence([
'
;
madeJS
+=
'
$.testHelper.stepSequence([ function () {
'
;
madeJS
+=
'
$body.on("test_runner", function (e) {
'
+
'
test_log += 1;
'
+
'
if (test_log === __number__) {
'
+
'
start();
'
+
'
}
'
+
'
});
'
+
'
}, function () {
'
;
break
;
case
"
click
"
:
ins
=
instruction
.
selector
;
wrap
=
selector
(
ins
);
find
=
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
wrap
[
1
];
madeJS
+=
'
function () {
'
+
'
$("
'
+
find
+
'
").trigger("click");
'
+
'
},
'
;
find
=
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
nth
(
ins
)
+
wrap
[
1
];
madeJS
+=
'
$i.find("
'
+
find
+
'
").trigger("click");
'
;
break
;
case
"
verifyAttribute
"
:
ins
=
instruction
.
selector
;
wrap
=
selector
(
ins
);
count
+=
1
;
find
=
(
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
wrap
[
1
]).
split
(
"
@
"
)[
0
];
test_
value
=
getParam
(
ins
);
madeJS
+=
'
function () {
'
;
find
=
(
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
nth
(
ins
)
+
wrap
[
1
]).
split
(
"
@
"
)[
0
];
test_
attr
=
getParam
(
ins
);
test_value
=
instruction
.
value
;
switch
(
test_value
)
{
case
'
class
'
:
madeJS
+=
'
var t = $.testHelper.testForAttribute("
'
+
find
+
'
", "
'
+
test_value
+
'
", "
'
+
instruction
.
value
+
'
");
'
;
break
;
}
madeJS
+=
'
}, function (t) {
'
+
'
ok(t, "attribute present");
'
+
'
},
'
;
madeJS
+=
'
$.testHelper.countDown(
'
+
'
["
'
+
find
+
'
", "
'
+
test_attr
+
'
", "
'
+
test_value
+
'
"],
'
+
'
"verifyAttribute"
'
+
'
);}, function () {
'
;
break
;
case
"
waitForElementPresent
"
:
ins
=
instruction
.
selector
;
wrap
=
selector
(
ins
);
find
=
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
wrap
[
1
];
find
=
tag
(
ins
)
+
wrap
[
0
]
+
val
(
ins
)
+
nth
(
ins
)
+
wrap
[
1
];
count
+=
1
;
madeJS
+=
'
function () {
'
+
'
var t = $.testHelper.testForElement("
'
+
find
+
'
");
'
+
'
}, function (t) {
'
+
'
ok(t, "element present");
'
+
'
},
'
;
madeJS
+=
'
$.testHelper.countDown(
'
+
'
["
'
+
find
+
'
", undefined, undefined],
'
+
'
"waitForElementPresent"
'
+
'
);}, function () {
'
;
break
;
}
}
if
(
close_async
)
{
madeJS
+=
'
function() {start();} ]) });
'
;
madeJS
=
madeJS
.
replace
(
/__number__/
,
count
.
toString
());
console
.
log
(
"
CLOSED
"
)
madeJS
+=
'
} ]) });
'
;
madeJS
=
madeJS
.
replace
(
/__number__/g
,
count
.
toString
());
close_asyn
=
undefined
;
count
=
undefined
;
}
console
.
log
(
madeJS
)
console
.
log
(
madeJS
);
// inject
add
=
d
.
createElement
(
"
script
"
);
add
.
type
=
"
text/javascript
"
;
...
...
@@ -984,79 +1016,7 @@
$
.
testHelper
=
testHelper
;
// just a dummy....
window
.
setTimeout
(
function
()
{
QUnit
.
start
();
// ========================
module
(
"
Network Section
"
);
asyncTest
(
"
Navigate to network page
"
,
function
()
{
var
network_page
,
menu_button
;
expect
(
1
);
$
.
testHelper
.
pageSequence
([
function
()
{
menu_button
=
$
(
"
#global-header
"
).
find
(
"
a[data-rel='panel']
"
);
ok
(
menu_button
.
length
===
1
,
"
Menu button exists, application init rendered correctly
"
);
menu_button
.
trigger
(
"
click
"
);
},
/*
function() {
setTimeout(function() {
ok( $("#global-panel").hasClass("ui-panel-open"), "panel opens when clicking menu button" );
$("a[href='#networks']").trigger("click");
}, 800);
},
function(){
setTimeout(function(){
network_page = $("div.ui-page").last();
ok( network_page.length === 1, "network page loaded" );
}, 800);
},
function(){
var table, new_button;
setTimeout(function(){
table = network_page.find("table");
new_button = $("a[href='#networks/new']");
ok( table.length === 1, "network table generated" );
ok( table.find("tbody tr").length > 0, "network table has records (zero result record, or 1+ records" );
ok( new_button.length === 1, "New network button available");
new_button.trigger("click");
}, 1000);
},
function() {
var new_network, form, input, submit;
setTimeout(function(){
new_network = $("div.ui-page").last();
form = new_network.find("form");
input = form.find("div.ui-input-text input[type='text']");
submit = form.find("input[type='submit']");
ok( input.length === 1, "new network title input exits");
input.val("foobarbazbam");
submit.trigger("click");
}, 800);
},
function() {
var i, network_page, inputs, test_value;
setTimeout(function() {
network_page = $("div.ui-page").last();
inputs = network_page.find("input");
for (i = 0; i < inputs.length; i += 1) {
if (inputs.eq(i)[0].value === "foobarbazbam") {
test_value = true;
}
}
ok(test_value, "network has been generated and the name is matching what was entered before");
}, 1000);
},*/
function
()
{
start
();
}
]);
})
},
1000
);
};
// let's go
...
...
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