From 05b1ccec74eb342023986ef948691be150b2c588 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 4 May 2016 11:25:53 -0400 Subject: [PATCH 01/39] dashboard --- modules/dashboard/test/DashboardTest.php | 172 +++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/modules/dashboard/test/DashboardTest.php b/modules/dashboard/test/DashboardTest.php index faa6b1bdeea..69f75db8e26 100644 --- a/modules/dashboard/test/DashboardTest.php +++ b/modules/dashboard/test/DashboardTest.php @@ -41,5 +41,177 @@ public function testDashboardPageLoads() ->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 testTargetNumberOfParticipants() + { + $this->safeGet($this->url . '/dashboard/'); + + $dashboardNum = $this->safeFindElement( + WebDriverBy::Xpath("//*[@id='overall-recruitment']/div/p")) + ->getText(); + + $this->safeGet($this->url . '/configuration/'); + + $this->safeFindElement + (WebDriverBy::Xpath("//*[@id='lorisworkspace']/div[1]/ul/li[5]/a")) + ->click(); + $configNum = $this->safeFindElement + (WebDriverBy::Xpath("//*[@id='41']/input")) + ->getAttribute('value'); + + + $this->assertEquals($dashboardNum,"Target: ".$configNum);; + } + + +/** + * Verify that for a user with 'conflict_resolver' permission, + * Check that site displayed is always 'All'. + * Click on this task and verify that you go to the conflict_resolver page. +*/ + public function testConflict_resolverPermission() + { + // check the element which shows on the My tasks panel + $this->setupPermissions(array("conflict_resolver")); + $this->safeGet($this->url . "/dashboard/"); + $bodyText = $this->safeFindElement + (WebDriverBy::Xpath("//*[@id='lorisworkspace']". + "/div/div[2]/div[1]"))->getText(); + $this->assertContains("Data entry conflicts", $bodyText); + // check the link + $this->safeGet($this->url . "/conflict_resolver/"); + $bodyText = $this->safeFindElement + (WebDriverBy::cssSelector("body"))->getText(); + + $this->assertNotContains("You do not have access to this page", $bodyText); + $this->resetPermissions(); + + } +/** + * Verify that for a user with 'data_entry' permission, + * Check that site displayed is always 'All'. +*/ + public function testData_EntryPermission() + { + // check the element which shows on the My tasks panel + $this->setupPermissions(array("data_entry","access_all_profiles")); + $this->safeGet($this->url . "/dashboard/"); + $bodyText = $this->safeFindElement + (WebDriverBy::Xpath("//*[@id='lorisworkspace']". + "/div/div[2]/div[1]"))->getText(); + $this->assertContains("Incomplete forms", $bodyText); + + $this->resetPermissions(); + } +/** + * Verify that for a user with 'Violated Scans: View all-sites' permissions, + * Check that site displayed is always 'All'. +*/ + public function testViolatedPermission() + { + // check the element which shows on the My tasks panel + $this->setupPermissions(array("violated_scans_view_allsites")); + $this->safeGet($this->url . "/dashboard/"); + $bodyText = $this->safeFindElement + (WebDriverBy::Xpath("//*[@id='lorisworkspace']". + "/div/div[2]/div[1]"))->getText(); + $this->assertContains("Violated scans", $bodyText); + // check the link + $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(); + + } +/** + * Verify that for a user with 'Across all sites create and edit user + * accounts' permission. + * Check that site displayed is always 'All'. +*/ + public function testAcrossAllPermission() + { + // check the element which shows on the My tasks panel + $this->setupPermissions(array("user_accounts_multisite","user_accounts")); + $this->safeGet($this->url . "/dashboard/"); + $bodyText = $this->safeFindElement + (WebDriverBy::Xpath("//*[@id='lorisworkspace']/div/div[2]/div[1]")) + ->getText(); + $this->assertContains("Accounts pending approval", $bodyText); + // check the link + $this->safeGet($this->url . "/user_accounts/"); + $bodyText = $this->safeFindElement + (WebDriverBy::cssSelector("body"))->getText(); + $this->assertNotContains("You do not have access to this page", $bodyText); + $this->resetPermissions(); + + } +/** + * Verify that for a user with "edit Final radiological review" or + * "view_final_radiological_review" permission. + * Check that site displayed is always 'All'. +*/ + public function testRadiologicalPermission() + { + // check the element which shows on the My tasks panel + $this->setupPermissions(array("edit_final_radiological_review", + "view_final_radiological_review")); + $this->safeGet($this->url . "/dashboard/"); + $bodyText = $this->safeFindElement + (WebDriverBy::Xpath("//*[@id='lorisworkspace']/div/div[2]/div[1]")) + ->getText(); + $this->assertContains("Accounts pending approval", $bodyText); + // check the link + $this->safeGet($this->url . "/final_radiological_review/"); + $bodyText = $this->safeFindElement + (WebDriverBy::cssSelector("body"))->getText(); + $this->assertNotContains("You do not have access to this page", $bodyText); + $this->resetPermissions(); + + } } ?> From e05d0a1f7f3f356524796acec8c6a7c46763a24e Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 4 May 2016 12:09:45 -0400 Subject: [PATCH 02/39] fda --- test/integration.sh | 8 ++++---- test/phpunit.xml | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) 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/phpunit.xml b/test/phpunit.xml index f21d6a24116..ee963b04ca6 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -4,7 +4,7 @@ verbose="true" colors="true"> - + - ../modules/candidate_list/test/ + ../modules/dashboard/test/ + From 2f4ece0686949b7d07837cc923b34384c70a8def Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Thu, 5 May 2016 15:30:02 -0400 Subject: [PATCH 03/39] dicom --- .../dicom_archive/test/dicom_archiveTest.php | 140 +++++++++++++++++- 1 file changed, 138 insertions(+), 2 deletions(-) diff --git a/modules/dicom_archive/test/dicom_archiveTest.php b/modules/dicom_archive/test/dicom_archiveTest.php index 516611dc459..4efb105d69e 100644 --- a/modules/dicom_archive/test/dicom_archiveTest.php +++ b/modules/dicom_archive/test/dicom_archiveTest.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,65 @@ 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(1024,1768); + $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. @@ -26,11 +86,27 @@ function testdicomArchiveDoespageLoad() $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 * text appears in the body. - * + * @author Wang Shen * @return void */ function testdicomArchiveViewDetailsDoespageLoad() @@ -39,5 +115,65 @@ function testdicomArchiveViewDetailsDoespageLoad() $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. + * @author Wang Shen + * @return void + */ + function testdicomArchivFilterClearBtn() + { + //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); + + } + function testdicomArchiveFileterByName() + { + //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); + } +function testdicomArchiveFileterByDateOfBirth() + { + //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 +?> From 87baaafc6b6e28c94691b045b97dc9a537b90851 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Thu, 5 May 2016 15:31:16 -0400 Subject: [PATCH 04/39] dicom --- test/config.xml | 8 ++++---- test/phpunit.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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/phpunit.xml b/test/phpunit.xml index ee963b04ca6..a5d35c18aa1 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -14,7 +14,7 @@ --> - ../modules/dashboard/test/ + ../modules/dicom_archive/test/ - ../modules/dicom_archive/test/ + ../modules/document_repository/test/ - ../modules/document_repository/test/ + ../modules/create_timepoint/test/ + + + + 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 + + + From 18288677b0a2bbe2e63b94e790407c25f3fb7800 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Tue, 5 Jul 2016 16:24:20 -0400 Subject: [PATCH 24/39] crreate --- .../test/create_timepointTest.php | 100 ++++++++++++------ 1 file changed, 70 insertions(+), 30 deletions(-) diff --git a/modules/create_timepoint/test/create_timepointTest.php b/modules/create_timepoint/test/create_timepointTest.php index cc342235b57..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 */ @@ -72,59 +73,98 @@ function testCreateTimepointDoespageLoad() */ function testCreateTimepoint() { - $this->safeGet( - $this->url . "/create_timepoint/?candID=900000&identifier=900000" - ); - + $this->_createTimepoint('900000','Experimental','V1'); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); - $this->assertContains("Create Time Point", $bodyText); + $this->assertContains("New time point successfully registered", $bodyText); - $select = $this->safeFindElement(WebDriverBy::Name("subprojectID")); - $element = new WebDriverSelect($select); - $element->selectByVisibleText("Experimental"); + } + /** + * Tests that, create a timepoint and test the success link + * + * + * @return void + */ + function testCreateTimepointSuccessLink() + { + $this->_createTimepoint('900000','Experimental','V9'); - $this->webDriver->findElement(WebDriverBy::Name("visitLabel"))->sendKeys("V2"); - $this->webDriver->findElement(WebDriverBy::Name("fire_away"))->click(); + $this->safeClick(WebDriverBy::LinkText("Click here to continue.")); + sleep(3); + $bodyText = $this->webDriver->getPageSource(); + $this->assertContains("V9", $bodyText); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); - $this->assertContains("New time point successfully registered", $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); + + } - // Test input a duplicate visit tag and get error message + /** + * 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->safeGet( - $this->url . "/create_timepoint/?candID=900000&identifier=900000" + $this->url . "/create_timepoint/?candID=" .$canID . "&identifier=" .$canID ); + $select = $this->safeFindElement(WebDriverBy::Name("subprojectID")); $element = new WebDriverSelect($select); - $element->selectByVisibleText("Control"); + $element->selectByVisibleText($subproject); - $this->webDriver->findElement(WebDriverBy::Name("visitLabel"))->sendKeys("V2"); + $this->webDriver->findElement(WebDriverBy::Name("visitLabel"))->sendKeys($visitlabel); $this->webDriver->findElement(WebDriverBy::Name("fire_away"))->click(); - + } - /** - * Tests that, when loading the create_timepoint module and input a delicate visit tag, - * some error text appears in the body. + + + /** + * Tests that, create a timepoint and input a empty subproject + * get Error message * * @return void */ - function testCreateTimepointWithError() + function testCreateTimepointErrorEmptySubproject() { $this->safeGet( $this->url . "/create_timepoint/?candID=900000&identifier=900000" ); - - $select = $this->safeFindElement(WebDriverBy::Name("subprojectID")); - $element = new WebDriverSelect($select); - $element->selectByVisibleText("Experimental"); - -// $this->webDriver->findElement(WebDriverBy::Name("visitLabel"))->sendKeys("V2"); $this->webDriver->findElement(WebDriverBy::Name("fire_away"))->click(); - sleep(20); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->webDriver->getPageSource(); $this->assertContains("A visit label is required for creating a timepoint.", $bodyText); } - + /** + * 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(); + } } ?> From a5de5ba24a7581a36dfcceb8084216107df8ffc5 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 6 Jul 2016 17:19:45 -0400 Subject: [PATCH 25/39] examiner --- modules/examiner/test/ExaminerTest.php | 150 +++++++++++++++++++++---- 1 file changed, 130 insertions(+), 20 deletions(-) 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); + + } } ?> From a19df87d51bda0668bd1edc630cc483d138ccdb9 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Tue, 12 Jul 2016 16:13:18 -0400 Subject: [PATCH 26/39] fdsa --- .../test/genomic_browserTest.php | 282 +++++------------- 1 file changed, 76 insertions(+), 206 deletions(-) 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 From f1781ddf7c38df7f164ee88e07efc12319ebbe0b Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 13 Jul 2016 17:32:29 -0400 Subject: [PATCH 27/39] dashboard --- modules/dashboard/test/DashboardTest.php | 389 ++++++++++++++++------- 1 file changed, 272 insertions(+), 117 deletions(-) diff --git a/modules/dashboard/test/DashboardTest.php b/modules/dashboard/test/DashboardTest.php index 69f75db8e26..d83e820c5ea 100644 --- a/modules/dashboard/test/DashboardTest.php +++ b/modules/dashboard/test/DashboardTest.php @@ -22,25 +22,190 @@ * @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' + ) + ); + $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( + "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') + ); + parent::tearDown(); + } + + + /** * Tests that, when loading the Dashboard, the word "Welcome" appears * in the welcome panel * * @return void */ - public function testDashboardPageLoads() +/* 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 @@ -50,7 +215,7 @@ public function testDashboardPageLoads() * * @return void */ - public function testDashboardRecruitmentView() +/* public function testDashboardRecruitmentView() { $this->safeGet($this->url . '/dashboard/'); $views = $this->webDriver @@ -61,6 +226,7 @@ public function testDashboardRecruitmentView() ) ); $views->click(); + $assertText1 = $this->webDriver ->findElement( WebDriverBy::XPath( @@ -78,140 +244,129 @@ public function testDashboardRecruitmentView() $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 testTargetNumberOfParticipants() + * Verify that for a user with 'conflict_resolver' permission, + * Check that site displayed is always 'All'. + * Click on this task and verify that you go to the conflict_resolver page. + * + *@return void + */ +/* public function testConflictResolverPermission() { - $this->safeGet($this->url . '/dashboard/'); - - $dashboardNum = $this->safeFindElement( - WebDriverBy::Xpath("//*[@id='overall-recruitment']/div/p")) - ->getText(); - - $this->safeGet($this->url . '/configuration/'); - - $this->safeFindElement - (WebDriverBy::Xpath("//*[@id='lorisworkspace']/div[1]/ul/li[5]/a")) - ->click(); - $configNum = $this->safeFindElement - (WebDriverBy::Xpath("//*[@id='41']/input")) - ->getAttribute('value'); - - - $this->assertEquals($dashboardNum,"Target: ".$configNum);; - } - - -/** - * Verify that for a user with 'conflict_resolver' permission, - * Check that site displayed is always 'All'. - * Click on this task and verify that you go to the conflict_resolver page. -*/ - public function testConflict_resolverPermission() - { - // check the element which shows on the My tasks panel + // check the element which shows on the My tasks panel $this->setupPermissions(array("conflict_resolver")); - $this->safeGet($this->url . "/dashboard/"); - $bodyText = $this->safeFindElement - (WebDriverBy::Xpath("//*[@id='lorisworkspace']". - "/div/div[2]/div[1]"))->getText(); - $this->assertContains("Data entry conflicts", $bodyText); - // check the link - $this->safeGet($this->url . "/conflict_resolver/"); - $bodyText = $this->safeFindElement - (WebDriverBy::cssSelector("body"))->getText(); + // check the link + $this->safeGet($this->url . "/conflict_resolver/"); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body")) + ->getText(); - $this->assertNotContains("You do not have access to this page", $bodyText); - $this->resetPermissions(); + $this->assertNotContains( + "You do not have access to this page", + $bodyText + ); + $this->resetPermissions(); - } -/** - * Verify that for a user with 'data_entry' permission, - * Check that site displayed is always 'All'. -*/ - public function testData_EntryPermission() - { - // check the element which shows on the My tasks panel - $this->setupPermissions(array("data_entry","access_all_profiles")); - $this->safeGet($this->url . "/dashboard/"); - $bodyText = $this->safeFindElement - (WebDriverBy::Xpath("//*[@id='lorisworkspace']". - "/div/div[2]/div[1]"))->getText(); - $this->assertContains("Incomplete forms", $bodyText); - - $this->resetPermissions(); - } -/** - * Verify that for a user with 'Violated Scans: View all-sites' permissions, - * Check that site displayed is always 'All'. + } */ - public function testViolatedPermission() - { - // check the element which shows on the My tasks panel + /** + * Verify that for a user with 'Violated Scans: View all-sites' permissions, + * Check that site displayed is always 'All'. + * + * @return void + */ +/* public function testViolatedPermission() + { $this->setupPermissions(array("violated_scans_view_allsites")); - $this->safeGet($this->url . "/dashboard/"); - $bodyText = $this->safeFindElement - (WebDriverBy::Xpath("//*[@id='lorisworkspace']". - "/div/div[2]/div[1]"))->getText(); - $this->assertContains("Violated scans", $bodyText); - // check the link + // check the link $this->safeGet($this->url . "/mri_violations/"); - $bodyText = $this->safeFindElement - (WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertNotContains("You do not have access to this page", $bodyText); $this->resetPermissions(); - } -/** - * Verify that for a user with 'Across all sites create and edit user - * accounts' permission. - * Check that site displayed is always 'All'. + } */ - public function testAcrossAllPermission() - { - // check the element which shows on the My tasks panel - $this->setupPermissions(array("user_accounts_multisite","user_accounts")); - $this->safeGet($this->url . "/dashboard/"); - $bodyText = $this->safeFindElement - (WebDriverBy::Xpath("//*[@id='lorisworkspace']/div/div[2]/div[1]")) - ->getText(); - $this->assertContains("Accounts pending approval", $bodyText); - // check the link + /** + * Verify that for a user with 'Across all sites create and edit user + * accounts' permission. + * Check that site displayed is always 'All'. + * + * @return void + */ +/* public function testAcrossAllPermission() + { + $this->setupPermissions(array("user_accounts_multisite", "user_accounts")); + // check the link $this->safeGet($this->url . "/user_accounts/"); - $bodyText = $this->safeFindElement - (WebDriverBy::cssSelector("body"))->getText(); + $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body")) + ->getText(); $this->assertNotContains("You do not have access to this page", $bodyText); $this->resetPermissions(); - } -/** - * Verify that for a user with "edit Final radiological review" or - * "view_final_radiological_review" permission. - * Check that site displayed is always 'All'. + } */ - public function testRadiologicalPermission() - { - // check the element which shows on the My tasks panel - $this->setupPermissions(array("edit_final_radiological_review", - "view_final_radiological_review")); - $this->safeGet($this->url . "/dashboard/"); - $bodyText = $this->safeFindElement - (WebDriverBy::Xpath("//*[@id='lorisworkspace']/div/div[2]/div[1]")) - ->getText(); - $this->assertContains("Accounts pending approval", $bodyText); - // check the link + /** + * Verify that for a user with "edit Final radiological review" or + * "view_final_radiological_review" permission. + * Check that site displayed is always 'All'. + * + * @return void + */ +/* + public function testRadiologicalPermission() + { + $this->setupPermissions( + array( + "edit_final_radiological_review", + "view_final_radiological_review", + ) + ); + // check the link $this->safeGet($this->url . "/final_radiological_review/"); - $bodyText = $this->safeFindElement - (WebDriverBy::cssSelector("body"))->getText(); + $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 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->_testMytaskPanelAndLink(".mri_violations","2","[Test]PatientName"); + } + + 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); + + } + } ?> From 2638db19825ff65e93d2748da83090c715af225b Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Thu, 14 Jul 2016 15:39:00 -0400 Subject: [PATCH 28/39] fdas --- modules/dashboard/test/DashboardTest.php | 179 +++++++++++------------ 1 file changed, 87 insertions(+), 92 deletions(-) diff --git a/modules/dashboard/test/DashboardTest.php b/modules/dashboard/test/DashboardTest.php index d83e820c5ea..713e2892ab2 100644 --- a/modules/dashboard/test/DashboardTest.php +++ b/modules/dashboard/test/DashboardTest.php @@ -69,12 +69,14 @@ function setUp() 'CenterID' => '55', 'UserID' => '1', 'PSCID' => '8888', - 'ProjectID' => '7777' + 'ProjectID' => '7777', + 'Entity_type' => 'Human' ) ); $this->DB->insert( "session", array( + 'ID' => '222222', 'CandID' => '999888', 'CenterID' => '55', 'UserID' => '1', @@ -131,8 +133,43 @@ function setUp() '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() { @@ -186,6 +223,18 @@ public function tearDown() "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(); } @@ -197,15 +246,13 @@ public function tearDown() * * @return void */ -/* public function testDashboardPageLoads() + 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 @@ -215,7 +262,7 @@ public function tearDown() * * @return void */ -/* public function testDashboardRecruitmentView() + public function testDashboardRecruitmentView() { $this->safeGet($this->url . '/dashboard/'); $views = $this->webDriver @@ -244,93 +291,7 @@ public function tearDown() $this->assertContains("View overall recruitment", $assertText1); $this->assertContains("View site breakdown", $assertText2); } -*/ - /** - * Verify that for a user with 'conflict_resolver' permission, - * Check that site displayed is always 'All'. - * Click on this task and verify that you go to the conflict_resolver page. - * - *@return void - */ -/* public function testConflictResolverPermission() - { - // check the element which shows on the My tasks panel - $this->setupPermissions(array("conflict_resolver")); - // check the link - $this->safeGet($this->url . "/conflict_resolver/"); - $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body")) - ->getText(); - - $this->assertNotContains( - "You do not have access to this page", - $bodyText - ); - $this->resetPermissions(); - } -*/ - /** - * Verify that for a user with 'Violated Scans: View all-sites' permissions, - * Check that site displayed is always 'All'. - * - * @return void - */ -/* public function testViolatedPermission() - { - $this->setupPermissions(array("violated_scans_view_allsites")); - // check the link - $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(); - - } -*/ - /** - * Verify that for a user with 'Across all sites create and edit user - * accounts' permission. - * Check that site displayed is always 'All'. - * - * @return void - */ -/* public function testAcrossAllPermission() - { - $this->setupPermissions(array("user_accounts_multisite", "user_accounts")); - // check the link - $this->safeGet($this->url . "/user_accounts/"); - $bodyText = $this->safeFindElement(WebDriverBy::cssSelector("body")) - ->getText(); - $this->assertNotContains("You do not have access to this page", $bodyText); - $this->resetPermissions(); - - } -*/ - /** - * Verify that for a user with "edit Final radiological review" or - * "view_final_radiological_review" permission. - * Check that site displayed is always 'All'. - * - * @return void - */ -/* - public function testRadiologicalPermission() - { - $this->setupPermissions( - array( - "edit_final_radiological_review", - "view_final_radiological_review", - ) - ); - // check the link - $this->safeGet($this->url . "/final_radiological_review/"); - $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 Dashboard and Config,the number of the Target * number of participants should be same. @@ -350,9 +311,43 @@ public function testPendingUser() 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/'); From 8d18293e5d934cb879ccb21fd47509539a807056 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Thu, 14 Jul 2016 15:39:26 -0400 Subject: [PATCH 29/39] fas --- modules/dashboard/templates/form_dashboard.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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}
From ab9e394c5a764b8239e17cf1458948e0fd4d0d1c Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Mon, 18 Jul 2016 16:03:40 -0400 Subject: [PATCH 30/39] fda --- .../statistics/test/.Statistics_Test.php.swp | Bin 0 -> 12288 bytes modules/statistics/test/Statistics_Test.php | 118 +++++++++++++----- 2 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 modules/statistics/test/.Statistics_Test.php.swp diff --git a/modules/statistics/test/.Statistics_Test.php.swp b/modules/statistics/test/.Statistics_Test.php.swp new file mode 100644 index 0000000000000000000000000000000000000000..19b626e472f8263d13eddb0508698bef81598ab2 GIT binary patch literal 12288 zcmeI2%a0UA9LEde3wiiDsL?|?Ak1#qZe%e=9?J@guyNI8cVRIE$C~cip33%gHB~h; zYzT7lq9KNOP>&`aJb00ViTJwc#e_e=i(ZV;n9>1gF89;4qi~8^9kc z3Hcp-3f=$*z;^K4y@dP*1t`X^u=D1j%y_GJ9lZn8Yp0^-Up(9u&t>qyZIBuzWq!ii;R#NwRuWi z5Npg3I%3k*~)0n70sDK5}C+ZW?VOs zE!^cFp-V5LGUL>?2)VV0IiwVt!fu7XL#vKsE_Cz}W*FU@8Fh>Kd6m~#Q^Gk;e z?)mCB(Yqn@4LZ1shSpqHc)8-5n{lq{LTk)cZGC{)lJ@8k#a@*S8cUi1lo=}vla0y?-rOT#pcQ-OuHh~FA^@t5V^*o;p5!nlF zpLAk%SEO}fx(alns{);H6HsGf1f8dwV9FE&JT8cC(_BE?%c_jX^GUqPpN8X;sC z&c>--or-)|gtXpnw}{Uy8AT80%+$)IFpNd>$gqg90&leKZ#){_geA4(B}-WTnhd?f z!dMvj29`zy9%mVHfv>LAG)fmBI|)z3cDVUnisyWFEvuGCXLJL*gtqA*%L}ER3!ceH%PsjI< z(?eX@z)PRO4SR2XU(w#9Q1mYAs2yV!zO0kmR%v3*j_n_Q_{t4h1PFdsYjTu QRV7pLvJ&suWfSZF1t|g|bN~PV literal 0 HcmV?d00001 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); + + } + } -?> From 7ec7853c301fdb857d6b627f07c32aea623fff7c Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 20 Jul 2016 10:52:37 -0400 Subject: [PATCH 31/39] instrument_builder --- .../test/instrument_builderTest.php | 101 +++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) 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 From 24b0b407bf76f1662944febd9001d404f8a68b47 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 20 Jul 2016 10:53:19 -0400 Subject: [PATCH 32/39] react --- .../js/react.instrument_builder.js | 12 ++++++------ modules/instrument_builder/js/react.questions.js | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/instrument_builder/js/react.instrument_builder.js b/modules/instrument_builder/js/react.instrument_builder.js index f0767ae2048..a81a83b5f9c 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"}, React.createElement("a", {href: "#Load", id: "load","aria-controls": "home", role: "tab", "data-toggle": "tab"}, "Load")), + React.createElement("li", {role: "presentation", className: "active"}, React.createElement("a", {href: "#Build", id: "build","aria-controls": "build", role: "tab", "data-toggle": "tab"}, "Build")), + React.createElement("li", {role: "presentation"}, React.createElement("a", {href: "#Save",id: "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 +}); From 484c3750de44d8edbc346d9e251682b81ed32272 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 20 Jul 2016 10:54:35 -0400 Subject: [PATCH 33/39] react jsx --- .../jsx/react.instrument_builder.js | 14 +++++++------- modules/instrument_builder/jsx/react.questions.js | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) 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..110c04c374d 100644 --- a/modules/instrument_builder/jsx/react.questions.js +++ b/modules/instrument_builder/jsx/react.questions.js @@ -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 ( From abce2e38e8d2a1841ddaee2c6f94cf3eff200f4f Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 20 Jul 2016 13:07:08 -0400 Subject: [PATCH 34/39] add class name --- modules/instrument_builder/jsx/react.questions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/instrument_builder/jsx/react.questions.js b/modules/instrument_builder/jsx/react.questions.js index 110c04c374d..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({
      From 41be2269494eda5a09bd24db212f915dea4ea27b Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 20 Jul 2016 13:23:33 -0400 Subject: [PATCH 35/39] a --- modules/instrument_builder/js/react.instrument_builder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/instrument_builder/js/react.instrument_builder.js b/modules/instrument_builder/js/react.instrument_builder.js index a81a83b5f9c..b0b6f37b126 100644 --- a/modules/instrument_builder/js/react.instrument_builder.js +++ b/modules/instrument_builder/js/react.instrument_builder.js @@ -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", id: "load","aria-controls": "home", role: "tab", "data-toggle": "tab"}, "Load")), - React.createElement("li", {role: "presentation", className: "active"}, React.createElement("a", {href: "#Build", id: "build","aria-controls": "build", role: "tab", "data-toggle": "tab"}, "Build")), - React.createElement("li", {role: "presentation"}, React.createElement("a", {href: "#Save",id: "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"}, From 915467c3d7fd59bc2f488361dbfe44e242806419 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Wed, 20 Jul 2016 16:56:31 -0400 Subject: [PATCH 36/39] reliabilityTest.php --- modules/reliability/test/reliabilityTest.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/reliability/test/reliabilityTest.php b/modules/reliability/test/reliabilityTest.php index f08b471f75c..fac0be593f6 100644 --- a/modules/reliability/test/reliabilityTest.php +++ b/modules/reliability/test/reliabilityTest.php @@ -299,10 +299,7 @@ function testReliabiliySwap() { //testing search by PSCID $this->safeGet($this->url . "/reliability/"); - try{ - $this->webDriver->findElement(WebDriverBy::ID("swapDown"))->click(); - } catch(RuntimeException $e){ - } + $this->webDriver->findElement(WebDriverBy::Name("Cand1PSCID"))->sendKeys ("8888"); $this->webDriver->findElement(WebDriverBy::Name("Cand2PSCID"))->sendKeys @@ -313,7 +310,7 @@ function testReliabiliySwap() getText(); $this->assertContains("Cannot swap candidates.", $bodyText); - } + } ?> From 3f0a4930d53baf1b694e0e0c69473a0b99ff6628 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Thu, 21 Jul 2016 16:04:15 -0400 Subject: [PATCH 37/39] try catch finally --- modules/help_editor/test/help_editorTest.php | 230 +++++++++++++++++-- 1 file changed, 217 insertions(+), 13 deletions(-) diff --git a/modules/help_editor/test/help_editorTest.php b/modules/help_editor/test/help_editorTest.php index 584b00fea3a..1dc9f73bbfa 100644 --- a/modules/help_editor/test/help_editorTest.php +++ b/modules/help_editor/test/help_editorTest.php @@ -1,42 +1,246 @@ + * @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' => '7292dd87f9a200f21bf40ded779a58c2', + '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, when loading the help editor, search Test Topic, click show data + * the Test Data should appear. + * + * @return void + */ + public function testSearchTopic() + { + $this->safeGet($this->url.'/help_editor/'); + try{ + $this->safeFindElement(WebDriverBy::ID("down"))->click(); + } catch(WebDriverException $ex){} + finally { + $this->safeFindElement(WebDriverBy::Name("topic"))->click(); + $searchbox = $this->safeFindElement(WebDriverBy::Name("topic")); + $searchbox->sendKeys("Test Topic"); + $showdata = $this->safeClick( + WebDriverBy::Xpath( + "//*[@id='panel-body']". + "/form/div[2]/div/div[1]/input" + ) + ); + $assertText = $this->safeFindElement(WebDriverBy::Id("Topic"))->getText(); + $this->assertContains("Test Topic", $assertText); + } + }//end test_search_topic() + + /** + * Tests that, when loading the help editor, search the keyword with This is + * a test content, click show data, the Test Topic should appear. + * + * @return void + */ + public function testSearchKeyword() + { + $this->safeGet($this->url.'/help_editor/'); + try{ + $this->safeFindElement(WebDriverBy::ID("down"))->click(); + } catch(WebDriverException $ex){} + finally { + $searchbox = $this->safeFindElement(WebDriverBy::Name("keyword")); + $searchbox->sendKeys("This is a test content."); + $showdata = $this->safeClick( + WebDriverBy::Xpath( + "//*[@id='panel-body']". + "/form/div[2]/div/div[1]/input" + ) + ); + $assertText = $this->safeFindElement(WebDriverBy::Id("Topic"))->getText(); + $this->assertContains("Test Topic", $assertText); + } + }//end test_search_keyword() + /** + * Tests that, when loading the help editor, search the keyword with This is + * a test content, click show data, and link to detail. + * + * @return void + */ + public function testSearchKeywordLinkToDetail() + { + $this->safeGet($this->url.'/help_editor/'); + try{ + $this->safeFindElement(WebDriverBy::ID("down"))->click(); + } catch(WebDriverException $ex){} + finally { + $searchbox = $this->safeFindElement(WebDriverBy::Name("keyword")); + $searchbox->sendKeys("This is a test content."); + $showdata = $this->safeClick( + WebDriverBy::Xpath( + "//*[@id='panel-body']". + "/form/div[2]/div/div[1]/input" + ) + ); + $linkDetail = $this->safeClick( + WebDriverBy::Xpath("//*[@id='Topic']/a") + ); + $assertText = $this->safeFindElement( + WebDriverBy::XPath( + "//*[@id='edit_help_content']/div/div/div[2]/div/textarea" + ) + )->getText(); + $this->assertContains("This is a test content.", $assertText); + } + }//end test_search_keyword_to_detail() + + + + /** + * Tests that, when loading the help editor, search Hand Preference, + * click clear form, the text Hand Preference should disappear. + * + * @return void + */ + public function testClearForm() { - $this->safeGet($this->url . "/help_editor/edit_help_content/"); - $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); - $this->assertContains("Edit Help Content", $bodyText); + $this->safeGet($this->url.'/help_editor/'); + try{ + $this->safeFindElement(WebDriverBy::ID("down"))->click(); + } catch(WebDriverException $ex){} + finally { + + $searchbox = $this->safeFindElement(WebDriverBy::Name("topic")); + $searchbox->sendKeys("Hand Preference"); + $clearform = $this->safeClick( + WebDriverBy::Xpath( + "//*[@id='panel-body']/". + "form/div[2]/div/div[2]/input" + ) + ); + $assertText = $this->safeFindElement(WebDriverBy::Name("topic"))->getText(); + $this->assertEquals(null, $assertText); + } + }//end test_clear_form() + + /** + * Tests that help editor loads with the permission + * + * @return void + */ + function testHelpEditorPermission() + { + $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 +?> From 2dbdb3b34e0a20736639c4b029c5790162c6fe3c Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Thu, 21 Jul 2016 17:27:08 -0400 Subject: [PATCH 38/39] help_editorTest.php --- modules/help_editor/test/help_editorTest.php | 117 +------------------ 1 file changed, 1 insertion(+), 116 deletions(-) diff --git a/modules/help_editor/test/help_editorTest.php b/modules/help_editor/test/help_editorTest.php index 1dc9f73bbfa..d5652ce0ee1 100644 --- a/modules/help_editor/test/help_editorTest.php +++ b/modules/help_editor/test/help_editorTest.php @@ -40,7 +40,7 @@ function setUp() array( 'helpID' => '999999', 'parentID' => '-1', - 'hash' => '7292dd87f9a200f21bf40ded779a58c2', + 'hash' => 'md5("the string being hashed")', 'topic' => 'Test Topic', 'content' => 'This is a test content.', 'created' => '2013-04-05 00:00:00', @@ -96,121 +96,6 @@ function testPageLoad() }//end test_page_load() - - /** - * Tests that, when loading the help editor, search Test Topic, click show data - * the Test Data should appear. - * - * @return void - */ - public function testSearchTopic() - { - $this->safeGet($this->url.'/help_editor/'); - try{ - $this->safeFindElement(WebDriverBy::ID("down"))->click(); - } catch(WebDriverException $ex){} - finally { - $this->safeFindElement(WebDriverBy::Name("topic"))->click(); - $searchbox = $this->safeFindElement(WebDriverBy::Name("topic")); - $searchbox->sendKeys("Test Topic"); - $showdata = $this->safeClick( - WebDriverBy::Xpath( - "//*[@id='panel-body']". - "/form/div[2]/div/div[1]/input" - ) - ); - $assertText = $this->safeFindElement(WebDriverBy::Id("Topic"))->getText(); - $this->assertContains("Test Topic", $assertText); - } - }//end test_search_topic() - - /** - * Tests that, when loading the help editor, search the keyword with This is - * a test content, click show data, the Test Topic should appear. - * - * @return void - */ - public function testSearchKeyword() - { - $this->safeGet($this->url.'/help_editor/'); - try{ - $this->safeFindElement(WebDriverBy::ID("down"))->click(); - } catch(WebDriverException $ex){} - finally { - $searchbox = $this->safeFindElement(WebDriverBy::Name("keyword")); - $searchbox->sendKeys("This is a test content."); - $showdata = $this->safeClick( - WebDriverBy::Xpath( - "//*[@id='panel-body']". - "/form/div[2]/div/div[1]/input" - ) - ); - $assertText = $this->safeFindElement(WebDriverBy::Id("Topic"))->getText(); - $this->assertContains("Test Topic", $assertText); - } - }//end test_search_keyword() - /** - * Tests that, when loading the help editor, search the keyword with This is - * a test content, click show data, and link to detail. - * - * @return void - */ - public function testSearchKeywordLinkToDetail() - { - $this->safeGet($this->url.'/help_editor/'); - try{ - $this->safeFindElement(WebDriverBy::ID("down"))->click(); - } catch(WebDriverException $ex){} - finally { - $searchbox = $this->safeFindElement(WebDriverBy::Name("keyword")); - $searchbox->sendKeys("This is a test content."); - $showdata = $this->safeClick( - WebDriverBy::Xpath( - "//*[@id='panel-body']". - "/form/div[2]/div/div[1]/input" - ) - ); - $linkDetail = $this->safeClick( - WebDriverBy::Xpath("//*[@id='Topic']/a") - ); - $assertText = $this->safeFindElement( - WebDriverBy::XPath( - "//*[@id='edit_help_content']/div/div/div[2]/div/textarea" - ) - )->getText(); - $this->assertContains("This is a test content.", $assertText); - } - }//end test_search_keyword_to_detail() - - - - /** - * Tests that, when loading the help editor, search Hand Preference, - * click clear form, the text Hand Preference should disappear. - * - * @return void - */ - public function testClearForm() - { - $this->safeGet($this->url.'/help_editor/'); - try{ - $this->safeFindElement(WebDriverBy::ID("down"))->click(); - } catch(WebDriverException $ex){} - finally { - - $searchbox = $this->safeFindElement(WebDriverBy::Name("topic")); - $searchbox->sendKeys("Hand Preference"); - $clearform = $this->safeClick( - WebDriverBy::Xpath( - "//*[@id='panel-body']/". - "form/div[2]/div/div[2]/input" - ) - ); - $assertText = $this->safeFindElement(WebDriverBy::Name("topic"))->getText(); - $this->assertEquals(null, $assertText); - } - }//end test_clear_form() - /** * Tests that help editor loads with the permission * From 32d359118c041869d467e4541c82cb7624d5f905 Mon Sep 17 00:00:00 2001 From: kongtiaowang Date: Fri, 22 Jul 2016 12:05:50 -0400 Subject: [PATCH 39/39] instrument_managerTest.php --- .../test/instrument_managerTest.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 +?>