Skip to content

Commit

Permalink
test add group
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson committed Jan 1, 2018
1 parent cb80316 commit b387da3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
9 changes: 7 additions & 2 deletions application/helpers/viewHelper.php
Expand Up @@ -302,10 +302,15 @@ public static function getLanguageData($bOrderByNative = false, $sLanguageCode =
/**
* Get a tag to help automated tests identify pages
* @param string $name unique view name
* @param string $model_id
* @return string
*/
public static function getViewTestTag($name)
public static function getViewTestTag($name,$model_id = null)
{
return sprintf('<x-test id="action::%s"></x-test>', $name);
$modelTag = null;
if($model_id){
$modelTag = sprintf('model_id="%s"', $model_id);
}
return sprintf('<x-test id="action::%s" %s></x-test>', $name, $modelTag);
}
}
13 changes: 11 additions & 2 deletions application/views/admin/survey/QuestionGroups/editGroup_view.php
@@ -1,6 +1,15 @@
<?php
echo PrepareEditorScript(false, $this);
$count = 0;
/**
* Survey default view
* @var AdminController $this
* @var QuestionGroup $oQuestionGroup
*/

// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('editGroup',$oQuestionGroup->gid);

echo PrepareEditorScript(false, $this);
$count = 0;
?>
<div id='edit-group' class='side-body <?php echo getSideBodyClass(false); ?>'>
<div class="row">
Expand Down
3 changes: 1 addition & 2 deletions application/views/admin/survey/surveySummary_view.php
Expand Up @@ -7,8 +7,7 @@
$count= 0;

// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('surveySummary');
echo '<x-test id="survey_id" survey_id="'.$oSurvey->primaryKey.'"></x-test>';
echo viewHelper::getViewTestTag('surveySummary',$oSurvey->primaryKey);

//TODO : move to controller
$templates = Template::getTemplateListWithPreviews();
Expand Down
11 changes: 9 additions & 2 deletions tests/controllers/CreateSurveyTest.php
Expand Up @@ -96,8 +96,7 @@ public function testCreateSurvey()
$element = $this->findViewTag('surveySummary');
$this->assertNotEmpty($element);

$idTag = self::find(WebDriverBy::id('survey_id'),5);
$sid = intval($idTag->getAttribute('survey_id'));
$sid = intval($element->getAttribute('model_id'));
$survey = \Survey::model()->findByPk($sid);
if($survey){
self::$survey = $survey;
Expand Down Expand Up @@ -153,6 +152,14 @@ public function testAddGroup(){

// Click save.
self::findAndClick(WebDriverBy::id('save-button'));
$element = $this->findViewTag('editGroup');
$this->assertNotEmpty($element);

$sid = intval($element->getAttribute('model_id'));
$survey = \Survey::model()->findByPk($sid);
if($survey){
self::$survey = $survey;
}


}
Expand Down

0 comments on commit b387da3

Please sign in to comment.