Skip to content
This repository
Browse code

Update/Add selenium tests

- 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
  • Loading branch information...
commit 82ed178d04b6dcfe9724b00fd4977f46f1e6e917 1 parent 99b3160
Jehan-Guillaume (ioguix) de Rorthais authored December 14, 2008
8  tests/selenium/README
@@ -45,9 +45,11 @@ and the static folder where the HTML tests files are created
45 45
 	);
46 46
 
47 47
 - once the TestBuilder instance is created, you can use it to write our tests.
48  
-	In particular, you should use the login($username, $pass) and logout() methods.
49  
-	Each selenium actions are mapped (or should be) as methods. As instance, if you want to use the clickAndWait action, you should call the
50  
-	 clickAndWait($locator) method. For the assertText, assertText($selector, $value), etc...
  48
+	- In particular, you should use the login($username, $pass) and logout() methods to create appropriate steps to login/logout to the current
  49
+	server.
  50
+	- Each selenium actions are mapped (or should be) as methods. As instance, if you want to use the clickAndWait action, you should call the
  51
+	clickAndWait($locator) method. For the assertText, assertText($selector, $value), etc...
  52
+	- Use the addComment method to show comments anywhere in the tests page. Usefull to explain whatthe next tests are going to do.
51 53
 
52 54
 - finish whith calling the TestBuilder's "writeTests" method which will create the selenium HTML test file in the static dir and append this
53 55
 new test file to the testSuite file.
3  tests/selenium/selenium-lib/core/TestRunner.hta
@@ -89,6 +89,9 @@ to work-around a bug in IE on Win2K whereby the HTA application doesn't function
89 89
                         <button type="button" id="runSuite" onClick="htmlTestRunner.startTestSuite();"
90 90
                                 title="Run All tests" accesskey="a">
91 91
                         </button>
  92
+						<button type="button" id="runRemainTests" onClick="htmlTestRunner.runRemainTests();"
  93
+                                title="Run the tests from the selected" accesskey="f">
  94
+                        </button>
92 95
                         <button type="button" id="runSeleniumTest" onClick="htmlTestRunner.runSingleTest();"
93 96
                                 title="Run the Selected test" accesskey="r">
94 97
                         </button>
3  tests/selenium/selenium-lib/core/TestRunner.html
@@ -89,6 +89,9 @@
89 89
                         <button type="button" id="runSuite" onClick="htmlTestRunner.startTestSuite();"
90 90
                                 title="Run All tests" accesskey="a">
91 91
                         </button>
  92
+                        <button type="button" id="runRemainTests" onClick="htmlTestRunner.runRemainTests();"
  93
+                                title="Run the tests from the selected" accesskey="f">
  94
+                        </button>
92 95
                         <button type="button" id="runSeleniumTest" onClick="htmlTestRunner.runSingleTest();"
93 96
                                 title="Run the Selected test" accesskey="r">
94 97
                         </button>
6  tests/selenium/selenium-lib/core/scripts/selenium-testrunner.js
@@ -144,6 +144,12 @@ objectExtend(HtmlTestRunner.prototype, {
144 144
         this.currentTest.start();
145 145
     },
146 146
 
  147
+	runRemainTests:function() {
  148
+        this.runAllTests = true;
  149
+        this.metrics.resetMetrics();
  150
+        this.startTest();
  151
+    },
  152
+
147 153
     runSingleTest:function() {
148 154
         this.runAllTests = false;
149 155
         this.metrics.resetMetrics();
5  tests/selenium/selenium-lib/core/selenium.css
@@ -109,6 +109,11 @@ body, html {
109 109
     background-image: url("icons/selected.png");
110 110
 }
111 111
 
  112
+#controlPanel #runRemainTests {
  113
+    width: 32px;
  114
+    background-image: url("icons/remains.png");
  115
+}
  116
+
112 117
 .cssPauseTest {
113 118
     background-image: url("icons/pause.png");
114 119
 }
6  tests/selenium/src/01-roles.php
@@ -16,9 +16,11 @@
16 16
 	);
17 17
 
18 18
 	/* 1 */
  19
+	$t->addComment('1. login as superuser');
19 20
 	$t->login($super_user[$server['desc']], $super_pass[$server['desc']]);
20 21
 
21 22
 	/* 2 */
  23
+	$t->addComment('2. create admin_user role/user with wrong pass conf -> fail');
22 24
 	if ($data->hasRoles()) {
23 25
 		$t->clickAndWait("link={$lang['strroles']}");
24 26
 		$t->clickAndWait("link={$lang['strcreaterole']}");
@@ -39,6 +41,7 @@
39 41
 	$t->assertText("//p[@class='message']", $lang['strpasswordconfirm']);
40 42
 
41 43
 	/* 3 */
  44
+	$t->addComment('3. create admin_user');
42 45
 	$t->type('formPassword', $admin_user_pass);
43 46
 	$t->type('formConfirm', $admin_user_pass);
44 47
 	$t->clickAndWait('create');
@@ -48,11 +51,13 @@
48 51
 		$t->assertText("//p[@class='message']", $lang['strusercreated']);
49 52
 
50 53
 	/* 4 */
  54
+	$t->addComment('4. logout & login as admin_user');
51 55
 	$t->logout();
52 56
 	$t->login($admin_user, $admin_user_pass);
53 57
 
54 58
 
55 59
 	/* 5 */
  60
+	$t->addComment('5. create user role/user with altered name, pass and props');
56 61
 	if ($data->hasRoles()) {
57 62
 		$t->clickAndWait("link={$lang['strroles']}");
58 63
 		$t->clickAndWait("link={$lang['strcreaterole']}");
@@ -77,6 +82,7 @@
77 82
 		$t->assertText("//p[@class='message']", $lang['strusercreated']);
78 83
 
79 84
 	/* 6 */
  85
+	$t->addComment('6. alter user back to the normal value');
80 86
 	if ($data->hasRoles()) {
81 87
 		$t->clickAndWait("link={$lang['strroles']}");
82 88
 		$t->clickAndWait("link={$user}toalter");
3  tests/selenium/src/04-database.php
@@ -15,6 +15,7 @@
15 15
 	$t->login($admin_user, $admin_user_pass);
16 16
 
17 17
 /** 1 **/
  18
+	$t->addComment('1. create test database with altered name and owner');
18 19
 	$t->clickAndWait("link={$lang['strdatabases']}");
19 20
 	$t->clickAndWait("link={$lang['strcreatedatabase']}");
20 21
 
@@ -32,6 +33,7 @@
32 33
 	$t->assertText("//p[@class='message']", $lang['strdatabasecreated']);
33 34
 
34 35
 /** 2 **/
  36
+	$t->addComment('2. alter DB\'s owner');
35 37
 	if ($data->hasAlterDatabaseOwner()) {
36 38
 		$t->clickAndWait("link={$lang['strdatabases']}");
37 39
 		/* we don't need to check if hasAlterDatabaseRename here because
@@ -44,6 +46,7 @@
44 46
 	}
45 47
 
46 48
 /** 3 **/
  49
+	$t->addComment('3. alter DB\'s name, owner and comment back to normal');
47 50
 	if ($data->hasAlterDatabase()) {
48 51
 		$t->clickAndWait("link={$lang['strdatabases']}");
49 52
 		/* we don't need to check if hasAlterDatabaseRename here because
2  tests/selenium/src/06-schema.php
@@ -14,6 +14,7 @@
14 14
 	$t->login($admin_user, $admin_user_pass);
15 15
 
16 16
 /** 1 **/
  17
+	$t->addComment('1. create test schema');
17 18
 	$t->clickAndWait("link={$lang['strdatabases']}");
18 19
 	$t->clickAndWait("link={$testdb}");
19 20
 	$t->clickAndWait("link={$lang['strschemas']}");
@@ -33,6 +34,7 @@
33 34
 	$t->assertText('//p[@class=\'message\']', $lang['strschemacreated']);
34 35
 
35 36
 /** 2 **/
  37
+	$t->addComment('2. alter schema\'s name, owner and comment');
36 38
 	if ($data->hasAlterSchema()) {
37 39
 		$t->clickAndWait("link={$lang['strschemas']}");
38 40
 		$t->clickAndWait("//tr/td/a[text()='test_schema_toalter']/../../td/a[text()='{$lang['stralter']}']");
5  tests/selenium/src/08-domaine.php
@@ -17,6 +17,7 @@
17 17
 	$t->login($admin_user, $admin_user_pass);
18 18
 
19 19
 /** 1 **/
  20
+	$t->addComment('1. create domain');
20 21
 	$t->clickAndWait("link={$lang['strdatabases']}");
21 22
 	$t->clickAndWait("link={$testdb}");
22 23
 	$t->clickAndWait("link={$lang['strschemas']}");
@@ -56,6 +57,7 @@
56 57
 	}
57 58
 	
58 59
 /** 2 **/
  60
+	$t->addComment('2. add unwanted domain constraint');
59 61
 	if ($data->hasDomainConstraints()) {
60 62
 		$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
61 63
 		$t->clickAndWait("link={$lang['strdomains']}");
@@ -69,6 +71,7 @@
69 71
 	}
70 72
 
71 73
 /** 3 **/
  74
+	$t->addComment('3. drop unwanted check constraint on domain');
72 75
 	if ($data->hasDomainConstraints()) {
73 76
 		$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
74 77
 		$t->clickAndWait("link={$lang['strdomains']}");
@@ -81,6 +84,7 @@
81 84
 	}
82 85
 
83 86
 /** 4 **/
  87
+	$t->addComment('4. alter domain giving owner to super_user');
84 88
 	if ($data->hasAlterDomains()) {
85 89
 		$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
86 90
 		$t->clickAndWait("link={$lang['strdomains']}");
@@ -97,6 +101,7 @@
97 101
 	}
98 102
 
99 103
 /** 5 **/
  104
+	$t->addComment('5. alter back the owner to admin_user');
100 105
 	if ($data->hasAlterDomains()) {
101 106
 		$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='test_schema']");
102 107
 		$t->clickAndWait("link={$lang['strdomains']}");
9  tests/selenium/src/10-table.php
@@ -17,6 +17,7 @@
17 17
 	$t->login($admin_user, $admin_user_pass);
18 18
 
19 19
 /** 1 **/
  20
+	$t->addComment('1. create a table student in public');
20 21
 	$t->clickAndWait("link={$lang['strdatabases']}");
21 22
 	$t->clickAndWait("link={$testdb}");
22 23
 	$t->clickAndWait("link={$lang['strschemas']}");
@@ -44,6 +45,7 @@
44 45
 	$t->assertText("//p[@class='message']", $lang['strtablecreated']);
45 46
 
46 47
 /** 2 **/
  48
+	$t->addComment('2. create table promo in test_schema');
47 49
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
48 50
 	$t->clickAndWait("link={$lang['strschemas']}");
49 51
 	$t->clickAndWait("link=test_schema");
@@ -67,6 +69,7 @@
67 69
 	$t->assertText("//p[@class='message']", $lang['strtablecreated']);
68 70
 
69 71
 /** 3 **/
  72
+	$t->addComment('3. create table like student in test_schema');
70 73
 	if ($data->hasCreateTableLike()) {
71 74
 		$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
72 75
 		$t->clickAndWait("link={$lang['strschemas']}");
@@ -102,7 +105,9 @@
102 105
 	}
103 106
 
104 107
 /** 4 **/
  108
+	$t->addComment('4. alter each param one by one on test_toalter');
105 109
 	/*table name*/
  110
+	$t->addComment('4.1. alter table name');
106 111
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
107 112
 	$t->clickAndWait("link={$lang['strschemas']}");
108 113
 	$t->clickAndWait("link=test_schema");
@@ -116,6 +121,7 @@
116 121
 	$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label']", 'test_renamed');
117 122
 
118 123
 	/*table comment*/
  124
+	$t->addComment('4.2. alter table comment');
119 125
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
120 126
 	$t->clickAndWait("link={$lang['strschemas']}");
121 127
 	$t->clickAndWait("link=test_schema");
@@ -130,6 +136,7 @@
130 136
 	
131 137
 	/*table owner*/
132 138
 	if ($data->hasAlterTableOwner()) {
  139
+		$t->addComment('4.3. alter table owner');
133 140
 		$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
134 141
 		$t->clickAndWait("link={$lang['strschemas']}");
135 142
 		$t->clickAndWait("link=test_schema");
@@ -145,6 +152,7 @@
145 152
 	
146 153
 	/*alter schema*/
147 154
 	if ($data->hasAlterTableSchema()) {
  155
+		$t->addComment('4.4. alter table schema');
148 156
 		$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
149 157
 		$t->clickAndWait("link={$lang['strschemas']}");
150 158
 		$t->clickAndWait("link=test_schema");
@@ -157,6 +165,7 @@
157 165
 	}
158 166
 
159 167
 /** 5 **/
  168
+	$t->addComment('5. alter back test_toalter in one step');
160 169
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
161 170
 	$t->clickAndWait("link={$lang['strschemas']}");
162 171
 	if ($data->hasAlterTableSchema())
4  tests/selenium/src/15-sequence.php
@@ -15,6 +15,7 @@
15 15
 	$t->login($admin_user, $admin_user_pass);
16 16
 
17 17
 /** 1 **/
  18
+	$t->addComment('1. Create a sequence');
18 19
 	$t->clickAndWait("link={$lang['strdatabases']}");
19 20
 	$t->clickAndWait("link={$testdb}");
20 21
 	$t->clickAndWait("link={$lang['strschemas']}");
@@ -40,6 +41,7 @@
40 41
 	$t->assertText("//tr/td[text()='testcase_seq']/../td[8]", $lang['stryes']);
41 42
 
42 43
 /** 2 **/
  44
+	$t->addComment('2. increment, reset sequence and set value');
43 45
 	$t->clickAndWait("link={$lang['strsetval']}");
44 46
 	$t->type('nextvalue', '2');
45 47
 	$t->clickAndWait('setval');
@@ -53,6 +55,7 @@
53 55
 	$t->assertText("//tr/td[text()='testcase_seq']/../td[2]", '1');
54 56
 
55 57
 /** 3 **/
  58
+	$t->addComment('3. alter sequence');
56 59
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
57 60
 	$t->clickAndWait("link={$lang['strschemas']}");
58 61
 	$t->clickAndWait('link=public');
@@ -94,6 +97,7 @@
94 97
 	$t->assertText("//tr/td[2]/a[text()='testcase_renamed_seq']/../../td[3]", $user);
95 98
 
96 99
 /** 4 **/
  100
+	$t->addComment('4. drop sequence');
97 101
 	$t->clickAndWait("link={$lang['strsequences']}");
98 102
 	$t->clickAndWait("//tr/td/a[text()='testcase_renamed_seq']/../../td/a[text()='{$lang['strdrop']}']");
99 103
 	$t->click('cascade');
112  tests/selenium/src/20-constraint.php
... ...
@@ -0,0 +1,112 @@
  1
+<?php
  2
+	global $testsuite_file, $test_static_dir;
  3
+
  4
+	/*
  5
+	 * 1/ Add 2 Foreign Keys
  6
+	 * 2/ Add check constraint
  7
+	 * 3/ Add unique key
  8
+	 * 4/ Drop PK before creating it again
  9
+	 * 5/ Add primary key
  10
+	 * 6/ Drop FK
  11
+	 * 7/ Drop unique
  12
+	 * 8/ Drop check
  13
+	 */
  14
+	$t = new TestBuilder($server['desc'],
  15
+		'Constraint tests',
  16
+		'Create and drop constraints...'
  17
+	);
  18
+
  19
+	$t->login($admin_user, $admin_user_pass);
  20
+
  21
+	/** 1 **/
  22
+	$t->addComment('1. Add 2 Foreign Keys');
  23
+	$t->addComment('1.1. Add 1st Foreign Keys');
  24
+	$t->clickAndWait("link={$lang['strdatabases']}");
  25
+	$t->clickAndWait("link={$testdb}");
  26
+	$t->clickAndWait("link={$lang['strschemas']}");
  27
+	$t->clickAndWait('link=public');
  28
+	$t->clickAndWait("link={$lang['strtables']}");
  29
+	$t->clickAndWait('link=student');
  30
+	$t->clickAndWait("link={$lang['strconstraints']}");
  31
+	$t->clickAndWait("link={$lang['straddfk']}");
  32
+	$t->type('name', 'student_id_promo_fk');
  33
+	$t->addSelection('TableColumnList','label=id_promo');
  34
+	$t->click('add');
  35
+	$t->select('target', 'label=test_schema.promo');
  36
+	$t->clickAndWait("//input[@value='Add']");
  37
+	$t->addSelection('TableColumnList', 'label=id');
  38
+	$t->click('add');
  39
+	$t->select('upd_action', 'label=CASCADE');
  40
+	$t->select('del_action', 'label=RESTRICT');
  41
+	$t->clickAndWait("//input[@value='Add']");
  42
+	$t->assertText("//p[@class='message']", $lang['strfkadded']);
  43
+
  44
+	/** 1' **/
  45
+	$t->addComment('1.2. Add 2nd Foreign Keys');
  46
+	$t->clickAndWait("link={$lang['straddfk']}");
  47
+	$t->type('name', 'fk_to_drop');
  48
+	$t->addSelection('TableColumnList', 'label=id_promo');
  49
+	$t->click('add');
  50
+	$t->select('target','label=test_schema.promo');
  51
+	$t->clickAndWait("//input[@value='Add']");
  52
+	$t->addSelection('TableColumnList', 'label=id');
  53
+	$t->click('add');
  54
+	$t->select('upd_action', 'label=CASCADE');
  55
+	$t->select('del_action', 'label=RESTRICT');
  56
+	$t->clickAndWait("//input[@value='Add']");
  57
+	$t->assertText("//p[@class='message']", $lang['strfkadded']);
  58
+
  59
+	/* 2 */
  60
+	$t->addComment('2. Add check constraint');
  61
+	$t->clickAndWait("link={$lang['straddcheck']}");
  62
+	$t->type('name', 'check_to_drop');
  63
+	$t->type('definition', 'extract(year from birthday) &lt; 2000');
  64
+	$t->clickAndWait('ok');
  65
+	$t->assertText("//p[@class='message']", $lang['strcheckadded']);
  66
+
  67
+	/* 3 */
  68
+	$t->addComment('3. Add unique key');
  69
+	$t->clickAndWait("link={$lang['stradduniq']}");
  70
+	$t->type('name', 'unique_to_drop');
  71
+	$t->addSelection('TableColumnList', 'label=name');
  72
+	$t->click('add');
  73
+	$t->clickAndWait("//input[@value='{$lang['stradd']}']");
  74
+	$t->assertText("//p[@class='message']", $lang['struniqadded']);
  75
+
  76
+	/* 4 */
  77
+	$t->addComment('4. Drop PK before creating it again');
  78
+	$t->clickAndWait("//tr/td/pre[text()='PRIMARY KEY (id)']/../../td/a[text()='{$lang['strdrop']}']");
  79
+	$t->clickAndWait('drop');
  80
+	$t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
  81
+
  82
+	/* 5 */
  83
+	$t->addComment('5. Add primary key');
  84
+	$t->clickAndWait("link={$lang['straddpk']}");
  85
+	$t->type('name', 'student_pk');
  86
+	$t->addSelection('TableColumnList', 'label=id');
  87
+	$t->click('add');
  88
+	$t->clickAndWait("//input[@value='Add']");
  89
+	$t->assertText("//p[@class='message']", $lang['strpkadded']);
  90
+
  91
+	/* 6 */
  92
+	$t->addComment('6. Drop FK');
  93
+	$t->clickAndWait("//tr/td[text()='fk_to_drop']/../td/a[text()='{$lang['strdrop']}']");
  94
+	$t->clickAndWait('drop');
  95
+	$t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
  96
+
  97
+	/* 7 */
  98
+	$t->addComment('7. Drop unique');
  99
+	$t->clickAndWait("//tr/td[text()='unique_to_drop']/../td/a[text()='{$lang['strdrop']}']");
  100
+	$t->clickAndWait('drop');
  101
+	$t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
  102
+
  103
+	/* 8 */
  104
+	$t->addComment('8. Drop check');
  105
+	$t->clickAndWait("//tr/td[text()='check_to_drop']/../td/a[text()='{$lang['strdrop']}']");
  106
+	$t->clickAndWait('drop');
  107
+	$t->assertText("//p[@class='message']", $lang['strconstraintdropped']);
  108
+
  109
+	$t->logout();
  110
+	$t->writeTests("{$test_static_dir}/{$server['desc']}/constraint.html", $testsuite_file);
  111
+	unset($t);
  112
+?>
94  tests/selenium/src/25-column.php
... ...
@@ -0,0 +1,94 @@
  1
+<?php
  2
+global $testsuite_file, $test_static_dir;
  3
+
  4
+/**
  5
+ * 1/ Add column
  6
+ * 2/ Alter column
  7
+ * 3/ Alter column bad
  8
+ * 4/ Drop column
  9
+ **/
  10
+$t = new TestBuilder($server['desc'],
  11
+	'Column tests',
  12
+	'Add/Alter/Drop a column'
  13
+);
  14
+
  15
+$t->login($admin_user, $admin_user_pass);
  16
+
  17
+/** 1 **/
  18
+$t->addComment('1. add column');
  19
+$t->clickAndWait("link={$lang['strdatabases']}");
  20
+$t->clickAndWait("link={$testdb}");
  21
+$t->clickAndWait("link={$lang['strschemas']}");
  22
+$t->clickAndWait('link=public');
  23
+$t->clickAndWait("link={$lang['strtables']}");
  24
+$t->clickAndWait('link=student');
  25
+$t->clickAndWait("link={$lang['strcolumns']}");
  26
+$t->clickAndWait("link={$lang['straddcolumn']}");
  27
+$t->type('field', 'new_col');
  28
+$t->select('type', 'label=integer');
  29
+$t->type('default', 0);
  30
+$t->type('comment', 'test col to drop');
  31
+$t->clickAndWait("//input[@value='Add']");
  32
+$t->assertText("//p[@class='message']", $lang['strcolumnadded']);
  33
+$t->assertText("//tr/td/a[text()='new_col']", 'new_col');
  34
+$t->assertText("//tr/td/a[text()='new_col']/../../td[2]", 'integer');
  35
+if ($data->hasCreateFieldWithConstraints()) {
  36
+	$t->assertText("//tr/td/a[text()='new_col']/../../td[3]", '');
  37
+	$t->assertText("//tr/td/a[text()='new_col']/../../td[4]", '0');
  38
+}
  39
+$t->assertText("//tr/td/a[text()='new_col']/../../td[9]", 'test col to drop');
  40
+
  41
+/** 2 **/
  42
+$t->addComment('2. alter column');
  43
+$t->clickAndWait("link={$lang['strcolumns']}");
  44
+$t->clickAndWait('link=new_col');
  45
+$t->clickAndWait("link={$lang['stralter']}");
  46
+$t->type('field', 'altered_col');
  47
+$current_type='integer';
  48
+$current_default='1';
  49
+if ($data->hasAlterColumnType()) {
  50
+	$t->select('type', 'label=character');
  51
+	$t->type('length', 1);
  52
+	$t->type('default', "'-'");
  53
+	$current_type='character(1)';
  54
+	$current_default="'-'";
  55
+}
  56
+else {
  57
+	$t->type('default', '2');
  58
+	$current_default='2';
  59
+}
  60
+$t->check('notnull');
  61
+$t->type('comment', 'altered col to drop');
  62
+$t->clickAndWait("//input[@value='Alter']");
  63
+$t->assertText("//p[@class='message']", $lang['strcolumnaltered']);
  64
+$t->assertText("//p[@class='comment']", 'altered col to drop');
  65
+$t->assertText("//tr/td[1 and @class='data1']/", 'altered_col');
  66
+$t->assertText("//tr/td[text()='altered_col']/../td[2]", $current_type);
  67
+$t->assertText("//tr/td[text()='altered_col']/../td[3]", 'NOT NULL');
  68
+$t->assertText("//tr/td[text()='altered_col']/../td[4]", "{$current_default}*");
  69
+
  70
+/** 3 **/
  71
+$t->addComment('3. alter column fail');
  72
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']");
  73
+$t->clickAndWait('link=name');
  74
+$t->clickAndWait("link={$lang['stralter']}");
  75
+$t->type('default', 'Bad default value');
  76
+$t->clickAndWait("//input[@value='Alter']");
  77
+$t->assertText("//p[@class='message']", $lang['strcolumnalteredbad']);
  78
+$t->clickAndWait('cancel');
  79
+
  80
+/** 4 **/
  81
+$t->addComment('4. drop column');
  82
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strtable']}']/span[@class='label' and text()='student']");
  83
+$t->clickAndWait('link=altered_col');
  84
+$t->clickAndWait("link={$lang['strdrop']}");
  85
+$t->click('cascade');
  86
+$t->clickAndWait('drop');
  87
+$t->assertText("//p[@class='message']", $lang['strcolumndropped']);
  88
+$t->assertErrorOnNext("Element //tr/td/a[text()='altered_col'] not found");
  89
+$t->clickAndWait("//tr/td/a[text()='altered_col']"); //fail
  90
+
  91
+$t->logout();
  92
+$t->writeTests("{$test_static_dir}/{$server['desc']}/column.html", $testsuite_file);
  93
+unset($t);
  94
+?>
103  tests/selenium/src/30-view.php
... ...
@@ -0,0 +1,103 @@
  1
+<?php
  2
+global $testsuite_file, $test_static_dir;
  3
+
  4
+/**
  5
+ * 1/ Create a view
  6
+ * 2/ Alter a view
  7
+ * 3/ Drop a view
  8
+ **/
  9
+$t = new TestBuilder($server['desc'],
  10
+	'View tests',
  11
+	'Add/Alter/Drop a view'
  12
+);
  13
+
  14
+$t->login($admin_user, $admin_user_pass);
  15
+
  16
+/** 1 **/
  17
+$t->addComment('1. Create the view');
  18
+$t->clickAndWait("link={$lang['strdatabases']}");
  19
+$t->clickAndWait("link={$testdb}");
  20
+$t->clickAndWait("link={$lang['strschemas']}");
  21
+$t->clickAndWait('link=public');
  22
+$t->clickAndWait("link={$lang['strviews']}");
  23
+$t->clickAndWait("link={$lang['strcreateview']}");
  24
+$t->type('formView', 'student_promo');
  25
+$t->type('formDefinition', 'SELECT s.id, name, birthday, resume, spe, year
  26
+	FROM student AS s
  27
+	JOIN test_schema.promo AS p ON (s.id_promo=p.id)');
  28
+$t->type('formComment', 'students and their promotion');
  29
+$t->clickAndWait("//input[@value='Create']");
  30
+$t->assertText("//p[@class='message']", "{$lang['strviewcreated']}");
  31
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[2]", 'student_promo');
  32
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user);
  33
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[8]", 'students and their promotion');
  34
+$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'public');
  35
+
  36
+/** 2 **/
  37
+$t->addComment('2. Alter the view');
  38
+$t->clickAndWait("link={$lang['strviews']}");
  39
+$t->clickAndWait('link=student_promo');
  40
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
  41
+//Alter name
  42
+$t->addComment('2.1. Alter view\'s name');
  43
+$t->type('name', 'student_promo_renamed');
  44
+$t->clickAndWait('alter');
  45
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
  46
+$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo_renamed');
  47
+//Alter comment
  48
+$t->addComment('2.2. Alter view\'s comment');
  49
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
  50
+$t->type('comment', 'students and their promotion (altered)');
  51
+$t->clickAndWait('alter');
  52
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
  53
+$t->assertText("//p[@class='comment']", 'students and their promotion (altered)');
  54
+// Alter schema
  55
+$current_shema='public';
  56
+if ($data->hasAlterTableSchema()) {
  57
+	$t->addComment('2.3. Alter view\'s schema');
  58
+	$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
  59
+	$t->select('newschema', 'label=test_schema');
  60
+	$t->clickAndWait('alter');
  61
+	$t->assertText("//p[@class='message']", $lang['strviewaltered']);
  62
+	$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label']", 'test_schema');
  63
+	$current_shema='test_schema';
  64
+}
  65
+// Alter owner
  66
+$t->addComment('2.4. Alter view\'s owner');
  67
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
  68
+$t->select('owner', "label={$user}");
  69
+$t->clickAndWait('alter');
  70
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
  71
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='{$current_shema}']");
  72
+$t->clickAndWait("link={$lang['strviews']}");
  73
+$t->assertText("//tr/td[2]/a[text()='student_promo_renamed']/../../td[3]", $user);
  74
+// Alter back everything
  75
+$t->addComment('2.5. Alter back everything');
  76
+$t->clickAndWait('link=student_promo_renamed');
  77
+$t->clickAndWait("//ul[@class='navlink']/li/a[text()='{$lang['stralter']}']");
  78
+$t->select('owner', "label={$admin_user}");
  79
+$t->type('name', 'student_promo');
  80
+if ($data->hasAlterTableSchema()) {
  81
+	$t->select('newschema', 'label=public');
  82
+}
  83
+$t->type('comment', 'students and their promotion');
  84
+$t->clickAndWait('alter');
  85
+$t->assertText("//p[@class='message']", $lang['strviewaltered']);
  86
+$t->assertText("//p[@class='comment']", 'students and their promotion');
  87
+$t->assertText("//div[@class='trail']/descendant::a[@title='{$lang['strview']}']/span[@class='label']", 'student_promo');
  88
+$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strschema']}']/span[@class='label' and text()='public']");
  89
+$t->clickAndWait("link={$lang['strviews']}");
  90
+$t->assertText("//tr/td[2]/a[text()='student_promo']/../../td[3]", $admin_user);
  91
+
  92
+/** 3 **/
  93
+$t->addComment('3. Drop the view');
  94
+$t->clickAndWait("//tr/td/a[text()='student_promo']/../../td/a[text()='{$lang['strdrop']}']");
  95
+$t->clickAndWait('drop');
  96
+$t->assertText("//p[@class='message']", $lang['strviewdropped']);
  97
+$t->assertErrorOnNext("Element //tr/td/a[text()='student_promo'] not found");
  98
+$t->clickAndWait("//tr/td/a[text()='student_promo']"); //fail
  99
+
  100
+$t->logout();
  101
+$t->writeTests("{$test_static_dir}/{$server['desc']}/view.html", $testsuite_file);
  102
+unset($t);
  103
+?>
42  tests/selenium/src/35-index.php
... ...
@@ -0,0 +1,42 @@
  1
+<?php
  2
+global $testsuite_file, $test_static_dir;
  3
+
  4
+/**
  5
+ * 1/ Create the unique index
  6
+ * 2/ Drop the index
  7
+ **/
  8
+$t = new TestBuilder($server['desc'],
  9
+	'Index tests',
  10
+	'Create/Drop an unique Index'
  11
+);
  12
+
  13
+$t->login($admin_user, $admin_user_pass);
  14
+
  15
+/** 1 **/
  16
+$t->addComment('1. Create the unique index');
  17
+$t->clickAndWait("link={$lang['strdatabases']}");
  18
+$t->clickAndWait("link={$testdb}");
  19
+$t->clickAndWait("link={$lang['strschemas']}");
  20
+$t->clickAndWait('link=public');
  21
+$t->clickAndWait("link={$lang['strtables']}");
  22
+$t->clickAndWait('link=student');
  23
+$t->clickAndWait("link={$lang['strindexes']}");
  24
+$t->clickAndWait("link={$lang['strcreateindex']}");
  25
+$t->type('formIndexName', 'name_unique');
  26
+$t->addSelection('TableColumnList', 'label=name');
  27
+$t->click('add');
  28
+$t->clickAndWait("//input[@value='{$lang['strcreate']}']");
  29
+$t->assertText("//p[@class='message']", $lang['strindexcreated']);
  30
+
  31
+/** 2 **/
  32
+$t->addComment('2. Drop the index');
  33
+$t->clickAndWait("link={$lang['strindexes']}");
  34
+$t->clickAndWait("//tr/td[text()='name_unique']/../td/a[text()='Drop']");
  35
+$t->click('cascade');
  36
+$t->clickAndWait('drop');
  37
+$t->assertText("//p[@class='message']", $lang['strindexdropped']);
  38
+
  39
+$t->logout();
  40
+$t->writeTests("{$test_static_dir}/{$server['desc']}/index.html", $testsuite_file);
  41
+unset($t);
  42
+?>
9  tests/selenium/src/99-cleantests.php
@@ -18,6 +18,7 @@
18 18
 	);
19 19
 
20 20
 /** 1 **/
  21
+	$t->addComment('1. login as user and try to drop database -> fail');
21 22
 	$t->login($user, $user_pass);
22 23
 	$t->clickAndWait("link={$lang['strdatabases']}");
23 24
 	$t->clickAndWait("//tr/td/a[text()='{$testdb}']/../../td/a[text()='{$lang['strdrop']}']");
@@ -25,6 +26,7 @@
25 26
 	$t->assertText('//p[@class=\'message\']', $lang['strdatabasedroppedbad']);
26 27
 
27 28
 /** 2 **/
  29
+	$t->addComment('2. logout / login as admin_user and drop user role/user');
28 30
 	$t->logout();
29 31
 	$t->login($admin_user, $admin_pass);
30 32
 	if ($data->hasRoles()) {
@@ -40,6 +42,7 @@
40 42
 	}
41 43
 
42 44
 /** 3 **/
  45
+	$t->addComment('3. try to drop himself -> fail');
43 46
 	if ($data->hasRoles()) {
44 47
 		$t->clickAndWait("link={$lang['strroles']}");
45 48
 		$t->clickAndWait("link={$admin_user}");
@@ -55,6 +58,7 @@
55 58
 	}
56 59
 
57 60
 /** 4 **/
  61
+	$t->addComment('4. drop domain -> fail table promo depend on it');
58 62
 	$t->clickAndWait("link={$lang['strdatabases']}");
59 63
 	$t->clickAndWait("link={$testdb}");
60 64
 	$t->clickAndWait("link={$lang['strschemas']}");
@@ -65,6 +69,7 @@
65 69
 	$t->assertText('//p[@class=\'message\']', $lang['strdomaindroppedbad']);
66 70
 
67 71
 /** 5 **/
  72
+	$t->addComment('5. drop domain with cascade, test if promo.year disapeared');
68 73
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strdatabase']}']/span[@class='label' and text()='{$testdb}']");
69 74
 	$t->clickAndWait("link={$lang['strschemas']}");
