From 2e501ad439b4d04bb9ede8d61208a145d3d9241c Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Fri, 11 Sep 2009 13:00:01 +0000
Subject: [PATCH] add a test to confirm if 'clone' works fine for web pages
 accessed by reference whose parent url is a web page.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28955 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_web_zuite/testWebPageClone.xml       | 158 ++++++++++++++++++
 .../WebPageModule_createTestWebPage.xml       |   8 +-
 .../WebSiteModule_resetWebZuite.xml           |   9 +-
 bt5/erp5_web_ui_test/bt/revision              |   2 +-
 4 files changed, 172 insertions(+), 5 deletions(-)
 create mode 100644 bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testWebPageClone.xml

diff --git a/bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testWebPageClone.xml b/bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testWebPageClone.xml
new file mode 100644
index 0000000000..73b853e59c
--- /dev/null
+++ b/bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testWebPageClone.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
+        <tuple/>
+      </tuple>
+    </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>_text</string> </key>
+            <value> <string encoding="cdata"><![CDATA[
+
+<html xmlns:tal="http://xml.zope.org/namespaces/tal"\n
+      xmlns:metal="http://xml.zope.org/namespaces/metal">\n
+<head>\n
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n
+<title>Test Previous Next Selection In Website</title>\n
+</head>\n
+<body>\n
+<table cellpadding="1" cellspacing="1" border="1">\n
+<thead>\n
+<tr><td rowspan="1" colspan="3">Test Change Id Website</td></tr>\n
+</thead><tbody>\n
+<tal:block metal:use-macro="here/Zuite_erp5_web_common/macros/init" />\n
+<tr>\n
+  <td>open</td>\n
+  <td>${base_url}/web_site_module/WebSiteModule_createTestSite?id=test_web_site&amp;title=Test Web Site</td>\n
+  <td></td>\n
+  <td>Create a new site</td>\n
+</tr>\n
+<tr>\n
+  <td>assertTextPresent</td>\n
+  <td>Created Successfully.</td>\n
+  <td></td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+  <td>open</td>\n
+  <td>${base_url}/web_page_module/WebPageModule_createTestWebPage?id=test_web_page&amp;reference=test_page&amp;publish:int=1</td>\n
+  <td></td>\n
+  <td>Create a new site</td>\n
+</tr>\n
+<tr>\n
+  <td>assertTextPresent</td>\n
+  <td>Created Successfully.</td>\n
+  <td></td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+  <td>open</td>\n
+  <td>${base_url}/web_page_module/WebPageModule_createTestWebPage?id=test_web_page_2&amp;reference=test_page_2</td>\n
+  <td></td>\n
+  <td>Create a new site</td>\n
+</tr>\n
+<tr>\n
+  <td>assertTextPresent</td>\n
+  <td>Created Successfully.</td>\n
+  <td></td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+  <td>open</td>\n
+  <td>${base_url}/web_site_module/Zuite_waitForActivities</td>\n
+  <td></td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+  <td>assertTextPresent</td>\n
+  <td>Done.</td>\n
+  <td></td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+  <td>open</td>\n
+  <td>${base_url}/web_site_module/test_web_site/web_page_module/test_web_page_2/test_page</td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+  <td>type</td>\n
+  <td>//input[@name="clone_version"]</td>\n
+  <td>1</td>\n
+</tr>\n
+<tr>\n
+  <td>clickAndWait</td>\n
+  <td>//button[@name="Base_cloneContent:method"]</td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+   <td>assertTextPresent</td>\n
+   <td>Created Clone Web Page.</td>\n
+   <td></td>\n
+</tr>\n
+<tr>\n
+  <td>assertTitle</td>\n
+  <td>Web Page - test_page | ERP5</td>\n
+  <td></td>\n
+</tr>\n
+<tr>\n
+  <td>assertLocation</td>\n
+  <td>${base_url}/web_site_module/test_web_site/web_page_module/*/view*</td>\n
+  <td></td>\n
+</tr>\n
+</tbody></table>\n
+</body>\n
+</html>\n
+
+
+]]></string> </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>testWebPageClone</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebPageModule_createTestWebPage.xml b/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebPageModule_createTestWebPage.xml
index 2351cdf249..16ef4ed372 100644
--- a/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebPageModule_createTestWebPage.xml
+++ b/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebPageModule_createTestWebPage.xml
@@ -54,6 +54,8 @@
         <item>
             <key> <string>_body</string> </key>
             <value> <string>web_page = context.newContent(portal_type=\'Web Page\', id=id, reference=reference)\n
+if publish:\n
+  web_page.publish()\n
 return "Created Successfully."\n
 </string> </value>
         </item>
@@ -65,7 +67,7 @@ return "Created Successfully."\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>id=id, reference=None</string> </value>
+            <value> <string>id=id, reference=None, publish=False</string> </value>
         </item>
         <item>
             <key> <string>_proxy_roles</string> </key>
@@ -93,7 +95,7 @@ return "Created Successfully."\n
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>2</int> </value>
+                        <value> <int>3</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
@@ -101,6 +103,7 @@ return "Created Successfully."\n
                           <tuple>
                             <string>id</string>
                             <string>reference</string>
+                            <string>publish</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>web_page</string>
@@ -118,6 +121,7 @@ return "Created Successfully."\n
               <tuple>
                 <global name="id" module="__builtin__"/>
                 <none/>
+                <int>0</int>
               </tuple>
             </value>
         </item>
diff --git a/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebSiteModule_resetWebZuite.xml b/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebSiteModule_resetWebZuite.xml
index 18d8b30b57..cce0aab739 100644
--- a/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebSiteModule_resetWebZuite.xml
+++ b/bt5/erp5_web_ui_test/SkinTemplateItem/portal_skins/erp5_web_ui_test/WebSiteModule_resetWebZuite.xml
@@ -69,8 +69,9 @@ if portal.web_site_module.has_key(\'test_web_site_2\'):\n
 if portal.web_site_module.has_key(\'test_web_site\'):\n
   portal.web_site_module.manage_delObjects(\'test_web_site\')\n
 \n
-if portal.web_page_module.has_key(\'test_web_page\'):\n
-  portal.web_page_module.manage_delObjects(\'test_web_page\')\n
+portal.web_page_module.manage_delObjects(\n
+  [x.getId() for x in portal.web_page_module.objectValues() \\\n
+   if x.getTitle().startswith(\'test_\')])\n
 \n
 # Create new users\n
 if not portal.person_module.has_key(\'test_webmaster\'):\n
@@ -138,6 +139,10 @@ return \'Reset Successfully.\'\n
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>portal</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
+                            <string>x</string>
                             <string>person</string>
                             <string>len</string>
                             <string>assignment</string>
diff --git a/bt5/erp5_web_ui_test/bt/revision b/bt5/erp5_web_ui_test/bt/revision
index 25bf17fc5a..dec2bf5d61 100644
--- a/bt5/erp5_web_ui_test/bt/revision
+++ b/bt5/erp5_web_ui_test/bt/revision
@@ -1 +1 @@
-18
\ No newline at end of file
+19
\ No newline at end of file
-- 
2.30.9