diff --git a/modules/create_timepoint/test/create_timepointTest.php b/modules/create_timepoint/test/create_timepointTest.php index 4b75c643479..3f36c961235 100644 --- a/modules/create_timepoint/test/create_timepointTest.php +++ b/modules/create_timepoint/test/create_timepointTest.php @@ -7,6 +7,7 @@ * @category Test * @package Test * @author Gregory Luneau + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -70,33 +71,100 @@ function testCreateTimepointDoespageLoad() * * @return void */ - function testCreateTimepointSelectSubproject() + function testCreateTimepoint() + { + $this->_createTimepoint('900000','Experimental','V1'); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $this->assertContains("New time point successfully registered", $bodyText); + + } + /** + * Tests that, create a timepoint and test the success link + * + * + * @return void + */ + function testCreateTimepointSuccessLink() + { + $this->_createTimepoint('900000','Experimental','V9'); + + $this->safeClick(WebDriverBy::LinkText("Click here to continue.")); + sleep(3); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("V9", $bodyText); + + } + + /** + * Tests that, create a timepoint and input a error format visit label + * get Error message + * + * @return void + */ + function testCreateTimepointErrorVisitLabel() + { + $this->_createTimepoint('900000','Experimental','V9999'); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("This visit label does not match the required structure.", $bodyText); + + } + + /** + * Create a timepoint with three parameters. + * + * @param string $canID ID of candidate + * @param string $subproject text of Subproject + * @param string $visitlabel + * @return void. + */ + private function _createTimepoint($canID, $subproject, $visitlabel) { - $this->markTestIncomplete("Create Timepoint Page Test not implemented"); - - /* $this->safeGet( - $this->url . "/create_timepoint/?candID=900000&identifier=900000" + $this->url . "/create_timepoint/?candID=" .$canID . "&identifier=" .$canID ); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); - $this->assertContains("Create Time Point", $bodyText); + $select = $this->safeFindElement(WebDriverBy::Name("subprojectID")); + $element = new WebDriverSelect($select); + $element->selectByVisibleText($subproject); - $subPS = $this->webDriver->findElement(WebDriverBy::Name("subprojectID")); - $subPS->sendKeys("subprojet 2\r"); + $this->webDriver->findElement(WebDriverBy::Name("visitLabel"))->sendKeys($visitlabel); + $this->webDriver->findElement(WebDriverBy::Name("fire_away"))->click(); + + } - $vl = $this->webDriver->findElement(WebDriverBy::Name("visitlabel")); - $vl->sendKeys("V06"); - $ctp = $this->webDriver->findElement(WebDriverBy::Name("fire_away")); - $ctp->click(); + /** + * Tests that, create a timepoint and input a empty subproject + * get Error message + * + * @return void + */ + function testCreateTimepointErrorEmptySubproject() + { + $this->safeGet( + $this->url . "/create_timepoint/?candID=900000&identifier=900000" + ); + $this->webDriver->findElement(WebDriverBy::Name("fire_away"))->click(); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("A visit label is required for creating a timepoint.", $bodyText); - $visitlabel = $this->webDriver->findElement( - WebDriverBy::cssSelector(".col-sm-12~ .col-sm-12+ .col-sm-12 label") - )->getText(); - $this->assertContains("Visit label", $visitlabel); - */ } - + /** + * Tests that timepoint loads with the permission + * + * @return void + */ + public function testCreateTimepointPermission() + { + $this->setupPermissions(array("data_entry")); + $this->safeGet($this->url . "/create_timepoint/?candID=900000&identifier=900000"); + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("body") + )->getText(); + + $this->assertNotContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + } } ?> + diff --git a/modules/dashboard/templates/form_dashboard.tpl b/modules/dashboard/templates/form_dashboard.tpl index bb99e048c2e..f3e7fcb04ca 100644 --- a/modules/dashboard/templates/form_dashboard.tpl +++ b/modules/dashboard/templates/form_dashboard.tpl @@ -129,7 +129,7 @@
{if $conflicts neq "" and $conflicts neq 0} - +
{$conflicts}
@@ -144,7 +144,7 @@ {/if} {if $incomplete_forms neq "" and $incomplete_forms neq 0} {if $incomplete_forms_site eq "Site: all"} -
+ {else} {/if} @@ -175,7 +175,7 @@ {/if} {if $violated_scans neq "" and $violated_scans neq 0} - +
{$violated_scans}
diff --git a/modules/dashboard/test/DashboardTest.php b/modules/dashboard/test/DashboardTest.php index faa6b1bdeea..713e2892ab2 100644 --- a/modules/dashboard/test/DashboardTest.php +++ b/modules/dashboard/test/DashboardTest.php @@ -22,11 +22,224 @@ * @category Test * @package Loris * @author Tara Campbell + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ class DashboardTest extends LorisIntegrationTest { + + /** + * Setup the screen size of Travis-cs + * + * @return void + */ + function setUp() + { + parent::setUp(); + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1280, 1024); + $window->setSize($size); + //Insert a pending user + $this->DB->insert( + "users", + array( + 'UserID' => 'testUser1', + 'Email' => 'test@test.com', + 'Password' => 'AA1234567!', + 'CenterID' => '1', + 'Password_expiry' => '2020-01-06' + ) + ); + //Insert two violation scan + $this->DB->insert( + "psc", + array( + 'CenterID' => '55', + 'Name' => 'TESTinPSC', + 'Alias' => 'test', + 'MRI_alias' => 'test' + ) + + ); + $this->DB->insert( + "candidate", + array( + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'PSCID' => '8888', + 'ProjectID' => '7777', + 'Entity_type' => 'Human' + ) + ); + $this->DB->insert( + "session", + array( + 'ID' => '222222', + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'MRIQCStatus' => 'Pass', + 'SubprojectID' => '6666' + ) + ); + $this->DB->insert( + "mri_protocol_violated_scans", + array( + 'ID' => '1001', + 'CandID' => '999888', + 'PatientName' => '[Test]PatientName', + 'time_run' => '2009-06-29 04:00:44', + 'minc_location' => 'assembly/test/test/mri/test/test.mnc', + 'series_description' => 'Test Series Description', + 'SeriesUID' => '5555' + ) + ); + $this->DB->insert( + "mri_protocol_violated_scans", + array( + 'ID' => '1002', + 'CandID' => '999888', + 'PatientName' => '[Test]PatientName', + 'time_run' => '2008-06-29 04:00:44', + 'minc_location' => 'assembly/test2/test2/mri/test2/test2.mnc', + 'series_description' => 'Test Series Description', + 'SeriesUID' => '5556' + ) + ); + $this->DB->insert( + "violations_resolved", + array( + 'ExtID' => '1001', + 'TypeTable' => 'mri_protocol_violated_scans', + 'Resolved' => 'other' + ) + ); + $this->DB->insert( + "violations_resolved", + array( + 'ExtID' => '1002', + 'TypeTable' => 'MRICandidateErrors', + 'Resolved' => 'unresolved' + ) + ); + $this->DB->insert( + "MRICandidateErrors", + array( + 'ID' => '1002', + 'PatientName' => '[Test]PatientName', + 'MincFile' => 'assembly/test2/test2/mri/test2/test2.mnc', + 'SeriesUID' => '5556' + ) + ); + //Insert an incomplete form data + $this->DB->insert( + "test_names", + array( + 'ID' => '111', + 'Test_name' => 'TestName11111111111', + ) + ); + $this->DB->insert( + "flag", + array( + 'ID' => '111111', + 'SessionID' => '222222', + 'Test_name' => 'TestName11111111111', + 'CommentID' => 'commentID111', + 'Data_entry' => 'In Progress', + ) + ); + //Insert a demo data into conflicts_unresolved + $this->DB->insert( + "conflicts_unresolved", + array( + 'TableName' => 'TestTestTest', + 'ExtraKeyColumn' => 'Test', + 'ExtraKey1' => 'Null', + 'ExtraKey2' => 'Null', + 'FieldName' => 'TestTestTest', + 'CommentId1' => '963443000111271151398976899', + 'Value1' => 'no', + 'CommentId2' => 'DDE_963443000111271151398976899', + 'Value2' => 'no', + ) + ); + + } + + + //Delete the test data + public function tearDown() + { + $this->DB->delete( + "users", + array('UserID'=>'testUser1') + ); + $this->DB->delete( + "session", + array('CandID' => '999888','CenterID' => '55') + ); + $this->DB->delete( + "candidate", + array('CandID' => '999888','CenterID' => '55') + ); + $this->DB->delete( + "mri_protocol_violated_scans", + array( + 'ID' => '1001', + 'CandID' => '999888' + ) + ); + $this->DB->delete( + "mri_protocol_violated_scans", + array( + 'ID' => '1002', + 'CandID' => '999888' + ) + ); + $this->DB->delete( + "violations_resolved", + array( + 'ExtID' => '1001', + 'TypeTable' => 'mri_protocol_violated_scans' + ) + ); + $this->DB->delete( + "MRICandidateErrors", + array( + 'ID' => '1002' + ) + ); + $this->DB->delete( + "violations_resolved", + array( + 'ExtID' => '1002', + 'TypeTable' => 'mri_protocol_violated_scans' + ) + ); + $this->DB->delete( + "psc", + array('CenterID' => '55', 'Name' => 'TESTinPSC') + ); + $this->DB->delete( + "flag", + array('CommentID' => 'commentID111') + ); + $this->DB->delete( + "test_names", + array('ID' => '111') + ); + $this->DB->delete( + "conflicts_unresolved", + array('TableName'=>'TestTestTest') + ); + parent::tearDown(); + } + + + /** * Tests that, when loading the Dashboard, the word "Welcome" appears * in the welcome panel @@ -36,10 +249,119 @@ class DashboardTest extends LorisIntegrationTest public function testDashboardPageLoads() { $this->safeGet($this->url . '/dashboard/'); - $welcomeText = $this->webDriver ->findElement(WebDriverBy::cssSelector(".welcome"))->getText(); $this->assertContains("Welcome", $welcomeText); } + + /** + * To test that, when loading the Dashboard, click the Views button of + * Recruitment, the items "View overall recruitment" and "View site breakdown" + * appear + * author : Wang Shen + * + * @return void + */ + public function testDashboardRecruitmentView() + { + $this->safeGet($this->url . '/dashboard/'); + $views = $this->webDriver + ->findElement( + WebDriverBy::Xpath( + "//*[@id='lorisworkspace']/div/di". + "v[1]/div[2]/div[1]/div/div/button" + ) + ); + $views->click(); + + $assertText1 = $this->webDriver + ->findElement( + WebDriverBy::XPath( + "//*[@id='lorisworkspace']/div/div[1]". + "/div[2]/div[1]/div/div/ul/li[1]/a" + ) + )->getText(); + $assertText2 = $this->webDriver + ->findElement( + WebDriverBy::XPath( + "//*[@id='lorisworkspace']/div/div[1]". + "/div[2]/div[1]/div/div/ul/li[2]/a" + ) + )->getText(); + $this->assertContains("View overall recruitment", $assertText1); + $this->assertContains("View site breakdown", $assertText2); + } + + /** + * Tests that, when loading the Dashboard and Config,the number of the Target + * number of participants should be same. + * + * @return void + */ + public function testPendingUser() + { + $this->setupPermissions( + array( + "user_accounts_multisite","user_accounts" + ) + ); + $this->_testMytaskPanelAndLink(".pending-accounts","1","testUser1"); + $this->resetPermissions(); + } + + public function testMriViolations() + { + $this->setupPermissions( + array( + "violated_scans_view_allsites" + ) + ); + $this->_testMytaskPanelAndLink(".mri_violations","2","[Test]PatientName"); + $this->resetPermissions(); + } + + public function testIncompleteForm() + { + + $this->setupPermissions( + array( + "data_entry","access_all_profiles" + ) + ); + $this->safeGet($this->url . '/dashboard/'); + $this->_testMytaskPanelAndLink(".statistics","1","Welcome to the statistics page."); + $this->resetPermissions(); + } + public function testDataEntryConflicts() + { + $this->setupPermissions( + array( + "conflict_resolver","access_all_profiles" + ) + ); + $this->safeGet($this->url . '/dashboard/'); + $this->_testMytaskPanelAndLink(".conflict_resolver","1","TestTestTest"); + $this->resetPermissions(); + } + public function testToDo() + { + $this->safeGet($this->url . '/dashboard/'); + sleep(30); + } + private function _testMytaskPanelAndLink($className,$value,$dataSeed) + { + $this->safeGet($this->url . '/dashboard/'); + sleep(5); + $link = $this->webDriver + ->findElement(WebDriverBy::cssSelector($className)); + $bodyText = $link->findElement(WebDriverBy::cssSelector(".huge"))->getText(); + $this->assertContains($value, $bodyText); + $link->click(); + sleep(5); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains($dataSeed, $bodyText); + + } + } ?> diff --git a/modules/dicom_archive/test/dicom_archiveTest.php b/modules/dicom_archive/test/dicom_archiveTest.php index 516611dc459..f804158d79d 100644 --- a/modules/dicom_archive/test/dicom_archiveTest.php +++ b/modules/dicom_archive/test/dicom_archiveTest.php @@ -1,12 +1,13 @@ + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -14,6 +15,64 @@ require_once __DIR__ . "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; class dicomArchiveTestIntegrationTest extends LorisIntegrationTest { + + /** + * Insert testing data into the database + * + * @return none + */ + function setUp() + { + parent::setUp(); +// $window = new WebDriverWindow($this->webDriver); + // $size = new WebDriverDimension(1600,1200); + // $window->setSize($size); + $this->DB->insert( + "tarchive", + array( + 'DicomArchiveID' => '9999999999', + 'PatientID' => '9999999999', + 'PatientName' => 'TestTestTest', + 'PatientDoB' => '1900-01-01', + 'PatientGender' => 'M', + 'neurodbCenterName' => 'NULL', + 'CenterName' => 'Mc Gill University', + 'LastUpdate' => '2014-05-30 13:49:36', + 'DateAcquired' => '2010-11-25', + 'DateFirstArchived' => '2014-05-30 13:47:11', + 'DateLastArchived' => '2014-05-30 13:49:36', + 'AcquisitionCount' => '166', + 'NonDicomFileCount' => '0', + 'DicomFileCount' => '881', + 'md5sumDicomOnly' => '5.150346.tar', + 'md5sumArchive' => '5.150346.tar', + 'CreatingUser' => 'lorisadmin', + 'sumTypeVersion' => '1', + 'tarTypeVersion' => '1', + 'SourceLocation' => '/tmp/bEu0Q_egfA/5.150346', + 'ArchiveLocation' => '2010/DCM5.150346.tar', + 'ScannerManufacturer' => 'SIEMENS', + 'ScannerModel' => 'TrioTim', + 'ScannerSerialNumber' => '35056', + 'ScannerSoftwareVersion' => 'syngo MR B15', + 'SessionID' => '44', + 'uploadAttempt' => '0', + 'CreateInfo' => 'NULL', + ) + ); + } + /** + * Delete testing data from database + * + * @return none + */ + function tearDown() + { + parent::tearDown(); + $this->DB->delete("tarchive", array('PatientName' => 'TestTestTest')); + } + + /** * Tests that, when loading the dicom_archive module, some * text appears in the body. @@ -22,10 +81,32 @@ class dicomArchiveTestIntegrationTest extends LorisIntegrationTest */ function testdicomArchiveDoespageLoad() { + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1600,1200); + $window->setSize($size); $this->safeGet($this->url . "/dicom_archive/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertContains("Dicom Archive", $bodyText); } + /** + * Tests that help editor loads with the permission + * + * @return void + */ + function testDicomArchivePermission() + { + $this->setupPermissions(array("dicom_archive_view_allsites")); + $this->safeGet($this->url . "/dicom_archive/"); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertNotContains( + "You do not have access to this page.", + $bodyText + ); + $this->resetPermissions(); + } /** * Tests that, when loading the dicom_archive module > viewDetails subtest, some @@ -36,8 +117,95 @@ function testdicomArchiveDoespageLoad() function testdicomArchiveViewDetailsDoespageLoad() { $this->safeGet($this->url . "/dicom_archive/viewDetails/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertContains("View Details", $bodyText); } + /** + * Tests that, when loading the dicom_archive module > viewDetails subtest, some + * text appears in the body. + * + * @return void + */ + function testdicomArchivFilterClearBtn() + { + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1600,1200); + $window->setSize($size); + //testing the Patient Name + $this->safeGet($this->url . "/dicom_archive/"); + $nameElement = $this->safeFindElement(WebDriverBy::Name("PatientName")); + $nameElement->sendKeys("TestPatientName"); + $this->safeClick(WebDriverBy::Name("reset")); + $name = $this->safeFindElement(WebDriverBy::Name("PatientName")) + ->getAttribute('value'); + $this->assertEquals('', $name); + //testing the Archive Location + $locationElement = $this->safeFindElement(WebDriverBy::Name("Location")); + $locationElement->sendKeys("TestLocation"); + $this->safeClick(WebDriverBy::Name("reset")); + $location = $this->safeFindElement(WebDriverBy::Name("Location")) + ->getAttribute('value'); + $this->assertEquals('', $location); + //testing the Patient ID + $idElement = $this->safeFindElement(WebDriverBy::Name("PatientID")); + $idElement->sendKeys("TestID"); + $this->safeClick(WebDriverBy::Name("reset")); + $idText = $this->safeFindElement(WebDriverBy::Name("PatientID")) + ->getAttribute('value'); + $this->assertEquals('', $idText); + //testing the Gender + $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); + $gender = new WebDriverSelect($genderElement); + $gender->selectByVisibleText("Male"); + $this->safeClick(WebDriverBy::Name("reset")); + $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); + $gender = new WebDriverSelect($genderElement); + $value = $gender->getFirstSelectedOption()->getAttribute('value'); + $this->assertEquals("", $value); + + } + /** + * Tests filter with Patient Name + * data appears in the body. + * + * @return void + */ + function testdicomArchiveFileterByName() + { + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1600,1200); + $window->setSize($size); + //testing the Patient Name + $this->safeGet($this->url . "/dicom_archive/"); + $nameElement = $this->safeFindElement(WebDriverBy::Name("PatientName")); + $nameElement->sendKeys("TestTestTest"); + $this->safeClick(WebDriverBy::Name("filter")); + $name = $this->safeFindElement(WebDriverBy::cssSelector("tbody")) + ->getText(); + $this->assertContains('TestTestTest', $name); + } + /** + * Tests filter with DateOfBirth + * data appears in the body. + * + * @return void + */ + function testdicomArchiveFileterByDateOfBirth() + { + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1600,1200); + $window->setSize($size); + //testing the Patient Name + $this->safeGet($this->url . "/dicom_archive/"); + $DoBElement = $this->safeFindElement(WebDriverBy::Name("DoB")); + $DoBElement->sendKeys("1900-01-01"); + $this->safeClick(WebDriverBy::Name("filter")); + $DoB = $this->safeFindElement(WebDriverBy::cssSelector("tbody")) + ->getText(); + $this->assertContains('1900-01-01', $DoB); + } + + } -?> \ No newline at end of file +?> diff --git a/modules/document_repository/test/document_repositoryTest.php b/modules/document_repository/test/document_repositoryTest.php index 1c51348fc73..ad19d584f66 100644 --- a/modules/document_repository/test/document_repositoryTest.php +++ b/modules/document_repository/test/document_repositoryTest.php @@ -1,4 +1,4 @@ - + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ -require_once __DIR__ . "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; +require_once __DIR__ . + "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; class documentRepositoryTestIntegrationTest extends LorisIntegrationTest { + + /** + * Does basic setting up of Loris variables for this test,after testing + * a test data, remove the testing data from database. + * @return none + */ + public function setUp() + { + parent::setUp(); +$this->DB->insert( + "document_repository_categories", + array( + 'id' => '9999999', + 'category_name' => 'TESTTESTTESTTEST', + 'parent_id' => '0', + 'comments' => 'Test Comment' + ) + ); +$this->DB->insert( + "document_repository", + array( + 'record_id' => '9999999', + 'Date_uploaded' => '2016-05-16 15:34:35', + 'Data_dir' => 'admin/README.md', + 'File_name' => 'README.md', + 'File_type' => 'NULL', + + 'File_size' => '3305', + 'uploaded_by' => 'admin', + 'For_site' => '3', + 'comments' => 'tester', + 'multipart' => 'NULL', + 'EARLI' => '0', + 'hide_video' => '0', + 'File_category' => '9999999' + ) + ); + + } + + public function tearDown() { + $this->DB->delete("document_repository_categories", + array('category_name' => 'TestTestTest')); + $this->DB->delete("document_repository_categories", + array('category_name' => 'test')); + $this->DB->delete("document_repository_categories", + array('id' => '9999999')); + $this->DB->delete("document_repository", + array('record_id' => '9999999')); + parent::tearDown(); + } + + + + + /** * Tests that, when loading the document_repository module, some * text appears in the body. @@ -23,8 +81,113 @@ class documentRepositoryTestIntegrationTest extends LorisIntegrationTest function testDocumentRepositoryDoespageLoad() { $this->safeGet($this->url . "/document_repository/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Document Repository", $bodyText); } + /** + * Tests creating a category and a sub category. + * + * @return void + */ + function testDocumentRepositoryCreateCategory() + { + //insert a category TestTestTest + $this->safeGet($this->url . "/document_repository/"); + $this->safeFindElement(WebDriverBy::Name("addCategory"), + 3000)->click(); + $this->safeFindElement(WebDriverBy::Name( + "category_name"),3000)->sendKeys("TestTestTest"); + $this->safeFindElement(WebDriverBy::Id("postCategory"))->click(); + sleep(10); + $selectAll = $this->webDriver->findElement( + WebDriverBy::Id("dir-tree"))->getText(); + $this->assertContains("TestTestTest", $selectAll); + + //insert a sub category test under TestTestTest + $this->safeGet($this->url . "/document_repository/"); + $this->safeFindElement(WebDriverBy::Name("addCategory"),2000)->click(); + $this->safeFindElement(WebDriverBy::Name("category_name") + )->sendKeys("test"); + $select = $this->safeFindElement(WebDriverBy::Id("parent_id")); + $element = new WebDriverSelect($select); + $element->selectByVisibleText("TestTestTest"); + $this->safeFindElement(WebDriverBy::Id("postCategory"))->click(); + sleep(10); + $this->safeFindElement( + WebDriverBy::Xpath("//*[@id='TestTestTesta']/td/span"))->click(); + $test = $this->safeFindElement(WebDriverBy::Id("testa"))->getText(); + $this->assertContains("test", $test); + + } + /** + * Tests that, upload function in document_repository module + * + * @return void + */ + function testDocumentRepositoryUploadFile() + { + //check a upload file under TestTestTest category + $this->safeGet($this->url . "/document_repository/"); + $this->safeFindElement( + WebDriverBy::Xpath("//*[@id='TESTTESTTESTTESTa']/td/span"))->click(); + $test = $this->safeFindElement(WebDriverBy::linkText("README.md"))->getText(); + $this->assertContains("README.md", $test); + + + // delete upload file + + } + + /** + * Tests that, upload function in document_repository module + * + * @return void + */ + function testDocumentRepositoryUploadFileEditDeleteComment() + { + $this->safeGet($this->url . "/document_repository/"); + $this->safeFindElement( + WebDriverBy::Xpath("//*[@id='TESTTESTTESTTESTa']/td/span"))->click(); + $this->safeFindElement( + WebDriverBy::Id("9999999"))->click(); + + + // modify comment,search it and check it + $select = $this->safeFindElement(WebDriverBy::Id("categoryEdit")); + $element = new WebDriverSelect($select); + $element->selectByVisibleText("TESTTESTTESTTEST"); + $site = $this->safeFindElement(WebDriverBy::Id("siteEdit")); + $elementSite = new WebDriverSelect($site); + $elementSite->selectByVisibleText("Any"); + $this->safeFindElement(WebDriverBy::Id("commentsEdit")) + ->sendKeys("This is a test comment!"); + $this->safeFindElement(WebDriverBy::Id("postEdit"))->click(); + sleep(5); + + $this->safeFindElement(WebDriverBy::Name + ("File_name"))->sendKeys("README.md"); + $this->safeFindElement(WebDriverBy::Name + ("filter"))->click(); + $text = $this->safeFindElement(WebDriverBy::cssSelector + ("#dir-tree > tr"),3000) + ->getText(); + $this->assertContains("This is a test comment!", $text); + + // delete upload file + + $this->safeFindElement(WebDriverBy::linkText + ("Delete"),3000)->click(); + + $this->safeFindElement(WebDriverBy::Id("postDelete"))->click(); + $this->safeFindElement(WebDriverBy::Name + ("File_name"))->sendKeys("README.md"); + $this->safeFindElement(WebDriverBy::Name + ("filter"))->click(); + sleep(5); + $text = $this->safeFindElement(WebDriverBy::cssSelector("tbody"),3000)->getText(); + $this->assertEquals('',$text); + + } } -?> \ No newline at end of file +?> diff --git a/modules/examiner/test/ExaminerTest.php b/modules/examiner/test/ExaminerTest.php index 20e8e2d518c..7b46071eabf 100644 --- a/modules/examiner/test/ExaminerTest.php +++ b/modules/examiner/test/ExaminerTest.php @@ -7,6 +7,7 @@ * @category Test * @package Loris * @author Tara Campbell + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -22,11 +23,53 @@ * @category Test * @package Loris * @author Tara Campbell + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ class ExaminerTest extends LorisIntegrationTest { + /** + * Insert testing data + * + * @return void + */ + public function setUp() + { + parent::setUp(); + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1024, 1768); + $window->setSize($size); + $this->DB->insert( + "psc", + array( + 'CenterID' => '9999999', + 'Name' => 'TEST_Site', + 'Study_site' => 'Y', + 'StateID' => '0', + 'Alias' => 'DDD', + 'MRI_alias' => 'TESTTEST', + ) + ); + } + /** + * Delete testing data + * + * @return void + */ + public function tearDown() + { + $this->DB->delete( + "examiners", + array('full_name' => 'Test_Examiner') + ); + + $this->DB->delete( + "psc", + array('Name' => 'TEST_Site') + ); + parent::tearDown(); + } /** * Tests that the breadcrumb loads, which it should regardless of the user's @@ -37,6 +80,7 @@ class ExaminerTest extends LorisIntegrationTest public function testBreadcrumbLoads() { $this->safeGet($this->url . "/examiner/"); +// sleep(100); $breadcrumbText = $this->webDriver ->findElement(WebDriverBy::id("breadcrumbs"))->getText(); $this->assertContains("Examiner", $breadcrumbText); @@ -90,7 +134,6 @@ function testSelectionFilterLoadsWithPermission() $this->resetPermissions(); } - /** * Tests that the Add Examiner form loads if the user has the correct permission * @@ -149,7 +192,6 @@ function testResultTableLoadsWithPermission() $this->resetPermissions(); } - /** * Tests that the certification column loads if EnableCertification is set in * the config @@ -158,17 +200,12 @@ function testResultTableLoadsWithPermission() */ function testExaminerLoadsCertificationElements() { - $this->markTestIncomplete("Test not implemented!"); - /*$this->setupConfigSetting('EnableCertification', '1'); + $this->_setupConfigSetting('EnableCertification', '1'); $this->safeGet($this->url . "/examiner/"); - + // Check that the certification column appears - $tableText = $this->webDriver->findElement( - WebDriverBy::cssSelector(".table-responsive") - )->getText(); - $this->assertContains("Certification", $tableText); - - $this->restoreConfigSetting("EnableCertification");*/ + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("Certification", $bodyText); } /** @@ -179,17 +216,9 @@ function testExaminerLoadsCertificationElements() */ function testExaminerDoesNotLoadCertificationElements() { - $this->markTestIncomplete("Test not implemented!"); - /*$this->setupConfigSetting('EnableCertification', '0'); $this->safeGet($this->url . "/examiner/"); - - // Check that the certification column does not appear - $tableText = $this->webDriver->findElement( - WebDriverBy::cssSelector(".table-responsive") - )->getText(); + $bodyText = $this->webDriver->getPageSource(); $this->assertNotContains("Certification", $bodyText); - - $this->restoreConfigSetting("EnableCertification");*/ } /** @@ -208,5 +237,86 @@ function testExaminerDoesNotLoadWithoutPermission() $this->assertContains("You do not have access to this page.", $bodyText); $this->resetPermissions(); } + /** + * Tests that examiner selection filter, search a Examiner name + * and click clear form, the input data should disappear. + * + * @return void + */ + function testExaminerFilterClearForm() + { + $this->safeGet($this->url . "/examiner/"); + $this->webDriver->findElement( + WebDriverBy::Name("examiner") + )->sendKeys("XXXX"); + $this->webDriver->findElement( + WebDriverBy::Name("reset") + )->click(); + $bodyText = $this->safeFindElement( + WebDriverBy::Name("examiner") + )->getText(); + $this->assertEquals("", $bodyText); + } + /** + * Tests that Add examiner section, insert an Examiner and find it. + * + * @return void + */ + function testExaminerAddExaminer() + { + //insert a new exmainer with name "Test_Examiner" and radiologist + //in the TEST_Site. + $this->safeGet($this->url . "/examiner/"); + $this->safeFindElement( + WebDriverBy::Name("addName") + )->sendKeys("Test_Examiner"); + $this->safeFindElement( + WebDriverBy::Name("addRadiologist") + )->click(); + $select = $this->safeFindElement(WebDriverBy::Name("addSite")); + $element = new WebDriverSelect($select); + $element->selectByVisibleText("TEST_Site"); + $bodyText = $this->safeFindElement( + WebDriverBy::Name("fire_away") + )->click(); + sleep(5); + //search the examiner which inserted + $this->webDriver->findElement( + WebDriverBy::Name("examiner") + )->sendKeys("Test_Examiner"); + $this->webDriver->findElement( + WebDriverBy::Name("filter") + )->click(); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertContains("Test_Examiner", $bodyText); + + } + private function _setupConfigSetting($node,$value) + { + // Set up database wrapper and config +// $this->factory = NDB_Factory::singleton(); + // $this->factory->reset(); + // $this->factory->setTesting(false); + + // $this->config = $this->factory->Config(CONFIG_XML); + // var_dump($this->config); + // $this->config->$node = $value; + // $newXml = $solrXml->asXML(); + +// $fp = fopen("solrConfig.xml","w+"); + + $Xml = simplexml_load_file("../project/config.xml"); +// print_r($Xml); + $Xml->EnableCertification = '1'; +// $Xml->page[1]->page[0]->layout = "1"; + $newXml = $Xml->asXML(); + + print_r($newXml); + // $fp = fopen("../project/config.xml","w+"); + // fwrite($fp,$newXml); + + } } ?> diff --git a/modules/final_radiological_review/test/final_radiological_reviewTest.php b/modules/final_radiological_review/test/final_radiological_reviewTest.php index 65f1dfe2313..6472e00e0a6 100644 --- a/modules/final_radiological_review/test/final_radiological_reviewTest.php +++ b/modules/final_radiological_review/test/final_radiological_reviewTest.php @@ -6,7 +6,7 @@ * * @category Test * @package Loris - * @author Ted Strauss + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -15,35 +15,263 @@ class finalRadiologicalReviewTestIntegrationTest extends LorisIntegrationTest { + public function setUp() + { + + parent::setUp(); + /** + * Insert testing data + * + * @return void + */ + $this->DB->insert( + 'test_names', + array( + 'Test_name' => 'testname99', + 'Full_name' => 'testname99' + ) + ); + + $this->DB->insert( + 'psc', + array( + 'CenterID' => '99', + 'Name' => 'DAC', + 'PSCArea' => 'DAC', + 'StateID' => 0, + 'Alias' => 'DAC', + 'MRI_alias' => 'DAC' + ) + ); + $this->DB->insert( + 'candidate', + array( + 'CandID' => '111222', + 'PSCID' => '111222', + 'CenterID' => '99', + 'DoB' => '2005-08-16' + ) + ); + $this->DB->insert( + 'session', + array( + 'ID' => '7777', + 'CandID' => '111222', + 'CenterID' => '99' + ) + ); + $this->DB->insert( + 'flag', + array( + 'SessionID' => '7777', + 'Test_name' => 'testname99', + 'CommentID' => 'testcid', + 'Administration' => 'All', + 'Data_entry' => 'Complete' + ) + ); + $this->DB->insert( + 'final_radiological_review', + array( + 'CommentID' => 'testcid', + 'Final_Review_Results' => 'normal', + 'Final_Exclusionary' => 'non_exclusionary', + 'SAS' => '1', + 'PVS' => '1' + ) + ); + $this->DB->insert( + 'radiology_review', + array( + 'CommentID' => 'testcid' + ) + ); + + } + /** + * Delete testing data + * + * @return void + */ + public function tearDown() + { + $this->DB->delete( + "radiology_review", + array('CommentID' => 'testcid') + ); + + $this->DB->delete( + "final_radiological_review", + array('CommentID' => 'testcid') + ); + $this->DB->delete( + "flag", + array('CommentID' => '111222') + ); + $this->DB->delete( + "session", + array('ID' => '7777') + ); + $this->DB->delete( + "candidate", + array('CandID' => '111222') + ); + $this->DB->delete( + "psc", + array('CenterID' => '99') + ); + $this->DB->delete( + "test_names", + array('Test_name' => 'testname99') + ); + + parent::tearDown(); + } + + /** + * Tests that the final Radiological Review loads if the user has the correct + * permissions (edit_final_radiological_review or view_final_radiological_review) + * It should only be able to see the menu item. + * @return void + */ + function testFinalRadiologicalReviewLoadsWithPermission() + { + $this->setupPermissions(array("edit_final_radiological_review")); + $this->safeGet($this->url . "/final_radiological_review/"); + + // Test that the Imaging menu appears in the first row + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("#example-navbar-collapse > ul:nth-child(1) > li:nth-child(1) > a") + )->getText(); + $this->assertContains("Imaging", $bodyText); + + $this->resetPermissions(); + } + /** + * Tests that the final Radiological Review loads if the user has the correct + * permissions (view_final_radiological_review) + * It should find filter section + * @return void + */ + function testPermissionWithViewFinalRadiologicalReview() + { + $this->setupPermissions(array("view_final_radiological_review")); + $this->safeGet($this->url . "/final_radiological_review/"); + + // Test that the Imaging menu appears in the first row + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertContains("Selection Filter", $bodyText); + + $this->resetPermissions(); + } /** - * Tests that, when loading the final_radiological_review module, some - * text appears in the body. - * + * Tests filter section, input some data which database doesn't have + * and search it, it shows no data is found. * @return void */ - function testFinalRadiologicalReviewDoespageLoad() + function testFinalRadiologicalReviewFilterWithNullResult() { - $this->markTestSkipped("The radiology_review instrument is missing for final_radiological_review test"); - /*$this->safeGet($this->url . "?test_name=final_radiological_review"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); - $this->assertContains("Final Radiological Review", $bodyText); - */ + $this->safeGet($this->url . "/final_radiological_review/"); + + // search a null data, get nothing found. + $this->webDriver->findElement( + WebDriverBy::Name("keyword") + )->sendKeys("hello test"); + $this->webDriver->findElement( + WebDriverBy::Name("filter") + )->click(); + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertContains("Nothing found", $bodyText); + } /** - * Tests that, when loading the final_radiological_review module > final_radiological_review submodule, some - * text appears in the body. - * + * Tests filter section, input data which database exists + * and search it, it shows the data. + * @return void + */ + function testFinalRadiologicalReviewFilterWithResult() + { + $this->safeGet($this->url . "/final_radiological_review/"); + + // search a testing data by PSCID, get the result. + $this->webDriver->findElement( + WebDriverBy::Name("pscid") + )->sendKeys("111222"); + $this->webDriver->findElement( + WebDriverBy::Name("filter") + )->click(); + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("#datatable > div > div > div > table > tbody > tr > td:nth-child(3)") + )->getText(); + $this->assertContains("111222", $bodyText); + + // search a testing data by DCCID, get the result. + $this->webDriver->findElement( + WebDriverBy::Name("dccid") + )->sendKeys("111222"); + $this->webDriver->findElement( + WebDriverBy::Name("filter") + )->click(); + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("#datatable > div > div > div > table > tbody > tr > td:nth-child(3)") + )->getText(); + $this->assertContains("111222", $bodyText); + + } + + /** + * Tests filter section,clear button. + * @return void + */ + function testFinalRadiologicalReviewFilterClearBtn() + { + $this->safeGet($this->url . "/final_radiological_review/"); + + $this->webDriver->findElement( + WebDriverBy::Name("pscid") + )->sendKeys("111222"); + $this->webDriver->findElement( + WebDriverBy::Name("reset") + )->click(); + $bodyText = $this->webDriver->findElement( + WebDriverBy::Name("pscid"))->getText(); + $this->assertEquals("", $bodyText); + + + } + /** + * Tests that PSCID column should be hyperlinks. * @return void */ - function testFinalRadiologicalReviewSubtestDoespageLoad() - { - $this->markTestSkipped("The radiology_review instrument is missing for final_radiological_review test"); - /* - $this->safeGet($this->url . "?test_name=final_radiological_review&subtest=final_radiological_review"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); - $this->assertContains("Final Radiological Review", $bodyText); - */ + function testFinalRadiologicalReviewPscidLink() + { + $this->safeGet($this->url . "/final_radiological_review/"); + + $this->webDriver->findElement( + WebDriverBy::Name("pscid") + )->sendKeys("111222"); + $this->webDriver->findElement( + WebDriverBy::Name("filter") + )->click(); + + $this->webDriver->findElement( + WebDriverBy::cssSelector(" + #datatable > div > div > div > table > tbody >". + " tr:nth-child(1) > td:nth-child(2) > a")) + ->click(); + $bodyText = $this->safeFindElement( + WebDriverBy::ID("final_review") + )->getText(); + $this->assertContains("111222", $bodyText); + + // $this->assertEquals("", $bodyText); + + } } diff --git a/modules/genomic_browser/test/genomic_browserTest.php b/modules/genomic_browser/test/genomic_browserTest.php index 78a8dcfd241..8c39b01be3c 100644 --- a/modules/genomic_browser/test/genomic_browserTest.php +++ b/modules/genomic_browser/test/genomic_browserTest.php @@ -37,24 +37,17 @@ class GenomicBrowserTestIntegrationTest extends LorisIntegrationTest private function _getCNVFilters() { return array( - 'centerID', - 'SubprojectID', - 'DCCID', - 'gender', - 'External_ID', - 'PSCID', - 'Gene_Symbol', - 'Gene_Name', - 'Chromosome', - 'Platform', - 'CNV_Type', - 'Event_Name', - 'Characteristics', - 'Common_CNV', - 'Copy_Num_Change', - 'Inheritance', - 'CNV_Description', - ); + 'No.', + 'PSCID', + 'Gender', + 'Location', + 'CNV Description', + 'CNV Type', + 'Copy Num Change', + 'Common CNV', + 'Characteristics', + 'Inheritance', + ); } /** @@ -65,30 +58,15 @@ private function _getCNVFilters() private function _getSNPFilters() { return array( - 'centerID', - 'DCCID', + 'No.', 'PSCID', - 'gender', - 'SubprojectID', - 'dob', - 'External_ID', - 'rsID', - 'SNP_Name', - 'SNP_Description', - 'SNP_External_Source', - 'Observed_Base', - 'Reference_Base', - 'Array_Report', - 'Markers', - 'Validation_Method', - 'Validated', - 'Function_Prediction', + 'Gender', + 'RsID', + 'Observed Base', + 'Reference Base', + 'Function Prediction', 'Damaging', - 'Genotype_Quality', - 'Exonic_Function', - 'Chromosome', - 'Gene_Symbol', - 'Platform', + 'Exonic Function', ); } @@ -373,7 +351,7 @@ public function assertColumnSorting($header, $col_number, $asc, $desc) ); $first_row_value = $body->findElement( WebDriverBy::xPath( - " + " //div[@id='lorisworkspace'] //table[contains(@class, 'dynamictable')] /tbody @@ -466,21 +444,15 @@ protected function assertFiltering($filter, $value, $count) */ function testGenomicBrowserDoespageLoad() { - $this->markTestIncomplete( - 'Test should be updated for new main genomic browser tab.' - ); + // $this->markTestIncomplete( + // 'Test should be updated for new main genomic browser tab.' + // ); $this->safeGet($this->url . "/genomic_browser/"); $breadcrumbText = $this->webDriver->findElement( WebDriverBy::xPath( - " - //div[@id='breadcrumbs'] - /div - /div - /div - /a[2] - /div + "//*[@id='bc2']/a[2]/div " ) )->getText(); @@ -504,20 +476,15 @@ function testGenomicBrowserDoespageLoadPermissions() $this->webDriver->navigate()->refresh(); $this->safeGet($this->url . "/genomic_browser/"); $errorText = $this->webDriver->findElement( - WebDriverBy::xPath( + WebDriverBy::cssSelector( " - //div[@class='page-content inset'] - /div - /ul - /li - /strong + body " ) )->getText(); - $this->assertEquals( + $this->assertContains( "You do not have access to this page.", - $errorText, - "Error message don't fit" + $errorText ); // With permission genomic_browser_view_site @@ -527,12 +494,7 @@ function testGenomicBrowserDoespageLoadPermissions() $breadcrumbText = $this->webDriver->findElement( WebDriverBy::xPath( " - //div[@id='breadcrumbs'] - /div - /div - /div - /a[2] - /div + //*[@id='bc2']/a[2]/div " ) )->getText(); @@ -545,12 +507,7 @@ function testGenomicBrowserDoespageLoadPermissions() $breadcrumbText = $this->webDriver->findElement( WebDriverBy::xPath( " - //div[@id='breadcrumbs'] - /div - /div - /div - /a[2] - /div + //*[@id='bc2']/a[2]/div " ) )->getText(); @@ -566,9 +523,9 @@ function testGenomicBrowserDoespageLoadPermissions() */ public function testConfigurationMenuDisplayWithPermissions() { - $this->markTestIncomplete( - 'Test should be updated for new main genomic browser tab.' - ); + // $this->markTestIncomplete( + // 'Test should be updated for new main genomic browser tab.' + // ); // Without permissions $this->setupPermissions(array('')); @@ -605,18 +562,16 @@ public function testConfigurationMenuDisplayWithPermissions() */ function testGenomicBrowserCNVBrowserDoespageLoad() { - $this->markTestIncomplete( - 'Test should be updated for new main genomic browser tab.' - ); +// $this->markTestIncomplete( +// 'Test should be updated for new main genomic browser tab.' +// ); $this->safeGet($this->url . "/genomic_browser/?submenu=cnv_browser"); $tabText = $this->webDriver->findElement( WebDriverBy::xPath( " - //div[@id='tabs'] - /ul - /li[contains(@class, 'active')] + //*[@id='onLoad']/strong " ) )->getText(); @@ -638,21 +593,9 @@ function testGenomicBrowserCNVEmptyDatatable() $this->safeGet($this->url . "/genomic_browser/?submenu=cnv_browser"); $message = $this->webDriver->findElement( - WebDriverBy::id("LogEntries") + WebDriverBy::Xpath("//*[@id='datatable']/div/strong") )->getText(); - $this->assertEquals("No variants found.", $message); - - $rows = $this->webDriver->findElements( - WebDriverBy::xPath( - " - //div[@id='lorisworkspace'] - //table[contains(@class, 'dynamictable')] - /tbody - /tr - " - ) - ); - $this->assertCount(0, $rows, ""); + $this->assertEquals("No result found.", $message); } /** @@ -667,21 +610,9 @@ function testGenomicBrowserCNVDatatable() $this->safeGet($this->url . "/genomic_browser/?submenu=cnv_browser"); $message = $this->webDriver->findElement( - WebDriverBy::id("LogEntries") + WebDriverBy::Xpath("//*[@id='datatable']/div/div[2]/div/div/div[1]/span[3]") )->getText(); - $this->assertEquals("Variants found: 5 total", $message); - $rows = $this->webDriver->findElements( - WebDriverBy::xPath( - " - //div[@id='lorisworkspace'] - //table[contains(@class, 'dynamictable')] - /tbody - /tr - " - ) - ); - - $this->assertCount(5, $rows, "There should be 5 records in the table."); + $this->assertEquals("5", $message); } /** @@ -693,40 +624,33 @@ function testGenomicBrowserCNVDatatable() */ function testGenomicBrowserCNVDataSortableBrief() { - $expected_headers = array( + $this->markTestIncomplete( + 'Test should be updated for new main genomic browser tab.' + ); + + $expected_headers = array( 'No.', - 'DCCID', 'PSCID', - 'Subproject', - 'Chromosome', - 'StartLoc', - 'Size', - 'Gene Name', - 'Platform', - 'CNV Type', + 'Gender', + 'Location', 'CNV Description', + 'CNV Type', 'Copy Num Change', 'Common CNV', + 'Characteristics', + 'Inheritance', ); $this->safeGet($this->url . "/genomic_browser/?submenu=cnv_browser"); - $headers = $this->webDriver->findElements( - WebDriverBy::xPath( - " - //div[@id='lorisworkspace'] - //table[contains(@class, 'dynamictable')] - /thead - /tr - /th - " - ) + $headers = $this->safeFindElements( + WebDriverBy::cssSelector(".info") ); - - $this->assertCount( + printf("================******************".$headers); + $this->assertEquals( count($expected_headers), - $headers, - "There should be " . count($expected_headers) . " columns in the table." + count($headers) + // "There should be " . count($expected_headers) . " columns in the table." ); foreach ($expected_headers as $index => $header) { @@ -763,11 +687,11 @@ function testGenomicBrowserCNVSitePermission() $this->safeGet($this->url . "/genomic_browser/?submenu=cnv_browser"); $message = $this->webDriver->findElement( - WebDriverBy::id("LogEntries") + WebDriverBy::Xpath("//*[@id='datatable']/div/div[2]/div/div/div[1]/span[3]") )->getText(); $this->resetPermissions(); - $this->assertEquals("Variants found: 3 total", $message); + $this->assertEquals("3", $message); } /** @@ -918,21 +842,10 @@ function testGenomicBrowserSNPEmptyDatatable() $this->safeGet($this->url . "/genomic_browser/?submenu=snp_browser"); $message = $this->webDriver->findElement( - WebDriverBy::id("LogEntries") + WebDriverBy::Xpath("//*[@id='datatable']/div/strong") )->getText(); - $this->assertEquals("No variants found.", $message); + $this->assertEquals("No result found.", $message); - $rows = $this->webDriver->findElements( - WebDriverBy::xPath( - " - //div[@id='lorisworkspace'] - //table[contains(@class, 'dynamictable')] - /tbody - /tr - " - ) - ); - $this->assertCount(0, $rows, ""); } /** @@ -947,21 +860,9 @@ function testGenomicBrowserSNPDatatable() $this->safeGet($this->url . "/genomic_browser/?submenu=snp_browser"); $message = $this->webDriver->findElement( - WebDriverBy::id("LogEntries") + WebDriverBy::Xpath("//*[@id='datatable']/div/div[2]/div/div/div[1]/span[3]") )->getText(); - $this->assertEquals("Variants found: 5 total", $message); - $rows = $this->webDriver->findElements( - WebDriverBy::xPath( - " - //div[@id='lorisworkspace'] - //table[contains(@class, 'dynamictable')] - /tbody - /tr - " - ) - ); - - $this->assertCount(5, $rows, "There should be 5 records in the table."); + $this->assertEquals("5", $message); } /** @@ -977,11 +878,11 @@ function testGenomicBrowserSNPSitePermission() $this->safeGet($this->url . "/genomic_browser/?submenu=snp_browser"); $message = $this->webDriver->findElement( - WebDriverBy::id("LogEntries") + WebDriverBy::Xpath("//*[@id='datatable']/div/div[2]/div/div/div[1]/span[3]") )->getText(); $this->resetPermissions(); - $this->assertEquals("Variants found: 3 total", $message); + $this->assertEquals("3", $message); } /** @@ -993,38 +894,29 @@ function testGenomicBrowserSNPSitePermission() */ function testGenomicBrowserSNPDataSortableBrief() { + $this->markTestIncomplete( + 'Test should be updated for new main genomic browser tab.' + ); $expected_headers = array( 'No.', - 'DCCID', 'PSCID', - 'Subproject', - 'Chromosome', - 'StartLoc', - 'Gene Name', - 'Platform', + 'Gender', 'RsID', - 'SNP Name', - 'SNP Description', + 'Observed Base', + 'Reference Base', 'Function Prediction', + 'Damaging', + 'Exonic Function', ); $this->safeGet($this->url . "/genomic_browser/?submenu=snp_browser"); $headers = $this->webDriver->findElements( - WebDriverBy::xPath( - " - //div[@id='lorisworkspace'] - //table[contains(@class, 'dynamictable')] - /thead - /tr - /th - " - ) - ); + WebDriverBy::cssSelector(".info") + )->getSize(); - $this->assertCount( + $this->assertEquals( count($expected_headers), - $headers, - "There should be " . count($expected_headers) . " columns in the table." + $headers ); foreach ($expected_headers as $i => $header) { @@ -1085,37 +977,15 @@ function testGenomicBrowserSNPShowBriefFields() $expected_headers = array( 'No.', - 'PSC', - 'DCCID', 'PSCID', 'Gender', - 'Subproject', - 'DoB', - 'ExternalID', - 'Chromosome', - 'Strand', - 'StartLoc', - 'EndLoc', - 'Size', - 'Gene Symbol', - 'Gene Name', - 'Platform', 'RsID', - 'SNP Name', - 'SNP Description', - 'External Source', 'Observed Base', 'Reference Base', - 'Array Report', - 'Markers', - 'Validation Method', - 'Validated', 'Function Prediction', 'Damaging', - 'Genotype Quality', 'Exonic Function', ); - $this->safeGet($this->url . "/genomic_browser/?submendu=snp_browser"); // Apply filter diff --git a/modules/help_editor/test/help_editorTest.php b/modules/help_editor/test/help_editorTest.php index 584b00fea3a..d5652ce0ee1 100644 --- a/modules/help_editor/test/help_editorTest.php +++ b/modules/help_editor/test/help_editorTest.php @@ -1,42 +1,131 @@ + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ -require_once __DIR__ . "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; -class helpEditorTestIntegrationTest extends LorisIntegrationTest +require_once __DIR__."/../../../test/integrationtest" +."s/LorisIntegrationTest.class.inc"; + /** + * Help_editor automated integration tests + * + * PHP Version 5 + * + * @category Test + * @package Loris + * @author Wang Shen + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://github.com/aces/Loris + */ +class HelpEditorTestIntegrationTest extends LorisIntegrationTest { + /** + * Insert testing data into the database + * + * @return none + */ + function setUp() + { + parent::setUp(); + $window = new WebDriverWindow($this->webDriver); + $window->maximize(); + $this->DB->insert( + "help", + array( + 'helpID' => '999999', + 'parentID' => '-1', + 'hash' => 'md5("the string being hashed")', + 'topic' => 'Test Topic', + 'content' => 'This is a test content.', + 'created' => '2013-04-05 00:00:00', + 'updated' => 'NULL', + ) + ); + } + /** + * Delete testing data from database + * + * @return none + */ + function tearDown() + { + parent::tearDown(); + $this->DB->delete("help", array('helpID' => '999999')); + } + /** * Tests that, when loading the help_editor module, some * text appears in the body. * + * @category Test + * @package Loris + * @author Wang Shen + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://github.com/aces/Loris + * * @return void */ - function testHelpEditorDoesPageLoad() + function testHelpPageLoad() { $this->safeGet($this->url . "/help_editor/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertContains("Help Editor", $bodyText); - } + }//end test_help_pageload() /** * Tests that, when loading the help_editor module > edit help submodule, some * text appears in the body. * * @return void */ - function testHelpEditorEditHelpContentDoesPageLoad() + function testPageLoad() + { + $this->safeGet($this->url."/help_editor/edit_help_content/"); + $assertText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + ) + ->getText(); + + $this->assertContains("Edit Help Content", $assertText); + + }//end test_page_load() + + /** + * Tests that help editor loads with the permission + * + * @return void + */ + function testHelpEditorPermission() { - $this->safeGet($this->url . "/help_editor/edit_help_content/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); - $this->assertContains("Edit Help Content", $bodyText); + $this->setupPermissions(array("context_help")); + $this->safeGet($this->url . "/help_editor/"); + $bodyText = $this->safeFindElement( + WebDriverBy::XPath("//*[@id='lorisworkspace']/table/tbody/tr/td[1]") + )->getText(); + $this->assertContains("List of Topics", $bodyText); + $this->resetPermissions(); } + /** + * Tests that help editor does not load with the permission + * + * @return void + */ + function testHelpEditorWithoutPermission() + { + $this->setupPermissions(array()); + $this->safeGet($this->url . "/help_editor/"); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + } + } -?> \ No newline at end of file +?> diff --git a/modules/instrument_builder/js/react.instrument_builder.js b/modules/instrument_builder/js/react.instrument_builder.js index f0767ae2048..b0b6f37b126 100644 --- a/modules/instrument_builder/js/react.instrument_builder.js +++ b/modules/instrument_builder/js/react.instrument_builder.js @@ -283,10 +283,10 @@ DisplayElements = React.createClass({displayName: "DisplayElements", React.createElement(LorisElement, {element: element}) ), React.createElement("td", {className: "col-xs-2"}, - React.createElement("button", {onClick: this.props.editElement.bind(this, i), className: "button"}, + React.createElement("button", {onClick: this.props.editElement.bind(this, i), className: "button editButton"}, "Edit" ), - React.createElement("button", {onClick: this.props.deleteElement.bind(this, i), className: "button"}, + React.createElement("button", {onClick: this.props.deleteElement.bind(this, i), className: "button deleteButton"}, "Delete" ) ) @@ -546,9 +546,9 @@ InstrumentBuilderApp = React.createClass({displayName: "InstrumentBuilderApp", return ( React.createElement("div", null, React.createElement("ul", {className: "nav nav-tabs", role: "tablist"}, - React.createElement("li", {role: "presentation"}, React.createElement("a", {href: "#Load", "aria-controls": "home", role: "tab", "data-toggle": "tab"}, "Load")), - React.createElement("li", {role: "presentation", className: "active"}, React.createElement("a", {href: "#Build", "aria-controls": "build", role: "tab", "data-toggle": "tab"}, "Build")), - React.createElement("li", {role: "presentation"}, React.createElement("a", {href: "#Save", "aria-controls": "messages", role: "tab", "data-toggle": "tab"}, "Save")) + React.createElement("li", {role: "presentation",id: "load"}, React.createElement("a", {href: "#Load","aria-controls": "home", role: "tab", "data-toggle": "tab"}, "Load")), + React.createElement("li", {role: "presentation", className: "active",id: "build"}, React.createElement("a", {href: "#Build","aria-controls": "build", role: "tab", "data-toggle": "tab"}, "Build")), + React.createElement("li", {role: "presentation",id: "save"}, React.createElement("a", {href: "#Save", "aria-controls": "messages", role: "tab", "data-toggle": "tab"}, "Save")) ), React.createElement("div", {className: "tab-content col-xs-12"}, @@ -559,4 +559,4 @@ InstrumentBuilderApp = React.createClass({displayName: "InstrumentBuilderApp", } }); -RInstrumentBuilderApp = React.createFactory(InstrumentBuilderApp); \ No newline at end of file +RInstrumentBuilderApp = React.createFactory(InstrumentBuilderApp); diff --git a/modules/instrument_builder/js/react.questions.js b/modules/instrument_builder/js/react.questions.js index 46a83f0e1c2..3b1c77cf53c 100644 --- a/modules/instrument_builder/js/react.questions.js +++ b/modules/instrument_builder/js/react.questions.js @@ -376,7 +376,9 @@ ListElements = React.createClass({ { id: 'selected-input', type: 'button', className: 'btn btn-default dropdown-toggle', 'data-toggle': 'dropdown' }, React.createElement( 'span', - { id: 'search_concept' }, + { id: 'search_concept', + className: 'SelectOne' + }, this.props.value, ' ' ), @@ -556,7 +558,7 @@ AddElement = React.createClass({ Description: '', Name: '', selected: { - id: '', + id: 'SelectOne', value: 'Select One' } }; @@ -767,14 +769,14 @@ AddElement = React.createClass({ } // Set the button/header based on whether you are editing or adding an element. if (this.props.element) { - buttons = React.createElement('input', { className: 'btn btn-default', type: 'button', value: 'Edit Row', onClick: this.addQuestion }); + buttons = React.createElement('input', { className: 'btn btn-default', id: 'EditRow',type: 'button', value: 'Edit Row', onClick: this.addQuestion }); } else { header = React.createElement( 'h2', null, 'Add Question' ); - buttons = React.createElement('input', { className: 'btn btn-default', type: 'button', value: 'Add Row', onClick: this.addQuestion }); + buttons = React.createElement('input', { className: 'btn btn-default',id: 'AddRow', type: 'button', value: 'Add Row', onClick: this.addQuestion }); } return React.createElement( 'div', @@ -797,4 +799,4 @@ AddElement = React.createClass({ ) ); } -}); \ No newline at end of file +}); diff --git a/modules/instrument_builder/jsx/react.instrument_builder.js b/modules/instrument_builder/jsx/react.instrument_builder.js index 721ba98d23c..602434cc2aa 100755 --- a/modules/instrument_builder/jsx/react.instrument_builder.js +++ b/modules/instrument_builder/jsx/react.instrument_builder.js @@ -283,10 +283,10 @@ DisplayElements = React.createClass({ - - @@ -477,7 +477,7 @@ BuildPane = React.createClass({
    @@ -546,9 +546,9 @@ InstrumentBuilderApp = React.createClass({ return (
    @@ -559,4 +559,4 @@ InstrumentBuilderApp = React.createClass({ } }); -RInstrumentBuilderApp = React.createFactory(InstrumentBuilderApp); \ No newline at end of file +RInstrumentBuilderApp = React.createFactory(InstrumentBuilderApp); diff --git a/modules/instrument_builder/jsx/react.questions.js b/modules/instrument_builder/jsx/react.questions.js index e80f6f29043..68c62236347 100644 --- a/modules/instrument_builder/jsx/react.questions.js +++ b/modules/instrument_builder/jsx/react.questions.js @@ -279,7 +279,7 @@ ListElements = React.createClass({
      @@ -357,7 +357,7 @@ AddElement = React.createClass({ Description: '', Name: '', selected: { - id: '', + id: 'SelectOne', value: 'Select One' } } @@ -569,14 +569,14 @@ AddElement = React.createClass({ // Set the button/header based on whether you are editing or adding an element. if(this.props.element){ buttons = ( - + ) } else { header = (

      Add Question

      ); buttons = ( - + ) } return ( diff --git a/modules/instrument_builder/test/instrument_builderTest.php b/modules/instrument_builder/test/instrument_builderTest.php index 7f5054e12cf..6e498833c46 100644 --- a/modules/instrument_builder/test/instrument_builderTest.php +++ b/modules/instrument_builder/test/instrument_builderTest.php @@ -7,6 +7,7 @@ * @category Test * @package Loris * @author Ted Strauss + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -23,8 +24,104 @@ class instrumentBuilderTestIntegrationTest extends LorisIntegrationTest function testInstrumentBuilderDoespageLoad() { $this->safeGet($this->url . "/instrument_builder/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertContains("Instrument Builder", $bodyText); + } + /** + * Tests that, when loading the Instrument builder module with permission, some + * text appears in the body. + * + * @return void + */ + function testInstrumentBuilderDoespageLoadWithPermission() + { + $this->setupPermissions(array("instrument_builder")); + $this->safeGet($this->url . "/instrument_builder/"); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body")) + ->getText(); + $this->assertContains("Instrument Builder", $bodyText); + $this->resetPermissions(); + } + /** + * Tests that, when loading the Instrument builder module without permisson, some + * text appears in the body. + * + * @return void + */ + function testInstrumentBuilderDoespageLoadWithoutPermission() + { + $this->setupPermissions(array("")); + $this->safeGet($this->url . "/instrument_builder/"); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body")) + ->getText(); + $this->assertContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + } + /** + * Tests that, when loading the Instrument builder module without permisson, some + * text appears in the body. + * + * @return void + */ + function testInstrumentBuilderBuildTabAddEditDeleteQuestion() + { + //Insert a text content + $this->safeGet($this->url . "/instrument_builder/"); + $this->webDriver->findElement(WebDriverBy::cssSelector(".SelectOne"))->click(); + $this->webDriver->findElement(WebDriverBy::ID("header"))->click(); + $this->webDriver->findElement(WebDriverBy::ID("questionText")) + ->sendKeys("Test Header"); + $this->webDriver->findElement(WebDriverBy::ID("AddRow"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#sortable > tbody > tr > td.col-xs-8 > div > h2"))->getText(); + $this->assertContains("Test Header", $bodyText); + + //Edit this text content + $this->webDriver->findElement(WebDriverBy::cssSelector(".editButton"))->click(); + $this->webDriver->findElement(WebDriverBy::ID("questionText")) + ->sendKeys("Header changed"); + $this->webDriver->findElement(WebDriverBy::ID("EditRow"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#sortable > tbody > tr > td.col-xs-8 > div > h2"))->getText(); + $this->assertContains("Header changed", $bodyText); + + //Delete this text content + $this->webDriver->findElement(WebDriverBy::cssSelector(".deleteButton"))->click(); + $element = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#sortable>tbody") + )->getText(); + $this->assertEquals(Null, $element); + } + + /** Tests that, when loading the load tab in Instrument builder module , some + * text appears in the body. + * + * @return void + */ + function testInstrumentBuilderTab() + { + $this->_testInstrumentBuilderTabLink("load","Load Instrument"); + $this->_testInstrumentBuilderTabLink("save","Save Instrument"); + $this->_testInstrumentBuilderTabLink("build","Build your Instrument"); + + } + /** Use this method to verify all the links, if the link gets click, some text should + * appears in the body. + * @param $id id of the tab link. + * @param $text the text of assertion. + * + * @return void + */ + private function _testInstrumentBuilderTabLink($id,$text) + { + $this->safeGet($this->url . "/instrument_builder/"); + $this->webDriver->findElement(WebDriverBy::ID($id))->click(); + $uniqueSelector = "#".ucfirst($id).">h1"; + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + $uniqueSelector + ))->getText(); + $this->assertContains($text, $bodyText); } + } -?> \ No newline at end of file diff --git a/modules/instrument_manager/test/instrument_managerTest.php b/modules/instrument_manager/test/instrument_managerTest.php index eb7b9d4f31d..4dd6d0368e3 100644 --- a/modules/instrument_manager/test/instrument_managerTest.php +++ b/modules/instrument_manager/test/instrument_managerTest.php @@ -7,6 +7,7 @@ * @category Test * @package Loris * @author Ted Strauss + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -26,5 +27,35 @@ function testInstrumentManagerDoespageLoad() $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Instrument Manager", $bodyText); } + /** + * Tests that, when loading the instrument_manager module with permission, some + * text appears in the body. + * + * @return void + */ + function testInstrumentManagerDoespageLoadWithpermission() + { + $this->setupPermissions(array(superuser)); + $this->safeGet($this->url . "/instrument_manager/"); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $this->assertContains("Instrument Manager", $bodyText); + $this->resetPermissions(); + } + /** + * Tests that, when loading the instrument_manager module without permission, some + * text appears in the body. + * + * @return void + */ + function testInstrumentManagerDoespageLoadWithoutpermission() + { + $this->setupPermissions(array()); + $this->safeGet($this->url . "/instrument_manager/"); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $this->assertContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + } + + } -?> \ No newline at end of file +?> diff --git a/modules/mri_violations/test/mri_violationsTest.php b/modules/mri_violations/test/mri_violationsTest.php index 332e7e69782..81050fa435f 100644 --- a/modules/mri_violations/test/mri_violationsTest.php +++ b/modules/mri_violations/test/mri_violationsTest.php @@ -7,6 +7,7 @@ * @category Test * @package Loris * @author Ted Strauss + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -14,6 +15,150 @@ require_once __DIR__ . "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; class MriViolationsTestIntegrationTest extends LorisIntegrationTest { + /** + * Insert testing data + * + * @return void + */ + public function setUp() + { + parent::setUp(); + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1024,768); + $window->setSize($size); + $this->DB->insert( + "psc", + array( + 'CenterID' => '55', + 'Name' => 'TESTinPSC', + 'Alias' => 'test', + 'MRI_alias' => 'test' + ) + + ); + $this->DB->insert( + "candidate", + array( + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'PSCID' => '8888', + 'ProjectID' => '7777' + ) + ); + $this->DB->insert( + "session", + array( + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'MRIQCStatus' => 'Pass', + 'SubprojectID' => '6666' + ) + ); + $this->DB->insert( + "mri_protocol_violated_scans", + array( + 'ID' => '1001', + 'CandID' => '999888', + 'PatientName' => '[Test]PatientName', + 'time_run' => '2009-06-29 04:00:44', + 'minc_location' => 'assembly/test/test/mri/test/test.mnc', + 'series_description' => 'Test Series Description', + 'SeriesUID' => '5555' + ) + ); + $this->DB->insert( + "mri_protocol_violated_scans", + array( + 'ID' => '1002', + 'CandID' => '999888', + 'PatientName' => '[Test]PatientName', + 'time_run' => '2008-06-29 04:00:44', + 'minc_location' => 'assembly/test2/test2/mri/test2/test2.mnc', + 'series_description' => 'Test Series Description', + 'SeriesUID' => '5556' + ) + ); + $this->DB->insert( + "violations_resolved", + array( + 'ExtID' => '1001', + 'TypeTable' => 'mri_protocol_violated_scans', + 'Resolved' => 'other' + ) + ); + $this->DB->insert( + "violations_resolved", + array( + 'ExtID' => '1002', + 'TypeTable' => 'MRICandidateErrors', + 'Resolved' => 'unresolved' + ) + ); + $this->DB->insert( + "MRICandidateErrors", + array( + 'ID' => '1002', + 'PatientName' => '[Test]PatientName', + 'MincFile' => 'assembly/test2/test2/mri/test2/test2.mnc', + 'SeriesUID' => '5556' + ) + ); + + } + //Delete the test data + public function tearDown() + { + + $this->DB->delete( + "session", + array('CandID' => '999888','CenterID' => '55') + ); + $this->DB->delete( + "candidate", + array('CandID' => '999888','CenterID' => '55') + ); + $this->DB->delete( + "mri_protocol_violated_scans", + array( + 'ID' => '1001', + 'CandID' => '999888' + ) + ); + $this->DB->delete( + "mri_protocol_violated_scans", + array( + 'ID' => '1002', + 'CandID' => '999888' + ) + ); + $this->DB->delete( + "violations_resolved", + array( + 'ExtID' => '1001', + 'TypeTable' => 'mri_protocol_violated_scans' + ) + ); + $this->DB->delete( + "MRICandidateErrors", + array( + 'ID' => '1002' + ) + ); + $this->DB->delete( + "violations_resolved", + array( + 'ExtID' => '1002', + 'TypeTable' => 'mri_protocol_violated_scans' + ) + ); + $this->DB->delete( + "psc", + array('CenterID' => '55', 'Name' => 'TESTinPSC') + ); + parent::tearDown(); + } /** * Tests that, when loading the Mri_violations module, some * text appears in the body. @@ -23,7 +168,8 @@ class MriViolationsTestIntegrationTest extends LorisIntegrationTest function testMriViolationsDoesPageLoad() { $this->safeGet($this->url . "/mri_violations/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertContains("Mri Violations", $bodyText); } @@ -36,12 +182,14 @@ function testMriViolationsDoesPageLoad() function testMriProtocolViolationsDoesPageLoad() { $this->safeGet($this->url . "/mri_violations/?submenu=mri_protocol_violations"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertContains("Mri Violations", $bodyText); } /** - * Tests that, when loading the Mri_violations module > mri_protocol_check_violations submodule, some + * Tests that, when loading the Mri_violations module > + * mri_protocol_check_violations submodule, some * text appears in the body. * * @return void @@ -52,7 +200,248 @@ function testMriProtocolCheckViolationsDoesPageLoad() $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Mri Violations", $bodyText); } -} + /** + *Tests landing the mri violation whit the permission 'violated_scans_view_allsites' + * + * @return void + */ + function testLoginWithPermission() + { + $this->setupPermissions(array("violated_scans_view_allsites")); + $this->safeGet($this->url . "/mri_violations/"); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertNotContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + } + /** + *Tests anding the mri violation whitout the permission + * + * @return void + */ + function testLoginWithoutPermission() + { + $this->setupPermissions(array("")); + $this->safeGet($this->url . "/mri_violations/"); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + } + + + /** + * Tests landing the sub page which named resolved violations + * + * @return void + */ + function testResolvedsubmenu() + { + $this->safeGet($this->url . "/mri_violations/?submenu=resolved_violations"); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector + ("#violationsTable > thead > tr > th:nth-child(1) > a"))->getText(); + $this->assertContains("Resolution status", $bodyText); + } + /** + * Tests clear button in the filter section, input some data, then click the clear button, + * all of data in the filter section will be gone. + * + * @return void + */ + function testResolvedClearButton() + { + //testing the Patient Name + $this->safeGet($this->url . "/mri_violations/?submenu=resolved_violations"); + $this->webDriver->findElement(WebDriverBy::Name("PatientName"))->sendKeys("test"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("PatientName")) + ->getText(); + $this->assertEquals("", $bodyText); + + //testing the Description + $this->webDriver->findElement(WebDriverBy::Name("Description"))->sendKeys("test"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("Description")) + ->getText(); + $this->assertEquals("", $bodyText); + + //testing the MincFile + $this->webDriver->findElement(WebDriverBy::Name("Filename"))->sendKeys("test"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("Filename")) + ->getText(); + $this->assertEquals("", $bodyText); + + //testing the Site + $siteElement = $this->safeFindElement(WebDriverBy::Name("Site")); + $site = new WebDriverSelect($siteElement); + $site->selectByVisibleText("TESTinPSC"); + $this->safeClick(WebDriverBy::Name("reset")); + $siteElement = $this->safeFindElement(WebDriverBy::Name("Site")); + $site = new WebDriverSelect($siteElement); + $value = $site->getFirstSelectedOption()->getAttribute('value'); + $this->assertEquals("",$value); + + //testing the Series UID + $this->webDriver->findElement(WebDriverBy::Name("SeriesUID"))->sendKeys + ("test"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("SeriesUID")) + ->getText(); + $this->assertEquals("", $bodyText); -?> \ No newline at end of file + } + /** + * Tests that, input some data and click search button, check the results. + * + * @return void + */ + function testResolvedSearchButton() + { + //testing search by PatientName + $this->safeGet($this->url . "/mri_violations/?submenu=resolved_violations"); + $this->webDriver->findElement(WebDriverBy::Name("PatientName"))->sendKeys + ("[Test]PatientName"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#violationsTable > tbody > tr:nth-child(1) > td:nth-child(3)") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by Filename + $this->webDriver->findElement(WebDriverBy::Name("Filename")) + ->sendKeys("assembly/test/test/mri/test/test.mnc"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#violationsTable > tbody > tr:nth-child(1) > td:nth-child(3)") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by Description + $this->webDriver->findElement(WebDriverBy::Name("Description"))->sendKeys + ("Test Series Description"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#violationsTable > tbody > tr:nth-child(1) > td:nth-child(3)") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by site + $siteElement = $this->safeFindElement(WebDriverBy::Name("Site")); + $site = new WebDriverSelect($siteElement); + $site->selectByVisibleText("TESTinPSC"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#violationsTable > tbody > tr:nth-child(1) > td:nth-child(3)") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by Description + $this->webDriver->findElement(WebDriverBy::Name("SeriesUID"))->sendKeys("5555"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector( + "#violationsTable > tbody > tr:nth-child(1) > td:nth-child(3)") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + } + + /** + * Tests that, input some data and click search button, check the results. + * + * @return void + */ + function testNotResolvedSearchButton() + { + //testing search by PatientName + $this->safeGet($this->url . "/mri_violations/"); + $this->webDriver->findElement(WebDriverBy::Name("PatientName"))->sendKeys + ("[Test]PatientName"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Xpath( + "//*[@id='violationsTable']/tbody/tr[1]/td[2]") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by Filename + $this->webDriver->findElement(WebDriverBy::Name("Filename")) + ->sendKeys("assembly/test2/test2/mri/test2/test2.mnc"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Xpath( + "//*[@id='violationsTable']/tbody/tr[1]/td[2]") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by Description + $this->webDriver->findElement(WebDriverBy::Name("Description"))->sendKeys + ("Test Series Description"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Xpath( + "//*[@id='violationsTable']/tbody/tr[1]/td[2]") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by site + $siteElement = $this->safeFindElement(WebDriverBy::Name("Site")); + $site = new WebDriverSelect($siteElement); + $site->selectByVisibleText("TESTinPSC"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Xpath( + "//*[@id='violationsTable']/tbody/tr[1]/td[2]") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + + //testing search by Description + $this->webDriver->findElement(WebDriverBy::Name("SeriesUID"))->sendKeys("5556"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Xpath( + "//*[@id='violationsTable']/tbody/tr[1]/td[2]") + )->getText(); + $this->assertEquals("[Test]PatientName", $bodyText); + } + /** + * Tests that,in the not resolved menu, change the Resolution status of the first row. + * Save it and check it. + * + * @return void + */ + function testNotResolvedSaveButton() + { + + $this->safeGet($this->url . "/mri_violations/"); + $resolutionElement = $this->safeFindElement(WebDriverBy::Name + ("resolvable[c57b919a921eaa1a43bb5e0c44cd4226]")); + $resolution = new WebDriverSelect($resolutionElement); + $resolution->selectByVisibleText("Inserted"); + $this->safeClick(WebDriverBy::Name("fire_away")); + + $resolutionElement = $this->safeFindElement(WebDriverBy::Name + ("resolvable[c57b919a921eaa1a43bb5e0c44cd4226]")); + $resolution = new WebDriverSelect($resolutionElement); + + $value = $resolution->getFirstSelectedOption()->getAttribute('value'); + $this->assertEquals("inserted",$value); + } + /** + * Tests that, click the link of the problem, the page will go to + * mri_protocol_check_violations + * + * @return void + */ + function testNotResolvedProblemLink() + { + $this->safeGet($this->url . "/mri_violations/"); + $this->webDriver->findElement(WebDriverBy::Name("PatientName")) + ->sendKeys("[Test]PatientName"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + + $this->webDriver->findElement(WebDriverBy::linkText("Could not identify scan type"))->click(); + $value = $this->webDriver->findElement(WebDriverBy::cssSelector + ("#content > table > tbody > tr > td:nth-child(2) > a")) + ->getText(); + $this->assertEquals("[Test]PatientName",$value); + } +} +?> diff --git a/modules/reliability/test/reliabilityTest.php b/modules/reliability/test/reliabilityTest.php index 552cda7a9ca..fac0be593f6 100644 --- a/modules/reliability/test/reliabilityTest.php +++ b/modules/reliability/test/reliabilityTest.php @@ -6,7 +6,7 @@ * * @category Test * @package Loris - * @author Ted Strauss + * @author WangShen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -20,11 +20,298 @@ class reliabilityTestIntegrationTest extends LorisIntegrationTest * * @return void */ + + /** + * Insert testing data + * + * @return void + */ + public function setUp() + { + parent::setUp(); + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1280,720); + $window->setSize($size); + $this->DB->insert( + "psc", + array( + 'CenterID' => '55', + 'Name' => 'TESTinPSC', + 'Alias' => 'test', + 'MRI_alias' => 'test' + ) + + ); + + + $this->DB->insert( + "candidate", + array( + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'PSCID' => '8888', + 'ProjectID' => '7777', + 'Gender' => 'Male' + ) + ); + $this->DB->insert( + "candidate", + array( + 'CandID' => '999889', + 'CenterID' => '55', + 'UserID' => '1', + 'PSCID' => '8889', + 'ProjectID' => '7777', + 'Gender' => 'Female' + ) + ); + $this->DB->insert( + "session", + array( + 'ID' => '111111', + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'MRIQCStatus' => 'Pass', + 'SubprojectID' => '6666' + ) + ); + $this->DB->insert( + "session", + array( + 'ID' => '111112', + 'CandID' => '999889', + 'CenterID' => '55', + 'UserID' => '1', + 'MRIQCStatus' => 'Pass', + 'SubprojectID' => '6666' + ) + ); + $this->DB->insert( + "reliability", + array( + 'ID' => '111111112', + 'CommentID' => 'testCommentID1', + 'Instrument' => 'testInstrument' + ) + ); + $this->DB->insert( + "reliability", + array( + 'ID' => '111111113', + 'CommentID' => 'testCommentID2', + 'Instrument' => 'testInstrument' + ) + ); + $this->DB->insert( + "test_names", + array( + 'ID' => '111111113', + 'Test_name' => 'test_name' + ) + ); + $this->DB->insert( + "flag", + array( + 'ID' => '111111111', + 'SessionID' => '111111', + 'CommentID' => 'testCommentID1', + 'Test_name' => 'test_name' + ) + ); + $this->DB->insert( + "flag", + array( + 'ID' => '111111112', + 'SessionID' => '111112', + 'CommentID' => 'testCommentID2', + 'Test_name' => 'test_name' + ) + ); + + } + //Delete the test data + public function tearDown() + { + + $this->DB->delete( + "session", + array('CandID' => '999888','CenterID' => '55') + ); + $this->DB->delete( + "session", + array('CandID' => '999889','CenterID' => '55') + ); + $this->DB->delete( + "candidate", + array('CandID' => '999888','CenterID' => '55') + ); + $this->DB->delete( + "candidate", + array('CandID' => '999889','CenterID' => '55') + ); + $this->DB->delete( + "reliability", + array( + 'ID' => '111111112' + ) + ); + $this->DB->delete( + "reliability", + array( + 'ID' => '111111113' + ) + ); + $this->DB->delete( + "flag", + array( + 'ID' => '111111111' + ) + ); + $this->DB->delete( + "flag", + array( + 'ID' => '111111112' + ) + ); + $this->DB->delete( + "psc", + array('CenterID' => '55', 'Name' => 'TESTinPSC') + ); + $this->DB->delete( + "test_names", + array('ID' => '111111113') + ); + parent::tearDown(); + } + function testReliabilityDoespageLoad() { $this->safeGet($this->url . "/reliability/"); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("reliability", $bodyText); } + + /** + *Tests landing the Reliability with the permission 'access_all_profiles' or 'reliability_edit_all' + * + * @return void + */ + function testLoginWithPermission() + { + $this->setupPermissions(array("access_all_profiles")); + $this->safeGet($this->url . "/reliability/"); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertNotContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + + $this->setupPermissions(array("reliability_edit_all")); + $this->safeGet($this->url . "/reliability/"); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertNotContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + + } + /** + * Tests that, input some data and click search button, check the results. + * + * @return void + */ + function testReliabilityShowDataButton() + { + //testing search by PSCID + $this->safeGet($this->url . "/reliability/"); + $this->webDriver->findElement(WebDriverBy::Name("PSCID"))->sendKeys + ("8888"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + sleep(2); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("8888", $bodyText); + + //testing search by DCCID + $this->safeGet($this->url . "/reliability/?reset=true"); + $this->webDriver->findElement(WebDriverBy::Name("DCCID"))->sendKeys + ("999888"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + sleep(2); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("8888", $bodyText); + + //testing search by Gender + $this->safeGet($this->url . "/reliability/?reset=true"); + $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); + $gender = new WebDriverSelect($genderElement); + $gender->selectByVisibleText("Male"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + sleep(2); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("8888", $bodyText); + } + /** + * Tests that, input some data and click click clear button, check the results. + * The form should refreash and the data should be gone. + * @return void + */ + function testReliabilityClearFormButton() + { + //testing search by PSCID + $this->safeGet($this->url . "/reliability/"); + $this->webDriver->findElement(WebDriverBy::Name("PSCID"))->sendKeys + ("8888"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("PSCID"))-> + getText(); + $this->assertEquals("", $bodyText); + + //testing search by DCCID + $this->safeGet($this->url . "/reliability/"); + $this->webDriver->findElement(WebDriverBy::Name("DCCID"))->sendKeys + ("8888"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("PSCID"))-> + getText(); + $this->assertEquals("", $bodyText); + + //testing search by Gender + $this->safeGet($this->url . "/reliability/"); + $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); + $gender = new WebDriverSelect($genderElement); + $gender->selectByVisibleText("Male"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $genderElement = $this->safeFindElement(WebDriverBy::Name("Gender")); + $gender = new WebDriverSelect($genderElement); + $value = $gender->getFirstSelectedOption()->getAttribute('value'); + $this->assertEquals("",$value); + + } + /** + * Tests that, Swap Candidates try swapping both different combinations of PSCID + * and visit lables and try a couple of different instruments. + * + * @return void + */ + function testReliabiliySwap() + { + //testing search by PSCID + $this->safeGet($this->url . "/reliability/"); + + $this->webDriver->findElement(WebDriverBy::Name("Cand1PSCID"))->sendKeys + ("8888"); + $this->webDriver->findElement(WebDriverBy::Name("Cand2PSCID"))->sendKeys + ("8889"); + sleep(50); + $this->webDriver->findElement(WebDriverBy::Xpath("//*[@id='swap-body']/form/div[6]/div[5]/input"))->click(); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector(".error"))-> + getText(); + $this->assertContains("Cannot swap candidates.", $bodyText); + + + } -?> \ No newline at end of file +?> + diff --git a/modules/statistics/test/.Statistics_Test.php.swp b/modules/statistics/test/.Statistics_Test.php.swp new file mode 100644 index 00000000000..19b626e472f Binary files /dev/null and b/modules/statistics/test/.Statistics_Test.php.swp differ diff --git a/modules/statistics/test/Statistics_Test.php b/modules/statistics/test/Statistics_Test.php index a8a674236d3..292c3690244 100644 --- a/modules/statistics/test/Statistics_Test.php +++ b/modules/statistics/test/Statistics_Test.php @@ -1,39 +1,99 @@ + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://github.com/aces/Loris + */ + +require_once __DIR__ . + "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; + +/** + * Statistics module automated integration tests + * + * PHP Version 5 + * + * @category Test + * @package Loris + * @author Wang Shen + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://github.com/aces/Loris + */ require_once __DIR__ . "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; class Statistics_Test extends LorisIntegrationTest { - public function testTabsFrameworkLoads() + +/** + * Tests that, when loading the create_timepoint module, some + * text appears in the body. + * + * @return void + */ + function testLoadPage() + { + $this->safeGet($this->url . "/statistics/"); + $bodyText = $this->safeFindElement(WebDriverBy::Xpath("//div[@id = 'page']/H2"))->getText(); + $this->assertContains("Welcome to the statistics page.", $bodyText); + + } + /** + * Tests that the final Radiological Review loads if the user has the correct + * permissions (view_final_radiological_review) + * It should find filter section + * + * @return void + */ + function testLoadPageWithoutPermission() { - $this->safeGet($this->url . '/statistics/'); - - try { - // If this is the mobile view, we need to expand the dropdown - // before the stats links are visible. - $expand = $this->webDriver->findElement(WebDriverBy::ID("down")); - $expand->click(); - } catch(ElementNotVisibleException $e) { - // Using the desktop version, so the mobile link isn't visible and - // doesn't need to be clicked. - } - - // Ensure that Demographic Statistics link is there. There's nothing special - // about Demographics, it's just a randomly chosen default tab to ensure that - // something shows up. Ideally, this should loop through the StatisticsTabs - // table and ensure that they all appear. - try { - $link = $this->webDriver->findElement(WebDriverBy::PartialLinkText("Demographic Statistics")); - $this->assertContains("Demographic", $link->getText()); - } catch(NoSuchElementException $e) { - print $this->webDriver->getPageSource(); - $this->fail("Could not find demographic tab link"); - } + $this->setupPermissions(array("")); + $this->safeGet($this->url . "/statistics/"); + + // Test that the Imaging menu appears in the first row + $bodyText = $this->webDriver->findElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertContains("You do not have access to this page.", $bodyText); + + $this->resetPermissions(); } - public function testGeneralDescriptionTabLoads() { - $this->safeGet($this->url . '/statistics/stats_general/?dynamictabs=dynamictabs'); - $header = $this->webDriver->findElement(WebDriverBy::XPath("//div[@id = 'page']/h2")); - $this->assertContains("Welcome to the statistics page", $header->getText()); + + + + /** Tests that, when loading the create_timepoint module, some + * text appears in the body. + * + * @return void + */ + function testBehaviouralTab() + { + $this->safeGet($this->url . "/statistics/stats_behavioural/?dynamictabs=dynamictabs"); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector(".statsH2"))->getText(); + $this->assertContains("Data Entry Statistics", $bodyText); + + //test one link inside this Tab + $this->safeFindElement(WebDriverBy::linkText("Click here for breakdown per participant"))->click(); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body"))->getText(); + $this->assertContains("All Completion Statistics", $bodyText); } + /** Tests that, when loading the create_timepoint module, some + * text appears in the body. + * + * @return void + */ + function testReliabilityStatisticsTab() + { + $this->safeGet($this->url . "/statistics/stats_reliability/?dynamictabs=dynamictabs"); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector(".statsH2"))->getText(); + $this->assertContains("Reliability Statistics", $bodyText); + + } + } -?> diff --git a/modules/survey_accounts/test/survey_accountsTest.php b/modules/survey_accounts/test/survey_accountsTest.php index 6d9168a8e38..b70c57aca24 100644 --- a/modules/survey_accounts/test/survey_accountsTest.php +++ b/modules/survey_accounts/test/survey_accountsTest.php @@ -7,6 +7,7 @@ * @category Test * @package Loris * @author Ted Strauss + * @author Wang Shen * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 * @link https://github.com/aces/Loris */ @@ -14,6 +15,111 @@ require_once __DIR__ . "/../../../test/integrationtests/LorisIntegrationTest.class.inc"; class survey_accountsTestIntegrationTest extends LorisIntegrationTest { + /** + * Insert testing data + * + * @return void + */ + public function setUp() + { + parent::setUp(); + $window = new WebDriverWindow($this->webDriver); + $size = new WebDriverDimension(1024,768); + $window->setSize($size); + $this->DB->insert( + "psc", + array( + 'CenterID' => '55', + 'Name' => 'TESTinPSC', + 'Alias' => 'test', + 'MRI_alias' => 'test' + ) + ); + $this->DB->insert( + "candidate", + array( + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'PSCID' => '8888', + 'ProjectID' => '7777' + ) + ); + $this->DB->insert( + "session", + array( + 'ID' => '111111', + 'CandID' => '999888', + 'CenterID' => '55', + 'UserID' => '1', + 'MRIQCStatus' => 'Pass', + 'SubprojectID' => '6666', + 'Visit' => 'In Progress' + ) + ); + $this->DB->insert( + "candidate", + array( + 'CandID' => '999999', + 'CenterID' => '55', + 'UserID' => '1', + 'PSCID' => '8889', + 'ProjectID' => '7777' + ) + ); + $this->DB->insert( + "session", + array( + 'ID' => '111112', + 'CandID' => '999999', + 'CenterID' => '55', + 'UserID' => '1', + 'MRIQCStatus' => 'Pass', + 'SubprojectID' => '6666', + 'Visit' => 'In Progress' + ) + ); + $this->DB->insert( + "participant_accounts", + array( + 'SessionID' => '111111', + 'Email' => 'TestTestTest@gmail.com', + 'Test_name' => 'Test', + 'Status' => 'In Progress', + 'OneTimePassword' => 'Test' + ) + ); + } + //Delete the test data + public function tearDown() + { + $this->DB->delete( + "participant_accounts", + array('SessionID'=>'111111') + ); + + $this->DB->delete( + "session", + array('CandID' => '999888') + ); + $this->DB->delete( + "candidate", + array('CandID' => '999888') + ); + $this->DB->delete( + "session", + array('CandID' => '999999') + ); + $this->DB->delete( + "candidate", + array('CandID' => '999999') + ); + $this->DB->delete( + "psc", + array('CenterID'=>'55') + ); + parent::tearDown(); + } /** * Tests that, when loading the Survey accounts module, some * text appears in the body. @@ -22,9 +128,11 @@ class survey_accountsTestIntegrationTest extends LorisIntegrationTest */ function testSurveyAccountsDoespageLoad() { + $this->setupPermissions(array("user_accounts")); $this->safeGet($this->url . "/survey_accounts/"); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Survey Accounts", $bodyText); + $this->resetPermissions(); } /** @@ -35,9 +143,114 @@ function testSurveyAccountsDoespageLoad() */ function testSurveyAccountsAddSurveyDoespageLoad() { - $this->safeGet($this->url . "/survey_accounts/add_survey/"); + $this->safeGet($this->url . "/survey_accounts/add_survey/"); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Add Survey", $bodyText); } + /** + * Tests that, when loading the Survey without right permission, some + * text appears in the body. + * + * @return void + */ + function testSurveyAccountsWithoutPermission() + { + $this->setupPermissions(array("")); + $this->safeGet($this->url . "/survey_accounts/"); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector("body") + )->getText(); + $this->assertContains("You do not have access to this page.", $bodyText); + $this->resetPermissions(); + } + + /** + * Tests that, when add a survey without visit tag + * it should appear the error message + * + * @return void + */ + function testSurveyAccountsAddSurvey() + { + //Visit does not exist for given candidate. + $this->safeGet($this->url . "/survey_accounts/"); + $this->safeFindElement( + WebDriverBy::Name("button") + )->click(); + $this->safeFindElement( + WebDriverBy::Name("CandID") + )->sendKeys("999999"); + $this->safeFindElement( + WebDriverBy::Name("PSCID") + )->sendKeys("8889"); + $this->safeFindElement( + WebDriverBy::Name("fire_away") + )->click(); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector(".error") + )->getText(); + $this->assertContains("Visit does not exist for given candidate", $bodyText); + //PSCID and DCC ID do not match or candidate does not exist. + $this->safeFindElement( + WebDriverBy::Name("CandID") + )->sendKeys("888888"); + $this->safeFindElement( + WebDriverBy::Name("PSCID") + )->sendKeys("8889"); + $this->safeFindElement( + WebDriverBy::Name("fire_away") + )->click(); + $bodyText = $this->safeFindElement( + WebDriverBy::cssSelector(".error") + )->getText(); + $this->assertContains("PSCID and DCC ID do not match or candidate does not exist", $bodyText); + } + + /** + * Tests clear button in the filter section, input some data, then click the clear button, + * all of data in the filter section will be gone. + * + * @return void + */ + function testSurveyAccountsClearButton() + { + //testing the PSCID + $this->safeGet($this->url . "/survey_accounts/"); + $this->webDriver->findElement(WebDriverBy::Name("PSCID"))->sendKeys("test"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("PSCID")) + ->getText(); + $this->assertEquals("", $bodyText); + + //testing the Email + $this->webDriver->findElement(WebDriverBy::Name("Email"))->sendKeys("test"); + $this->webDriver->findElement(WebDriverBy::Name("reset"))->click(); + $bodyText = $this->webDriver->findElement(WebDriverBy::Name("Email")) + ->getText(); + $this->assertEquals("", $bodyText); + } + /** + * Tests that, input some data and click search button, check the results. + * + * @return void + */ + function testResolvedSearchButton() + { + //testing search by PSCID + $this->safeGet($this->url . "/survey_accounts/"); + $this->webDriver->findElement(WebDriverBy::Name("PSCID"))->sendKeys + ("8888"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("8888", $bodyText); + + //testing search by Email + $this->safeGet($this->url . "/survey_accounts/"); + $this->webDriver->findElement(WebDriverBy::Name("Email")) + ->sendKeys("TestTestTest@gmail.com"); + $this->webDriver->findElement(WebDriverBy::Name("filter"))->click(); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("TestTestTest@gmail.com", $bodyText); + } } -?> \ No newline at end of file +?> diff --git a/project/config.xml b/project/config.xml new file mode 100644 index 00000000000..6e6131657ab --- /dev/null +++ b/project/config.xml @@ -0,0 +1,167 @@ + + + + + + 0 + + + + + ace-db-1.cbrain.mcgill.ca + wangshen + 123456 + wangshen_test + SQLTestUser + TestPassword + Test database + + + + + false + + + + + + + user + + + + + + + random + + BBB + + + + + + + candidate_comment + ProbandDoB + MRI_Done + + + + + user + /^[A-Z0-9]{2}$/i + 2 + V%value% + + V%value% + + + + + user + /^[A-Z0-9]{2}$/i + 2 + V%value% + + V%value% + + + + + + aosi + 0.5 + AOSI + + + adi_r_proband + 89.5 + ADI-R (Proband) + + + adi_r_subject + 89.5 + ADI-R (Subject) + + + csbs + 79.5 + CSBS + + + ados_module1 + 79.5 + ADOS (Module1) + + + ados_module2 + 79.5 + ADOS (Module2) + + + + + + 0 + + + + + + + + + + + + + + + false + + study_consent + + + + + + + + + 0 + + + + + + false + + + + sampleInstrument + + sampleInstrumentPermissionName + + + sampleInstrument2 + sampleInstrument2PermissionName + + + diff --git a/test/config.xml b/test/config.xml index f741c52071a..1eef0bcf5e7 100644 --- a/test/config.xml +++ b/test/config.xml @@ -16,10 +16,10 @@ - %HOSTNAME% - %USERNAME% - %PASSWORD% - %DATABASE% + ace-db-1.cbrain.mcgill.ca + wangshen + 123456 + wangshen_sandbox SQLTestUser TestPassword Test database diff --git a/test/integration.sh b/test/integration.sh index 4e686c6ae11..0673a9472ea 100755 --- a/test/integration.sh +++ b/test/integration.sh @@ -15,10 +15,10 @@ # * Set sandbox mode to 1: 1 # * Set SyncAccounts to false: false -host="127.0.0.1" -database="LorisTest" -username="SQLTestUser" -password="TestPassword" +host="ace-db-1.cbrain.mcgill.ca" +database="wangshen_sandbox" +username="wangshen" +password="123456" url="http://localhost:8000" # Custom DB variables specified by optional commandline arguments diff --git a/test/integrationtests/LorisIntegrationTestForDocRepo.class.inc b/test/integrationtests/LorisIntegrationTestForDocRepo.class.inc new file mode 100644 index 00000000000..78f7b597823 --- /dev/null +++ b/test/integrationtests/LorisIntegrationTestForDocRepo.class.inc @@ -0,0 +1,49 @@ + + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://www.github.com/aces/Loris/ + */ + +require_once __DIR__ . "/LorisIntegrationTest.class.inc"; +/** + * Implementation of LorisIntegrationTest helper class. + * + * @category Test + * @package Test + * @author Wang Shen + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://www.github.com/aces/Loris/ + */ +abstract class LorisIntegrationTestForDocRepo extends LorisIntegrationTest +{ + + /** + * Does basic setting up of Loris variables for this test,after testing + * a test data, remove the testing data from database. + * @return none + */ + public function setUp() + { + parent::setUp(); + + } + + public function tearDown() { + $this->DB->delete("document_repository_categories", + array('category_name' => 'TestTestTest','category_name' => 'test')); + parent::tearDown(); + } +} +?> diff --git a/test/phpunit.xml b/test/phpunit.xml index f21d6a24116..d1d86f89b1c 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -4,7 +4,7 @@ verbose="true" colors="true"> - + - ../modules/candidate_list/test/ + ../modules/create_timepoint/test/ +