diff --git a/codeception.yml b/codeception.yml index 7fa846cd3..c38b039d8 100644 --- a/codeception.yml +++ b/codeception.yml @@ -4,13 +4,11 @@ include: # - tests/PyzTest/Yves/Application # - tests/PyzTest/Yves/Assets # - tests/PyzTest/Yves/Availability - +# # - tests/PyzTest/Yves/Cart # - tests/PyzTest/Yves/Checkout -# - tests/PyzTest/Yves/Customer + - tests/PyzTest/Yves/Customer # - tests/PyzTest/Yves/Newsletter -# - tests/PyzTest/Yves/Product -# - tests/PyzTest/Zed/Availability # - tests/PyzTest/Zed/Calculation # - tests/PyzTest/Zed/CmsGui # - tests/PyzTest/Zed/Console @@ -18,10 +16,9 @@ include: # - tests/PyzTest/Zed/Product # - tests/PyzTest/Zed/ProductOption # - tests/PyzTest/Zed/ProductRelation -# - tests/PyzTest/Zed/Sales # - tests/PyzTest/Zed/Tax # - tests/PyzTest/Zed/Touch - - vendor/spryker/spryker/Bundles/*/* +# - vendor/spryker/spryker/Bundles/*/* paths: log: tests/_output diff --git a/composer.json b/composer.json index b62f39f22..2212b40df 100644 --- a/composer.json +++ b/composer.json @@ -95,18 +95,16 @@ }, "psr-4": { "PyzTest\\Shared\\Testify\\Helper\\": "tests/PyzTest/Shared/Testify/_support/Helper", + "PyzTest\\Yves\\Application\\PageObject\\": "tests/PyzTest/Yves/Application/_support/PageObject", "PyzTest\\Yves\\Cart\\PageObject\\": "tests/PyzTest/Yves/Cart/_support/PageObject", "PyzTest\\Yves\\Checkout\\Helper\\": "tests/PyzTest/Yves/Checkout/_support/Helper", "PyzTest\\Yves\\Customer\\PageObject\\": "tests/PyzTest/Yves/Customer/_support/PageObject", + "PyzTest\\Yves\\Customer\\Helper\\": "tests/PyzTest/Yves/Customer/_support/Helper", "PyzTest\\Yves\\Product\\PageObject\\": "tests/PyzTest/Yves/Product/_support/PageObject", "PyzTest\\Zed\\Availability\\PageObject\\": "tests/PyzTest/Zed/Availability/_support/PageObject", "PyzTest\\Zed\\CmsGui\\PageObject\\": "tests/PyzTest/Zed/CmsGui/_support/PageObject", "PyzTest\\Zed\\Console\\Helper\\": "tests/PyzTest/Zed/Console/_support/Helper" - }, - "files": [ - "tests/PyzTest/Zed/Availability/_support/_generated/AvailabilityPresentationTesterActions.php", - "tests/PyzTest/Zed/Availability/_support/AvailabilityPresentationTester.php" - ] + } }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/tests/PyzTest/Shared/Testify/_support/Helper/Environment.php b/tests/PyzTest/Shared/Testify/_support/Helper/Environment.php index f478acfe9..882b5384a 100644 --- a/tests/PyzTest/Shared/Testify/_support/Helper/Environment.php +++ b/tests/PyzTest/Shared/Testify/_support/Helper/Environment.php @@ -1,10 +1,5 @@ loadCustomerByEmail($email); - if ($customerEntity) { - return; - } - $this->setupSession(); - $customerTransfer = Customer::getCustomerData($email); + $customerBuilder = new CustomerBuilder($seed); + $customerTransfer = $customerBuilder->build(); + $password = $customerTransfer->getPassword(); $mailMock = new CustomerToMailBridge($this->getMailMock()); $this->setDependency(CustomerDependencyProvider::FACADE_MAIL, $mailMock); $this->getFacade()->registerCustomer($customerTransfer); + + $customerTransfer->setPassword($password); + + return $customerTransfer; } /** @@ -213,23 +215,24 @@ public function addNewsletterSubscription($email, $type = NewsletterConstants::E } /** - * @param string $email + * @param array $seed * - * @return void + * @return \Generated\Shared\Transfer\CustomerTransfer */ - public function amLoggedInCustomer($email = Customer::NEW_CUSTOMER_EMAIL) + public function amLoggedInCustomer(array $seed) { - $this->haveRegisteredCustomer($email); - $customerTransfer = Customer::getCustomerData($email); + $customerTransfer = $this->haveRegisteredCustomer($seed); - $i = $this->getWebDriver(); - $i->amOnPage(CustomerLoginPage::URL); - $i->submitForm(['name' => 'loginForm'], [ + $tester = $this->getWebDriver(); + $tester->amOnPage(CustomerLoginPage::URL); + $tester->submitForm(['name' => 'loginForm'], [ CustomerLoginPage::FORM_FIELD_SELECTOR_EMAIL => $customerTransfer->getEmail(), CustomerLoginPage::FORM_FIELD_SELECTOR_PASSWORD => $customerTransfer->getPassword(), ]); - $i->wait(2); + $tester->wait(2); + + return $customerTransfer; } /** diff --git a/tests/PyzTest/Yves/Newsletter/Presentation/NewsletterSubscriptionCest.php b/tests/PyzTest/Yves/Newsletter/Presentation/NewsletterSubscriptionCest.php index 47b54d302..d4f425011 100644 --- a/tests/PyzTest/Yves/Newsletter/Presentation/NewsletterSubscriptionCest.php +++ b/tests/PyzTest/Yves/Newsletter/Presentation/NewsletterSubscriptionCest.php @@ -7,8 +7,8 @@ namespace PyzTest\Yves\Newsletter\Yves; +use Generated\Shared\DataBuilder\CustomerBuilder; use PyzTest\Yves\Application\PageObject\Homepage; -use PyzTest\Yves\Customer\PageObject\Customer; use PyzTest\Yves\Customer\PageObject\CustomerNewsletterPage; use PyzTest\Yves\Customer\PageObject\CustomerOverviewPage; use PyzTest\Yves\Newsletter\NewsletterPresentationTester; @@ -38,7 +38,9 @@ public function iCanSubscribeWithAnUnsubscribedEmail(NewsletterPresentationTeste $i->amOnPage(Homepage::URL); - $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, NewsletterSubscriptionHomePage::NEW_EMAIL); + $customerTransfer = $this->buildCustomerTransfer(); + + $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, $customerTransfer->getEmail()); $i->click(NewsletterSubscriptionHomePage::FORM_SUBMIT); $i->see(NewsletterSubscriptionHomePage::SUCCESS_MESSAGE); @@ -56,9 +58,11 @@ public function iCanNotSubscribeWithAnAlreadySubscribedEmail(NewsletterPresentat $i->amOnPage(Homepage::URL); - $i->haveAnAlreadySubscribedEmail(NewsletterSubscriptionHomePage::EXISTING_EMAIL); + $customerTransfer = $this->buildCustomerTransfer(); + + $i->haveAnAlreadySubscribedEmail($customerTransfer->getEmail()); - $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, NewsletterSubscriptionHomePage::EXISTING_EMAIL); + $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, $customerTransfer->getEmail()); $i->click(NewsletterSubscriptionHomePage::FORM_SUBMIT); $i->see(NewsletterSubscriptionHomePage::ERROR_MESSAGE); @@ -76,10 +80,12 @@ public function subscribedEmailIsLinkedWithCustomerAfterRegistration(NewsletterP $i->amOnPage(Homepage::URL); - $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, Customer::NEW_CUSTOMER_EMAIL); + $customerTransfer = $this->buildCustomerTransfer(); + + $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, $customerTransfer->getEmail()); $i->click(NewsletterSubscriptionHomePage::FORM_SUBMIT); - $i->amLoggedInCustomer(Customer::NEW_CUSTOMER_EMAIL); + $i->amLoggedInCustomer($customerTransfer->toArray()); $i->amOnPage(CustomerOverviewPage::URL); $i->see(CustomerOverviewPage::NEWSLETTER_SUBSCRIBED); @@ -97,10 +103,12 @@ public function subscribedEmailCanBeUnsubscribedByCustomerAfterRegistration(News $i->amOnPage(Homepage::URL); - $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, Customer::NEW_CUSTOMER_EMAIL); + $customerTransfer = $this->buildCustomerTransfer(); + + $i->fillField(NewsletterSubscriptionHomePage::FORM_SELECTOR, $customerTransfer->getEmail()); $i->click(NewsletterSubscriptionHomePage::FORM_SUBMIT); - $i->amLoggedInCustomer(Customer::NEW_CUSTOMER_EMAIL); + $i->amLoggedInCustomer($customerTransfer->toArray()); $i->amOnPage(CustomerOverviewPage::URL); $i->see(CustomerOverviewPage::NEWSLETTER_SUBSCRIBED); @@ -114,4 +122,14 @@ public function subscribedEmailCanBeUnsubscribedByCustomerAfterRegistration(News $i->dontSeeCheckboxIsChecked(['name' => CustomerNewsletterPage::FORM_FIELD_SELECTOR_NEWSLETTER_SUBSCRIPTION]); } + /** + * @return \Generated\Shared\Transfer\CustomerTransfer|\Spryker\Shared\Kernel\Transfer\AbstractTransfer + */ + protected function buildCustomerTransfer() + { + $customerTransfer = (new CustomerBuilder())->build(); + + return $customerTransfer; + } + } diff --git a/tests/PyzTest/Yves/Newsletter/codeception.yml b/tests/PyzTest/Yves/Newsletter/codeception.yml index d4fae673b..d247407fa 100644 --- a/tests/PyzTest/Yves/Newsletter/codeception.yml +++ b/tests/PyzTest/Yves/Newsletter/codeception.yml @@ -19,14 +19,15 @@ suites: enabled: - \PyzTest\Shared\Testify\Helper\Environment - \SprykerTest\Shared\Config\Helper\ConfigInit + - \SprykerTest\Shared\Testify\Helper\LocatorHelper - \SprykerTest\Shared\Propel\Helper\ConnectionHelper + - \SprykerTest\Shared\Application\Helper\YvesHelper - \PyzTest\Yves\Customer\Helper\CustomerHelper - - \SprykerTest\Shared\Propel\Helper\PropelInstallHelper - WebDriver: url: '' browser: chrome window_size: 1920x1080 host: 0.0.0.0 restart: false + - \SprykerTest\Shared\Testify\Helper\DependencyHelper - \SprykerTest\Shared\Testify\Helper\DataCleanupHelper - - \SprykerTest\Shared\Application\Helper\YvesHelper diff --git a/tests/PyzTest/Yves/Product/codeception.yml b/tests/PyzTest/Yves/Product/codeception.yml deleted file mode 100644 index 4eab0575b..000000000 --- a/tests/PyzTest/Yves/Product/codeception.yml +++ /dev/null @@ -1,12 +0,0 @@ -namespace: PyzTest\Yves\Product - -paths: - tests: . - data: _data - support: _support - log: _output - -coverage: - enabled: true - remote: false - whitelist: { include: ['../../../../src/*'] } diff --git a/tests/PyzTest/Zed/Availability/Presentation/.gitkeep b/tests/PyzTest/Zed/Availability/Presentation/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/PyzTest/Zed/Availability/_support/AvailabilityPresentationTester.php b/tests/PyzTest/Zed/Availability/_support/AvailabilityPresentationTester.php deleted file mode 100644 index 8226d7448..000000000 --- a/tests/PyzTest/Zed/Availability/_support/AvailabilityPresentationTester.php +++ /dev/null @@ -1,39 +0,0 @@ -amZed(); - $this->amLoggedInUser(); - } - -} diff --git a/tests/PyzTest/Zed/Availability/_support/PageObject/AvailabilityViewPage.php b/tests/PyzTest/Zed/Availability/_support/PageObject/AvailabilityViewPage.php index 99f5caf20..5eef2db07 100644 --- a/tests/PyzTest/Zed/Availability/_support/PageObject/AvailabilityViewPage.php +++ b/tests/PyzTest/Zed/Availability/_support/PageObject/AvailabilityViewPage.php @@ -1,8 +1,4 @@ wantTo('Create cms page with multiple translations'); - $iPage->expect('Page is persisted in Zed, exported to Yves and is accesible.'); - - $iPage->amLoggedInUser(); - $iPage->amOnPage(CmsCreatePage::URL); - $iPage->selectOption('//*[@id="cms_page_fkTemplate"]', 'static full page'); - - $iPage->setValidFrom('1985-07-01'); - $iPage->setValidTo('2050-07-01'); - $iPage->fillLocalizedUrlForm(0, CmsCreatePage::getLocalizedName('en'), CmsCreatePage::getLocalizedUrl('en')); - $iPage->expandLocalizedUrlPane(); - $iPage->fillLocalizedUrlForm(1, CmsCreatePage::getLocalizedName('de'), CmsCreatePage::getLocalizedUrl('de')); - $iPage->clickSubmit(); - - $iPage->see(CmsCreatePage::PAGE_CREATED_SUCCESS_MESSAGE); - - $iGlossary->includeJquery(); - - $iGlossary->fillPlaceholderContents(0, 0, CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'en')); - $iGlossary->fillPlaceholderContents(0, 1, CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'de')); - - $iGlossary->fillPlaceholderContents(1, 0, CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'en')); - $iGlossary->fillPlaceholderContents(1, 1, CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'de')); - - $iGlossary->clickSubmit(); - - $idCmsPage = $iGlossary->grabCmsPageId(); - - $iPage->amOnPage(sprintf(CmsEditPage::URL, $idCmsPage)); - - $iPage->clickPublishButton(); - - $iPage->see(CmsEditPage::PAGE_PUBLISH_SUCCESS_MESSAGE); - - $iPage->runCollectors(); - - $yvesTester = $iPage->haveFriend('yvesTester', YvesAcceptanceTester::class); - - $yvesTester->does(function (YvesAcceptanceTester $i) { - - $i->amOnPage(CmsCreatePage::getLocalizedUrl('de')); - - $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'de')); - $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'de')); - - $i->amOnPage(CmsCreatePage::getLocalizedUrl('en')); - - $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'en')); - $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'en')); - - }); - } - -} diff --git a/tests/PyzTest/Zed/CmsGui/Presentation/CmsGuiCreatePageCest.php b/tests/PyzTest/Zed/CmsGui/Presentation/CmsGuiCreatePageCest.php new file mode 100644 index 000000000..3b6146083 --- /dev/null +++ b/tests/PyzTest/Zed/CmsGui/Presentation/CmsGuiCreatePageCest.php @@ -0,0 +1,85 @@ +wantTo('Create cms page with multiple translations'); + $i->expect('Page is persisted in Zed, exported to Yves and is accesible.'); + + $i->amLoggedInUser(); + $i->amOnPage(CmsCreatePage::URL); + $i->selectOption('//*[@id="cms_page_fkTemplate"]', 'static full page'); + + $i->setValidFrom('1985-07-01'); + $i->setValidTo('2050-07-01'); + $i->fillLocalizedUrlForm(0, CmsCreatePage::getLocalizedName('en'), CmsCreatePage::getLocalizedUrl('en')); + $i->expandLocalizedUrlPane(); + $i->fillLocalizedUrlForm(1, CmsCreatePage::getLocalizedName('de'), CmsCreatePage::getLocalizedUrl('de')); + $i->clickSubmit(); + + $i->see(CmsCreatePage::PAGE_CREATED_SUCCESS_MESSAGE); + + $i->includeJquery(); + + $i->fillPlaceholderContents(0, 0, CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'en')); + $i->fillPlaceholderContents(0, 1, CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'de')); + + $i->fillPlaceholderContents(1, 0, CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'en')); + $i->fillPlaceholderContents(1, 1, CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'de')); + + $i->clickSubmit(); + + $idCmsPage = $i->grabCmsPageId(); + + $i->amOnPage(sprintf(CmsEditPage::URL, $idCmsPage)); + + $i->clickPublishButton(); + + $i->see(CmsEditPage::PAGE_PUBLISH_SUCCESS_MESSAGE); + + $i->runCollectors(); + + // TODO re-enable +// $yvesTester = $i->haveFriend('yvesTester', YvesAcceptanceTester::class); +// +// $yvesTester->does(function (YvesAcceptanceTester $i) { +// +// $i->amOnPage(CmsCreatePage::getLocalizedUrl('de')); +// +// $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'de')); +// $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'de')); +// +// $i->amOnPage(CmsCreatePage::getLocalizedUrl('en')); +// +// $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('title', 'en')); +// $i->see(CmsCreateGlossaryPage::getLocalizedPlaceholderData('contents', 'en')); +// +// }); + } + +} diff --git a/tests/PyzTest/Zed/CmsGui/Acceptance/CmsGuiPageListCest.php b/tests/PyzTest/Zed/CmsGui/Presentation/CmsGuiPageListCest.php similarity index 79% rename from tests/PyzTest/Zed/CmsGui/Acceptance/CmsGuiPageListCest.php rename to tests/PyzTest/Zed/CmsGui/Presentation/CmsGuiPageListCest.php index 95fbf464e..b7cb98760 100644 --- a/tests/PyzTest/Zed/CmsGui/Acceptance/CmsGuiPageListCest.php +++ b/tests/PyzTest/Zed/CmsGui/Presentation/CmsGuiPageListCest.php @@ -6,7 +6,7 @@ namespace PyzTest\Zed\CmsGui\Acceptance; -use PyzTest\Zed\CmsGui\CmsGuiAcceptanceTester; +use PyzTest\Zed\CmsGui\CmsGuiPresentationTester; use PyzTest\Zed\CmsGui\PageObject\CmsListPage; /** @@ -22,11 +22,11 @@ class CmsGuiPageListCest { /** - * @param \PyzTest\Zed\CmsGui\CmsGuiAcceptanceTester $i + * @param \PyzTest\Zed\CmsGui\CmsGuiPresentationTester $i * * @return void */ - public function testICanOpenCmsPageList(CmsGuiAcceptanceTester $i) + public function testICanOpenCmsPageList(CmsGuiPresentationTester $i) { $i->amLoggedInUser(); $i->amOnPage(CmsListPage::URL); diff --git a/tests/PyzTest/Zed/CmsGui/Tester/CmsCreateGlossaryTester.php b/tests/PyzTest/Zed/CmsGui/Tester/CmsCreateGlossaryTester.php deleted file mode 100644 index acc0fa073..000000000 --- a/tests/PyzTest/Zed/CmsGui/Tester/CmsCreateGlossaryTester.php +++ /dev/null @@ -1,64 +0,0 @@ -executeJS("$('#$translationElementId').text('$contents');"); - } - - /** - * @return $this - */ - public function includeJquery() - { - $this->executeJS( - ' - var jq = document.createElement("script"); - jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; - document.getElementsByTagName("head")[0].appendChild(jq); - ' - ); - - $this->wait(1); - - return $this; - } - - /** - * @return int - */ - public function grabCmsPageId() - { - return $this->grabFromCurrentUrl('/id-cms-page=(\d+)/'); - } - - /** - * @return $this - */ - public function clickSubmit() - { - $this->click('//*[@id="submit-cms"]'); - - return $this; - } - -} diff --git a/tests/PyzTest/Zed/CmsGui/Tester/CmsCreatePageTester.php b/tests/PyzTest/Zed/CmsGui/Tester/CmsCreatePageTester.php deleted file mode 100644 index d45d06909..000000000 --- a/tests/PyzTest/Zed/CmsGui/Tester/CmsCreatePageTester.php +++ /dev/null @@ -1,83 +0,0 @@ -fillField("//*[@id=\"cms_page_validFrom\"]", $date); - - return $this; - } - - /** - * @param string $date - * - * @return $this - */ - public function setValidTo($date) - { - $this->fillField("//*[@id=\"cms_page_validTo\"]", $date); - - return $this; - } - - /** - * @param int $formIndex - * @param string $name - * @param string $url - * - * @return $this - */ - public function fillLocalizedUrlForm($formIndex, $name, $url) - { - $this->fillField('//*[@id="cms_page_pageAttributes_' . $formIndex . '_name"]', $name); - $this->fillField('//*[@id="cms_page_pageAttributes_' . $formIndex . '_url"]', $url); - - return $this; - } - - /** - * @return $this - */ - public function expandLocalizedUrlPane() - { - $this->click('//*[@id="tab-content-general"]/div/div[5]/div[1]/a'); - - return $this; - } - - /** - * @return $this - */ - public function clickSubmit() - { - $this->click('//*[@id="submit-cms"]'); - - return $this; - } - - /** - * @return $this - */ - public function clickPublishButton() - { - $this->click('//*[@id="page-wrapper"]/div[2]/div[2]/div/a[1]'); - - return $this; - } - -} diff --git a/tests/PyzTest/Zed/CmsGui/Tester/CmsPageListTester.php b/tests/PyzTest/Zed/CmsGui/Tester/CmsPageListTester.php deleted file mode 100644 index 2fcc03bb8..000000000 --- a/tests/PyzTest/Zed/CmsGui/Tester/CmsPageListTester.php +++ /dev/null @@ -1,13 +0,0 @@ -executeJS("$('#$translationElementId').text('$contents');"); + $this->amZed(); + $this->amLoggedInUser(); } /** + * @param string $date + * * @return $this */ - public function includeJquery() + public function setValidFrom($date) { - $this->executeJS( - ' - var jq = document.createElement("script"); - jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; - document.getElementsByTagName("head")[0].appendChild(jq); - ' - ); - - $this->wait(1); + $this->fillField("//*[@id=\"cms_page_validFrom\"]", $date); return $this; } /** - * @return int + * @param string $date + * + * @return $this */ - public function grabCmsPageId() + public function setValidTo($date) { - return $this->grabFromCurrentUrl('/id-cms-page=(\d+)/'); + $this->fillField("//*[@id=\"cms_page_validTo\"]", $date); + + return $this; } /** + * @param int $formIndex + * @param string $name + * @param string $url + * * @return $this */ - public function clickSubmit() + public function fillLocalizedUrlForm($formIndex, $name, $url) { - $this->click('//*[@id="submit-cms"]'); + $this->fillField('//*[@id="cms_page_pageAttributes_' . $formIndex . '_name"]', $name); + $this->fillField('//*[@id="cms_page_pageAttributes_' . $formIndex . '_url"]', $url); return $this; } /** - * @param string $date + * @param int $placeHolderIndex + * @param int $localeIndex + * @param string $contents * - * @return $this + * @return void */ - public function setValidFrom($date) + public function fillPlaceholderContents($placeHolderIndex, $localeIndex, $contents) { - $this->fillField("//*[@id=\"cms_page_validFrom\"]", $date); + $translationElementId = 'cms_glossary_glossaryAttributes_' . $placeHolderIndex . '_translations_' . $localeIndex . '_translation'; - return $this; + $this->executeJS("$('#$translationElementId').text('$contents');"); } /** - * @param string $date - * * @return $this */ - public function setValidTo($date) + public function expandLocalizedUrlPane() { - $this->fillField("//*[@id=\"cms_page_validTo\"]", $date); + $this->click('//*[@id="tab-content-general"]/div/div[5]/div[1]/a'); return $this; } /** - * @param int $formIndex - * @param string $name - * @param string $url - * * @return $this */ - public function fillLocalizedUrlForm($formIndex, $name, $url) + public function clickSubmit() { - $this->fillField('//*[@id="cms_page_pageAttributes_' . $formIndex . '_name"]', $name); - $this->fillField('//*[@id="cms_page_pageAttributes_' . $formIndex . '_url"]', $url); + $this->click('//*[@id="submit-cms"]'); return $this; } @@ -115,9 +111,9 @@ public function fillLocalizedUrlForm($formIndex, $name, $url) /** * @return $this */ - public function expandLocalizedUrlPane() + public function clickPublishButton() { - $this->click('//*[@id="tab-content-general"]/div/div[5]/div[1]/a'); + $this->click('//*[@id="page-wrapper"]/div[2]/div[2]/div/a[1]'); return $this; } @@ -125,11 +121,27 @@ public function expandLocalizedUrlPane() /** * @return $this */ - public function clickPublishButton() + public function includeJquery() { - $this->click('//*[@id="page-wrapper"]/div[2]/div[2]/div/a[1]'); + $this->executeJS( + ' + var jq = document.createElement("script"); + jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; + document.getElementsByTagName("head")[0].appendChild(jq); + ' + ); + + $this->wait(1); return $this; } + /** + * @return int + */ + public function grabCmsPageId() + { + return $this->grabFromCurrentUrl('/id-cms-page=(\d+)/'); + } + } diff --git a/tests/PyzTest/Zed/CmsGui/_support/PageObject/CmsCreateGlossaryPage.php b/tests/PyzTest/Zed/CmsGui/_support/PageObject/CmsCreateGlossaryPage.php index 6ac8604fd..56611037b 100644 --- a/tests/PyzTest/Zed/CmsGui/_support/PageObject/CmsCreateGlossaryPage.php +++ b/tests/PyzTest/Zed/CmsGui/_support/PageObject/CmsCreateGlossaryPage.php @@ -1,8 +1,4 @@ amLoggedInUser(); $i->amOnPage(NavigationCreatePage::URL); @@ -46,11 +48,11 @@ public function testICanCreateReadUpdateAndDeleteNavigation(NavigationCRUDTester } /** - * @param \Acceptance\NavigationGui\Tester\NavigationCRUDTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return int */ - protected function create(NavigationCRUDTester $i) + protected function create(NavigationGuiPresentationTester $i) { $i->wantTo('Create navigation.'); $i->expect('Navigation is persisted in Zed.'); @@ -66,11 +68,11 @@ protected function create(NavigationCRUDTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationCRUDTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - protected function read(NavigationCRUDTester $i) + protected function read(NavigationGuiPresentationTester $i) { $i->wantTo('See navigation list.'); $i->expect('Navigation table is shown and not empty'); @@ -79,12 +81,12 @@ protected function read(NavigationCRUDTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationCRUDTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * @param int $idNavigation * * @return void */ - protected function update(NavigationCRUDTester $i, $idNavigation) + protected function update(NavigationGuiPresentationTester $i, $idNavigation) { $i->wantTo('Update existing navigation.'); $i->expect('Navigation is persisted in Zed'); @@ -98,11 +100,11 @@ protected function update(NavigationCRUDTester $i, $idNavigation) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationCRUDTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - protected function activate(NavigationCRUDTester $i) + protected function activate(NavigationGuiPresentationTester $i) { $i->wantTo('Activate navigation.'); $i->expect('New navigation status persisted in Zed.'); @@ -115,11 +117,11 @@ protected function activate(NavigationCRUDTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationCRUDTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - protected function delete(NavigationCRUDTester $i) + protected function delete(NavigationGuiPresentationTester $i) { $i->wantTo('Delete navigation.'); $i->expect('Navigation is removed from Zed.'); diff --git a/tests/PyzTest/Zed/NavigationGui/Presentation/NavigationTreeCest.php b/tests/PyzTest/Zed/NavigationGui/Presentation/NavigationTreeCest.php index 9fe4c55cb..cb8074171 100644 --- a/tests/PyzTest/Zed/NavigationGui/Presentation/NavigationTreeCest.php +++ b/tests/PyzTest/Zed/NavigationGui/Presentation/NavigationTreeCest.php @@ -5,22 +5,24 @@ * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ -namespace Acceptance\NavigationGui; +namespace PyzTest\Zed\NavigationGui\Presentation; -use Acceptance\NavigationGui\PageObject\NavigationNodeCreatePage; -use Acceptance\NavigationGui\PageObject\NavigationNodeUpdatePage; -use Acceptance\NavigationGui\PageObject\NavigationPage; -use Acceptance\NavigationGui\Tester\NavigationTreeTester; use Generated\Shared\Transfer\NavigationNodeLocalizedAttributesTransfer; use Generated\Shared\Transfer\NavigationNodeTransfer; use Generated\Shared\Transfer\NavigationTransfer; use Generated\Shared\Transfer\NavigationTreeNodeTransfer; use Generated\Shared\Transfer\NavigationTreeTransfer; +use PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester; +use PyzTest\Zed\NavigationGui\PageObject\NavigationNodeCreatePage; +use PyzTest\Zed\NavigationGui\PageObject\NavigationNodeUpdatePage; +use PyzTest\Zed\NavigationGui\PageObject\NavigationPage; /** * Auto-generated group annotations - * @group Acceptance + * @group PyzTest + * @group Zed * @group NavigationGui + * @group Presentation * @group NavigationTreeCest * Add your own group annotations below this line */ @@ -28,11 +30,11 @@ class NavigationTreeCest { /** - * @param \Acceptance\NavigationGui\Tester\NavigationTreeTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - public function testSeeEmptyNavigationTree(NavigationTreeTester $i) + public function testSeeEmptyNavigationTree(NavigationGuiPresentationTester $i) { $i->wantTo('See navigation tree.'); $i->expect('Empty navigation tree displayed.'); @@ -50,11 +52,11 @@ public function testSeeEmptyNavigationTree(NavigationTreeTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationTreeTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - public function testCreateChildNodeWithoutType(NavigationTreeTester $i) + public function testCreateChildNodeWithoutType(NavigationGuiPresentationTester $i) { $i->wantTo('Create child node without type.'); $i->expect('Navigation should have a root node persisted.'); @@ -79,11 +81,11 @@ public function testCreateChildNodeWithoutType(NavigationTreeTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationTreeTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - public function testCreateChildNodeWithExternalUrlType(NavigationTreeTester $i) + public function testCreateChildNodeWithExternalUrlType(NavigationGuiPresentationTester $i) { $i->wantTo('Create external URL child node.'); $i->expect('Navigation should have a root node persisted.'); @@ -113,11 +115,11 @@ public function testCreateChildNodeWithExternalUrlType(NavigationTreeTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationTreeTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - public function testUpdateNodeToCategoryType(NavigationTreeTester $i) + public function testUpdateNodeToCategoryType(NavigationGuiPresentationTester $i) { $i->wantTo('Update child node to category type.'); $i->expect('Node changes should persist in Zed.'); @@ -152,11 +154,11 @@ public function testUpdateNodeToCategoryType(NavigationTreeTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationTreeTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - public function testCreateChildNodeWithCmsPageType(NavigationTreeTester $i) + public function testCreateChildNodeWithCmsPageType(NavigationGuiPresentationTester $i) { $i->wantTo('Create CMS page child node.'); $i->expect('Navigation should have a new child node persisted.'); @@ -193,11 +195,11 @@ public function testCreateChildNodeWithCmsPageType(NavigationTreeTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationTreeTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - public function testChangeNavigationTreeStructure(NavigationTreeTester $i) + public function testChangeNavigationTreeStructure(NavigationGuiPresentationTester $i) { $i->wantTo('Change tree structure and save.'); $i->expect('Updated navigation tree structure should have persisted.'); @@ -250,11 +252,11 @@ public function testChangeNavigationTreeStructure(NavigationTreeTester $i) } /** - * @param \Acceptance\NavigationGui\Tester\NavigationTreeTester $i + * @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i * * @return void */ - public function testDeleteNavigationNode(NavigationTreeTester $i) + public function testDeleteNavigationNode(NavigationGuiPresentationTester $i) { /** * Test skipped because popup confirmation is not working as expected under phantomjs. diff --git a/tests/PyzTest/Zed/NavigationGui/Tester/NavigationCRUDTester.php b/tests/PyzTest/Zed/NavigationGui/Tester/NavigationCRUDTester.php deleted file mode 100644 index 04ddfc4d8..000000000 --- a/tests/PyzTest/Zed/NavigationGui/Tester/NavigationCRUDTester.php +++ /dev/null @@ -1,106 +0,0 @@ -fillField('//*[@id="navigation_name"]', $value); - } - - /** - * @param string $value - * - * @return void - */ - public function setKeyField($value) - { - $this->fillField('//*[@id="navigation_key"]', $value); - } - - /** - * @param bool $checked - * - * @return void - */ - public function checkIsActiveField($checked) - { - if ($checked) { - $this->checkOption('//*[@id="navigation_is_active"]'); - } else { - $this->uncheckOption('//*[@id="navigation_is_active"]'); - } - } - - /** - * @return void - */ - public function submitNavigationForm() - { - $this->click('//*[@id="navigation-save-btn"]'); - } - - /** - * @param string $pattern - * @param string $value - * - * @return void - */ - public function seeMatches($pattern, $value) - { - $this->assertRegExp($pattern, $value); - } - - /** - * @return void - */ - public function clickEditFirstRowInList() - { - $this->click('//*[@id="navigation-table"]/tbody/tr[1]/td[5]/a'); - } - - /** - * @param string $expectedMessagePattern - * - * @return int - */ - public function seeSuccessMessage($expectedMessagePattern) - { - $successMessage = $this->grabTextFrom('//*[@id="page-wrapper"]/div[3]/div[1]/div'); - $this->seeMatches($expectedMessagePattern, $successMessage); - - preg_match($expectedMessagePattern, $successMessage, $matches); - - return $matches[1]; - } - - /** - * @return void - */ - public function activateFirstNavigationRow() - { - $this->click('//*[@id="navigation-table"]/tbody/tr[1]/td[5]/a[2]'); - } - - /** - * @return void - */ - public function deleteFirstNavigationRow() - { - $this->submitForm('//*[@id="navigation-table"]/tbody/tr/td[5]/form[1]', []); - } - -} diff --git a/tests/PyzTest/Zed/NavigationGui/Tester/NavigationTreeTester.php b/tests/PyzTest/Zed/NavigationGui/Tester/NavigationTreeTester.php deleted file mode 100644 index c53ddbd15..000000000 --- a/tests/PyzTest/Zed/NavigationGui/Tester/NavigationTreeTester.php +++ /dev/null @@ -1,349 +0,0 @@ -navigationFacade = new NavigationFacade(); - $this->localeFacade = new LocaleFacade(); - } - - /** - * @return int - */ - public function prepareTestNavigationEntity() - { - $navigationEntity = new SpyNavigation(); - $navigationEntity - ->setName('Acceptance navigation (2)') - ->setKey('acceptance2') - ->setIsActive(true) - ->save(); - - return $navigationEntity->getIdNavigation(); - } - - /** - * @param string $pattern - * @param string $value - * - * @return void - */ - public function seeMatches($pattern, $value) - { - $this->assertRegExp($pattern, $value); - } - - /** - * @param string $expectedMessagePattern - * - * @return int - */ - public function seeSuccessMessage($expectedMessagePattern) - { - $successMessage = $this->grabTextFrom(self::SUCCESS_MESSAGE_SELECTOR); - $this->seeMatches($expectedMessagePattern, $successMessage); - - preg_match($expectedMessagePattern, $successMessage, $matches); - - return $matches[1]; - } - - /** - * @param string $localeName - * - * @return void - */ - public function expandLocalizedForm($localeName) - { - $this->click(sprintf(self::LOCALIZED_FORM_CONTAINER_SELECTOR, $localeName)); - } - - /** - * @return void - */ - public function clickRootNode() - { - $this->click(self::ROOT_NODE_ANCHOR_SELECTOR); - } - - /** - * @param int $idNavigationNode - * - * @return void - */ - public function clickNode($idNavigationNode) - { - $this->click(sprintf(self::CHILD_NODE_ANCHOR_SELECTOR, $idNavigationNode)); - } - - /** - * @return void - */ - public function waitForNavigationTree() - { - $this->waitForElement(self::NAVIGATION_TREE_SELECTOR, 5); - $this->wait(1); - } - - /** - * @param int $count - * - * @return void - */ - public function seeNumberOfNavigationNodes($count) - { - $this->seeNumberOfElements(self::NAVIGATION_NODE_SELECTOR, $count); - } - - /** - * @param int $idParentNavigationNode - * @param int $idChildNavigationNode - * - * @return void - */ - public function seeNavigationNodeHierarchy($idParentNavigationNode, $idChildNavigationNode) - { - $this->seeElement(sprintf( - self::NODE_CHILD_SELECTOR, - $idParentNavigationNode, - $idChildNavigationNode - )); - } - - /** - * @param int $idNavigationNode - * @param int $idTargetNavigationNode - * - * @return void - */ - public function moveNavigationNode($idNavigationNode, $idTargetNavigationNode) - { - $this->dragAndDrop( - sprintf(self::CHILD_NODE_ANCHOR_SELECTOR, $idNavigationNode), - sprintf(self::CHILD_NODE_ANCHOR_SELECTOR, $idTargetNavigationNode) - ); - } - - /** - * @return void - */ - public function saveNavigationTreeOrder() - { - $this->click(self::NAVIGATION_TREE_SAVE_BUTTON_SELECTOR); - } - - /** - * @param string $message - * - * @return void - */ - public function seeSuccessfulOrderSaveMessage($message) - { - $this->waitForElement(self::SWEET_ALERT_SELECTOR, 5); - $this->wait(1); - $this->see($message); - $this->click(self::SWEET_ALERT_CONFIRM_SELECTOR); - } - - /** - * @return void - */ - public function switchToNodeForm() - { - $this->switchToIFrame(self::NODE_FORM_IFRAME_NAME); - $this->waitForElement(self::NODE_FORM_SELECTOR, 5); - } - - /** - * @return void - */ - public function switchToNavigationTree() - { - $this->switchToIFrame(); - $this->waitForNavigationTree(); - } - - /** - * @return void - */ - public function clickRemoveNodeButton() - { - $this->click(self::REMOVE_NODE_BUTTON_SELECTOR); - } - - /** - * @return void - */ - public function clickAddChildNodeButton() - { - $this->click(self::ADD_CHILD_NODE_BUTTON_SELECTOR); - } - - /** - * @param string $title - * - * @return void - */ - public function submitCreateNodeFormWithoutType($title) - { - $this->expandLocalizedForm('de_DE'); - - $this->submitForm(self::NODE_FORM_SELECTOR, [ - 'navigation_node[navigation_node_localized_attributes][0][title]' => $title, - 'navigation_node[navigation_node_localized_attributes][1][title]' => $title, - 'navigation_node[is_active]' => true, - ]); - } - - /** - * @param string $title - * @param string $externalUrl - * - * @return void - */ - public function submitCreateNodeFormWithExternalUrlType($title, $externalUrl) - { - $this->expandLocalizedForm('de_DE'); - - $this->submitForm(self::NODE_FORM_SELECTOR, [ - 'navigation_node[node_type]' => 'external_url', - 'navigation_node[navigation_node_localized_attributes][0][external_url]' => $externalUrl, - 'navigation_node[navigation_node_localized_attributes][1][external_url]' => $externalUrl, - 'navigation_node[navigation_node_localized_attributes][0][title]' => $title, - 'navigation_node[navigation_node_localized_attributes][1][title]' => $title, - 'navigation_node[is_active]' => true, - ]); - } - - /** - * @param string $categoryUrl_en_US - * @param string $categoryUrl_de_DE - * - * @return void - */ - public function submitUpdateNodeToCategoryType($categoryUrl_en_US, $categoryUrl_de_DE) - { - $this->expandLocalizedForm('de_DE'); - - $this->submitForm(self::NODE_FORM_SELECTOR, [ - 'navigation_node[node_type]' => 'category', - 'navigation_node[navigation_node_localized_attributes][0][category_url]' => $categoryUrl_en_US, - 'navigation_node[navigation_node_localized_attributes][1][category_url]' => $categoryUrl_de_DE, - ]); - } - - /** - * @param string $title - * @param string $cmsPageUrl_en_US - * @param string $cmsPageUrl_de_DE - * - * @return void - */ - public function submitCreateNodeFormWithCmsPageType($title, $cmsPageUrl_en_US, $cmsPageUrl_de_DE) - { - $this->expandLocalizedForm('de_DE'); - - $this->submitForm(self::NODE_FORM_SELECTOR, [ - 'navigation_node[node_type]' => 'cms_page', - 'navigation_node[navigation_node_localized_attributes][0][title]' => $title, - 'navigation_node[navigation_node_localized_attributes][0][cms_page_url]' => $cmsPageUrl_en_US, - 'navigation_node[navigation_node_localized_attributes][1][title]' => $title, - 'navigation_node[navigation_node_localized_attributes][1][cms_page_url]' => $cmsPageUrl_de_DE, - 'navigation_node[is_active]' => true, - ]); - } - - /** - * @param \Generated\Shared\Transfer\NavigationTreeTransfer $navigationTreeTransfer - * - * @return \Generated\Shared\Transfer\NavigationTreeTransfer - */ - public function prepareTestNavigationTreeEntities(NavigationTreeTransfer $navigationTreeTransfer) - { - $navigationTransfer = $this->navigationFacade->createNavigation($navigationTreeTransfer->getNavigation()); - - foreach ($navigationTreeTransfer->getNodes() as $navigationTreeNodeTransfer) { - $this->createNavigationNodesRecursively($navigationTreeNodeTransfer, $navigationTransfer->getIdNavigation()); - } - - return $navigationTreeTransfer; - } - - /** - * @param \Generated\Shared\Transfer\NavigationTreeNodeTransfer $navigationTreeNodeTransfer - * @param int $idNavigation - * @param int|null $idParentNavigationNode - * - * @return void - */ - protected function createNavigationNodesRecursively(NavigationTreeNodeTransfer $navigationTreeNodeTransfer, $idNavigation, $idParentNavigationNode = null) - { - $navigationNodeTransfer = $navigationTreeNodeTransfer->getNavigationNode(); - $navigationNodeTransfer - ->setFkNavigation($idNavigation) - ->setFkParentNavigationNode($idParentNavigationNode); - - $navigationNodeTransfer = $this->navigationFacade->createNavigationNode($navigationNodeTransfer); - - foreach ($navigationTreeNodeTransfer->getChildren() as $childNavigationTreeNodeTransfer) { - $this->createNavigationNodesRecursively($childNavigationTreeNodeTransfer, $idNavigation, $navigationNodeTransfer->getIdNavigationNode()); - } - } - - /** - * @param string $locale - * - * @return int - */ - public function getIdLocale($locale) - { - return $this->localeFacade->getLocale($locale)->getIdLocale(); - } - -} diff --git a/tests/PyzTest/Zed/NavigationGui/_support/NavigationGuiPresentationTester.php b/tests/PyzTest/Zed/NavigationGui/_support/NavigationGuiPresentationTester.php index c3eb37ecf..9413071d3 100644 --- a/tests/PyzTest/Zed/NavigationGui/_support/NavigationGuiPresentationTester.php +++ b/tests/PyzTest/Zed/NavigationGui/_support/NavigationGuiPresentationTester.php @@ -1,7 +1,18 @@ amZed(); + $this->amLoggedInUser(); + } + + /** + * @param string $value + * + * @return void + */ + public function setNameField($value) + { + $this->fillField('//*[@id="navigation_name"]', $value); + } + + /** + * @param string $value + * + * @return void + */ + public function setKeyField($value) + { + $this->fillField('//*[@id="navigation_key"]', $value); + } + + /** + * @param bool $checked + * + * @return void + */ + public function checkIsActiveField($checked) + { + if ($checked) { + $this->checkOption('//*[@id="navigation_is_active"]'); + } else { + $this->uncheckOption('//*[@id="navigation_is_active"]'); + } + } + + /** + * @return void + */ + public function submitNavigationForm() + { + $this->click('//*[@id="navigation-save-btn"]'); + } + + /** + * @param string $pattern + * @param string $value + * + * @return void + */ + public function seeMatches($pattern, $value) + { + $this->assertRegExp($pattern, $value); + } + + /** + * @return void + */ + public function clickEditFirstRowInList() + { + $this->click('//*[@id="navigation-table"]/tbody/tr[1]/td[5]/a'); + } + + /** + * @param string $expectedMessagePattern + * + * @return int + */ + public function seeSuccessMessage($expectedMessagePattern) + { + $successMessage = $this->grabTextFrom('//div[@class="flash-messages"]/div'); + $this->seeMatches($expectedMessagePattern, $successMessage); + + preg_match($expectedMessagePattern, $successMessage, $matches); + + return $matches[1]; + } + + /** + * @return void + */ + public function activateFirstNavigationRow() + { + $this->click('//*[@id="navigation-table"]/tbody/tr[1]/td[5]/a[2]'); + } + + /** + * @return void + */ + public function deleteFirstNavigationRow() + { + $this->submitForm('//*[@id="navigation-table"]/tbody/tr/td[5]/form[1]', []); + } + + /** + * @return void + */ + public function testSeeEmptyNavigationTree() + { + $i = $this; + $i->wantTo('See navigation tree.'); + $i->expect('Empty navigation tree displayed.'); + + $i->amLoggedInUser(); + $i->prepareTestNavigationTreeEntities((new NavigationTreeTransfer()) + ->setNavigation((new NavigationTransfer()) + ->setName('Create child node without type test') + ->setKey('Create child node without type test') + ->setIsActive(true))); + $i->amOnPage(NavigationPage::URL); + + $i->waitForNavigationTree(); + $i->seeNumberOfNavigationNodes(1); + } + + /** + * @return void + */ + public function testCreateChildNodeWithoutType() + { + $i = $this; + $i->wantTo('Create child node without type.'); + $i->expect('Navigation should have a root node persisted.'); + + $i->amLoggedInUser(); + $i->prepareTestNavigationTreeEntities((new NavigationTreeTransfer()) + ->setNavigation((new NavigationTransfer()) + ->setName('Create child node without type test') + ->setKey('Create child node without type test') + ->setIsActive(true))); + $i->amOnPage(NavigationPage::URL); + + $i->waitForNavigationTree(); + $i->switchToNodeForm(); + $i->see('Create child node'); + $i->submitCreateNodeFormWithoutType('Child 1'); + + $i->seeSuccessMessage(NavigationNodeCreatePage::MESSAGE_SUCCESS); + + $i->switchToNavigationTree(); + $i->seeNumberOfNavigationNodes(2); + } + + /** + * @return void + */ + public function testCreateChildNodeWithExternalUrlType() + { + $i = $this; + $i->wantTo('Create external URL child node.'); + $i->expect('Navigation should have a root node persisted.'); + + $i->amLoggedInUser(); + $i->prepareTestNavigationTreeEntities((new NavigationTreeTransfer()) + ->setNavigation((new NavigationTransfer()) + ->setName('Create child node with external URL type test') + ->setKey('Create child node with external URL type test') + ->setIsActive(true)) + ->addNode((new NavigationTreeNodeTransfer()) + ->setNavigationNode((new NavigationNodeTransfer()) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('en_US')) + ->setTitle('foo'))))); + $i->amOnPage(NavigationPage::URL); + + $i->waitForNavigationTree(); + $i->switchToNodeForm(); + $i->see('Create child node'); + $i->submitCreateNodeFormWithExternalUrlType('Child 2', 'http://google.com'); + + $i->seeSuccessMessage(NavigationNodeCreatePage::MESSAGE_SUCCESS); + + $i->switchToNavigationTree(); + $i->seeNumberOfNavigationNodes(3); + } + + /** + * @return void + */ + public function testUpdateNodeToCategoryType() + { + $i = $this; + $i->wantTo('Update child node to category type.'); + $i->expect('Node changes should persist in Zed.'); + + $i->amLoggedInUser(); + $navigationTreeTransfer = $i->prepareTestNavigationTreeEntities((new NavigationTreeTransfer()) + ->setNavigation((new NavigationTransfer()) + ->setName('Update child node to category type test') + ->setKey('Update child node to category type test') + ->setIsActive(true)) + ->addNode((new NavigationTreeNodeTransfer()) + ->setNavigationNode((new NavigationNodeTransfer()) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('en_US')) + ->setTitle('foo')) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('de_DE')) + ->setTitle('foo'))))); + $i->amOnPage(NavigationPage::URL); + + $idNavigationNode = $navigationTreeTransfer->getNodes()[0]->getNavigationNode()->getIdNavigationNode(); + + $i->waitForNavigationTree(); + $i->clickNode($idNavigationNode); + $i->switchToNodeForm(); + $i->see('Update node'); + $i->submitUpdateNodeToCategoryType('/en/computer', '/de/computer'); + + $i->seeSuccessMessage(NavigationNodeUpdatePage::MESSAGE_SUCCESS); + $i->switchToNavigationTree(); + $i->seeNumberOfNavigationNodes(2); + } + + /** + * @return void + */ + public function testCreateChildNodeWithCmsPageType() + { + $i = $this; + $i->wantTo('Create CMS page child node.'); + $i->expect('Navigation should have a new child node persisted.'); + + $i->amLoggedInUser(); + $navigationTreeTransfer = $i->prepareTestNavigationTreeEntities((new NavigationTreeTransfer()) + ->setNavigation((new NavigationTransfer()) + ->setName('Create child node with CMS page type test') + ->setKey('Create child node with CMS page type test') + ->setIsActive(true)) + ->addNode((new NavigationTreeNodeTransfer()) + ->setNavigationNode((new NavigationNodeTransfer()) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('en_US')) + ->setTitle('foo')) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('de_DE')) + ->setTitle('foo'))))); + $i->amOnPage(NavigationPage::URL); + + $idNavigationNode = $navigationTreeTransfer->getNodes()[0]->getNavigationNode()->getIdNavigationNode(); + + $i->waitForNavigationTree(); + $i->clickNode($idNavigationNode); + $i->switchToNodeForm(); + $i->clickAddChildNodeButton(); + $i->see('Create child node'); + $i->submitCreateNodeFormWithCmsPageType('Child 1.1', '/en/imprint', '/de/impressum'); + + $idChildNavigationNode = $i->seeSuccessMessage(NavigationNodeCreatePage::MESSAGE_SUCCESS); + $i->switchToNavigationTree(); + $i->seeNumberOfNavigationNodes(3); + $i->seeNavigationNodeHierarchy($idNavigationNode, $idChildNavigationNode); + } + + /** + * @return void + */ + public function testChangeNavigationTreeStructure() + { + $i = $this; + $i->wantTo('Change tree structure and save.'); + $i->expect('Updated navigation tree structure should have persisted.'); + + $i->amLoggedInUser(); + $navigationTreeTransfer = $i->prepareTestNavigationTreeEntities((new NavigationTreeTransfer()) + ->setNavigation((new NavigationTransfer()) + ->setName('Create child node with CMS page type test') + ->setKey('Create child node with CMS page type test') + ->setIsActive(true)) + ->addNode((new NavigationTreeNodeTransfer()) + ->setNavigationNode((new NavigationNodeTransfer()) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('en_US')) + ->setTitle('node_1')) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('de_DE')) + ->setTitle('node_1'))) + ->addChild((new NavigationTreeNodeTransfer()) + ->setNavigationNode((new NavigationNodeTransfer()) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('en_US')) + ->setTitle('node_1.1')) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('de_DE')) + ->setTitle('node_1.1'))))) + ->addNode((new NavigationTreeNodeTransfer()) + ->setNavigationNode((new NavigationNodeTransfer()) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('en_US')) + ->setTitle('node_2')) + ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) + ->setFkLocale($i->getIdLocale('de_DE')) + ->setTitle('node_2'))))); + $i->amOnPage(NavigationPage::URL); + + $idNavigationNode = $navigationTreeTransfer->getNodes()[0] + ->getChildren()[0] + ->getNavigationNode() + ->getIdNavigationNode(); + $idTargetNavigationNode = $navigationTreeTransfer->getNodes()[1] + ->getNavigationNode() + ->getIdNavigationNode(); + + $i->waitForNavigationTree(); + $i->moveNavigationNode($idNavigationNode, $idTargetNavigationNode); + $i->seeNavigationNodeHierarchy($idTargetNavigationNode, $idNavigationNode); + $i->saveNavigationTreeOrder(); + $i->seeSuccessfulOrderSaveMessage(NavigationPage::MESSAGE_TREE_UPDATE_SUCCESS); + } + + /** + * @return void + */ + public function testDeleteNavigationNode() + { + $i = $this; + /** + * Test skipped because popup confirmation is not working as expected under phantomjs. + * TODO: once we have Selenium, enable this test case. + */ + return; +// +// $i->wantTo('Remove child node.'); +// $i->expect('Node should be removed from Zed.'); +// +// $i->amLoggedInUser(); +// $navigationTreeTransfer = $i->prepareTestNavigationTreeEntities((new NavigationTreeTransfer()) +// ->setNavigation((new NavigationTransfer()) +// ->setName('Delete navigation node') +// ->setKey('Delete navigation node') +// ->setIsActive(true)) +// ->addNode((new NavigationTreeNodeTransfer()) +// ->setNavigationNode((new NavigationNodeTransfer()) +// ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) +// ->setFkLocale($i->getIdLocale('en_US')) +// ->setTitle('foo')) +// ->addNavigationNodeLocalizedAttribute((new NavigationNodeLocalizedAttributesTransfer()) +// ->setFkLocale($i->getIdLocale('de_DE')) +// ->setTitle('foo'))))); +// $i->amOnPage(NavigationPage::URL); +// +// $idNavigationNode = $navigationTreeTransfer->getNodes()[0]->getNavigationNode()->getIdNavigationNode(); +// +// $i->waitForNavigationTree(); +// $i->clickNode($idNavigationNode); +// $i->switchToNodeForm(); +// $i->clickRemoveNodeButton(); +// $i->canSeeInPopup('Are you sure you remove the selected node and all its children?'); +// $i->acceptPopup(); +// +// $i->seeSuccessMessage(NavigationNodeDeletePage::MESSAGE_SUCCESS); +// $i->switchToNavigationTree(); +// $i->seeNumberOfNavigationNodes(1); + } + + /** + * @return int + */ + public function prepareTestNavigationEntity() + { + $navigationEntity = new SpyNavigation(); + $navigationEntity + ->setName('Acceptance navigation (2)') + ->setKey('acceptance2') + ->setIsActive(true) + ->save(); + + return $navigationEntity->getIdNavigation(); + } + + /** + * @param string $localeName + * + * @return void + */ + public function expandLocalizedForm($localeName) + { + $this->click(sprintf(self::LOCALIZED_FORM_CONTAINER_SELECTOR, $localeName)); + } + + /** + * @return void + */ + public function clickRootNode() + { + $this->click(self::ROOT_NODE_ANCHOR_SELECTOR); + } + + /** + * @param int $idNavigationNode + * + * @return void + */ + public function clickNode($idNavigationNode) + { + $this->click(sprintf(self::CHILD_NODE_ANCHOR_SELECTOR, $idNavigationNode)); + } + + /** + * @return void + */ + public function waitForNavigationTree() + { + $this->waitForElement(self::NAVIGATION_TREE_SELECTOR, 5); + $this->wait(1); + } + + /** + * @param int $count + * + * @return void + */ + public function seeNumberOfNavigationNodes($count) + { + $this->seeNumberOfElements(self::NAVIGATION_NODE_SELECTOR, $count); + } + + /** + * @param int $idParentNavigationNode + * @param int $idChildNavigationNode + * + * @return void + */ + public function seeNavigationNodeHierarchy($idParentNavigationNode, $idChildNavigationNode) + { + $this->seeElement(sprintf( + self::NODE_CHILD_SELECTOR, + $idParentNavigationNode, + $idChildNavigationNode + )); + } + + /** + * @param int $idNavigationNode + * @param int $idTargetNavigationNode + * + * @return void + */ + public function moveNavigationNode($idNavigationNode, $idTargetNavigationNode) + { + $this->dragAndDrop( + sprintf(self::CHILD_NODE_ANCHOR_SELECTOR, $idNavigationNode), + sprintf(self::CHILD_NODE_ANCHOR_SELECTOR, $idTargetNavigationNode) + ); + } + + /** + * @return void + */ + public function saveNavigationTreeOrder() + { + $this->click(self::NAVIGATION_TREE_SAVE_BUTTON_SELECTOR); + } + + /** + * @param string $message + * + * @return void + */ + public function seeSuccessfulOrderSaveMessage($message) + { + $this->waitForElement(self::SWEET_ALERT_SELECTOR, 5); + $this->wait(1); + $this->see($message); + $this->click(self::SWEET_ALERT_CONFIRM_SELECTOR); + } + + /** + * @return void + */ + public function switchToNodeForm() + { + $this->switchToIFrame(self::NODE_FORM_IFRAME_NAME); + $this->waitForElement(self::NODE_FORM_SELECTOR, 5); + } + + /** + * @return void + */ + public function switchToNavigationTree() + { + $this->switchToIFrame(); + $this->waitForNavigationTree(); + } + + /** + * @return void + */ + public function clickRemoveNodeButton() + { + $this->click(self::REMOVE_NODE_BUTTON_SELECTOR); + } + + /** + * @return void + */ + public function clickAddChildNodeButton() + { + $this->click(self::ADD_CHILD_NODE_BUTTON_SELECTOR); + } + + /** + * @param string $title + * + * @return void + */ + public function submitCreateNodeFormWithoutType($title) + { + $this->expandLocalizedForm('de_DE'); + + $this->submitForm(self::NODE_FORM_SELECTOR, [ + 'navigation_node[navigation_node_localized_attributes][0][title]' => $title, + 'navigation_node[navigation_node_localized_attributes][1][title]' => $title, + 'navigation_node[is_active]' => true, + ]); + } + + /** + * @param string $title + * @param string $externalUrl + * + * @return void + */ + public function submitCreateNodeFormWithExternalUrlType($title, $externalUrl) + { + $this->expandLocalizedForm('de_DE'); + + $this->submitForm(self::NODE_FORM_SELECTOR, [ + 'navigation_node[node_type]' => 'external_url', + 'navigation_node[navigation_node_localized_attributes][0][external_url]' => $externalUrl, + 'navigation_node[navigation_node_localized_attributes][1][external_url]' => $externalUrl, + 'navigation_node[navigation_node_localized_attributes][0][title]' => $title, + 'navigation_node[navigation_node_localized_attributes][1][title]' => $title, + 'navigation_node[is_active]' => true, + ]); + } + + /** + * @param string $categoryUrl_en_US + * @param string $categoryUrl_de_DE + * + * @return void + */ + public function submitUpdateNodeToCategoryType($categoryUrl_en_US, $categoryUrl_de_DE) + { + $this->expandLocalizedForm('de_DE'); + + $this->submitForm(self::NODE_FORM_SELECTOR, [ + 'navigation_node[node_type]' => 'category', + 'navigation_node[navigation_node_localized_attributes][0][category_url]' => $categoryUrl_en_US, + 'navigation_node[navigation_node_localized_attributes][1][category_url]' => $categoryUrl_de_DE, + ]); + } + + /** + * @param string $title + * @param string $cmsPageUrl_en_US + * @param string $cmsPageUrl_de_DE + * + * @return void + */ + public function submitCreateNodeFormWithCmsPageType($title, $cmsPageUrl_en_US, $cmsPageUrl_de_DE) + { + $this->expandLocalizedForm('de_DE'); + + $this->submitForm(self::NODE_FORM_SELECTOR, [ + 'navigation_node[node_type]' => 'cms_page', + 'navigation_node[navigation_node_localized_attributes][0][title]' => $title, + 'navigation_node[navigation_node_localized_attributes][0][cms_page_url]' => $cmsPageUrl_en_US, + 'navigation_node[navigation_node_localized_attributes][1][title]' => $title, + 'navigation_node[navigation_node_localized_attributes][1][cms_page_url]' => $cmsPageUrl_de_DE, + 'navigation_node[is_active]' => true, + ]); + } + + /** + * @param \Generated\Shared\Transfer\NavigationTreeTransfer $navigationTreeTransfer + * + * @return \Generated\Shared\Transfer\NavigationTreeTransfer + */ + public function prepareTestNavigationTreeEntities(NavigationTreeTransfer $navigationTreeTransfer) + { + $navigationTransfer = $this->getLocator()->navigation()->facade()->createNavigation($navigationTreeTransfer->getNavigation()); + + foreach ($navigationTreeTransfer->getNodes() as $navigationTreeNodeTransfer) { + $this->createNavigationNodesRecursively($navigationTreeNodeTransfer, $navigationTransfer->getIdNavigation()); + } + + return $navigationTreeTransfer; + } + + /** + * @param \Generated\Shared\Transfer\NavigationTreeNodeTransfer $navigationTreeNodeTransfer + * @param int $idNavigation + * @param int|null $idParentNavigationNode + * + * @return void + */ + protected function createNavigationNodesRecursively(NavigationTreeNodeTransfer $navigationTreeNodeTransfer, $idNavigation, $idParentNavigationNode = null) + { + $navigationNodeTransfer = $navigationTreeNodeTransfer->getNavigationNode(); + $navigationNodeTransfer + ->setFkNavigation($idNavigation) + ->setFkParentNavigationNode($idParentNavigationNode); + + $navigationNodeTransfer = $this->getLocator()->navigation()->facade()->createNavigationNode($navigationNodeTransfer); + + foreach ($navigationTreeNodeTransfer->getChildren() as $childNavigationTreeNodeTransfer) { + $this->createNavigationNodesRecursively($childNavigationTreeNodeTransfer, $idNavigation, $navigationNodeTransfer->getIdNavigationNode()); + } + } + + /** + * @param string $locale + * + * @return int + */ + public function getIdLocale($locale) + { + return $this->getLocator()->locale()->facade()->getLocale($locale)->getIdLocale(); + } } diff --git a/tests/PyzTest/Zed/NavigationGui/_support/PageObject/NavigationCreatePage.php b/tests/PyzTest/Zed/NavigationGui/_support/PageObject/NavigationCreatePage.php index f88247927..116e7d478 100644 --- a/tests/PyzTest/Zed/NavigationGui/_support/PageObject/NavigationCreatePage.php +++ b/tests/PyzTest/Zed/NavigationGui/_support/PageObject/NavigationCreatePage.php @@ -1,10 +1,6 @@ wantTo('I want to create up selling relation'); $i->expect('relation is persisted, exported to yves and carousel component is visible'); @@ -51,16 +52,10 @@ public function testICanCreateProductRelationAndSeeInYves(ProductRelationCreateR $i->runCollectors(); - $yvesTester = $i->haveFriend('yvesTester', YvesAcceptanceTester::class); - - $yvesTester->does(function (YvesAcceptanceTester $i) { - - $i->amOnPage('/en/samsung-bundle-214'); - - $i->canSee('Similar products'); - $i->canSee('HP EliteDesk 800 G2'); - - }); + $i->amYves(); + $i->amOnPage('/en/samsung-bundle-214'); + $i->canSee('Similar products'); + $i->canSee('HP EliteDesk 800 G2'); } } diff --git a/tests/PyzTest/Zed/ProductRelation/Tester/ProductRelationCreateRelationTester.php b/tests/PyzTest/Zed/ProductRelation/Tester/ProductRelationCreateRelationTester.php deleted file mode 100644 index 33080b0d1..000000000 --- a/tests/PyzTest/Zed/ProductRelation/Tester/ProductRelationCreateRelationTester.php +++ /dev/null @@ -1,110 +0,0 @@ -selectOption('//*[@id="product_relation_productRelationType"]', $type); - - return $this; - } - - /** - * @param string $name - * - * @return $this - */ - public function filterProductsByName($name) - { - $this->fillField('//*[@id="product-table_filter"]/label/input', $name); - - return $this; - } - - /** - * @param string $sku - * - * @return $this - */ - public function selectProduct($sku) - { - $buttonElementId = sprintf('//*[@id="select-product-%s"]', $sku); - - $this->waitForElementNotVisible('//*[@id="product-table_processing"]', 5); - $this->waitForElement($buttonElementId, 5); - - $this->click($buttonElementId); - - return $this; - } - - /** - * @return $this - */ - public function switchToAssignProductsTab() - { - $this->click('//*[@id="form-product-relation"]/div/ul/li[2]/a'); - - return $this; - } - - /** - * @param string $ruleName - * @param string $operator - * @param string $value - * - * @return $this - */ - public function selectProductRule($ruleName, $operator, $value) - { - $ruleSelectorBaseId = sprintf('[@id="builder_rule_%d"]', $this->numberOfRulesSelected); - - $this->selectOption(sprintf('//*%s/div[3]/select', $ruleSelectorBaseId), $ruleName); - $this->selectOption(sprintf('//*%s/div[4]/select', $ruleSelectorBaseId), $operator); - $this->fillField(sprintf('//*%s/div[5]/input', $ruleSelectorBaseId), $value); - - $this->numberOfRulesSelected++; - - return $this; - } - - /** - * @return $this - */ - public function clickSaveButton() - { - $this->click('//*[@id="submit-relation"]'); - - return $this; - } - - /** - * @return $this - */ - public function activateRelation() - { - $this->click('//*[@id="activate-relation"]'); - - return $this; - } - -} diff --git a/tests/PyzTest/Zed/ProductRelation/_support/PageObject/ProductRelationCreatePage.php b/tests/PyzTest/Zed/ProductRelation/_support/PageObject/ProductRelationCreatePage.php index 9eec37ec5..cc19a66ae 100644 --- a/tests/PyzTest/Zed/ProductRelation/_support/PageObject/ProductRelationCreatePage.php +++ b/tests/PyzTest/Zed/ProductRelation/_support/PageObject/ProductRelationCreatePage.php @@ -4,7 +4,7 @@ * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ -namespace Acceptance\ProductRelation\PageObject; +namespace PyzTest\Zed\ProductRelation\PageObject; class ProductRelationCreatePage { diff --git a/tests/PyzTest/Zed/ProductRelation/_support/ProductRelationPresentationTester.php b/tests/PyzTest/Zed/ProductRelation/_support/ProductRelationPresentationTester.php index 063cf092e..978d3a988 100644 --- a/tests/PyzTest/Zed/ProductRelation/_support/ProductRelationPresentationTester.php +++ b/tests/PyzTest/Zed/ProductRelation/_support/ProductRelationPresentationTester.php @@ -2,6 +2,7 @@ namespace PyzTest\Zed\ProductRelation; use Codeception\Actor; +use Codeception\Scenario; /** * Inherited Methods @@ -23,8 +24,111 @@ class ProductRelationPresentationTester extends Actor use _generated\ProductRelationPresentationTesterActions; - /** - * Define custom actions here - */ + /** + * @var int + */ + protected $numberOfRulesSelected = 0; + + /** + * @param \Codeception\Scenario $scenario + */ + public function __construct(Scenario $scenario) + { + parent::__construct($scenario); + + $this->amZed(); + $this->amLoggedInUser(); + } + + /** + * @param string $type + * + * @return $this + */ + public function selectRelationType($type) + { + $this->selectOption('//*[@id="product_relation_productRelationType"]', $type); + + return $this; + } + + /** + * @param string $name + * + * @return $this + */ + public function filterProductsByName($name) + { + $this->fillField('//*[@id="product-table_filter"]/label/input', $name); + + return $this; + } + + /** + * @param string $sku + * + * @return $this + */ + public function selectProduct($sku) + { + $buttonElementId = sprintf('//*[@id="select-product-%s"]', $sku); + + $this->waitForElementNotVisible('//*[@id="product-table_processing"]', 5); + $this->waitForElement($buttonElementId, 5); + + $this->click($buttonElementId); + + return $this; + } + + /** + * @return $this + */ + public function switchToAssignProductsTab() + { + $this->click('//*[@id="form-product-relation"]/div/ul/li[2]/a'); + + return $this; + } + + /** + * @param string $ruleName + * @param string $operator + * @param string $value + * + * @return $this + */ + public function selectProductRule($ruleName, $operator, $value) + { + $ruleSelectorBaseId = sprintf('[@id="builder_rule_%d"]', $this->numberOfRulesSelected); + + $this->selectOption(sprintf('//*%s/div[3]/select', $ruleSelectorBaseId), $ruleName); + $this->selectOption(sprintf('//*%s/div[4]/select', $ruleSelectorBaseId), $operator); + $this->fillField(sprintf('//*%s/div[5]/input', $ruleSelectorBaseId), $value); + + $this->numberOfRulesSelected++; + + return $this; + } + + /** + * @return $this + */ + public function clickSaveButton() + { + $this->click('//*[@id="submit-relation"]'); + + return $this; + } + + /** + * @return $this + */ + public function activateRelation() + { + $this->click('//*[@id="activate-relation"]'); + + return $this; + } } diff --git a/tests/PyzTest/Zed/ProductRelation/codeception.yml b/tests/PyzTest/Zed/ProductRelation/codeception.yml index debda175a..cbbaab01b 100644 --- a/tests/PyzTest/Zed/ProductRelation/codeception.yml +++ b/tests/PyzTest/Zed/ProductRelation/codeception.yml @@ -33,3 +33,5 @@ suites: - \SprykerTest\Shared\Discount\Helper\DiscountDataHelper - \SprykerTest\Shared\Testify\Helper\DataCleanupHelper - \SprykerTest\Shared\Application\Helper\ZedHelper + - \SprykerTest\Shared\Application\Helper\YvesHelper + - \SprykerTest\Shared\Application\Helper\SetupHelper diff --git a/tests/PyzTest/Zed/Sales/Presentation/.gitkeep b/tests/PyzTest/Zed/Sales/Presentation/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/PyzTest/Zed/Sales/_support/SalesPresentationTester.php b/tests/PyzTest/Zed/Sales/_support/SalesPresentationTester.php deleted file mode 100644 index eee243efb..000000000 --- a/tests/PyzTest/Zed/Sales/_support/SalesPresentationTester.php +++ /dev/null @@ -1,30 +0,0 @@ -wantTo('Create valid tax rate.'); $i->expect('Tax rate is successfully created'); @@ -42,13 +40,11 @@ public function testCreateValidTaxRateShouldShowSuccessMessage(TaxRateTester $i) } /** - * @group Overview - * - * @param \Acceptance\Tax\Zed\Tester\TaxRateTester $i + * @param \PyzTest\Zed\Tax\TaxPresentationTester $i * * @return void */ - public function testCreateInvalidTaxRateShouldShowErrorMessages(TaxRateTester $i) + public function testCreateInvalidTaxRateShouldShowErrorMessages(TaxPresentationTester $i) { $i->wantTo('Create invalid tax rate'); $i->expect('Error messages are displayed. Tax rate is not created'); @@ -58,13 +54,11 @@ public function testCreateInvalidTaxRateShouldShowErrorMessages(TaxRateTester $i } /** - * @group Overview - * - * @param \Acceptance\Tax\Zed\Tester\TaxRateTester $i + * @param \PyzTest\Zed\Tax\TaxPresentationTester $i * * @return void */ - public function testBackToListOfTaxRatesShouldOpenTaxRateListPageWithoutSaving(TaxRateTester $i) + public function testBackToListOfTaxRatesShouldOpenTaxRateListPageWithoutSaving(TaxPresentationTester $i) { $i->wantTo('Create valid tax rate and back to list of tax rates'); $i->expect('List of tax rates is opened, tax rate is not created'); @@ -80,13 +74,11 @@ public function testBackToListOfTaxRatesShouldOpenTaxRateListPageWithoutSaving(T } /** - * @group Overview - * - * @param \Acceptance\Tax\Zed\Tester\TaxRateTester $i + * @param \PyzTest\Zed\Tax\TaxPresentationTester $i * * @return void */ - public function testCreateTaxRateWhichAlreadyExistsShouldShowErrorMessage(TaxRateTester $i) + public function testCreateTaxRateWhichAlreadyExistsShouldShowErrorMessage(TaxPresentationTester $i) { $i->wantTo('Create tax rate which already exists'); $i->expect('Error message is displayed on attempt to create one and the same Tax Rate'); @@ -100,13 +92,11 @@ public function testCreateTaxRateWhichAlreadyExistsShouldShowErrorMessage(TaxRat } /** - * @group Overview - * - * @param \Acceptance\Tax\Zed\Tester\TaxRateTester $i + * @param \PyzTest\Zed\Tax\TaxPresentationTester $i * * @return void */ - public function testCreateAlreadyExistedTaxRateShouldShowErrorMessage(TaxRateTester $i) + public function testCreateAlreadyExistedTaxRateShouldShowErrorMessage(TaxPresentationTester $i) { $i->wantTo('Create tax rate which already exists'); $i->expect('Error message is displayed on attempt to create one and the same Tax Rate'); diff --git a/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateCreatePage.php b/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateCreatePage.php index 5d5dd3b47..e736fef13 100644 --- a/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateCreatePage.php +++ b/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateCreatePage.php @@ -5,7 +5,7 @@ * For full license information, please view the LICENSE file that was distributed with this source code. */ -namespace Acceptance\Tax\Zed\PageObject; +namespace PyzTest\Zed\Tax\PageObject; class TaxRateCreatePage { diff --git a/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateListPage.php b/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateListPage.php index 3ad8b73b2..fbccf9b6c 100644 --- a/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateListPage.php +++ b/tests/PyzTest/Zed/Tax/_support/PageObject/TaxRateListPage.php @@ -5,12 +5,12 @@ * For full license information, please view the LICENSE file that was distributed with this source code. */ -namespace Acceptance\Tax\Zed\PageObject; +namespace PyzTest\Zed\Tax\PageObject; class TaxRateListPage { - const URL = 'tax/rate/list'; + const URL = '/tax/rate/list'; const SELECTOR_DATA_TABLE = '.dataTables_wrapper'; diff --git a/tests/PyzTest/Zed/Tax/_support/TaxPresentationTester.php b/tests/PyzTest/Zed/Tax/_support/TaxPresentationTester.php index 13a43ebda..5bbe2ad44 100644 --- a/tests/PyzTest/Zed/Tax/_support/TaxPresentationTester.php +++ b/tests/PyzTest/Zed/Tax/_support/TaxPresentationTester.php @@ -2,6 +2,10 @@ namespace PyzTest\Zed\Tax; use Codeception\Actor; +use Codeception\Scenario; +use Orm\Zed\Tax\Persistence\SpyTaxRateQuery; +use PyzTest\Zed\Tax\PageObject\TaxRateCreatePage; +use PyzTest\Zed\Tax\PageObject\TaxRateListPage; /** * Inherited Methods @@ -23,8 +27,167 @@ class TaxPresentationTester extends Actor use _generated\TaxPresentationTesterActions; - /** - * Define custom actions here - */ + /** + * @param \Codeception\Scenario $scenario + */ + public function __construct(Scenario $scenario) + { + parent::__construct($scenario); + + $this->amZed(); + $this->amLoggedInUser(); + } + + /** + * @param string $taxRateName + * + * @return $this + */ + public function createTaxRate($taxRateName) + { + $i = $this; + + $i->fillTaxRateForm($taxRateName); + $i->click(TaxRateCreatePage::SELECTOR_SAVE); + } + + /** + * @param string $taxRateName + * + * @return void + */ + protected function fillTaxRateForm($taxRateName) + { + $i = $this; + + $i->amLoggedInUser(); + $i->amOnPage(TaxRateCreatePage::URL); + + $i->wait(4); + + $i->fillField(TaxRateCreatePage::SELECTOR_NAME, TaxRateCreatePage::$taxRateData[$taxRateName]['name']); + $i->selectOption(TaxRateCreatePage::SELECTOR_COUNTRY, TaxRateCreatePage::$taxRateData[$taxRateName]['country']); + $i->fillField(TaxRateCreatePage::SELECTOR_PERCENTAGE, TaxRateCreatePage::$taxRateData[$taxRateName]['percentage']); + } + + /** + * @param string $taxRateName + * + * @return $this + */ + public function createTaxRateWithoutSaving($taxRateName) + { + $i = $this; + $i->fillTaxRateForm($taxRateName); + } + + /** + * @param string $taxRateName + * + * @return $this + */ + public function searchForTaxRate($taxRateName) + { + $i = $this; + + $i->fillField(TaxRateListPage::SELECTOR_SEARCH, TaxRateCreatePage::$taxRateData[$taxRateName]['name']); + } + + /** + * @param string $taxRateName + * + * @return $this + */ + public function deleteTaxRate($taxRateName) + { + $i = $this; + $i->amOnPage(TaxRateListPage::URL); + + $i->fillField(TaxRateListPage::SELECTOR_SEARCH, TaxRateCreatePage::$taxRateData[$taxRateName]['name']); + $i->click(TaxRateListPage::SELECTOR_DELETE); + } + + /** + * @return $this + */ + public function seeErrorMessages() + { + $i = $this; + + $i->see(TaxRateCreatePage::ERROR_MESSAGE_NAME_SHOULD_NOT_BE_BLANK); + $i->see(TaxRateCreatePage::ERROR_MESSAGE_COUNTRY_SHOULD_NOT_BE_BLANK); + $i->see(TaxRateCreatePage::ERROR_MESSAGE_PERCENTAGE_SHOULD_BE_VALID_NUMBER); + } + + /** + * @param string $taxRateName + * + * @return $this + */ + public function createOneAndTheSameTaxRate($taxRateName) + { + $i = $this; + + $i->amLoggedInUser(); + $i->amOnPage(TaxRateCreatePage::URL); + + $i->wait(4); + + $i->fillField(TaxRateCreatePage::SELECTOR_NAME, TaxRateCreatePage::$taxRateData[$taxRateName]['name']); + $i->selectOption(TaxRateCreatePage::SELECTOR_COUNTRY, TaxRateCreatePage::$taxRateData[$taxRateName]['country']); + $i->fillField(TaxRateCreatePage::SELECTOR_PERCENTAGE, TaxRateCreatePage::$taxRateData[$taxRateName]['percentage']); + + $i->click(TaxRateCreatePage::SELECTOR_SAVE); + + $i->amOnPage(TaxRateCreatePage::URL); + + $i->wait(2); + + $i->fillField(TaxRateCreatePage::SELECTOR_NAME, TaxRateCreatePage::$taxRateData[$taxRateName]['name']); + $i->selectOption(TaxRateCreatePage::SELECTOR_COUNTRY, TaxRateCreatePage::$taxRateData[$taxRateName]['country']); + $i->fillField(TaxRateCreatePage::SELECTOR_PERCENTAGE, TaxRateCreatePage::$taxRateData[$taxRateName]['percentage']); + + $i->click(TaxRateCreatePage::SELECTOR_SAVE); + } + + /** + * @param string $taxRateName + * + * @return $this + */ + public function editTaxRateWithValidData($taxRateName) + { + $i = $this; + + $i->fillField(TaxRateCreatePage::SELECTOR_NAME, TaxRateCreatePage::$taxRateData[$taxRateName]['name']); + $i->selectOption(TaxRateCreatePage::SELECTOR_COUNTRY, TaxRateCreatePage::$taxRateData[$taxRateName]['country']); + $i->fillField(TaxRateCreatePage::SELECTOR_PERCENTAGE, TaxRateCreatePage::$taxRateData[$taxRateName]['percentage']); + + $i->click(TaxRateCreatePage::SELECTOR_SAVE); + } + + /** + * @return $this + */ + public function deleteTaxRateFromEditForm() + { + $i = $this; + + $i->click(TaxRateCreatePage::SELECTOR_DELETE_FROM_EDIT); + } + + /** + * @param string $taxRateName + * + * @return void + */ + public function removeTaxRateFromDatabase($taxRateName) + { + $taxRateQuery = new SpyTaxRateQuery(); + $taxRateEntity = $taxRateQuery->findOneByName(TaxRateCreatePage::$taxRateData[$taxRateName]['name']); + if ($taxRateEntity) { + $taxRateEntity->delete(); + } + } } diff --git a/tests/PyzTest/Zed/Tax/codeception.yml b/tests/PyzTest/Zed/Tax/codeception.yml index c91299f2e..f5abf25a0 100644 --- a/tests/PyzTest/Zed/Tax/codeception.yml +++ b/tests/PyzTest/Zed/Tax/codeception.yml @@ -17,5 +17,22 @@ suites: class_name: TaxPresentationTester modules: enabled: - - Asserts - - \PyzTest\Shared\Testify\Helper\Environment + - Asserts + - \PyzTest\Shared\Testify\Helper\Environment + - \SprykerTest\Shared\Config\Helper\ConfigInit + - \SprykerTest\Shared\Testify\Helper\LocatorHelper: + projectNamespaces: ['Pyz'] + + - \SprykerTest\Shared\Propel\Helper\PropelInstallHelper + - WebDriver: + url: '' + browser: chrome + window_size: 1920x1080 + host: 0.0.0.0 + restart: false + - SprykerTest\Shared\Propel\Helper\ConnectionHelper + - \SprykerTest\Shared\Discount\Helper\DiscountDataHelper + - \SprykerTest\Shared\Testify\Helper\DataCleanupHelper + - \SprykerTest\Shared\Application\Helper\ZedHelper + - \SprykerTest\Shared\Application\Helper\YvesHelper + - \SprykerTest\Shared\Application\Helper\SetupHelper