diff --git a/behat.yml.dist b/behat.yml.dist index 72ba728..f8a0467 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -4,6 +4,13 @@ imports: default: extensions: + Behat\MinkExtension: + base_url: http://127.0.0.1:8080 + javascript_session: selenium2 + browser_name: 'chrome' + selenium2: + capabilities: { "browserName": "chrome", "browser": "chrome", "version": "62", 'chrome': {'switches':['--no-sandbox', '--headless']}} + FriendsOfBehat\ContextServiceExtension: imports: - vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml @@ -18,4 +25,24 @@ default: Lakion\Behat\MinkDebugExtension: directory: etc/build clean_start: false - screenshot: true + screenshot: false + + +javascript: + extensions: + Lakion\Behat\MinkDebugExtension: + directory: etc/build + clean_start: false + screenshot: false + + Behat\MinkExtension: + base_url: http://127.0.0.1:8080 + javascript_session: selenium2 + browser_name: chrome + show_auto: false + selenium2: + capabilities: { "marionette": null, "browserName": "chrome", "browser": "chrome", "version": "63", 'chrome': {'switches':['--no-sandbox', '--headless', 'start-maximized']}} + + gherkin: + filters: + tags: "@javascript" \ No newline at end of file diff --git a/etc/build/.gitkeep b/etc/build/.gitkeep old mode 100644 new mode 100755 diff --git a/features/store/managing_stores/adding_store.feature b/features/store/managing_stores/adding_store.feature new file mode 100644 index 0000000..c373d17 --- /dev/null +++ b/features/store/managing_stores/adding_store.feature @@ -0,0 +1,15 @@ +@managing_stores +Feature: Adding a new store + As an Administrator + I want to add a new store to the registry + + Background: + And the store is available in "English (United States)" + And I am logged in as an administrator + When I want to create a new store + + @ui @javascript + Scenario: Adding a new store + And I specify its code as "bunny_store" + And I name it "Bunny Store" in "English (United States)" + And I define it for the "United States" zone diff --git a/features/store/managing_stores/browsing_stores.feature b/features/store/managing_stores/browsing_stores.feature new file mode 100644 index 0000000..598e05e --- /dev/null +++ b/features/store/managing_stores/browsing_stores.feature @@ -0,0 +1,16 @@ +@managing_stores +Feature: Browsing stores + In order to have a overview of all defined stores + As an Administrator + I want to be able to browse list of them + + Background: + Given I am logged in as an administrator + Given the store has "Dragon Store" store location + Given the store has "Bunny Store" store location + + @ui + Scenario: Browsing defined stores + When I want to browse stores + Then I should see 2 stores in the list + And the store "Bunny Store" should be in the registry diff --git a/features/store/managing_stores/deleteing_store.feature b/features/store/managing_stores/deleteing_store.feature new file mode 100644 index 0000000..5069532 --- /dev/null +++ b/features/store/managing_stores/deleteing_store.feature @@ -0,0 +1,16 @@ +@managing_stores +Feature: Deleting a store + In order to remove test, obsolete or incorrect stores + As an Administrator + I want to be able to delete a store + + Background: + Given the store has "Dragon Store" store location + Given the store has "Bunny Store" store location + And I am logged in as an administrator + + @ui + Scenario: Deleted store should disappear from the registry + When I delete store "Dragon Store" + Then I should see 1 stores in the list + And the store "Bunny Store" should be in the registry diff --git a/features/checkout/shipping_method/seeing_store_locator_index_page.feature b/features/store/seeing_store_locator_index_page.feature similarity index 100% rename from features/checkout/shipping_method/seeing_store_locator_index_page.feature rename to features/store/seeing_store_locator_index_page.feature diff --git a/features/checkout/shipping_method/seeing_store_locator_show_page.feature b/features/store/seeing_store_locator_show_page.feature similarity index 100% rename from features/checkout/shipping_method/seeing_store_locator_show_page.feature rename to features/store/seeing_store_locator_show_page.feature diff --git a/tests/Behat/Context/Transform/StoreContext.php b/tests/Behat/Context/Transform/StoreContext.php new file mode 100644 index 0000000..091e4a6 --- /dev/null +++ b/tests/Behat/Context/Transform/StoreContext.php @@ -0,0 +1,40 @@ +storeRepository = $storeRepository; + } + + /** + * @Transform /^store "([^"]+)"$/ + * @Transform /^"([^"]+)" store/ + * @Transform /^store to "([^"]+)"$/ + * @Transform :store + */ + public function getStoreByName($storeName) + { + $store = $this->storeRepository->findOneByCode(StringInflector::nameToCode(strtolower($storeName))); + + if($store === null){ + throw new NotFoundException('Store with name '.$storeName.' not found"'); + } + + return $store; + } +} \ No newline at end of file diff --git a/tests/Behat/Context/Ui/Admin/ManagingStoresContext.php b/tests/Behat/Context/Ui/Admin/ManagingStoresContext.php new file mode 100644 index 0000000..619541f --- /dev/null +++ b/tests/Behat/Context/Ui/Admin/ManagingStoresContext.php @@ -0,0 +1,104 @@ +indexPage = $indexPage; + $this->createPage = $createPage; + $this->updatePage = $updatePage; + } + + /** + * @When /^I want to browse stores$/ + */ + public function iWantToBrowseStores() + { + $this->indexPage->open(); + } + + /** + * @Then /^I should see (\d+) stores in the list$/ + */ + public function iShouldSeeStoresInTheList(int $numberOfStores) + { + Assert::same($this->indexPage->countItems(), $numberOfStores); + } + + /** + * @Given /^the store "([^"]*)" should be in the registry$/ + */ + public function theStoreShouldBeInTheRegistry($storeName) + { + $this->iWantToBrowseStores(); + + Assert::true($this->indexPage->isSingleResourceOnPage(['name' => $storeName])); + } + + /** + * @When /^I delete (store "[^"]+")$/ + */ + public function iDeleteStore(StoreInterface $store) + { + $this->indexPage->open(); + $this->indexPage->deleteResourceOnPage(['code' => $store->getCode()]); + } + + /** + * @When /^I want to create a new store$/ + */ + public function iWantToCreateANewStore() + { + $driver = $this->getSession()->getDriver(); + + if (!$driver instanceof Selenium2Driver) { + throw new UnsupportedDriverActionException('Selenium2Driver not installed.'); + + return; + } + + $this->createPage->open(); + } + + /** + * @When I specify its code as :storeCode + */ + public function iSpecifyItsCodeAs($storeCode) + { + $this->createPage->specifyCode($storeCode); + } +} \ No newline at end of file diff --git a/tests/Behat/Page/Admin/Store/CreatePage.php b/tests/Behat/Page/Admin/Store/CreatePage.php new file mode 100644 index 0000000..8ccda41 --- /dev/null +++ b/tests/Behat/Page/Admin/Store/CreatePage.php @@ -0,0 +1,32 @@ +getDocument()->fillField('Code', $code); + } + + /*public function open(array $urlParameters = []) + { + dump($this->getUrl($urlParameters)); + $this->getSession()->visit($this->getUrl($urlParameters)); + }*/ + +} \ No newline at end of file diff --git a/tests/Behat/Page/Admin/Store/CreatePageInterface.php b/tests/Behat/Page/Admin/Store/CreatePageInterface.php new file mode 100644 index 0000000..2912807 --- /dev/null +++ b/tests/Behat/Page/Admin/Store/CreatePageInterface.php @@ -0,0 +1,9 @@ +