Update/Add selenium tests
authorGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Sun, 14 Dec 2008 22:15:20 +0000 (17:15 -0500)
committerGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Sun, 14 Dec 2008 22:15:20 +0000 (17:15 -0500)
- Add tests for constraints, columns, views and index
- Add method addComment in testBuilder class to insert comment in the tests page
- Add comments to all tests
Sequence tests still fail for 8.4. We need to review all these tests to add some forgottent testcases and asserts

17 files changed:
tests/selenium/README
tests/selenium/selenium-lib/core/TestRunner.hta
tests/selenium/selenium-lib/core/TestRunner.html
tests/selenium/selenium-lib/core/scripts/selenium-testrunner.js
tests/selenium/selenium-lib/core/selenium.css
tests/selenium/src/01-roles.php
tests/selenium/src/04-database.php
tests/selenium/src/06-schema.php
tests/selenium/src/08-domaine.php
tests/selenium/src/10-table.php
tests/selenium/src/15-sequence.php
tests/selenium/src/20-constraint.php [new file with mode: 0644]
tests/selenium/src/25-column.php [new file with mode: 0644]
tests/selenium/src/30-view.php [new file with mode: 0644]
tests/selenium/src/35-index.php [new file with mode: 0644]
tests/selenium/src/99-cleantests.php
tests/selenium/testBuilder.class.php

index 9f797ce8ef9fc23e7b8fc5ebd2d9de2969f19524..3125e38cd59192145e230f141b08a488a30b1687 100644 (file)
@@ -45,9 +45,11 @@ and the static folder where the HTML tests files are created
        );
 
 - once the TestBuilder instance is created, you can use it to write our tests.
-       In particular, you should use the login($username, $pass) and logout() methods.
-       Each selenium actions are mapped (or should be) as methods. As instance, if you want to use the clickAndWait action, you should call the
-        clickAndWait($locator) method. For the assertText, assertText($selector, $value), etc...
+       - In particular, you should use the login($username, $pass) and logout() methods to create appropriate steps to login/logout to the current
+       server.
+       - Each selenium actions are mapped (or should be) as methods. As instance, if you want to use the clickAndWait action, you should call the
+       clickAndWait($locator) method. For the assertText, assertText($selector, $value), etc...
+       - Use the addComment method to show comments anywhere in the tests page. Usefull to explain whatthe next tests are going to do.
 
 - finish whith calling the TestBuilder's "writeTests" method which will create the selenium HTML test file in the static dir and append this
 new test file to the testSuite file.
index eb2e626144e81bb1adea13eff6e3e24335512119..f66958f87c337feece825ba63face68cc63ca4d8 100644 (file)
@@ -88,6 +88,9 @@ to work-around a bug in IE on Win2K whereby the HTA application doesn't function
                     <div id="imageButtonPanel">\r
                         <button type="button" id="runSuite" onClick="htmlTestRunner.startTestSuite();"\r
                                 title="Run All tests" accesskey="a">\r
+                        </button>\r
+                                               <button type="button" id="runRemainTests" onClick="htmlTestRunner.runRemainTests();"\r
+                                title="Run the tests from the selected" accesskey="f">\r
                         </button>\r
                         <button type="button" id="runSeleniumTest" onClick="htmlTestRunner.runSingleTest();"\r
                                 title="Run the Selected test" accesskey="r">\r
index eb2e626144e81bb1adea13eff6e3e24335512119..87a52245d4f47dcb720a13b1284f89cce4c8d8bc 100644 (file)
@@ -89,6 +89,9 @@ to work-around a bug in IE on Win2K whereby the HTA application doesn't function
                         <button type="button" id="runSuite" onClick="htmlTestRunner.startTestSuite();"\r
                                 title="Run All tests" accesskey="a">\r
                         </button>\r
+                        <button type="button" id="runRemainTests" onClick="htmlTestRunner.runRemainTests();"\r
+                                title="Run the tests from the selected" accesskey="f">\r
+                        </button>\r
                         <button type="button" id="runSeleniumTest" onClick="htmlTestRunner.runSingleTest();"\r
                                 title="Run the Selected test" accesskey="r">\r
                         </button>\r
