Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mikolaï Krol
erp5
Commits
4cb7b670
Commit
4cb7b670
authored
Sep 20, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
officejs_support_request_ui_test: test graphs on the front page
parent
4bb40946
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
472 additions
and
2 deletions
+472
-2
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardLastMonthActivity.xml
...uest_ui_zuite/testFrontPageDashboardLastMonthActivity.xml
+58
-0
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardLastMonthActivity.zpt
...uest_ui_zuite/testFrontPageDashboardLastMonthActivity.zpt
+157
-0
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardSupportRequestPipe.xml
...est_ui_zuite/testFrontPageDashboardSupportRequestPipe.xml
+58
-0
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardSupportRequestPipe.zpt
...est_ui_zuite/testFrontPageDashboardSupportRequestPipe.zpt
+158
-0
bt5/erp5_officejs_support_request_ui_test/SkinTemplateItem/portal_skins/erp5_officejs_support_request_test/ERP5Site_createSupportRequestUITestDataSet.py
...equest_test/ERP5Site_createSupportRequestUITestDataSet.py
+41
-2
No files found.
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardLastMonthActivity.xml
0 → 100644
View file @
4cb7b670
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ZopePageTemplate"
module=
"Products.PageTemplates.ZopePageTemplate"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/html
</string>
</value>
</item>
<item>
<key>
<string>
expand
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
testFrontPageDashboardLastMonthActivity
</string>
</value>
</item>
<item>
<key>
<string>
output_encoding
</string>
</key>
<value>
<string>
utf-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<unicode>
Last Month Activity on Front Page Dashboard
</unicode>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardLastMonthActivity.zpt
0 → 100644
View file @
4cb7b670
<html>
<head>
<title
tal:content=
"template/title"
></title>
<meta
http-equiv=
"content-type"
content=
"text/html;charset=utf-8"
>
</head>
<body>
<table
cellpadding=
"1"
cellspacing=
"1"
border=
"1"
>
<thead>
<tr><td
colspan=
"3"
tal:content=
"template/title"
></td></tr>
</thead><tbody>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplate/macros/init"
/>
<tal:block
metal:use-macro=
"here/Zuite_SupportRequestUITemplate/macros/cleanup_module"
/>
<tal:block
metal:use-macro=
"here/Zuite_SupportRequestUITemplate/macros/create_data"
/>
<tr><td>
open
</td>
<td>
${base_url}/web_site_module/erp5_officejs_support_request_ui/
</td><td></td></tr>
<!-- reset filter is disabled -->
<tr><td>
waitForElementPresent
</td>
<td>
//input[@data-i18n="[value]Reset Filter" and @disabled]
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
css=#wrap2 iframe
</td><td></td></tr>
<tr><td>
selectFrame
</td>
<td>
css=#wrap2 iframe
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//canvas
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//div[@class="graph-content" and not(@disabled)]
</td><td></td></tr>
<tr><td>
storeEval
</td>
<td>
selenium.browserbot.getCurrentWindow().echarts.getInstanceByDom(
selenium.browserbot.findElement("css=.graph-content"))
</td>
<td>
graph_instance
</td></tr>
<tr><td>
assertEval
</td>
<td>
(function(){
var series = storedVars['graph_instance'].getOption()['series'],
title = storedVars['graph_instance'].getOption()['title'][0].text;
Assert.equals("Last Month Activity", title);
Assert.equals(1, series.length);
Assert.equals("pie", series[0]["type"]);
Assert.equals("Support Request", series[0]["name"]);
Assert.equals(
JSON.stringify([
{name: "Opened", value: 3},
{name: "Submitted", value: 2},
{name: "Suspended", value: 0},
{name: "Closed", value: 0}]),
JSON.stringify(series[0]["data"].map(e => {return {name: e.name, value: e.value}; })));
return "ok";
})()
</td>
<td>
ok
</td></tr>
<tr><td
colspan=
"3"
><b>
Clicking on a serie filter the listbox of recent updates
</b></td></tr>
<!--
In the last month, we have 4 Opened and 3 Submitted. The pie shows submitted on the right
and opened on the left.
0 x 100%
0 --------------------------------------- ... >
| Last Month Activity
| [ ] Opened [ ] Submitted ....
|
| _____
| Submitted .-' | '-.
| \ .' | '.
y | \ / | \
| ;\ X | ;
| | \ / ---|---- Opened
| ; / ;
| \ / /
| './ .'
| '-._____.-'
.
.
V 100%
We click in the `Submitted` zone, where's there's a X in this ascii art.
debugging tips:
selenium.browserbot.findElement('//canvas').addEventListener(
'click',
function(e) {
canvasSize = {
x: selenium.browserbot.findElement('//canvas').clientWidth,
y: selenium.browserbot.findElement('//canvas').clientHeight }
console.log(
`${e.clientX} x ${e.clientY}\n${(e.clientX / canvasSize.x * 100).toFixed(2)}% ${(e.clientY / canvasSize.y * 100).toFixed(2)}%`
)
})
or use conditional breakpoint on "clientToLocal" from echarts-all.js :
(e.type == "click" || e.type == "mousedown") && console.log(e.type +" at", e.clientX, e.clientY, (e.clientX / document.querySelector('canvas').clientWidth * 100).toFixed(2), (e.clientY / document.querySelector('canvas').clientHeight * 100).toFixed(2))
and compare real click with simulated clicks.
-->
<tr><td>
storeEval
</td>
<!-- 49% of the horizontal axis -->
<td>
Math.floor(selenium.browserbot.findElement('//canvas').clientWidth * 0.49)
</td>
<td>
x
</td></tr>
<tr><td>
storeEval
</td>
<!-- 40% of of vertical axis -->
<td>
Math.floor(selenium.browserbot.findElement('//canvas').clientHeight * 0.4)
</td>
<td>
y
</td></tr>
<tr><td>
assertEval
</td>
<!-- echarts ignore the click without a mousedown on the element before -->
<td>
var e = new MouseEvent("mousedown", {});
/* echarts will adjust the location with browser based heuristics
https://github.com/ecomfe/zrender/blob/4.0.5/src/core/event.js#L20
to make this easier, we precalculate the coordinates in a way that should
be cross browser compatible. */
e.zrX = storedVars.x;
e.zrY = storedVars.y;
selenium.browserbot.findElement("//canvas/..").dispatchEvent(e)
</td>
<td>
true
</td></tr>
<tr><td>
assertEval
</td>
<td>
var e = new MouseEvent("click", {});
e.zrX = storedVars.x;
e.zrY = storedVars.y;
selenium.browserbot.findElement("//canvas/..").dispatchEvent(e)
</td>
<td>
true
</td></tr>
<!-- XXX shouldn't selenium "clickAt" do this ?
<tr><td>clickAt</td>
<td>//canvas/..</td>
<td>${x},${y}</td></tr> -->
<tr><td
colspan=
"3"
><b>
Recent updates listbox is updated with the clicked series.
</b></td>
<tr><td>
selectFrame
</td>
<td>
relative=top
</td><td></td></tr>
<tr><td>
waitForText
</td>
<td>
//h1[@data-i18n="Recent Updates"]
</td>
<td>
Recent Updates (3)
</td></tr>
<!-- FIXME: this should be 2 here. 123dsfa is not "last month" -->
<tr><td>
waitForText
</td>
<td>
//h1[@data-i18n="Recent Updates"]/../..//td[1]/a
</td>
<td>
Yesterday - RobotMaking - Submitted
</td></tr>
<!-- reset filter is now enabled -->
<tr><td>
waitForElementPresent
</td>
<td>
//input[@data-i18n="[value]Reset Filter" and not(@disabled)]
</td><td></td></tr>
<tr><td>
click
</td>
<td>
//input[@data-i18n="[value]Reset Filter"]
</td><td></td></tr>
<tr><td>
waitForText
</td>
<td>
//h1[@data-i18n="Recent Updates"]
</td>
<td>
glob:Recent Updates (1 - 5 / *)
</td></tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardSupportRequestPipe.xml
0 → 100644
View file @
4cb7b670
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ZopePageTemplate"
module=
"Products.PageTemplates.ZopePageTemplate"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/html
</string>
</value>
</item>
<item>
<key>
<string>
expand
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
testFrontPageDashboardSupportRequestPipe
</string>
</value>
</item>
<item>
<key>
<string>
output_encoding
</string>
</key>
<value>
<string>
utf-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<unicode>
Support Request Pipe on Front Page Dashboard
</unicode>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_officejs_support_request_ui_test/PathTemplateItem/portal_tests/officejs_support_request_ui_zuite/testFrontPageDashboardSupportRequestPipe.zpt
0 → 100644
View file @
4cb7b670
<html>
<head>
<title
tal:content=
"template/title"
></title>
<meta
http-equiv=
"content-type"
content=
"text/html;charset=utf-8"
>
</head>
<body>
<table
cellpadding=
"1"
cellspacing=
"1"
border=
"1"
>
<thead>
<tr><td
colspan=
"3"
tal:content=
"template/title"
></td></tr>
</thead><tbody>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplate/macros/init"
/>
<tal:block
metal:use-macro=
"here/Zuite_SupportRequestUITemplate/macros/cleanup_module"
/>
<tal:block
metal:use-macro=
"here/Zuite_SupportRequestUITemplate/macros/create_data"
/>
<tr><td>
open
</td>
<td>
${base_url}/web_site_module/erp5_officejs_support_request_ui/
</td><td></td></tr>
<!-- reset filter is disabled -->
<tr><td>
waitForElementPresent
</td>
<td>
//input[@data-i18n="[value]Reset Filter" and @disabled]
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
css=#wrap1 iframe
</td><td></td></tr>
<tr><td>
selectFrame
</td>
<td>
css=#wrap1 iframe
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//canvas
</td><td></td></tr>
<tr><td>
waitForElementPresent
</td>
<td>
//div[@class="graph-content" and not(@disabled)]
</td><td></td></tr>
<tr><td>
storeEval
</td>
<td>
selenium.browserbot.getCurrentWindow().echarts.getInstanceByDom(
selenium.browserbot.findElement("css=.graph-content"))
</td>
<td>
graph_instance
</td></tr>
<tr><td>
assertEval
</td>
<td>
(function(){
var series = storedVars['graph_instance'].getOption()['series'],
title = storedVars['graph_instance'].getOption()['title'][0].text;
Assert.equals("Support Request Pipe", title);
Assert.equals(3, series.length);
Assert.equals("bar", series[0]["type"]);
Assert.equals("Opened", series[0]["name"]);
Assert.equals(
JSON.stringify([
{name: "
<
2
",
value:
1
},
{
name:
"
2-7
",
value:
2
},
{
name:
"
7-30
",
value:
0
},
{
name:
"
>
30", value: 1}]),
JSON.stringify(series[0]["data"].map(e => {return {name: e.name, value: e.value}; })));
Assert.equals("Submitted", series[1]["name"]);
Assert.equals(
JSON.stringify([
{name: "
<
2
",
value:
1
},
{
name:
"
2-7
",
value:
0
},
{
name:
"
7-30
",
value:
1
},
{
name:
"
>
30", value: 1}]),
JSON.stringify(series[1]["data"].map(e => {return {name: e.name, value: e.value}; })));
Assert.equals("Suspended", series[2]["name"]);
Assert.equals(
JSON.stringify([
{name: "
<
2
",
value:
0
},
{
name:
"
2-7
",
value:
0
},
{
name:
"
7-30
",
value:
0
},
{
name:
"
>
30", value: 1}]),
JSON.stringify(series[2]["data"].map(e => {return {name: e.name, value: e.value}; })));
return "ok";
})()
</td>
<td>
ok
</td></tr>
<tr><td
colspan=
"3"
><b>
Clicking on a serie filter the listbox of recent updates
</b></td></tr>
<!--
Click on the first series (Open < 2), which should be the easiest to hit,
0 x 100%
0 ----------------------------------------------------- ... >
| Support Request Pipe
| [ ] Opened [ ] Submitted ....
|
|
| <-XXX ->
| __
| |//|
| we click |//|
y | on this X |//|
| V |//|
| __ __ |//|
| | | |//| |//|
| | X| |//| |//|
| | | |//| |//|
| | | |//| |//|
| | | |//| |//|
.----------------------|--------------- ....
. < 2 2-7
.
V 100%
The width of the XXX area depends on the total available width, so it's really hard to
estimate where to click.
On a 409x285 canvas (959x703 outer window), 20% is OK.
On a 639x285 canvas (1666x703 outer window), 30% is OK.
The approximated formula (by trial and error, so it migth be just wrong) is:
( 15% + (height/with ratio) * 10% ) of height
-->
<tr><td>
storeEval
</td>
<td>
Math.floor(
( selenium.browserbot.findElement('//canvas').clientHeight/
selenium.browserbot.findElement('//canvas').clientWidth) * 0.1 +
selenium.browserbot.findElement('//canvas').clientWidth * 0.15)
</td>
<td>
x
</td></tr>
<tr><td>
storeEval
</td>
<!-- 70% of of vertical axis -->
<td>
Math.floor(selenium.browserbot.findElement('//canvas').clientHeight * 0.7)
</td>
<td>
y
</td></tr>
<tr><td>
assertEval
</td>
<!-- echarts ignore the click without a mousedown on the element before -->
<td>
var e = new MouseEvent("mousedown", {});
e.zrX = storedVars.x;
e.zrY = storedVars.y;
selenium.browserbot.findElement("//canvas/..").dispatchEvent(e)
</td>
<td>
true
</td></tr>
<tr><td>
assertEval
</td>
<td>
var e = new MouseEvent("click", {});
e.zrX = storedVars.x;
e.zrY = storedVars.y;
selenium.browserbot.findElement("//canvas/..").dispatchEvent(e)
</td>
<td>
true
</td></tr>
<tr><td
colspan=
"3"
><b>
Recent updates listbox is updated with the clicked series.
</b></td>
<tr><td>
selectFrame
</td>
<td>
relative=top
</td><td></td></tr>
<tr><td>
waitForText
</td>
<td>
//h1[@data-i18n="Recent Updates"]
</td>
<td>
Recent Updates (1)
</td></tr>
<tr><td>
waitForText
</td>
<td>
//h1[@data-i18n="Recent Updates"]/../..//td[1]/a
</td>
<td>
Yesterday - PlaneMaking - Open
</td></tr>
<!-- reset filter is now enabled -->
<tr><td>
waitForElementPresent
</td>
<td>
//input[@data-i18n="[value]Reset Filter" and not(@disabled)]
</td><td></td></tr>
<tr><td>
click
</td>
<td>
//input[@data-i18n="[value]Reset Filter"]
</td><td></td></tr>
<tr><td>
waitForText
</td>
<td>
//h1[@data-i18n="Recent Updates"]
</td>
<td>
glob:Recent Updates (1 - 5 / *)
</td></tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
bt5/erp5_officejs_support_request_ui_test/SkinTemplateItem/portal_skins/erp5_officejs_support_request_test/ERP5Site_createSupportRequestUITestDataSet.py
View file @
4cb7b670
"""Create some data for support request UI test.
Logged in user needs to be Assignee / Assignor on the support requests
*
Logged in user needs to be Assignee / Assignor on the support requests
included in business template.
* Some "static" data is already in business template, but because the dashboard
display statistics about recent support requests (like "less than 2 days from now"),
we need to generate support requests at a date relative from now.
"""
from
DateTime
import
DateTime
from
datetime
import
timedelta
portal
=
context
.
getPortalObject
()
now
=
DateTime
().
asdatetime
()
for
support_request
in
portal
.
support_request_module
.
contentValues
():
if
support_request
.
getId
().
startswith
(
'erp5_officejs_support_request_ui_test'
):
...
...
@@ -11,6 +18,38 @@ for support_request in portal.support_request_module.contentValues():
portal
.
portal_membership
.
getAuthenticatedMember
().
getId
(),
[
'Assignee'
,
'Assignor'
])
support_request
.
reindexObject
()
portal
.
portal_caches
.
clearAllCache
()
portal
.
support_request_module
.
newContent
(
portal_type
=
'Support Request'
,
title
=
"Two Weeks ago - PlaneMaking - Submitted"
,
start_date
=
DateTime
(
now
-
timedelta
(
days
=
15
)),
source_project_value
=
portal
.
project_module
.
erp5_officejs_support_request_ui_test_project_001
,
).
submit
()
portal
.
support_request_module
.
newContent
(
portal_type
=
'Support Request'
,
title
=
"Last Week 2 - RobotMaking - Open"
,
start_date
=
DateTime
(
now
-
timedelta
(
days
=
5
)),
source_project_value
=
portal
.
project_module
.
erp5_officejs_support_request_ui_test_project_001
,
).
validate
()
portal
.
support_request_module
.
newContent
(
portal_type
=
'Support Request'
,
title
=
"Last Week - RobotMaking - Open"
,
start_date
=
DateTime
(
now
-
timedelta
(
days
=
4
)),
source_project_value
=
portal
.
project_module
.
erp5_officejs_support_request_ui_test_project_001
,
).
validate
()
portal
.
support_request_module
.
newContent
(
portal_type
=
'Support Request'
,
title
=
"Yesterday - RobotMaking - Submitted"
,
start_date
=
DateTime
(
now
-
timedelta
(
days
=
1
)),
source_project_value
=
portal
.
project_module
.
erp5_officejs_support_request_ui_test_project_001
,
).
submit
()
portal
.
support_request_module
.
newContent
(
portal_type
=
'Support Request'
,
title
=
"Yesterday - PlaneMaking - Open"
,
start_date
=
DateTime
(
now
-
timedelta
(
days
=
1
)),
source_project_value
=
portal
.
project_module
.
erp5_officejs_support_request_ui_test_project_001
,
).
validate
()
return
"Done."
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