From 2b7d54502d18ec4988f51e713bca5a818f17805e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gre=CC=81goire=20Humeau?= Date: Tue, 11 Apr 2017 14:25:09 +0200 Subject: [PATCH 1/2] Update Victoire test-suite --- victoire-test-suite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/victoire-test-suite b/victoire-test-suite index a8ddf89..1b688b5 160000 --- a/victoire-test-suite +++ b/victoire-test-suite @@ -1 +1 @@ -Subproject commit a8ddf89e127d362dff2e4c7dc8f0b8ffab81bb06 +Subproject commit 1b688b5f8d21e6f86589367f57ae7e643cc6833e From 5f4ce05f3ccf2ba44462dada033bf2a052b4c49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gre=CC=81goire=20Humeau?= Date: Tue, 11 Apr 2017 14:25:18 +0200 Subject: [PATCH 2/2] Add Behat tests and Contexts --- Tests/Context/WidgetContext.php | 58 +++++++++++++++++++++++++++++++++ Tests/Features/create.feature | 12 ------- Tests/Features/manage.feature | 22 +++++++++++++ 3 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 Tests/Context/WidgetContext.php delete mode 100644 Tests/Features/create.feature create mode 100644 Tests/Features/manage.feature diff --git a/Tests/Context/WidgetContext.php b/Tests/Context/WidgetContext.php new file mode 100644 index 0000000..0141659 --- /dev/null +++ b/Tests/Context/WidgetContext.php @@ -0,0 +1,58 @@ +getSession()->getPage(); + + $button = $page->find('xpath', sprintf( + 'descendant-or-self::div[contains(@class, "localeSwitcher")]/button[@data-toggle="dropdown"]', + $locale + )); + + $button->click(); + + $link = $page->find('xpath', sprintf( + 'descendant-or-self::div[contains(@class, "localeSwitcher")]/ul[@class="dropdown-menu"]//a[@lang="%s"]', + $locale + )); + + if (!$link) { + throw new \RuntimeException(sprintf( + 'Link for LocalSwitcher locale "%s" could not be found.', + $locale + )); + } + + $link->click(); + } + + /** + * @Then /^I should see "(.+)" current locale in LocaleSwitcher$/ + */ + public function iShouldSeeCurrentLocaleInLocaleSwitcher($locale) + { + $page = $this->getSession()->getPage(); + + $flag = $page->find('xpath', sprintf( + 'descendant-or-self::button[@data-toggle="dropdown"]/img[@class="localeSwitcher-flag" and @src="/bundles/victoirewidgetlocaleswitcher/images/flags/%s.png"]', + $locale + )); + + if (!$flag) { + throw new \RuntimeException(sprintf( + 'It seems that current locale is not "%s" in LocaleSwitcher or element could not be found.', + $locale + )); + } + } +} diff --git a/Tests/Features/create.feature b/Tests/Features/create.feature deleted file mode 100644 index ca2f3c9..0000000 --- a/Tests/Features/create.feature +++ /dev/null @@ -1,12 +0,0 @@ -@mink:selenium2 @alice(Page) @reset-schema -Feature: Create a LocaleSwitcher widget - - Background: - Given I maximize the window - And I am on homepage - - Scenario: I create a new LocaleSwitcher widget - When I switch to "layout" mode - Then I should see "New content" - When I select "Language selector" from the "1" select of "main_content" slot - Then I should see "Widget (Language selector)" \ No newline at end of file diff --git a/Tests/Features/manage.feature b/Tests/Features/manage.feature new file mode 100644 index 0000000..bc1ae83 --- /dev/null +++ b/Tests/Features/manage.feature @@ -0,0 +1,22 @@ +@mink:selenium2 @alice(Page) @reset-schema +Feature: Manage a Language selector widget + + Background: + Given I am on homepage + + Scenario: I can create a new Language selector widget + When I switch to "layout" mode + Then I should see "New content" + When I select "Language selector" from the "1" select of "main_content" slot + Then I should see "Widget (Language selector)" + And I should see "1" quantum + When I submit the widget + Then I should see the success message for Widget edit + When I reload the page + And I switch to "readonly" mode + Then I should see "en" current locale in LocaleSwitcher + Given I change locale to "fr" in LocaleSwitcher + Then I should be on "/fr" + And I should see "fr" current locale in LocaleSwitcher + Given I change locale to "en" in LocaleSwitcher + Then I should be on "/en" \ No newline at end of file