Skip to content
Snippets Groups Projects
Commit 6957e4d3 authored by Vitalii Koval's avatar Vitalii Koval Committed by Taras Kruts
Browse files

Issue #3377397 by Kovalskiy266: Add behat test with scenario for checking...

Issue #3377397 by Kovalskiy266: Add behat test with scenario for checking duplication of enrollees and organisers

Issue #3377397 by Kovalskiy266: Change name of user in behat test and fix message in MinkContext exception
parent 2b77e6ad
No related branches found
No related tags found
No related merge requests found
......@@ -236,4 +236,84 @@ class SocialMinkContext extends MinkContext {
}
}
/**
* Checks, that (?P<num>\d+) text exist in a selector on the page
* Example: Then I should see "text" 5 times in ".teaser__title"
* Example: And I should see "text" 1 time in "h4"
*
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" (?P<num>\d+) time(s?) in "(?P<selector>(?:[^"]|\\")*)"$/
*/
public function assertNumTextCss($num, $text, $selector) {
$session = $this->getSession();
$elements = $session->getPage()->findAll('css', $selector);
$regex = '/' . preg_quote($text, '/') . '/ui';
$count = 0;
foreach ($elements as $element) {
$element_text = $element->getText();
$actual = preg_replace('/\s+/u', ' ', $element_text);
preg_match($regex, $actual, $matches);
$count += count($matches);
}
if ($count !== (int) $num) {
throw new \Exception(sprintf('The text %s was not found %d time(s) in the text of the current page.', $text, $num));
}
return TRUE;
}
/**
* Ensure a select field does not contain the following options.
*
* @Given /^the "(?P<locator>[^"]+)" select field should not contain the following options:$/
*/
public function theSelectFieldShouldNotContainTheFollowingOptions(string $locator, TableNode $options): void {
$field = $this->getSession()->getPage()->findField($locator);
if (NULL === $field) {
throw new ElementNotFoundException($this->getSession()->getDriver(), 'form field', 'id|name|label|value', $locator);
}
foreach ($options->getHash() as $value) {
$option = $field->find('named', ['option', $value['options']]);
if ($option !== NULL) {
throw new \Exception("The field was supposed to not contain '$option' but it was an option in the select field.");
}
}
}
/**
* Ensure a select field does contain the following options.
*
* @Given /^the "(?P<locator>[^"]+)" select field should contain the following options:$/
*/
public function theSelectFieldShouldContainTheFollowingOptions(string $locator, TableNode $options): void {
$field = $this->getSession()->getPage()->findField($locator);
if (NULL === $field) {
throw new ElementNotFoundException($this->getSession()->getDriver(), 'form field', 'id|name|label|value', $locator);
}
foreach ($options->getHash() as $value) {
$option = $field->find('named', ['option', $value['options']]);
if ($option === NULL) {
throw new \Exception("The field was supposed to contain '$option' but it was not an option in the select field.");
}
}
}
/**
* @Then /^I should see "([^"]*)" exactly "([^"]*)" times$/
*/
public function iShouldSeeTheTextCertainNumberTimes($text, $expectedNumber): void {
$allText = $this->getSession()->getPage()->getText();
$numberText = substr_count($allText, $text);
if ($expectedNumber != $numberText) {
throw new \Exception('Found '.$numberText.' times of "'.$text.'" when expecting '.$expectedNumber);
}
}
}
......@@ -4,6 +4,10 @@ Feature: Event Management
Role: As a Verified
Goal/desire: I want to assign event organiser
Background:
Given I enable the module "social_language"
And I enable the module "social_content_translation"
@verified @perfect @critical
Scenario: Successfully assign event organiser
Given I enable the module "social_event_managers"
......@@ -93,3 +97,55 @@ Feature: Event Management
| Topic regression test | Description |
And I open the "topic" node with title "Topic regression test"
Then I should not see "Organisers"
Scenario: Ensure, that if we have several translations of the event, the enrollees and organisers are not duplicated
# Add Dutch language.
Given I am logged in as an "administrator"
And I turn off translations import
And I am on "/admin/config/regional/language"
And I click the xth "0" element with the css ".local-actions .button--action"
And I select "Dutch" from "Language name"
And I press "Add language"
And I wait for AJAX to finish
Given I am viewing my event:
| title | My awesome event |
| body | Body text |
| field_event_date | +7 days |
| field_event_date_end | +7 days |
| status | 1 |
| field_content_visibility | public |
And users:
| name | pass | mail | status | roles |
| Ryan Gosling | event_organiser | event_organiser@example.com | 1 | verified |
When I am editing the event "My awesome event"
And I expand the "Additional information" section
And I fill in "Ryan Gosling" for "field_event_managers[0][target_id]"
And I press "Save"
# Enroll for event
When I press the "Enroll" button
And I wait for AJAX to finish
Then I should see the text "Meetup: My awesome event" in the "Modal"
And I press the "Close" button
# Add translation for this event.
And I should see "Translate"
When I click "Translate"
Then I should see "Dutch"
And I should see "Not translated"
And I should see "Add"
And I click "Add"
And I press "Create event (this translation)"
# Check if enrollees aren't duplicated.
And I should see "1 people have enrolled"
When I click "Manage enrollments"
Then I should see "1 Enrollees"
# Check if organisers aren't duplicated.
When I click "Organisers"
Then I should see "Ryan Gosling" exactly "1" times
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment