Skip to content

Commit

Permalink
Update/Add selenium tests
Browse files Browse the repository at this point in the history
- 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
ioguix committed Dec 14, 2008
1 parent 99b3160 commit 82ed178
Show file tree
Hide file tree
Showing 17 changed files with 417 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/selenium/README
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions tests/selenium/selenium-lib/core/TestRunner.hta
Expand Up @@ -88,6 +88,9 @@ to work-around a bug in IE on Win2K whereby the HTA application doesn't function
<div id="imageButtonPanel">
<button type="button" id="runSuite" onClick="htmlTestRunner.startTestSuite();"
title="Run All tests" accesskey="a">
</button>
<button type="button" id="runRemainTests" onClick="htmlTestRunner.runRemainTests();"
title="Run the tests from the selected" accesskey="f">
</button>
<button type="button" id="runSeleniumTest" onClick="htmlTestRunner.runSingleTest();"
title="Run the Selected test" accesskey="r">
Expand Down
3 changes: 3 additions & 0 deletions tests/selenium/selenium-lib/core/TestRunner.html
Expand Up @@ -89,6 +89,9 @@ <h1><a href="http://selenium.thoughtworks.com" title="The Selenium Project">Sele
<button type="button" id="runSuite" onClick="htmlTestRunner.startTestSuite();"
title="Run All tests" accesskey="a">
</button>
<button type="button" id="runRemainTests" onClick="htmlTestRunner.runRemainTests();"
title="Run the tests from the selected" accesskey="f">
</button>
<button type="button" id="runSeleniumTest" onClick="htmlTestRunner.runSingleTest();"
title="Run the Selected test" accesskey="r">
</button>
Expand Down
Expand Up @@ -144,6 +144,12 @@ objectExtend(HtmlTestRunner.prototype, {
this.currentTest.start();
},

runRemainTests:function() {
this.runAllTests = true;
this.metrics.resetMetrics();
this.startTest();
},

runSingleTest:function() {
this.runAllTests = false;
this.metrics.resetMetrics();
Expand Down
5 changes: 5 additions & 0 deletions tests/selenium/selenium-lib/core/selenium.css
Expand Up @@ -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");
}
Expand Down
6 changes: 6 additions & 0 deletions tests/selenium/src/01-roles.php
Expand Up @@ -16,9 +16,11 @@
);

/* 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']}");
Expand All @@ -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');
Expand All @@ -48,11 +51,13 @@
$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']}");
Expand All @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions tests/selenium/src/04-database.php
Expand Up @@ -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']}");

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/selenium/src/06-schema.php
Expand Up @@ -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']}");
Expand All @@ -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']}']");
Expand Down
5 changes: 5 additions & 0 deletions tests/selenium/src/08-domaine.php
Expand Up @@ -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']}");
Expand Down Expand Up @@ -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']}");
Expand All @@ -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']}");
Expand All @@ -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']}");
Expand All @@ -97,6 +101,7 @@
}

/** 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']}");
Expand Down
9 changes: 9 additions & 0 deletions tests/selenium/src/10-table.php
Expand Up @@ -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']}");
Expand Down Expand Up @@ -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");
Expand All @@ -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']}");
Expand Down Expand Up @@ -102,7 +105,9 @@
}

/** 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");
Expand All @@ -116,6 +121,7 @@
$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");
Expand All @@ -130,6 +136,7 @@

/*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");
Expand All @@ -145,6 +152,7 @@

/*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");
Expand All @@ -157,6 +165,7 @@
}

/** 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())
Expand Down
4 changes: 4 additions & 0 deletions tests/selenium/src/15-sequence.php
Expand Up @@ -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']}");
Expand All @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
112 changes: 112 additions & 0 deletions tests/selenium/src/20-constraint.php
@@ -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);
?>

0 comments on commit 82ed178

Please sign in to comment.