Commit 813d4942 authored by Jérome Perrin's avatar Jérome Perrin

core: fix error when submitting "View Diff" dialog

This action was working fine the first time displayed, but clicking
again on "View Diff" button was causing an IndexError: list index out of range
when used on one document.

This was because in this case list_selection_name exists in REQUEST, but
is an empty string. Instead of checking that this selection name is not
None to detect if we are in module mode or in document mode, check that
its true-ish to also tolerate an empty string.
parent e7c4e387
Pipeline #11976 failed with stage
in 0 seconds
......@@ -63,48 +63,56 @@
<td>Diff Module Objects</td>
</tr>
<!-- Check the diff content -->
<tr>
<td>verifyValue</td>
<td>field_your_first_path</td>
<td>bar_module/1</td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_second_path</td>
<td>bar_module/2</td>
</tr>
<tal:block tal:repeat="_ python: (1, 2)">
<tr>
<td>assertText</td>
<td>//a[@class="listbox_title"]</td>
<td>exact:Diff</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//tr[@class='listbox-data-line-2 DataA']</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-2 DataA']/td[1]</td>
<td>title</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//tr[@class='listbox-data-line-2 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-2 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>
</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@@-Title1+Title2</td>
</tr>
<!-- Check the diff content -->
<tr>
<td>verifyValue</td>
<td>field_your_first_path</td>
<td>bar_module/1</td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_second_path</td>
<td>bar_module/2</td>
</tr>
<tr>
<td>assertText</td>
<td>//a[@class="listbox_title"]</td>
<td>exact:Diff</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//tr[@class='listbox-data-line-2 DataA']</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-2 DataA']/td[1]</td>
<td>title</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//tr[@class='listbox-data-line-2 DataA']/td[2]/div[@data-gadget-sandbox="public"]</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-2 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>
</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@@-Title1+Title2</td>
</tr>
<!-- submit the action again, it should be same -->
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
</tal:block>
</body>
</html>
\ No newline at end of file
......@@ -54,48 +54,58 @@
<td>Diff Object</td>
</tr>
<!-- Check the diff content -->
<tr>
<td>verifyValue</td>
<td>field_your_first_path</td>
<td>bar_module/1</td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_second_path</td>
<td>bar_module/1</td>
</tr>
<tal:block tal:repeat="_ python: (1, 2)">
<tr>
<td>assertText</td>
<td>//a[@class="listbox_title"]</td>
<td>exact:Diff</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//tr[@class='listbox-data-line-1 DataB']</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-1 DataB']/td[1]</td>
<td>title</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//tr[@class='listbox-data-line-1 DataB']/td[2]/div[@data-gadget-sandbox="public"]</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-1 DataB']/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>
</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@@-Title1+Title2</td>
</tr>
<!-- Check the diff content -->
<tr>
<td>verifyValue</td>
<td>field_your_first_path</td>
<td>bar_module/1</td>
</tr>
<tr>
<td>verifyValue</td>
<td>field_your_second_path</td>
<td>bar_module/1</td>
</tr>
<tr>
<td>assertText</td>
<td>//a[@class="listbox_title"]</td>
<td>exact:Diff</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//tr[@class='listbox-data-line-1 DataB']</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//tr[@class='listbox-data-line-1 DataB']/td[1]</td>
<td>title</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//tr[@class='listbox-data-line-1 DataB']/td[2]/div[@data-gadget-sandbox="public"]</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>document.querySelector('#selenium_myiframe').contentWindow.document.evaluate("//tr[@class='listbox-data-line-1 DataB']/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>
</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@@-Title1+Title2</td>
</tr>
<!-- submit the action again, it should be same -->
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
</tal:block>
</body>
</html>
\ No newline at end of file
......@@ -98,7 +98,7 @@ if ((first_path is None and second_path is None) and
# In case the list_selection_name is there, it can be the case of selection
# from the module, hence we get the paths from the selection and use them to
# create diff.
if list_selection_name is not None:
if list_selection_name:
selected_object_list = portal.portal_selections.getSelectionCheckedValueList(
selection_name=list_selection_name)
first_object = selected_object_list[0]
......
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