index c0aa069f26c64d2af004fccec6b7dce9080a40bf..89cb80e907b9e77e3af81ea680c564e2af2ac4aa 100644 (file)
@@ -144,6 +144,12 @@ objectExtend(HtmlTestRunner.prototype, {
         this.currentTest.start();\r
     },\r
 \r
+       runRemainTests:function() {\r
+        this.runAllTests = true;\r
+        this.metrics.resetMetrics();\r
+        this.startTest();\r
+    },\r
+\r
     runSingleTest:function() {\r
         this.runAllTests = false;\r
         this.metrics.resetMetrics();\r
index a717934a62a9e5322722ca606629e02cd15a59f4..04a194ac7c48b02dabcfa84b1f93111082b3eb90 100644 (file)
@@ -109,6 +109,11 @@ body, html {
     background-image: url("icons/selected.png");
 }
 
+#controlPanel #runRemainTests {
+    width: 32px;
+    background-image: url("icons/remains.png");
+}
+
 .cssPauseTest {
     background-image: url("icons/pause.png");
 }
index b319b1808980d97f395f6bd074141d2653ebdbd2..d39062fbb36c357fea0937671f377730c6258e3f 100644 (file)
        );
 
        /* 1 */
+       $t->addComment('1. login as superuser');
        $t->login($super_user[$server['desc']], $super_pass[$server['desc']]);
 
        /* 2 */
