Commit 7295e01a authored by Vincent Bechu's avatar Vincent Bechu

[officejs_test] Fix functional tests

parent 4e8a490f
...@@ -9,10 +9,22 @@ ...@@ -9,10 +9,22 @@
<thead> <thead>
<tr><td rowspan="1" colspan="3">Test RenderJS UI</td></tr> <tr><td rowspan="1" colspan="3">Test RenderJS UI</td></tr>
</thead><tbody> </thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForOfficejsAppstoreUi/macros/appstore_init" /> <tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr>
<td>openAndWait</td>
<td>${base_url}/ERP5Site_setupDummyMailHost</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>True</td>
<td></td>
</tr>
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/ERP5Site_removeTestUserList</td> <td>${base_url}/web_site_module/application-list/publisher/ERP5Site_removeTestUserList</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
...@@ -23,14 +35,14 @@ ...@@ -23,14 +35,14 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" /> <tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/web_site_module/officejs_runner/WebSite_logout</td> <td>${base_url}/web_site_module/application-list/publisher/WebSite_logout</td>
<td></td> <td></td>
</tr> </tr>
<!-- Initialize --> <!-- Initialize -->
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/web_site_module/officejs_runner/</td> <td>${base_url}/web_site_module/application-list/publisher/</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
...@@ -103,7 +115,7 @@ ...@@ -103,7 +115,7 @@
<!-- Initialize --> <!-- Initialize -->
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/web_site_module/officejs_runner/</td> <td>${base_url}/web_site_module/application-list/publisher/</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
......
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" /> <tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/web_site_module/officejs_runner/WebSite_logout</td> <td>${base_url}/web_site_module/application-list/publisher/WebSite_logout</td>
<td></td> <td></td>
</tr> </tr>
<!-- Account already exist --> <!-- Account already exist -->
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/web_site_module/officejs_runner/</td> <td>${base_url}/web_site_module/application-list/publisher/</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<!-- Password and confirmation not same --> <!-- Password and confirmation not same -->
<tr> <tr>
<td>open</td> <td>open</td>
<td>${base_url}/web_site_module/officejs_runner/</td> <td>${base_url}/web_site_module/application-list/publisher/</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
......
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
import time
from StringIO import StringIO
import zipfile
import json
class LocalStringIO(StringIO):
__allow_access_to_unprotected_subobjects__=1
def __init__(self, filename, *args, **kw):
self.filename = filename
StringIO.__init__(self, *args, **kw)
class TestOfficeJSScenario(SecurityTestCase):
def getTitle(self):
return "Test OfficeJS Scenario Appstore"
def getBusinessTemplateList(self):
"""
Tuple of Business Templates we need to install
"""
return ('officejs_meta', 'officejs_credential')
def createNewUser(self,
first_name="John_test",
last_name="Smith_test",
email="john.smith@example.com"):
"""
Add new member using script for the website sign-in
"""
user = self.portal.person_module.newContent(
portal_type="Person",
first_name=first_name,
last_name=last_name,
default_email_coordinate_text=email,
career_role_list=["author"]
)
user.validate()
assignment = user.newContent(portal_type="Assignment", role="author")
assignment.open()
return user
def createNewAdmin(self,
first_name="Brandon_test",
last_name="Cougar_test",
email="brandon.cougar@example.com"):
"""
Add new member using script for the website sign-in
"""
user = self.portal.person_module.newContent(
portal_type="Person",
first_name=first_name,
last_name=last_name,
default_email_coordinate_text=email,
career_role_list=["administration"]
)
user.validate()
assignment = user.newContent(portal_type="Assignment", group="my_group")
assignment.open()
return user
def createApplicationAndPublish(self, title):
person_user = self.createNewUser()
person_admin = self.createNewAdmin()
self.tic()
self.login(person_user.getUserId())
import_file = LocalStringIO('app.zip')
my_zip = zipfile.ZipFile(import_file, 'w')
my_zip.writestr('index.html', '<html><head><link rel="manifest" href="app_manifest.json"></head></html>')
my_zip.writestr('app_manifest.json', '{"short_name": "%s","name": "%s","description": "application test", "icons": [{"src": "logo.png","sizes": "any","type": "image/png"}],"start_url": "../","display": "standalone"}' % (title, title))
my_zip.writestr('logo.png', 'skapoutch')
my_zip.close()
self.portal.SoftwareProductModule_createNewApplication(
import_file,
title
)
self.logout()
self.login()
self.tic()
self.portal.portal_alarms.officejs_process_submit_software_publication\
.activeSense()
self.tic()
software_product = self.portal.portal_catalog.getResultValue(
portal_type='Software Product',
title=title
)
web_site = software_product.SoftwareProduct_getRelatedWebSite()
web_section = web_site.objectValues()[0]
self.logout()
self.login(person_user.getUserId())
software_publication = self.portal.portal_catalog.getResultValue(
portal_type='Software Publication',
reference='SP-%s' % web_section.getId()
)
software_publication.open()
self.tic()
self.logout()
self.login(person_admin.getUserId())
software_publication.accept()
self.tic()
self.logout()
self.login()
self.tic()
self.portal.portal_alarms.officejs_process_update_appstore.activeSense()
self.tic()
def getApplicationWithTitle(self, title):
application_list = json.loads(self.portal.document_module['store_officejs_data_application_sample_json'].getData())
for app in application_list:
if app['application_title'] == title:
return app
return None
def checkApplicationWithTitle(self, title):
app = self.getApplicationWithTitle(title)
self.assertTrue(app is not None)
self.assertTrue('logo.png' in app['application_image_url'])
self.assertEquals(app['application_description'], 'application test')
self.assertEquals(app['application_image_type'], 'image')
def test_appstore_add_an_application(self):
title = 'My Application %s' % time.time()
self.assertEquals(self.getApplicationWithTitle(title), None)
self.createApplicationAndPublish(title)
self.checkApplicationWithTitle(title)
return title
def test_appstore_add_multiple_application(self):
t_list = []
for _ in range(4):
t_list.append(self.test_appstore_add_an_application())
for t in t_list:
self.checkApplicationWithTitle(t)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testOfficeJSScenarioAppsore</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testOfficeJSScenarioAppsore</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
test.erp5.testOfficeJSSecurity test.erp5.testOfficeJSSecurity
test.erp5.testOfficeJSScenario test.erp5.testOfficeJSScenario
test.erp5.testOfficeJSScenarioRjsUI test.erp5.testOfficeJSScenarioRjsUI
test.erp5.testFunctionalOfficeJSAppstoreUI test.erp5.testFunctionalOfficeJSAppstoreUI
\ No newline at end of file test.erp5.testOfficeJSScenarioAppsore
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment