From 0ec18d17b12f214e2e9df60e4da52d918c3e3f17 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Fri, 8 Dec 2023 16:39:02 -0300 Subject: [PATCH] Add indexPageWithLoginUser test case to LoginCest. --- tests/Acceptance/LoginCest.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/Acceptance/LoginCest.php b/tests/Acceptance/LoginCest.php index 1268f8d..c90fbac 100644 --- a/tests/Acceptance/LoginCest.php +++ b/tests/Acceptance/LoginCest.php @@ -164,6 +164,37 @@ public function indexPage(AcceptanceTester $I): void $I->see(Yii::t('yii.user', 'Please fill out the following fields to Sign in.')); } + public function indexPageWithLoginUser(AcceptanceTester $I): void + { + $I->wantTo('security login username submit form success data.'); + $I->haveFixtures([Account::class => AccountFixture::class]); + $account = $I->grabFixture(Account::class, 'confirmed'); + + $I->amGoingTo('navigate to the login page.'); + $I->amOnRoute('login/index'); + + $I->wantTo('ensure that login page works.'); + $I->expectTo('see page index.'); + $I->see(Yii::t('yii.user', 'Sign in'), 'h1'); + $I->see(Yii::t('yii.user', 'Please fill out the following fields to Sign in.')); + + $I->expectTo('fill in the form.'); + $I->fillField('#loginform-login', $account->email); + $I->fillField('#loginform-password', '123456'); + $I->click(Yii::t('yii.user', 'Sign in')); + + $I->expectTo('see that the user is logged in.'); + $I->seeLink(Yii::t('yii.user', 'Logout')); + + $I->amGoingTo('navigate to the login page.'); + $I->amOnRoute('login/index'); + + $I->expectTo('see message home page and not see login page.'); + $I->see(Yii::t('app.basic', 'Web Application')); + $I->dontSee(Yii::t('yii.user', 'Sign in'), 'h1'); + $I->dontSee(Yii::t('yii.user', 'Please fill out the following fields to Sign in.')); + } + public function linkResendConfirmationMessage(AcceptanceTester $I): void { $I->amGoingTo('set confirmation true.');