From 44e1c8750dd2aec94ef59cfc12bd115d5e4fc6c8 Mon Sep 17 00:00:00 2001 From: dsmewara Date: Thu, 21 Jul 2016 18:20:12 +0530 Subject: [PATCH 1/3] Adding gherkin scenarios for Banners --- tests/acceptance/banner.feature | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/acceptance/banner.feature diff --git a/tests/acceptance/banner.feature b/tests/acceptance/banner.feature new file mode 100644 index 0000000000..0b9b0b26b8 --- /dev/null +++ b/tests/acceptance/banner.feature @@ -0,0 +1,52 @@ +Feature: Banner + In order to manage Banner article in the web + I need to create modify trash archived Check-In And publish and Unpublish Banner + + Background: + Given Joomla CMS is installed + When Login into Joomla administrator with username "admin" and password "admin" + Then I see administrator dashboard + + Scenario: Create a Banner + Given There is an add Banner link + When I create a new banner with field title as "Gsocbanner" + And I save a Banner + Then I should see the "Banner successfully saved." message + + Scenario: Modify a Banner + Given There is a Banner listing page + When I Click the Banner with Name "Gsocbanner" + And I have Change the Banner field title to "Gsocbanner" + And I save a Banner + Then I should see the "Banner successfully saved." message + + Scenario: publish a Banner + Given There is a Banner listing page + When I select the Banner with Name "Gsocbanner" which needs to be published + And I have publish the Banner + Then I should see the "1 banner successfully published." message + + Scenario: Unpublish an Banner + Given There is a Banner listing page + When I select the Banner with Name "Gsocbanner" which needs to be unpublished + And I have unpublish the Banner + Then I should see the "1 banner successfully unpublished." message + + Scenario: Trash a Banner + Given There is a Banner listing page + When I select the Banner with Name "Gsocbanner" which needs to be Trash + And I Trash the Banner + Then I should see the "1 banner successfully trashed." message + + Scenario: archived a Banner + Given There is a Banner listing page + When I select the Banner with Name "Gsocbanner" which needs to be archived + And I archived the Banner + Then I should see the "1 banner successfully archived." message + + Scenario: Check-In a Banner + Given There is a Banner listing page + When I select the Banner with Name "Gsocbanner" which needs to be Check-In + And I Check-In the Banner + Then I should see the "1 banner successfully checked in." message + \ No newline at end of file From 0b9d6883cb08c89b9ef335eb519799e66527b56e Mon Sep 17 00:00:00 2001 From: dsmewara Date: Tue, 26 Jul 2016 11:22:55 +0530 Subject: [PATCH 2/3] Writing Acceptance suites for banner --- RoboFile.php | 9 + tests/_support/AcceptanceTester.php | 3 + .../Acceptance/Administrator/BannerPage.php | 19 ++ .../Step/Acceptance/Administrator/Banner.php | 219 ++++++++++++++++++ tests/acceptance.suite.dist.yml | 3 +- tests/acceptance/banner.feature | 42 ++-- 6 files changed, 280 insertions(+), 15 deletions(-) create mode 100644 tests/_support/Page/Acceptance/Administrator/BannerPage.php create mode 100644 tests/_support/Step/Acceptance/Administrator/Banner.php diff --git a/RoboFile.php b/RoboFile.php index ac70104829..320f093840 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -291,6 +291,15 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->run() ->stopOnFail(); + $this->taskCodecept($pathToCodeception) + ->arg('--steps') + ->arg('--debug') + ->arg('--fail-fast') + ->arg('--env ' . $opts['env']) + ->arg('tests/acceptance/banner.feature') + ->run() + ->stopOnFail(); + /* $this->taskCodecept($pathToCodeception) ->arg('--steps') ->arg('--debug') diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 9c96a19885..b5d29ef5c5 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -128,6 +128,9 @@ public function clickToolbarButton($button) case "archive": $I->click(['xpath' => "//div[@id='toolbar-archive']//button"]); break; + case "unarchive": + $I->click(['xpath' => "//div[@id='toolbar-unarchive']//button"]); + break; case "check-in": $I->click(['xpath' => "//div[@id='toolbar-checkin']//button"]); break; diff --git a/tests/_support/Page/Acceptance/Administrator/BannerPage.php b/tests/_support/Page/Acceptance/Administrator/BannerPage.php new file mode 100644 index 0000000000..cc5d589587 --- /dev/null +++ b/tests/_support/Page/Acceptance/Administrator/BannerPage.php @@ -0,0 +1,19 @@ + 'jform_name']; + + public static $aliasField = ['id' => 'jform_alias']; + + public static $searchField = ['id' => 'filter_search']; + + public static $searchButton = ['class' => 'icon-search']; + + public static $searchToolButton = ['css' => 'button[data-original-title="Filter the list items."]']; +} diff --git a/tests/_support/Step/Acceptance/Administrator/Banner.php b/tests/_support/Step/Acceptance/Administrator/Banner.php new file mode 100644 index 0000000000..13568e9783 --- /dev/null +++ b/tests/_support/Step/Acceptance/Administrator/Banner.php @@ -0,0 +1,219 @@ +amOnPage(BannerPage::$url); + $I->clickToolbarButton('New'); + } + + /** + * @When I create a new banner with field title as :title + */ + public function iCreateANewBannerWithFieldTitleAs($title) + { + $I = $this; + $I->fillField(BannerPage::$titleField, $title); + } + + /** + * @When I save a Banner + */ + public function iSaveABanner() + { + $I = $this; + $I->clickToolbarButton('Save & Close'); + } + + /** + * @Then I should see the :Banner successfully saved. message + */ + public function iShouldSeeTheMessage($message) + { + $I = $this; + $I->waitForText($message, TIMEOUT, AdminPage::$systemMessageContainer); + $I->see($message, AdminPage::$systemMessageContainer); + } + + /** + * @Given There is a Banner listing page + */ + public function thereIsABannerListingPage() + { + $I = $this; + $I->amOnPage(BannerPage::$url); + } + + /** + * @When I Click the Banner with Name :Gsocbanner + */ + public function iClickTheBannerWithName($title) + { + $I = $this; + $I->fillField(BannerPage::$searchField, $title); + $I->Click(BannerPage::$searchButton); + $I->checkAllResults(); + $I->clickToolbarButton('edit'); + } + + /** + * @When I have Change the Banner field title to :Gsocbanner + */ + public function iHaveChangeTheBannerFieldTitleTo($title) + { + $I = $this; + $I->fillField(BannerPage::$titleField, $title); + $I->fillField(BannerPage::$aliasField, $title); + } + + /** + * @When I select the Banner with Name :Gsocbanner which needs to be published + */ + public function iSelectTheBannerWithNameWhichNeedsToBePublished($title) + { + $I = $this; + $I->fillField(BannerPage::$searchField, $title); + $I->Click(BannerPage::$searchButton); + $I->checkAllResults(); + } + + /** + * @When I have publish the Banner + */ + public function iHavePublishTheBanner() + { + $I = $this; + $I->clickToolbarButton('Publish'); + } + + /** + * @When I select the Banner with Name :Gsocbanner which needs to be unpublished + */ + public function iSelectTheBannerWithNameWhichNeedsToBeUnpublished($title) + { + $I = $this; + $I->fillField(BannerPage::$searchField, $title); + $I->Click(BannerPage::$searchButton); + $I->checkAllResults(); + } + + /** + * @When I have unpublish the Banner + */ + public function iHaveUnpublishTheBanner() + { + $I = $this; + $I->clickToolbarButton('Unpublish'); + } + + /** + * @When I select the Banner with Name :Gsocbanner which needs to be Trash + */ + public function iSelectTheBannerWithNameWhichNeedsToBeTrash($title) + { + $I = $this; + $I->fillField(BannerPage::$searchField, $title); + $I->Click(BannerPage::$searchButton); + $I->checkAllResults(); + } + + /** + * @When I have Trash the Banner + */ + public function iTrashTheBanner() + { + $I = $this; + $I->clickToolbarButton('Trash'); + } + + /** + * @When I select the Banner with Name "Gsocbanner" which needs to be Remove Trash + */ + public function iSelectTheBannerWithNameWhichNeedsToBeRemoveTrash() + { + $I = $this; + $I->Click(BannerPage::$searchToolButton); + $I->selectOptionInChosenById('filter_published', "Trashed"); + $I->checkAllResults(); + } + + /** + * @When I Remove Trash the Banner + */ + public function iRemoveTrashTheBanner() + { + $I = $this; + $I->clickToolbarButton('Empty trash'); + $I->acceptPopup(); + } + + /** + * @When I select the Banner with Name :Gsocbanner which needs to be archived + */ + public function iSelectTheBannerWithNameWhichNeedsToBeArchived($title) + { + $I = $this; + $I->fillField(BannerPage::$searchField, $title); + $I->Click(BannerPage::$searchButton); + $I->checkAllResults(); + } + + /** + * @When I archived the Banner + */ + public function iArchivedTheBanner() + { + $I = $this; + $I->clickToolbarButton('Archive'); + } + + /** + * @When I select the Banner with Name :Gsocbanner which needs to be Unarchive + */ + public function iSelectTheBannerWithNameWhichNeedsToBeUnarchive() + { + $I = $this; + $I->Click(BannerPage::$searchToolButton); + $I->selectOptionInChosenById('filter_published', "Archived"); + $I->checkAllResults(); + } + + /** + * @When I Unarchive the Banner + */ + public function iUnarchiveTheBanner() + { + $I = $this; + $I->clickToolbarButton('unarchive'); + } + + /** + * @When I select the Banner with Name :arg1 which needs to be Check-In + */ + public function iSelectTheBannerWithNameWhichNeedsToBeCheckIn($title) + { + $I = $this; + $I->fillField(BannerPage::$searchField, $title); + $I->Click(BannerPage::$searchButton); + $I->checkAllResults(); + } + + /** + * @When I Check-In the Banner + */ + public function iCheckInTheBanner() + { + $I = $this; + $I->clickToolbarButton('Check-in'); + } + +} diff --git a/tests/acceptance.suite.dist.yml b/tests/acceptance.suite.dist.yml index b28adc8165..66e095e90a 100644 --- a/tests/acceptance.suite.dist.yml +++ b/tests/acceptance.suite.dist.yml @@ -38,4 +38,5 @@ gherkin: - AcceptanceTester - Step\Acceptance\Administrator\User - Page\Acceptance\Administrator\Login - - Step\Acceptance\Administrator\Content \ No newline at end of file + - Step\Acceptance\Administrator\Content + - Step\Acceptance\Administrator\Banner \ No newline at end of file diff --git a/tests/acceptance/banner.feature b/tests/acceptance/banner.feature index 0b9b0b26b8..b671850fd9 100644 --- a/tests/acceptance/banner.feature +++ b/tests/acceptance/banner.feature @@ -8,15 +8,15 @@ Feature: Banner Then I see administrator dashboard Scenario: Create a Banner - Given There is an add Banner link - When I create a new banner with field title as "Gsocbanner" - And I save a Banner - Then I should see the "Banner successfully saved." message - + Given There is an add Banner link + When I create a new banner with field title as "Gsocbanner" + And I save a Banner + Then I should see the "Banner successfully saved." message + Scenario: Modify a Banner Given There is a Banner listing page When I Click the Banner with Name "Gsocbanner" - And I have Change the Banner field title to "Gsocbanner" + And I have Change the Banner field title to "Gsocbanner1" And I save a Banner Then I should see the "Banner successfully saved." message @@ -32,11 +32,11 @@ Feature: Banner And I have unpublish the Banner Then I should see the "1 banner successfully unpublished." message - Scenario: Trash a Banner + Scenario: Check-In a Banner Given There is a Banner listing page - When I select the Banner with Name "Gsocbanner" which needs to be Trash - And I Trash the Banner - Then I should see the "1 banner successfully trashed." message + When I select the Banner with Name "Gsocbanner" which needs to be Check-In + And I Check-In the Banner + Then I should see the "1 banner successfully checked in." message Scenario: archived a Banner Given There is a Banner listing page @@ -44,9 +44,23 @@ Feature: Banner And I archived the Banner Then I should see the "1 banner successfully archived." message - Scenario: Check-In a Banner + Scenario: Unarchive a Banner Given There is a Banner listing page - When I select the Banner with Name "Gsocbanner" which needs to be Check-In - And I Check-In the Banner - Then I should see the "1 banner successfully checked in." message + When I select the Banner with Name "Gsocbanner" which needs to be Unarchive + And I Unarchive the Banner + Then I should see the "1 banner successfully published." message + + Scenario: Trash a Banner + Given There is a Banner listing page + When I select the Banner with Name "Gsocbanner" which needs to be Trash + And I have Trash the Banner + Then I should see the "1 banner successfully trashed." message + + Scenario: Remove trash a Banner + Given There is a Banner listing page + When I select the Banner with Name "Gsocbanner" which needs to be Remove Trash + And I Remove Trash the Banner + Then I should see the "1 banner successfully deleted." message + + \ No newline at end of file From 419f656fa11fff764363b3ece441cb7358e005a7 Mon Sep 17 00:00:00 2001 From: dsmewara Date: Tue, 26 Jul 2016 11:51:57 +0530 Subject: [PATCH 3/3] Correct the background scenarios --- tests/acceptance/banner.feature | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/banner.feature b/tests/acceptance/banner.feature index b671850fd9..bfe1b21773 100644 --- a/tests/acceptance/banner.feature +++ b/tests/acceptance/banner.feature @@ -3,9 +3,8 @@ Feature: Banner I need to create modify trash archived Check-In And publish and Unpublish Banner Background: - Given Joomla CMS is installed - When Login into Joomla administrator with username "admin" and password "admin" - Then I see administrator dashboard + When I Login into Joomla administrator with username "admin" and password "admin" + And I see the administrator dashboard Scenario: Create a Banner Given There is an add Banner link