From ff849ea0444a7bf2e8ecb8493e4242c052ed92df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 2 Nov 2023 15:15:29 +0100
Subject: [PATCH] ui_test: add missing zelenium test for reinstall business
 template

---
 .../testReinstallBusinessTemplate.xml         |  62 +++++++++
 .../testReinstallBusinessTemplate.zpt         | 123 ++++++++++++++++++
 ...Site_setUpBusinessTemplateReinstallTest.py |  14 ++
 ...ite_setUpBusinessTemplateReinstallTest.xml |  62 +++++++++
 4 files changed, 261 insertions(+)
 create mode 100644 bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.xml
 create mode 100644 bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.zpt
 create mode 100644 bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.py
 create mode 100644 bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.xml

diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.xml b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.xml
new file mode 100644
index 00000000000..645bf77bc5a
--- /dev/null
+++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.xml
@@ -0,0 +1,62 @@
+<?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="_reconstructor" module="copy_reg"/>
+                </klass>
+                <tuple>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                  <global name="object" module="__builtin__"/>
+                  <none/>
+                </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>testReinstallBusinessTemplate</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>Re-install Business Template</unicode> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.zpt b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.zpt
new file mode 100644
index 00000000000..0775ed41fff
--- /dev/null
+++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/business_template_zuite/testReinstallBusinessTemplate.zpt
@@ -0,0 +1,123 @@
+<html xmlns:tal="http://xml.zope.org/namespaces/tal"
+      xmlns:metal="http://xml.zope.org/namespaces/metal">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title tal:content="template/title_and_id"></title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3" tal:content="template/title_and_id"></td></tr>
+</thead><tbody>
+<tal:block metal:use-macro="here/BTZuite_CommonTemplate/macros/init" />
+<tr>
+  <td>open</td>
+  <td>${base_url}/ERP5Site_setUpBusinessTemplateReinstallTest</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertPortalStatusMessage</td>
+  <td>Setup OK</td>
+  <td></td>
+</tr>
+<tr>
+  <td>selectAndWait</td>
+  <td>select_action</td>
+  <td>Re-install Business Template</td>
+</tr>
+<tr>
+<tr>
+  <td>assertText</td>
+  <td>//button[@name="Base_callDialogMethod:method"]/span</td>
+  <td>Re-install Business Template</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>css=.listbox-current-page-total-number</td>
+  <td> 1 records </td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//tr[@class="listbox-data-line-0 DataA"]/td[1]</td>
+  <td>portal_skins/erp5_test/test_file</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//tr[@class="listbox-data-line-0 DataA"]/td[2]</td>
+  <td>Skin</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//tr[@class="listbox-data-line-0 DataA"]/td[3]</td>
+  <td>Modified</td>
+</tr>
+<tr>
+  <td>assertText</td>
+  <td>//tr[@class="listbox-data-line-0 DataA"]/td[4]/label</td>
+  <td>Backup And Upgrade</td>
+</tr>
+<tr>
+  <td>assertChecked</td>
+  <td>//tr[@class="listbox-data-line-0 DataA"]/td[4]/label/input</td>
+  <td></td>
+</tr>
+
+<!-- preview diff -->
+<tr>
+  <td>clickAndWait</td>
+  <td>//tr[@class="listbox-data-line-0 DataA"]/td[1]/a</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>modified !</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>test1\n</td>
+  <td></td>
+</tr>
+<tr>
+  <td>goBack</td>
+  <td></td>
+  <td></td>
+</tr>
+<tr>
+  <td>waitForText</td>
+  <td>//button[@name="Base_callDialogMethod:method"]/span</td>
+  <td>Re-install Business Template</td>
+</tr>
+
+<tr>
+  <td>clickAndWait</td>
+  <td>Base_callDialogMethod:method</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertPortalStatusMessage</td>
+  <td>Status changed.</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td>${base_url}/portal_skins/erp5_test/test_file</td>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>test2</td>
+  <td></td>
+</tr>
+<tr>
+  <td>open</td>
+  <td tal:content="string: ${here/portal_url}/foo_module/BTZuite_reset?end=1"/>
+  <td></td>
+</tr>
+<tr>
+  <td>assertTextPresent</td>
+  <td>Reset Successfully.</td>
+  <td></td>
+</tr>
+</body>
+</html>
\ No newline at end of file
diff --git a/bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.py b/bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.py
new file mode 100644
index 00000000000..d0944f0f6e1
--- /dev/null
+++ b/bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.py
@@ -0,0 +1,14 @@
+"""Installs test_core and make local change, so that later we can reinstall
+and see that our local changes are gone.
+"""
+portal = context.getPortalObject()
+portal.portal_templates.installBusinessTemplateListFromRepository(['test_core'])
+bt = portal.portal_templates.getInstalledBusinessTemplate('test_core')
+
+portal.portal_skins.erp5_test.test_file.manage_edit(
+  title='',
+  content_type='text/plain',
+  filedata='modified !'
+)
+
+return bt.Base_redirect('view', keep_items={'portal_status_message': 'Setup OK'})
diff --git a/bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.xml b/bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.xml
new file mode 100644
index 00000000000..67939a64c24
--- /dev/null
+++ b/bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/ERP5Site_setUpBusinessTemplateReinstallTest.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="_reconstructor" module="copy_reg"/>
+                </klass>
+                <tuple>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                  <global name="object" module="__builtin__"/>
+                  <none/>
+                </tuple>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <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>_params</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ERP5Site_setUpBusinessTemplateReinstallTest</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
-- 
2.30.9