Skip to content

Commit

Permalink
fixed tests and added missing frontend elements
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Gonzalez <[email protected]>
  • Loading branch information
XzAeRo committed Apr 24, 2020
1 parent 4e2e2ee commit 1904d4a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/modules/user/views/sign-in/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<?php echo $form->field($model, 'password_confirm')->passwordInput() ?>

<div class="form-group">
<?php echo Html::submitButton(Yii::t('frontend', 'Sign up'), ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'login-button']) ?>
<?php echo Html::submitButton(Yii::t('frontend', 'Sign up'), ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'signup-button']) ?>
</div>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions frontend/views/article/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@
<?php endif; ?>

<?php echo HtmlPurifier::process($model->body) ?>

<?php if (!empty($model->articleAttachments)): ?>
<h3><?php echo Yii::t('frontend', 'Attachments') ?></h3>
<ul id="article-attachments">
<?php foreach ($model->articleAttachments as $attachment): ?>
<li>
<?php echo \yii\helpers\Html::a(
Html::encode($attachment->name),
['attachment-download', 'id' => $attachment->id])
?>
(<?php echo Yii::$app->formatter->asSize($attachment->size) ?>)
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>

<div class="col-sm-4 col-lg-3">
Expand Down
6 changes: 3 additions & 3 deletions tests/frontend/acceptance/LoginCept.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
$I->amGoingTo('submit login form with no data');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username or email cannot be blank.', '.help-block');
$I->see('Password cannot be blank.', '.help-block');
$I->see('Username or email cannot be blank.', '.alert.alert-danger');
$I->see('Password cannot be blank.', '.alert.alert-danger');

$I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors');
$I->see('Incorrect username or password.', '.help-block');
$I->see('Incorrect username or password.', '.alert.alert-danger');

$I->amGoingTo('try to login with correct credentials');
$loginPage->login('webmaster', 'webmaster');
Expand Down
19 changes: 18 additions & 1 deletion tests/frontend/acceptance/SignupCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testUserSignup($I, $scenario)
$I->wantTo('ensure that signup works');

$signupPage = SignupPage::openBy($I);
$I->see('Signup', 'h1');
$I->see('Sign up', 'h1');

$I->amGoingTo('submit signup form with no data');

Expand All @@ -44,24 +44,41 @@ public function testUserSignup($I, $scenario)
$I->see('Username cannot be blank.', '.alert.alert-danger');
$I->see('E-mail cannot be blank.', '.alert.alert-danger');
$I->see('Password cannot be blank.', '.alert.alert-danger');
$I->see('Confirm Password cannot be blank.', '.alert.alert-danger');

$I->amGoingTo('submit signup form with not correct email');
$signupPage->submit([
'username' => 'tester',
'email' => 'tester.email',
'password' => 'tester_password',
'password_confirm' => 'tester_password',
]);

$I->expectTo('see that email address is wrong');
$I->dontSee('Username cannot be blank.', '.alert.alert-danger');
$I->dontSee('Password cannot be blank.', '.alert.alert-danger');
$I->dontSee('Confirm Password cannot be blank.', '.alert.alert-danger');
$I->see('E-mail is not a valid email address.', '.alert.alert-danger');

$I->amGoingTo('submit signup form with different passwords');
$signupPage->submit([
'username' => 'tester',
'email' => '[email protected]',
'password' => 'tester_password',
'password_confirm' => 'wrong_password',
]);

$I->expectTo('see that confirm password is wrong');
$I->dontSee('Confirm Password cannot be blank.', '.alert.alert-danger');
$I->dontSee('Password cannot be blank.', '.alert.alert-danger');
$I->see('Confirm Password must be equal to "Password".', '.alert.alert-danger');

$I->amGoingTo('submit signup form with correct email');
$signupPage->submit([
'username' => 'tester',
'email' => '[email protected]',
'password' => 'tester_password',
'password_confirm' => 'tester_password',
]);
if (method_exists($I, 'wait')) {
$I->wait(3); // only for selenium
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/functional/ArticleCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public function testArticlesList(FunctionalTester $I)
{
$I->amOnPage(['article/index']);
$I->canSee('Articles', 'h1');
$I->canSee('Test Article 1', 'h2');
$I->dontSee('Test Article 2', 'h2');
$I->canSee('Test Article 1', '.h3.card-title');
$I->dontSee('Test Article 2', '.h3.card-title');
}

public function testArticleView(FunctionalTester $I)
Expand Down
6 changes: 5 additions & 1 deletion tests/frontend/functional/SignupCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testUserSignup($I, $scenario)
$I->wantTo('ensure that signup works');

$signupPage = SignupPage::openBy($I);
$I->see('Signup', 'h1');
$I->see('Sign up', 'h1');

$I->amGoingTo('submit signup form with no data');

Expand All @@ -58,17 +58,20 @@ public function testUserSignup($I, $scenario)
$I->see('Username cannot be blank.', '.alert.alert-danger');
$I->see('E-mail cannot be blank.', '.alert.alert-danger');
$I->see('Password cannot be blank.', '.alert.alert-danger');
$I->see('Confirm Password cannot be blank.', '.alert.alert-danger');

$I->amGoingTo('submit signup form with not correct email');
$signupPage->submit([
'username' => 'tester',
'email' => 'tester.email',
'password' => 'tester_password',
'password_confirm' => 'tester_password',
]);

$I->expectTo('see that email address is wrong');
$I->dontSee('Username cannot be blank.', '.alert.alert-danger');
$I->dontSee('Password cannot be blank.', '.alert.alert-danger');
$I->dontSee('Password Confirm cannot be blank.', '.alert.alert-danger');
$I->see('E-mail is not a valid email address.', '.alert.alert-danger');


Expand All @@ -77,6 +80,7 @@ public function testUserSignup($I, $scenario)
'username' => 'tester',
'email' => '[email protected]',
'password' => 'tester_password',
'password_confirm' => 'tester_password',
]);

$I->expectTo('see that user is created');
Expand Down

0 comments on commit 1904d4a

Please sign in to comment.