Commit f700a7a2 authored by Ayush Tiwari's avatar Ayush Tiwari

[erp5_core] Revert view for Historical Comparison.

Partila revert from 2f121c19
parent 38731317
......@@ -130,21 +130,20 @@
<td>title</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td>
<td></td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]</td>
<td>Title 0</td> <!-- before -->
</tr>
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');</td>
<td>_data_gadget_value</td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[3]</td>
<td>Version 1</td> <!-- after -->
</tr>
<tr>
<td>verifyEval</td>
<td>storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td>
<td>---+++@@-1+1@@-Title0+Version1</td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[4]</td>
<td>Version 3</td> <!-- now -->
</tr>
</tal:block>
<tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'">
......@@ -191,21 +190,20 @@
<td>title</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td>
<td></td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]</td>
<td>Version 1</td> <!-- before -->
</tr>
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');</td>
<td>_data_gadget_value</td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[3]</td>
<td>Version 2</td> <!-- after -->
</tr>
<tr>
<td>verifyEval</td>
<td>storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td>
<td>---+++@@-1+1@@-Version1+Version2</td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[4]</td>
<td>Version 3</td> <!-- now -->
</tr>
</tal:block>
<tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'">
......@@ -270,21 +268,20 @@
<td>title</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td>
<td></td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[2]</td>
<td>Version 2</td> <!-- before -->
</tr>
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-0 DataA']/td[2]/div[@data-gadget-sandbox='public']", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('data-gadget-value');</td>
<td>_data_gadget_value</td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[3]</td>
<td>Version 3</td> <!-- after -->
</tr>
<tr>
<td>verifyEval</td>
<td>storedVars['_data_gadget_value'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td>
<td>---+++@@-1+1@@-Version2+Version3</td>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-0 DataA']/td[4]</td>
<td>Version 3</td> <!-- now -->
</tr>
</tal:block>
<tal:block tal:condition="python: context.TestTool_getSkinName()=='Mobile'">
......
......@@ -130,32 +130,19 @@
<tr>
<td>verifyText</td>
<td>//div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[2]</td>
<td>Diff Viewer</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe</td>
<td></td>
<td>Old Value</td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<!-- Check for the value of diff in Iframe -->
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//div[@data-gadget-scope='field_listbox']//table/tbody/tr[2]/td[2]//iframe", document.querySelector('#selenium_myiframe').contentWindow.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.contentWindow.document.body.textContent</td>
<td>diff_content</td>
<td>verifyText</td>
<td>//div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[3]</td>
<td>New Value</td>
</tr>
<tr>
<td>verifyEval</td>
<!-- Verify the value after removing the spaces and line breaks -->
<td>storedVars['diff_content'].replace(/(\r\n\t|\n|\r\t)/gm,"").replace(/\s+/g, '')</td>
<td>1-1+Anewfoo</td>
<td>verifyText</td>
<td>//div[@data-gadget-scope='field_listbox']//table/thead/tr[1]/th[4]</td>
<td>Current Value</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
</html>
from Products.ERP5Type.Document import newTempBase
from Products.PythonScripts.standard import Object
from ZODB.POSException import ConflictError
from zExceptions import Unauthorized
Base_translateString = context.Base_translateString
portal = context.getPortalObject()
portal_diff = portal.portal_diff
try:
context.HistoricalRevisions[serial]
except (ConflictError, Unauthorized):
raise
except Exception:
return [newTempBase(portal, Base_translateString('Historical revisions are'
except Exception: # POSKeyError
return [Object(property_name=Base_translateString('Historical revisions are'
' not available, maybe the database has been packed'))]
if next_serial == '0.0.0.0':
# In case the next serial is 0.0.0.0, we should always be considering the
# new object as the current context
new_getProperty = context.getProperty
new = context
else:
new = context.HistoricalRevisions[next_serial]
new_getProperty = new.getProperty
old = context.HistoricalRevisions[serial]
result = []
# XXX: Instead of creating a separate property list here, we can use DiffTool
# to directly find out the beautified diff and send it to the listbox
binary_data_explanation = Base_translateString("Binary data can't be displayed")
base_error_message = Base_translateString('(value retrieval failed)')
diff = portal_diff.diffPortalObject(old, new).asBeautifiedJSONDiff()
for prop_dict in context.getPropertyMap():
prop = prop_dict['id']
error = False
try:
current_value = context.getProperty(prop)
except TypeError:
error = True
current_value = base_error_message
try:
old_value = old.getProperty(prop)
except TypeError:
error = True
old_value = base_error_message
try:
new_value = new_getProperty(prop)
except TypeError:
error = True
new_value = base_error_message
if new_value != old_value or error:
# check if values are unicode convertible (binary are not)
if isinstance(new_value, (str, unicode)):
try:
unicode(str(new_value), 'utf-8')
except UnicodeDecodeError:
new_value = binary_data_explanation
if isinstance(old_value, (str, unicode)):
try:
unicode(str(old_value), 'utf-8')
except UnicodeDecodeError:
old_value = binary_data_explanation
if isinstance(current_value, (str, unicode)):
try:
unicode(str(current_value), 'utf-8')
except UnicodeDecodeError:
current_value = binary_data_explanation
tempbase_list = []
uid = 900
for x in diff:
temp_obj = newTempBase(portal,
x['path'],
**x)
temp_obj.setUid('new_%s' % uid)
uid = uid + 1
tempbase_list.append(temp_obj)
return tempbase_list
result.append( Object( property_name=prop,
new_value=new_value,
old_value=old_value,
current_value=current_value))
return result
......@@ -90,9 +90,7 @@
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_diff</string>
</list>
<list/>
</value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>css_class</string>
<string>default</string>
<string>gadget_url</string>
<string>js_sandbox</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_diff</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string>listbox-gadget</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_gadget_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Diff Viewer</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.diff</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: field.restrictedTraverse(\'gadget_erp5_side_by_side_diff.html\').absolute_url()</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.Base_getDiffGadgetSandbox()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,7 +50,6 @@ class TestXHTMLMixin(ERP5TypeTestCase):
# some forms have intentionally empty listbox selections like RSS generators
FORM_LISTBOX_EMPTY_SELECTION_PATH_LIST = ['erp5_web_widget_library/WebSection_viewContentListAsRSS',
'erp5_core/Base_viewHistoricalComparison',
'erp5_diff/ERP5Site_viewDiffTwoObjectDialog',]
JSL_IGNORE_FILE_LIST = (
'diff2html.js',
......
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