diff --git a/RoboFile.php b/RoboFile.php index 4ea8469676..421e9f761d 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -336,6 +336,15 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->run() ->stopOnFail(); + $this->taskCodecept($pathToCodeception) + ->arg('--steps') + ->arg('--debug') + ->arg('--fail-fast') + ->env($opts['env']) + ->arg($this->testsPath . 'acceptance/contact.feature') + ->run() + ->stopOnFail(); + $this->taskCodecept($pathToCodeception) ->arg('--steps') ->arg('--debug') @@ -671,4 +680,4 @@ private function createDatabase() $this->yell("Error creating database: " . $connection->error); } } -} +} \ No newline at end of file diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php index 6e8d1a31cc..9b29315567 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php @@ -42,6 +42,14 @@ class AdminPage extends \AcceptanceTester */ public static $title = ['id' => 'jform_title']; + /** + * Locator for contact name + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $name = ['id' => 'jform_name']; + /** * Locator for search input field * diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/ContactManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/ContactManagerPage.php new file mode 100644 index 0000000000..7cbb5f8369 --- /dev/null +++ b/tests/codeception/_support/Page/Acceptance/Administrator/ContactManagerPage.php @@ -0,0 +1,94 @@ + "//table[@id='contactList']//tr[1]//td[4]"]; + + /** + * Locator for contact's unfeatured icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeFeatured = ['xpath' => "//table[@id='contactList']//*//span[@class='icon-featured']"]; + + /** + * Locator for contact's unfeatured icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeUnfeatured = ['xpath' => "//table[@id='contactList']//*//span[@class='icon-unfeatured']"]; + + /** + * Locator for contact's access level field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeAccessLevel = ['xpath' => "//table[@id='contactList']//tr[1]//td[6]"]; + + /** + * Locator for contact's unpublish icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeUnpublished = ['xpath' => "//table[@id='contactList']//*//span[@class='icon-unpublish']"]; + + /** + * Method to create new contact + * + * @param string $name The contact name + * + * @When I create new contact with field name as :name + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function fillContactCreateForm($name) + { + $I = $this; + + $I->fillField(self::$name, $name); + } +} diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php b/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php index 24b3bdec86..387738ece5 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php @@ -13,6 +13,7 @@ use Page\Acceptance\Administrator\AdminPage; use Page\Acceptance\Administrator\ArticleManagerPage; use Page\Acceptance\Administrator\CategoryManagerPage; +use Page\Acceptance\Administrator\ContactManagerPage; use Page\Acceptance\Administrator\ExtensionManagerPage; use Page\Acceptance\Administrator\MenuManagerPage; use Page\Acceptance\Administrator\UserAclPage; @@ -91,6 +92,15 @@ class Admin extends \AcceptanceTester */ protected $menuManagerPage = null; + /** + * Contact Manager Page Object for this class + * + * @var null|ContactManagerPage + * + * @since __DEPLOY_VERSION__ + */ + protected $contactManagerPage = null; + /** * User constructor. * @@ -103,13 +113,14 @@ public function __construct(Scenario $scenario) parent::__construct($scenario); // Initialize Page Objects - $this->adminPage = new AdminPage($scenario); - $this->articleManagerPage = new ArticleManagerPage($scenario); - $this->categoryManagerPage = new CategoryManagerPage($scenario); - $this->userManagerPage = new UserManagerPage($scenario); - $this->userGroupPage = new UserGroupPage($scenario); - $this->userAclPage = new UserAclPage($scenario); - $this->menuManagerPage = new MenuManagerPage($scenario); + $this->adminPage = new AdminPage($scenario); + $this->articleManagerPage = new ArticleManagerPage($scenario); + $this->categoryManagerPage = new CategoryManagerPage($scenario); + $this->userManagerPage = new UserManagerPage($scenario); + $this->userGroupPage = new UserGroupPage($scenario); + $this->userAclPage = new UserAclPage($scenario); + $this->menuManagerPage = new MenuManagerPage($scenario); + $this->contactManagerPage = new ContactManagerPage($scenario); $this->extensionManagerPage = new ExtensionManagerPage($scenario); } diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Contact.php b/tests/codeception/_support/Step/Acceptance/Administrator/Contact.php new file mode 100644 index 0000000000..0deadddedf --- /dev/null +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Contact.php @@ -0,0 +1,238 @@ +amOnPage(ContactManagerPage::$url); + $I->adminPage->clickToolbarButton('New'); + } + + /** + * @When I create new contact with field name as :arg1 + */ + public function iCreateNewContactWithFieldNameAs($name) + { + $this->contactManagerPage->fillContactCreateForm($name); + } + + /** + * @When I save the contact :arg1 + */ + public function iSaveTheContact($name) + { + $I = $this; + + $I->adminPage->clickToolbarButton('Save & Close'); + $I->searchForItem($name); + $I->checkExistenceOf($name); + } + + /** + * @Then I should see the contact :arg1 is created + */ + public function iShouldSeeTheContactIsCreated($name) + { + $I = $this; + + $I->contactManagerPage->seeItemIsCreated($name); + } + + /** + * @Given I select the contact with name :$name + */ + public function iSelectTheContactWithName($name) + { + $this->contactManagerPage->haveItemUsingSearch($name); + } + + /** + * @When I change access level as a :arg1 + */ + public function iChangeAccessLevelAsA($accessLevel) + { + $I = $this; + + $I->adminPage->selectOptionInChosenByIdUsingJs('jform_access', $accessLevel); + } + + /** + * @Then I should see the :arg1 as contact access level + */ + public function iShouldSeeTheAsContactAccessLevel($accessLevel) + { + $I = $this; + + $I->see($accessLevel, ContactManagerPage::$seeAccessLevel); + } + + /** + * @Given I have contact with name :arg1 + */ + public function iHaveContactWithName($name) + { + $this->contactManagerPage->haveItemUsingSearch($name); + } + + /** + * @When I unpublish the contact + */ + public function iUnpublishTheContact() + { + $I = $this; + + $I->adminPage->clickToolbarButton('unpublish'); + + } + + /** + * @Then I should see the contact is now unpublished + */ + public function iShouldSeeTheContactIsNowUnpublished() + { + $I = $this; + + $I->seeNumberOfElements(ContactManagerPage::$seeUnpublished, 1); + } + + /** + * @Given I have :arg1 contact which needs to be Trashed + */ + public function iHaveContactWhichNeedsToBeTrashed($name) + { + $this->contactManagerPage->haveItemUsingSearch($name); + } + + /** + * @When I Trash the contact + */ + public function iTrashTheContact() + { + $I = $this; + + $I->adminPage->clickToolbarButton('trash'); + } + + /** + * @Then I should see the contact :arg1 in trash + */ + public function iShouldSeeTheContactInTrash($name) + { + $I = $this; + + $I->contactManagerPage->seeItemInTrash($name, ContactManagerPage::$contactTitle); + } + + /** + * @Given I select the contact with the name :arg1 + */ + public function iSelectTheContactWithTheName($name) + { + $I = $this; + + $I->contactManagerPage->haveItemUsingSearch($name); + $I->adminPage->clickToolbarButton('edit'); + } + + /** + * @Given I have :arg1 contact which is need to be Trashed + */ + public function iHaveContactWhichIsNeedToBeTrashed($name) + { + $this->contactManagerPage->haveItemUsingSearch($name); + } + + /** + * @Given I have :arg1 contact which is Trashed + */ + public function iHaveContactWhichIsTrashed($name) + { + $I = $this; + $I->amOnPage(ContactManagerPage::$url); + $I->waitForText(ContactManagerPage::$contactTitle); + $I->selectOptionInChosenByIdUsingJs('filter_published', "Trashed"); + $I->searchForItem($name); + $I->checkExistenceOf($name); + } + + /** + * @When I empty the trash + */ + public function iEmptyTheTrash() + { + $I = $this; + $I->checkAllResults(); + $I->clickToolbarButton('Empty trash'); + $I->acceptPopup(); + } + + /** + * @Then I should not see the contact :arg1 in trash + */ + public function iShouldNotSeeTheContactInTrash($name) + { + $I = $this; + $I->selectOptionInChosenByIdUsingJs('filter_published', "Trashed"); + $I->searchForItem($name); + $I->dontSee($name); + } + + /** + * @Given I have :arg1 contact which will be featured + */ + public function iHaveContactWhichWillBeFeatured($name) + { + $I = $this; + + $I->amOnPage(ContactManagerPage::$url); + $I->waitForText(ContactManagerPage::$contactTitle); + $I->searchForItem($name); + $I->checkExistenceOf($name); + } + + /** + * @When I feature the contact + */ + public function iFeatureTheContact() + { + $I = $this; + + $I->adminPage->checkAllResults(); + $I->adminPage->clickToolbarButton('featured'); + } + + /** + * @Then I should see the contact is now featured + */ + public function iShouldSeeTheContactIsNowFeatured() + { + $I = $this; + + $I->seeNumberOfElements(ContactManagerPage::$seeFeatured, 1); + } +} diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php index 9e786e68bb..73fa5108b2 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php @@ -170,7 +170,7 @@ public function iSetAccessLevelAsA($accessLevel) { $I = $this; - $I->adminPage->selectOptionInChosenById('jform_access', $accessLevel); + $I->adminPage->selectOptionInChosenByIdUsingJs('jform_access', $accessLevel); } /** diff --git a/tests/codeception/acceptance.suite.dist.yml b/tests/codeception/acceptance.suite.dist.yml index 1199139950..652ebe2604 100644 --- a/tests/codeception/acceptance.suite.dist.yml +++ b/tests/codeception/acceptance.suite.dist.yml @@ -51,3 +51,4 @@ gherkin: - Step\Acceptance\Administrator\Admin - Step\Acceptance\Administrator\Extension - Step\Acceptance\Administrator\Banner + - Step\Acceptance\Administrator\Contact diff --git a/tests/codeception/acceptance/contact.feature b/tests/codeception/acceptance/contact.feature new file mode 100644 index 0000000000..bf85388631 --- /dev/null +++ b/tests/codeception/acceptance/contact.feature @@ -0,0 +1,40 @@ +Feature: contact + In order to manage contacts in the web + As an owner + I need to create modify trash publish and Unpublish contacts + + Background: + When I Login into Joomla administrator + And I see the administrator dashboard + + Scenario: Create an contact + Given There is a add contact link + When I create new contact with field name as "Contact One" + And I save the contact "Contact One" + Then I should see the contact "Contact One" is created + + Scenario: Modify an contact + Given I select the contact with the name "Contact One" + When I change access level as a "Registered" + And I save the contact "Contact One" + Then I should see the "Registered" as contact access level + + Scenario: Featured an contact + Given I have "Contact One" contact which will be featured + When I feature the contact + Then I should see the contact is now featured + + Scenario: Unpublish an contact + Given I have contact with name "Contact One" + When I unpublish the contact + Then I should see the contact is now unpublished + + Scenario: Trash an contact + Given I have "Contact One" contact which is need to be Trashed + When I Trash the contact + Then I should see the contact "Contact One" in trash + + Scenario: Remove contact from trash + Given I have "Contact One" contact which is Trashed + When I empty the trash + Then I should not see the contact "Contact One" in trash