From 8900b5d3e2aa489cfb913dc09856ca0325f5c83b Mon Sep 17 00:00:00 2001
From: Thomas Gambier <thomas.gambier@nexedi.com>
Date: Mon, 24 Sep 2018 16:00:19 +0000
Subject: [PATCH] [erp5_officejs_ui_test] Fix some OfficeJS UI tests

After clicking on "Documents", we need to wait for the listbox to be loaded before doing anything else. In particular, if we do a search after clicking on "Documents" the listbox is loaded twice (once after clicking on Documents and once after clicking on search). If we don't wait for the listbox to be loaded before doing the search, the search macro might end too early.
---
 .../testOfficeJSCodeMirrorErp5Synchronization.zpt               | 2 ++
 .../testOfficeJSTextEditorErp5Synchronization.zpt               | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_codemirror_zuite/testOfficeJSCodeMirrorErp5Synchronization.zpt b/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_codemirror_zuite/testOfficeJSCodeMirrorErp5Synchronization.zpt
index 369591fc1e..baa2e4c6f0 100644
--- a/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_codemirror_zuite/testOfficeJSCodeMirrorErp5Synchronization.zpt
+++ b/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_codemirror_zuite/testOfficeJSCodeMirrorErp5Synchronization.zpt
@@ -127,6 +127,7 @@
   <td>//a[@data-i18n='Document']</td>
   <td></td>
 </tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
 <!-- Verify Search, add another document -->
 <tr>
   <td>waitForElementPresent</td>
@@ -173,6 +174,7 @@
   <td>//a[@data-i18n='Document']</td>
   <td></td>
 </tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
 <tal:block tal:define="search_query python: 'Titre'">
   <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list_without_header_url" />
 </tal:block>
diff --git a/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_texteditor_zuite/testOfficeJSTextEditorErp5Synchronization.zpt b/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_texteditor_zuite/testOfficeJSTextEditorErp5Synchronization.zpt
index f20d7fa3f6..1e8bc69160 100644
--- a/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_texteditor_zuite/testOfficeJSTextEditorErp5Synchronization.zpt
+++ b/bt5/erp5_officejs_ui_test/PathTemplateItem/portal_tests/officejs_ui_texteditor_zuite/testOfficeJSTextEditorErp5Synchronization.zpt
@@ -127,6 +127,7 @@
   <td>//a[@data-i18n='Document']</td>
   <td></td>
 </tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
 <!-- Verify Search, add another document -->
 <tr>
   <td>waitForElementPresent</td>
@@ -173,6 +174,7 @@
   <td>//a[@data-i18n='Document']</td>
   <td></td>
 </tr>
+<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
 <tal:block tal:define="search_query python: 'Titre'">
   <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list_without_header_url" />
 </tal:block>
-- 
2.30.9