70 75
 	$t->clickAndWait("link=test_schema");
@@ -81,6 +86,7 @@
81 86
 	$t->clickAndWait("link=year");
82 87
 
83 88
 /** 6 **/
  89
+	$t->addComment('6. drop table student with cascade using the action button');
84 90
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
85 91
 	$t->clickAndWait("link={$lang['strdatabases']}");
86 92
 	$t->clickAndWait("link={$testdb}");
@@ -92,6 +98,7 @@
92 98
 	$t->assertText('//p[@class=\'message\']', $lang['strtabledropped']);
93 99
 
94 100
 /** 7 **/
  101
+	$t->addComment('7. drop table promo using the button from tblproperties');
95 102
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
96 103
 	$t->clickAndWait("link={$lang['strdatabases']}");
97 104
 	$t->clickAndWait("link={$testdb}");
@@ -104,6 +111,7 @@
104 111
 	$t->assertText('//p[@class=\'message\']', $lang['strtabledropped']);
105 112
 	
106 113
 /** 8 **/
  114
+	$t->addComment('8. drop test database');
107 115
 	$t->clickAndWait("//div[@class='trail']/descendant::a[@title='{$lang['strserver']}']/span[@class='label' and text()='{$server['desc']}']");
108 116
 	$t->clickAndWait("link={$lang['strdatabases']}");
