Test case for customer create

This commit is contained in:
rahul shukla 2020-02-14 18:02:19 +05:30
parent 3fb2b8a5c9
commit 4e3fef5b04
1 changed files with 45 additions and 0 deletions

View File

@ -23,4 +23,49 @@ class CustomerCest
$I->see($customer->id, '//script[@type="text/x-template"]');
$I->see($customer->last_name, '//script[@type="text/x-template"]');
}
public function testCreate(FunctionalTester $I): void
{
$I->loginAsAdmin();
$I->amOnAdminRoute('admin.customer.index');
$I->click(__('admin::app.customers.customers.add-title'), '//*[contains(@class, "page-action")]');
$I->seeCurrentRouteIs('admin.customer.create');
$I->click(__('admin::app.customers.customers.save-btn-title'), '//*[contains(@class, "page-action")]');
$I->seeFormHasErrors();
$testData = $this->fillForm($I);
$I->click(__('admin::app.customers.customers.save-btn-title'), '//*[contains(@class, "page-action")]');
$I->dontSeeFormErrors();
$I->seeCurrentRouteIs('admin.customer.index');
$I->seeRecord(Customer::class, $testData);
}
/**
* @param FunctionalTester $I
*
* @return array with the test-data
*/
private function fillForm(FunctionalTester $I): array
{
$testData = [
'first_name' => $I->fake()->firstName,
'last_name' => $I->fake()->lastName,
'gender' => $I->fake()->randomElement([
'Male',
'Female',
'Other',
]),
'email' => $I->fake()->email,
];
$I->fillField('first_name', $testData['first_name']);
$I->fillField('last_name', $testData['last_name']);
$I->selectOption('gender', $testData['gender']);
$I->fillField('email', $testData['email']);
return $testData;
}
}