+       $t->addComment('2. create admin_user role/user with wrong pass conf -> fail');
        if ($data->hasRoles()) {
                $t->clickAndWait("link={$lang['strroles']}");
                $t->clickAndWait("link={$lang['strcreaterole']}");
@@ -39,6 +41,7 @@
        $t->assertText("//p[@class='message']", $lang['strpasswordconfirm']);
 
        /* 3 */
+       $t->addComment('3. create admin_user');
        $t->type('formPassword', $admin_user_pass);
        $t->type('formConfirm', $admin_user_pass);
        $t->clickAndWait('create');
                $t->assertText("//p[@class='message']", $lang['strusercreated']);
 
        /* 4 */
+       $t->addComment('4. logout & login as admin_user');
        $t->logout();
        $t->login($admin_user, $admin_user_pass);
 
 
        /* 5 */
+       $t->addComment('5. create user role/user with altered name, pass and props');
        if ($data->hasRoles()) {
                $t->clickAndWait("link={$lang['strroles']}");
                $t->clickAndWait("link={$lang['strcreaterole']}");
@@ -77,6 +82,7 @@
                $t->assertText("//p[@class='message']", $lang['strusercreated']);
 
        /* 6 */
+       $t->addComment('6. alter user back to the normal value');
        if ($data->hasRoles()) {
                $t->clickAndWait("link={$lang['strroles']}");
                $t->clickAndWait("link={$user}toalter");
index fd740972eff072e60a9866ca2a16620b22be55ef..fc64b96ffe230840267ff896bfa8446785ca2e2e 100644 (file)
@@ -15,6 +15,7 @@
        $t->login($admin_user, $admin_user_pass);
 
 /** 1 **/
+       $t->addComment('1. create test database with altered name and owner');
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$lang['strcreatedatabase']}");
 
@@ -32,6 +33,7 @@
        $t->assertText("//p[@class='message']", $lang['strdatabasecreated']);
 
 /** 2 **/
+       $t->addComment('2. alter DB\'s owner');
        if ($data->hasAlterDatabaseOwner()) {
                $t->clickAndWait("link={$lang['strdatabases']}");
                /* we don't need to check if hasAlterDatabaseRename here because
@@ -44,6 +46,7 @@
        }
 
 /** 3 **/
+       $t->addComment('3. alter DB\'s name, owner and comment back to normal');
        if ($data->hasAlterDatabase()) {
                $t->clickAndWait("link={$lang['strdatabases']}");
                /* we don't need to check if hasAlterDatabaseRename here because
index 8d4c6b675df656944181c44eb5f9fbd3fe268822..c92fc848d9ebfddbfae392b0c76e3f15a8926635 100644 (file)
@@ -14,6 +14,7 @@
        $t->login($admin_user, $admin_user_pass);
 
 /** 1 **/
+       $t->addComment('1. create test schema');
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$testdb}");
        $t->clickAndWait("link={$lang['strschemas']}");
@@ -33,6 +34,7 @@
        $t->assertText('//p[@class=\'message\']', $lang['strschemacreated']);
 
 /** 2 **/
+       $t->addComment('2. alter schema\'s name, owner and comment');
        if ($data->hasAlterSchema()) {
                $t->clickAndWait("link={$lang['strschemas']}");
                $t->clickAndWait("//tr/td/a[text()='test_schema_toalter']/../../td/a[text()='{$lang['stralter']}']");
index e40c49a992f2e6b1582f4d71f6e45d677641c16b..9f197abb63ed2b334eba17b9bdfd3ee1b8cdd6a8 100644 (file)
@@ -17,6 +17,7 @@
        $t->login($admin_user, $admin_user_pass);
 
 /** 1 **/
+       $t->addComment('1. create domain');
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$testdb}");
        $t->clickAndWait("link={$lang['strschemas']}");
@@ -56,6 +57,7 @@
        }
        
 /** 2 **/
+       $t->addComment('2. add unwanted domain constraint');
        if ($data->hasDomainConstraints()) {
                $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
                $t->clickAndWait("link={$lang['strdomains']}");
@@ -69,6 +71,7 @@
        }
 
 /** 3 **/
+       $t->addComment('3. drop unwanted check constraint on domain');
        if ($data->hasDomainConstraints()) {
                $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
                $t->clickAndWait("link={$lang['strdomains']}");
@@ -81,6 +84,7 @@
        }
 
 /** 4 **/
+       $t->addComment('4. alter domain giving owner to super_user');
        if ($data->hasAlterDomains()) {
                $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
                $t->clickAndWait("link={$lang['strdomains']}");
        }
 
 /** 5 **/
+       $t->addComment('5. alter back the owner to admin_user');
        if ($data->hasAlterDomains()) {
                $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
                $t->clickAndWait("link={$lang['strdomains']}");
index d6102ef2bca51d90cd0fc36bc7406c93c01323da..7396bb888199ca2616d7a74b45b530e159374ad4 100644 (file)
@@ -17,6 +17,7 @@
        $t->login($admin_user, $admin_user_pass);
 
 /** 1 **/
+       $t->addComment('1. create a table student in public');
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$testdb}");
        $t->clickAndWait("link={$lang['strschemas']}");
@@ -44,6 +45,7 @@
        $t->assertText("//p[@class='message']", $lang['strtablecreated']);
 
 /** 2 **/
+       $t->addComment('2. create table promo in test_schema');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
        $t->clickAndWait("link={$lang['strschemas']}");
        $t->clickAndWait("link=test_schema");
@@ -67,6 +69,7 @@
        $t->assertText("//p[@class='message']", $lang['strtablecreated']);
 
 /** 3 **/
+       $t->addComment('3. create table like student in test_schema');
        if ($data->hasCreateTableLike()) {
                $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
                $t->clickAndWait("link={$lang['strschemas']}");
        }
 
 /** 4 **/
+       $t->addComment('4. alter each param one by one on test_toalter');
        /*table name*/
+       $t->addComment('4.1. alter table name');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
        $t->clickAndWait("link={$lang['strschemas']}");
        $t->clickAndWait("link=test_schema");
        $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test_renamed');
 
        /*table comment*/
+       $t->addComment('4.2. alter table comment');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
        $t->clickAndWait("link={$lang['strschemas']}");
        $t->clickAndWait("link=test_schema");
        
        /*table owner*/
        if ($data->hasAlterTableOwner()) {
+               $t->addComment('4.3. alter table owner');
                $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
                $t->clickAndWait("link={$lang['strschemas']}");
                $t->clickAndWait("link=test_schema");
        
        /*alter schema*/
        if ($data->hasAlterTableSchema()) {
+               $t->addComment('4.4. alter table schema');
                $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
                $t->clickAndWait("link={$lang['strschemas']}");
                $t->clickAndWait("link=test_schema");
        }
 
 /** 5 **/
+       $t->addComment('5. alter back test_toalter in one step');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
        $t->clickAndWait("link={$lang['strschemas']}");
        if ($data->hasAlterTableSchema())
index af0831fbc51ed74e00b00454258ab58e102c4dc9..918bcc30e99a34bc78178c702f0357d5aa89b55c 100644 (file)
@@ -15,6 +15,7 @@
        $t->login($admin_user, $admin_user_pass);
 
 /** 1 **/
+       $t->addComment('1. Create a sequence');
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$testdb}");
        $t->clickAndWait("link={$lang['strschemas']}");
@@ -40,6 +41,7 @@
        $t->assertText("//tr/td[text()='testcase_seq']/../td[8]", $lang['stryes']);
 
 /** 2 **/
+       $t->addComment('2. increment, reset sequence and set value');
        $t->clickAndWait("link={$lang['strsetval']}");
        $t->type('nextvalue', '2');
        $t->clickAndWait('setval');
@@ -53,6 +55,7 @@
        $t->assertText("//tr/td[text()='testcase_seq']/../td[2]", '1');
 
 /** 3 **/
+       $t->addComment('3. alter sequence');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
        $t->clickAndWait("link={$lang['strschemas']}");
        $t->clickAndWait('link=public');
@@ -94,6 +97,7 @@
        $t->assertText("//tr/td[2]/a[text()='testcase_renamed_seq']/../../td[3]", $user);
 
 /** 4 **/
+       $t->addComment('4. drop sequence');
        $t->clickAndWait("link={$lang['strsequences']}");
        $t->clickAndWait("//tr/td/a[text()='testcase_renamed_seq']/../../td/a[text()='{$lang['strdrop']}']");
        $t->click('cascade');
diff --git a/tests/selenium/src/20-constraint.php b/tests/selenium/src/20-constraint.php
new file mode 100644 (file)
index 0000000..f72225c
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+       global $testsuite_file, $test_static_dir;
+
+       /*
+        * 1/ Add 2 Foreign Keys
+        * 2/ Add check constraint
+        * 3/ Add unique key
+        * 4/ Drop PK before creating it again
+        * 5/ Add primary key
+        * 6/ Drop FK
+        * 7/ Drop unique
+        * 8/ Drop check
+        */
+       $t = new TestBuilder($server['desc'],
+               'Constraint tests',
+               'Create and drop constraints...'
+       );
+
+       $t->login($admin_user, $admin_user_pass);
+
+       /** 1 **/
+       $t->addComment('1. Add 2 Foreign Keys');
+       $t->addComment('1.1. Add 1st Foreign Keys');
+       $t->clickAndWait("link={$lang['strdatabases']}");
+       $t->clickAndWait("link={$testdb}");
+       $t->clickAndWait("link={$lang['strschemas']}");
+       $t->clickAndWait('link=public');
+       $t->clickAndWait("link={$lang['strtables']}");
+       $t->clickAndWait('link=student');
+       $t->clickAndWait("link={$lang['strconstraints']}");
+       $t->clickAndWait("link={$lang['straddfk']}");
+       $t->type('name', 'student_id_promo_fk');
+       $t->addSelection('TableColumnList','label=id_promo');
+       $t->click('add');
+       $t->select('target', 'label=test_schema.promo');
+       $t->clickAndWait("//input[@value='Add']");
+       $t->addSelection('TableColumnList', 'label=id');
+       $t->click('add');
+       $t->select('upd_action', 'label=CASCADE');
+       $t->select('del_action', 'label=RESTRICT');
+       $t->clickAndWait("//input[@value='Add']");
+       $t->assertText("//p[@class='message']", $lang['strfkadded']);
+
+       /** 1' **/
+       $t->addComment('1.2. Add 2nd Foreign Keys');
+       $t->clickAndWait("link={$lang['straddfk']}");
+       $t->type('name', 'fk_to_drop');
+       $t->addSelection('TableColumnList', 'label=id_promo');
+       $t->click('add');
+       $t->select('target','label=test_schema.promo');
+       $t->clickAndWait("//input[@value='Add']");
+       $t->addSelection('TableColumnList', 'label=id');
+       $t->click('add');
+       $t->select('upd_action', 'label=CASCADE');
+       $t->select('del_action', 'label=RESTRICT');
+       $t->clickAndWait("//input[@value='Add']");
+       $t->assertText("//p[@class='message']", $lang['strfkadded']);
+
+       /* 2 */
+       $t->addComment('2. Add check constraint');
+       $t->clickAndWait("link={$lang['straddcheck']}");
+       $t->type('name', 'check_to_drop');
+       $t->type('definition', 'extract(year from birthday) &lt; 2000');
+       $t->clickAndWait('ok');
+       $t->assertText("//p[@class='message']", $lang['strcheckadded']);
+
+       /* 3 */
+       $t->addComment('3. Add unique key');
+       $t->clickAndWait("link={$lang['stradduniq']}");
+       $t->type('name', 'unique_to_drop');
+       $t->addSelection('TableColumnList', 'label=name');
+       $t->click('add');
+       $t->clickAndWait("//input[@value='{$lang['stradd']}']");
+       $t->assertText("//p[@class='message']", $lang['struniqadded']);
+
+       /* 4 */
+       $t->addComment('4. Drop PK before creating it again');
+       $t->clickAndWait("//tr/td/pre[text()='PRIMARY KEY (id)']/../../td/a[text()='{$lang['strdrop']}']");
+       $t->clickAndWait('drop');
+       $t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
+
+       /* 5 */
+       $t->addComment('5. Add primary key');
+       $t->clickAndWait("link={$lang['straddpk']}");
+       $t->type('name', 'student_pk');
+       $t->addSelection('TableColumnList', 'label=id');
+       $t->click('add');
+       $t->clickAndWait("//input[@value='Add']");
+       $t->assertText("//p[@class='message']", $lang['strpkadded']);
+
+       /* 6 */
+       $t->addComment('6. Drop FK');
+       $t->clickAndWait("//tr/td[text()='fk_to_drop']/../td/a[text()='{$lang['strdrop']}']");
+       $t->clickAndWait('drop');
+       $t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
+
+       /* 7 */
+       $t->addComment('7. Drop unique');
+       $t->clickAndWait("//tr/td[text()='unique_to_drop']/../td/a[text()='{$lang['strdrop']}']");
+       $t->clickAndWait('drop');
+       $t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
+
+       /* 8 */
+       $t->addComment('8. Drop check');
+       $t->clickAndWait("//tr/td[text()='check_to_drop']/../td/a[text()='{$lang['strdrop']}']");
+       $t->clickAndWait('drop');
+       $t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
+
+       $t->logout();
+       $t->writeTests("{$test_static_dir}/{$server['desc']}/constraint.html", $testsuite_file);
+       unset($t);
+?>
\ No newline at end of file
diff --git a/tests/selenium/src/25-column.php b/tests/selenium/src/25-column.php
new file mode 100644 (file)
index 0000000..462b3c7
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+global $testsuite_file, $test_static_dir;
+
+/**
+ * 1/ Add column
+ * 2/ Alter column
+ * 3/ Alter column bad
+ * 4/ Drop column
+ **/
+$t = new TestBuilder($server['desc'],
+       'Column tests',
+       'Add/Alter/Drop a column'
+);
+
+$t->login($admin_user, $admin_user_pass);
+
+/** 1 **/
+$t->addComment('1. add column');
+$t->clickAndWait("link={$lang['strdatabases']}");
+$t->clickAndWait("link={$testdb}");
+$t->clickAndWait("link={$lang['strschemas']}");
+$t->clickAndWait('link=public');
+$t->clickAndWait("link={$lang['strtables']}");
+$t->clickAndWait('link=student');
+$t->clickAndWait("link={$lang['strcolumns']}");
+$t->clickAndWait("link={$lang['straddcolumn']}");
+$t->type('field', 'new_col');
+$t->select('type', 'label=integer');
+$t->type('default', 0);
+$t->type('comment', 'test col to drop');
+$t->clickAndWait("//input[@value='Add']");
+$t->assertText("//p[@class='message']", $lang['strcolumnadded']);
+$t->assertText("//tr/td/a[text()='new_col']", 'new_col');
+$t->assertText("//tr/td/a[text()='new_col']/../../td[2]", 'integer');
+if ($data->hasCreateFieldWithConstraints()) {
+       $t->assertText("//tr/td/a[text()='new_col']/../../td[3]", '');
+       $t->assertText("//tr/td/a[text()='new_col']/../../td[4]", '0');
+}
+$t->assertText("//tr/td/a[text()='new_col']/../../td[9]", 'test col to drop');
+
+/** 2 **/
+$t->addComment('2. alter column');
+$t->clickAndWait("link={$lang['strcolumns']}");
+$t->clickAndWait('link=new_col');
+$t->clickAndWait("link={$lang['stralter']}");
+$t->type('field', 'altered_col');
+$current_type='integer';
+$current_default='1';
+if ($data->hasAlterColumnType()) {
+       $t->select('type', 'label=character');
+       $t->type('length', 1);
+       $t->type('default', "'-'");
+       $current_type='character(1)';
+       $current_default="'-'";
+}
+else {
+       $t->type('default', '2');
+       $current_default='2';
+}
+$t->check('notnull');
+$t->type('comment', 'altered col to drop');
+$t->clickAndWait("//input[@value='Alter']");
+$t->assertText("//p[@class='message']", $lang['strcolumnaltered']);
+$t->assertText("//p[@class='comment']", 'altered col to drop');
+$t->assertText("//tr/td[1 and @class='data1']/", 'altered_col');
+$t->assertText("//tr/td[text()='altered_col']/../td[2]", $current_type);
+$t->assertText("//tr/td[text()='altered_col']/../td[3]", 'NOT NULL');
+$t->assertText("//tr/td[text()='altered_col']/../td[4]", "{$current_default}*");
+
+/** 3 **/
+$t->addComment('3. alter column fail');
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']");
+$t->clickAndWait('link=name');
+$t->clickAndWait("link={$lang['stralter']}");
+$t->type('default', 'Bad default value');
+$t->clickAndWait("//input[@value='Alter']");
+$t->assertText("//p[@class='message']", $lang['strcolumnalteredbad']);
+$t->clickAndWait('cancel');
+
+/** 4 **/
+$t->addComment('4. drop column');
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']");
+$t->clickAndWait('link=altered_col');
+$t->clickAndWait("link={$lang['strdrop']}");
+$t->click('cascade');
+$t->clickAndWait('drop');
+$t->assertText("//p[@class='message']", $lang['strcolumndropped']);
+$t->assertErrorOnNext("Element //tr/td/a[text()='altered_col'] not found");
+$t->clickAndWait("//tr/td/a[text()='altered_col']"); //fail
+
+$t->logout();
+$t->writeTests("{$test_static_dir}/{$server['desc']}/column.html", $testsuite_file);
+unset($t);
+?>
\ No newline at end of file
diff --git a/tests/selenium/src/30-view.php b/tests/selenium/src/30-view.php
new file mode 100644 (file)
index 0000000..b5ec22f
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+global $testsuite_file, $test_static_dir;
+
+/**
+ * 1/ Create a view
+ * 2/ Alter a view
+ * 3/ Drop a view
+ **/
+$t = new TestBuilder($server['desc'],
+       'View tests',
+       'Add/Alter/Drop a view'
+);
+
+$t->login($admin_user, $admin_user_pass);
+
+/** 1 **/
+$t->addComment('1. Create the view');
+$t->clickAndWait("link={$lang['strdatabases']}");
+$t->clickAndWait("link={$testdb}");
+$t->clickAndWait("link={$lang['strschemas']}");
+$t->clickAndWait('link=public');
+$t->clickAndWait("link={$lang['strviews']}");
+$t->clickAndWait("link={$lang['strcreateview']}");
+$t->type('formView', 'student_promo');
+$t->type('formDefinition', 'SELECT s.id, name, birthday, resume, spe, year
+       FROM student AS s
+       JOIN test_schema.promo AS p ON (s.id_promo=p.id)');
+$t->type('formComment', 'students and their promotion');
+$t->clickAndWait("//input[@value='Create']");
+$t->assertText("//p[@class='message']", "{$lang['strviewcreated']}");
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[2]", 'student_promo');
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user);
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[8]", 'students and their promotion');
+$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'public');
+
+/** 2 **/
+$t->addComment('2. Alter the view');
+$t->clickAndWait("link={$lang['strviews']}");
+$t->clickAndWait('link=student_promo');
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+//Alter name
+$t->addComment('2.1. Alter view\'s name');
+$t->type('name', 'student_promo_renamed');
+$t->clickAndWait('alter');
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
+$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo_renamed');
+//Alter comment
+$t->addComment('2.2. Alter view\'s comment');
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+$t->type('comment', 'students and their promotion (altered)');
+$t->clickAndWait('alter');
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
+$t->assertText("//p[@class='comment']", 'students and their promotion (altered)');
+// Alter schema
+$current_shema='public';
+if ($data->hasAlterTableSchema()) {
+       $t->addComment('2.3. Alter view\'s schema');
+       $t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+       $t->select('newschema', 'label=test_schema');
+       $t->clickAndWait('alter');
+       $t->assertText("//p[@class='message']", $lang['strviewaltered']);
+       $t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema');
+       $current_shema='test_schema';
+}
+// Alter owner
+$t->addComment('2.4. Alter view\'s owner');
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+$t->select('owner', "label={$user}");
+$t->clickAndWait('alter');
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='{$current_shema}']");
+$t->clickAndWait("link={$lang['strviews']}");
+$t->assertText("//tr/td[2]/a[text()='student_promo_renamed']/../../td[3]", $user);
+// Alter back everything
+$t->addComment('2.5. Alter back everything');
+$t->clickAndWait('link=student_promo_renamed');
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
+$t->select('owner', "label={$admin_user}");
+$t->type('name', 'student_promo');
+if ($data->hasAlterTableSchema()) {
+       $t->select('newschema', 'label=public');
+}
+$t->type('comment', 'students and their promotion');
+$t->clickAndWait('alter');
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
+$t->assertText("//p[@class='comment']", 'students and their promotion');
+$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo');
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='public']");
+$t->clickAndWait("link={$lang['strviews']}");
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user);
+
+/** 3 **/
+$t->addComment('3. Drop the view');
+$t->clickAndWait("//tr/td/a[text()='student_promo']/../../td/a[text()='{$lang['strdrop']}']");
+$t->clickAndWait('drop');
+$t->assertText("//p[@class='message']", $lang['strviewdropped']);
+$t->assertErrorOnNext("Element //tr/td/a[text()='student_promo'] not found");
+$t->clickAndWait("//tr/td/a[text()='student_promo']"); //fail
+
+$t->logout();
+$t->writeTests("{$test_static_dir}/{$server['desc']}/view.html", $testsuite_file);
+unset($t);
+?>
\ No newline at end of file
diff --git a/tests/selenium/src/35-index.php b/tests/selenium/src/35-index.php
new file mode 100644 (file)
index 0000000..5b9c19b
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+global $testsuite_file, $test_static_dir;
+
+/**
+ * 1/ Create the unique index
+ * 2/ Drop the index
+ **/
+$t = new TestBuilder($server['desc'],
+       'Index tests',
+       'Create/Drop an unique Index'
+);
+
+$t->login($admin_user, $admin_user_pass);
+
+/** 1 **/
+$t->addComment('1. Create the unique index');
+$t->clickAndWait("link={$lang['strdatabases']}");
+$t->clickAndWait("link={$testdb}");
+$t->clickAndWait("link={$lang['strschemas']}");
+$t->clickAndWait('link=public');
+$t->clickAndWait("link={$lang['strtables']}");
+$t->clickAndWait('link=student');
+$t->clickAndWait("link={$lang['strindexes']}");
+$t->clickAndWait("link={$lang['strcreateindex']}");
+$t->type('formIndexName', 'name_unique');
+$t->addSelection('TableColumnList', 'label=name');
+$t->click('add');
+$t->clickAndWait("//input[@value='{$lang['strcreate']}']");
+$t->assertText("//p[@class='message']", $lang['strindexcreated']);
+
+/** 2 **/
+$t->addComment('2. Drop the index');
+$t->clickAndWait("link={$lang['strindexes']}");
+$t->clickAndWait("//tr/td[text()='name_unique']/../td/a[text()='Drop']");
+$t->click('cascade');
+$t->clickAndWait('drop');
+$t->assertText("//p[@class='message']", $lang['strindexdropped']);
+
+$t->logout();
+$t->writeTests("{$test_static_dir}/{$server['desc']}/index.html", $testsuite_file);
+unset($t);
+?>
\ No newline at end of file
index ecb47d16e8bae9a70b70f6d0caf5c322368add41..fa5f3b334cbae5d909278c1ea857507e3ca36e63 100644 (file)
@@ -18,6 +18,7 @@
        );
 
 /** 1 **/