109 117
 	$t->clickAndWait("//tr/td/a[text()='{$testdb}']/../../td/a[text()='{$lang['strdrop']}']");
@@ -111,6 +119,7 @@
111 119
 	$t->assertText('//p[@class=\'message\']', $lang['strdatabasedropped']);
112 120
 
113 121
 /** 9 **/
  122
+	$t->addComment('9. logout & login as superuser and drop admin_user');
114 123
 	$t->logout();
115 124
 	$t->login($super_user[$server['desc']], $super_pass[$server['desc']]);
116 125
 
6  tests/selenium/testBuilder.class.php
@@ -62,6 +62,10 @@ public function test($action, $selector, $value='') {
62 62
 			$this->code .= "<tr>\n<td>$action</td>\n<td>$selector</td>\n<td>$value</td>\n</tr>\n";
63 63
 		}
64 64
 
  65
+		public function addComment($c) {
  66
+			$this->code .= "<tr>\n<th colspan=\"3\">{$c}</th>\n</tr>\n";
  67
+		}
  68
+
65 69
 		/**
66 70
 		 * Add steps to login on PPA using the given credentials
67 71
 		 * @param $u The username to use
@@ -69,6 +73,7 @@ public function test($action, $selector, $value='') {
69 73
 		 */
70 74
 		public function login($u, $p) {
71 75
 			global $webUrl, $data;
  76
+			$this->addComment("Login as {$u}");
72 77
 			$this->test('open', "{$webUrl}/login.php?server={$data->conn->host}&subject=server");
73 78
 			$this->test('type', "//input[@name='loginUsername']", $u);
74 79
 			$this->test('type', "//input[@id='loginPassword']", $p);
@@ -82,6 +87,7 @@ public function login($u, $p) {
82 87
 		public function logout() {
83 88
 			global $lang;
84 89
 
  90
+			$this->addComment("Logout");
85 91
 			$this->test('clickAndWait', "//div[@class='trail']/descendant::tr/td[1]/a/span[@class='label' and text()='phpPgAdmin']");
86 92
 			$this->test('clickAndWait', "link={$lang['strservers']}");
87 93
 			$this->test('clickAndWait', "//tr/td/a[text()='{$this->servDesc}']/../../td/a[text()='{$lang['strlogout']}']");

0 notes on commit 82ed178

Please sign in to comment.
Something went wrong with that request. Please try again.