From 6c56b7be8d3929b11a69813c304c88887aa5e5bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 20 Dec 2022 19:28:46 +0900
Subject: [PATCH] sql_browser_ui_test: non regression for test bug of multiple
 select

---
 .../test_query_commands_out_of_sync.xml       | 58 +++++++++++++++
 .../test_query_commands_out_of_sync.zpt       | 73 +++++++++++++++++++
 2 files changed, 131 insertions(+)
 create mode 100644 bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.xml
 create mode 100644 bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.zpt

diff --git a/bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.xml b/bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.xml
new file mode 100644
index 0000000000..9d9ffec301
--- /dev/null
+++ b/bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.xml
@@ -0,0 +1,58 @@
+<?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="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <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>test_query_commands_out_of_sync</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></unicode> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.zpt b/bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.zpt
new file mode 100644
index 0000000000..c436a49217
--- /dev/null
+++ b/bt5/erp5_sql_browser_ui_test/PathTemplateItem/portal_tests/sql_browser_zuite/test_query_commands_out_of_sync.zpt
@@ -0,0 +1,73 @@
+<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>
+      <tr>
+        <td>open</td>
+        <td tal:content="string: ${here/portal_url}/erp5_sql_connection/ZMySQLDAConnection_viewQueryBrowser"></td>
+        <td></td>
+      </tr>
+
+      <tr>
+        <td>waitForElementPresent</td>
+        <td>css=div.monaco-editor.vs</td>
+        <td></td>
+      </tr>
+      <tr>
+        <td>assertEval</td>
+        <td>
+          selenium.browserbot.getCurrentWindow().monaco_editor.trigger('', 'type', {'text': 'select 1+1; select "boom"'})
+        </td>
+        <td>null</td>
+      </tr>
+      <tr>
+        <td>click</td>
+        <td>//button[@name="Query"]</td>
+        <td></td>
+      </tr>
+      <tr>
+        <td>waitForElementPresent</td>
+        <td>//div[contains(@class, "noty_message")]/span[@class="noty_text" and contains(text(), "Error")]</td>
+        <td></td>
+      </tr>
+      <tr>
+        <td>assertEval</td>
+        <td>
+          selenium.browserbot.getCurrentWindow().monaco_editor.trigger('', 'editor.action.smartSelect.expand');
+          selenium.browserbot.getCurrentWindow().monaco_editor.trigger('', 'editor.action.deleteLines');
+          selenium.browserbot.getCurrentWindow().monaco_editor.trigger('', 'type', {'text': 'select 1+1'})
+        </td>
+        <td>null</td>
+      </tr>
+      <tr>
+        <td>click</td>
+        <td>//button[@name="Query"]</td>
+        <td></td>
+      </tr>
+      <tr>
+        <td>waitForText</td>
+        <td>xpath=(//div[contains(@class, "handsontable")]//th//span[@class="colHeader"])[2]</td>
+        <td>1+1</td>
+      </tr>
+      <tr>
+        <td>assertText</td>
+        <td>//div[contains(@class, "handsontable")]//tbody/tr/td</td>
+        <td>2</td>
+      </tr>
+
+    </tbody>
+  </table>
+</body>
+
+</html>
\ No newline at end of file
-- 
2.30.9