+       $t->addComment('1. login as user and try to drop database -> fail');
        $t->login($user, $user_pass);
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("//tr/td/a[text()='{$testdb}']/../../td/a[text()='{$lang['strdrop']}']");
@@ -25,6 +26,7 @@
        $t->assertText('//p[@class=\'message\']', $lang['strdatabasedroppedbad']);
 
 /** 2 **/
+       $t->addComment('2. logout / login as admin_user and drop user role/user');
        $t->logout();
        $t->login($admin_user, $admin_pass);
        if ($data->hasRoles()) {
@@ -40,6 +42,7 @@
        }
 
 /** 3 **/
+       $t->addComment('3. try to drop himself -> fail');
        if ($data->hasRoles()) {
                $t->clickAndWait("link={$lang['strroles']}");
                $t->clickAndWait("link={$admin_user}");
@@ -55,6 +58,7 @@
        }
 
 /** 4 **/
+       $t->addComment('4. drop domain -> fail table promo depend on it');
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$testdb}");
        $t->clickAndWait("link={$lang['strschemas']}");
@@ -65,6 +69,7 @@
        $t->assertText('//p[@class=\'message\']', $lang['strdomaindroppedbad']);
 
 /** 5 **/
+       $t->addComment('5. drop domain with cascade, test if promo.year disapeared');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
        $t->clickAndWait("link={$lang['strschemas']}");
        $t->clickAndWait("link=test_schema");
@@ -81,6 +86,7 @@
        $t->clickAndWait("link=year");
 
 /** 6 **/
+       $t->addComment('6. drop table student with cascade using the action button');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$testdb}");
@@ -92,6 +98,7 @@
        $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']);
 
 /** 7 **/
+       $t->addComment('7. drop table promo using the button from tblproperties');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("link={$testdb}");
        $t->assertText('//p[@class=\'message\']', $lang['strtabledropped']);
        
 /** 8 **/
+       $t->addComment('8. drop test database');
        $t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
        $t->clickAndWait("link={$lang['strdatabases']}");
        $t->clickAndWait("//tr/td/a[text()='{$testdb}']/../../td/a[text()='{$lang['strdrop']}']");
        $t->assertText('//p[@class=\'message\']', $lang['strdatabasedropped']);
 
 /** 9 **/
+       $t->addComment('9. logout & login as superuser and drop admin_user');
        $t->logout();
        $t->login($super_user[$server['desc']], $super_pass[$server['desc']]);
 
index 65a9423faac9417312d7a6faa45d142daa9a188e..2cebffa1d5a6a0f4193e7c67ded17a9fcb8a9718 100644 (file)
                        $this->code .= "<tr>\n<td>$action</td>\n<td>$selector</td>\n<td>$value</td>\n</tr>\n";
                }
 
+               public function addComment($c) {
+                       $this->code .= "<tr>\n<th colspan=\"3\">{$c}</th>\n</tr>\n";
+               }
+
                /**
                 * Add steps to login on PPA using the given credentials
                 * @param $u The username to use
@@ -69,6 +73,7 @@
                 */
                public function login($u, $p) {
                        global $webUrl, $data;
+                       $this->addComment("Login as {$u}");
                        $this->test('open', "{$webUrl}/login.php?server={$data->conn->host}&subject=server");
                        $this->test('type', "//input[@name='loginUsername']", $u);
                        $this->test('type', "//input[@id='loginPassword']", $p);
@@ -82,6 +87,7 @@
                public function logout() {
                        global $lang;
 
+                       $this->addComment("Logout");
                        $this->test('clickAndWait', "//div[@class='trail']/descendant::tr/td[1]/a/span[@class='label' and text()='phpPgAdmin']");
                        $this->test('clickAndWait', "link={$lang['strservers']}");
                        $this->test('clickAndWait', "//tr/td/a[text()='{$this->servDesc}']/../../td/a[text()='{$lang['strlogout']}']");