Skip to content

Commit

Permalink
Merge branch 'kilip-behat-fixes' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cbleek committed Jan 19, 2018
2 parents 321e68b + 69f7379 commit dce9eab
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 49 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "module/Orders"]
path = module/Orders
url = https://github.com/yawik/Orders.git
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ before_install:
- sudo apt-get update > /dev/null
- "mongo --eval 'db.runCommand({setParameter: 1, textSearchEnabled: true})' admin"
# setup xvfb to be used by selenium
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1920x1080x16"
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1680x1050x16
- export DISPLAY=:99

install:
# install php packages required for running YAWIK phpunit tests
Expand Down Expand Up @@ -40,8 +41,7 @@ before_script:
- ./composer.phar install --dev

# setup display, behat, and selenium
- "export DISPLAY=:99.0"
- "wget http://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip -O chromedriver.zip && unzip chromedriver.zip && sudo mv chromedriver /usr/bin"
- "wget http://chromedriver.storage.googleapis.com/2.33/chromedriver_linux64.zip -O chromedriver.zip && unzip chromedriver.zip && sudo mv chromedriver /usr/bin"
- ./vendor/bin/selenium-server-standalone -Dwebdriver.chrome.driver=/usr/bin/chromedriver > /dev/null 2>&1 &
- sleep 5
- APPLICATION_ENV=development php -S localhost:8000 -t public public/index.php > /dev/null 2>&1 &
Expand All @@ -53,7 +53,7 @@ script:
- cd test
- ./phpunit --configuration $TRAVIS_BUILD_DIR/test/phpunit.xml.dist
- cd $TRAVIS_BUILD_DIR
- APPLICATION_ENV=development ./vendor/bin/behat --strict --no-interaction -vvv -f progress --tags="@javascript && ~@todo && ~@skip-travis"
- APPLICATION_ENV=development ./vendor/bin/behat --strict --no-interaction -f progress --tags="@javascript && ~@todo && ~@skip-travis"

after_script:
- cd $TRAVIS_BUILD_DIR
Expand Down
1 change: 1 addition & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ default:
chrome:
switches:
- "start-maximized"
- "start-fullscreen"
- "no-sandbox"
show_auto: false

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"imagine/imagine": "*",
"zendframework/zend-progressbar": "^2.5",
"zendframework/zend-math": "^3.0",
"zendframework/zend-captcha": "^2.7"
"zendframework/zend-captcha": "^2.7",
"behat/mink-extension": "2.2"
},
"require-dev": {
"cbleek/pecl-solr-hint": "dev-master",
Expand All @@ -73,7 +74,6 @@
"behat/behat": "^3.2",
"behat/mink": "^1.7",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.2",
"behat/mink-selenium2-driver": "^1.3",
"lakion/mink-debug-extension": "^1.2.3",
"se/selenium-server-standalone": "^2.52",
Expand Down
1 change: 1 addition & 0 deletions features/account/profile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Feature: Editing user profile
And I select "Mr." from "info-gender"
And I press "Save"
And I wait for the ajax response
And I wait for 3 seconds
Then I should see "Test Profile Edited"
And I should see "Some Street Address"
And I should see "77777"
Expand Down
2 changes: 1 addition & 1 deletion features/account/social_profiles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Social profile feature
| fullname | Test Social Profile |
And I log in with username "test@social-profile.com" and password "test"

@javascript @profile-facebook
@javascript @profile-facebook @skip-travis
Scenario: Link to facebook
When I go to profile page
And I press "Facebook"
Expand Down
31 changes: 15 additions & 16 deletions features/applications/apply.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@todo
Feature: Apply a job
In order to start working
As a user
Expand All @@ -19,7 +18,6 @@ Feature: Apply a job
| Company Name | Test Company |
| User | test@admin.com |


@javascript
Scenario: Apply job as guest
Given I apply for "Apply a Job Test" job
Expand All @@ -35,16 +33,16 @@ Feature: Apply a job
| Phone | 654321 |
| Email | guest@apply.com |
And I select "Mr." from "Salutation"
And I scroll "#contact-contact-buttons-submit" into view
And I press "Save"
And I wait for the ajax response
And I scroll "#send-application-buttons" into view
And I wait for 3 seconds
And check "I have read the Privacy Policy and accept it"
And I wait for 5 seconds
And I press "Save"
And I wait for the ajax response
Then I should see "Guest Applicant"
And I should see "Some Street 123456"
And I should see "4321 Some City"
And I should see "654321"
And I should see "guest@apply.com"
And I follow "Send application"
Then I should see "Apply a Job Test"
And I should see "your application was sent successfully"

@javascript
Scenario: Apply job as registered user
Expand All @@ -66,12 +64,13 @@ Feature: Apply a job
| Phone | 654321 |
| Email | test@apply.com |
And I select "Mr." from "Salutation"
And I scroll "#send-application-buttons" into view
And check "I have read the Privacy Policy and accept it"
And I scroll "#contact-contact-buttons-submit" into view
And I press "Save"
And I wait for the ajax response
Then I should see "Test Applicant"
And I should see "Some Street 123456"
And I should see "4321 Some City"
And I should see "654321"
And I should see "test@apply.com"
And I scroll "#send-application-buttons" into view
And I wait for 3 seconds
And check "I have read the Privacy Policy and accept it"
And I wait for 5 seconds
And I follow "Send application"
Then I should see "Apply a Job Test"
And I should see "your application was sent successfully"
13 changes: 9 additions & 4 deletions features/jobs/publish.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@todo
Feature: Publish Job
In order to get applicants
As recruiter
Expand All @@ -20,14 +19,20 @@ Feature: Publish Job
| User | test@recruiter.com |
And I am logged in as "test@recruiter.com" identified by "test"

@javascript
# disabled because we can not test email feature on travis
@javascript @skip-travis
Scenario: Successfully publish a job
Given I go to edit job draft with title "Test Publishing a Job"
And I wait for the ajax response
And I scroll "#yk-footer" into view
And I follow "Create job opening"
And I wait for the ajax response
And I follow "Preview"
And I click "I have read the terms an conditions and accept it" form
And I wait for 60 seconds
And I wait for the ajax response
And I scroll "#job_incomplete" into view
And I check "I have read the terms an conditions and accept it"
And I wait for the ajax response
And I scroll "#job_incomplete" into view
And I follow "Publish job"
And I wait for the ajax response
Then I should see "Publishing successfully finished"
7 changes: 4 additions & 3 deletions features/organization/insert.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Feature: Add new organization
Then I should see "Sorry, you may not create organizations."
And I should see "Before you are able to create organizations, you have to create your main organization first."

@todo @javascript @organization
@javascript @organization @todo
Scenario: Create organization successfully
Given I am logged in as a recruiter with "Cross Solution" as organization
And I go to create new organization page
And I click edit on name form
And I wait for the ajax response
And I fill in "Organizationname" with "Some Organization"
And I save name form
And I save "organization name" form
And I wait for the ajax response
Then I should see "Some Organization"

Expand All @@ -31,7 +31,8 @@ Feature: Add new organization
| City | Some City |
| Phone | 123123 |
| Fax | 321321 |
And I save location form
And I scroll "#form-organizationLogo" into view
And I save "organization location" form
And I wait for the ajax response
Then I should see "Some Street"
And I should see "12345"
Expand Down
5 changes: 3 additions & 2 deletions features/organization/update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Feature: Updating my organization
| City | Some City |
| Phone | 123123 |
| Fax | 321321 |
And I press "Save"
And I save "organization location" form
And I wait for the ajax response
Then I should see "Some Street"
And I should see "12345"
Expand Down Expand Up @@ -57,7 +57,8 @@ Feature: Updating my organization
And I uncheck "accept Applications by Department Managers"
And I uncheck "assign department managers to jobs"
And I wait for the ajax response
And I press "Save"
And I scroll "#sf-workflowSettings" into view
And I save workflow form
And I wait for the ajax response
Then the "accept Applications by Department Managers" checkbox should not be checked
And the "assign department managers to jobs" checkbox should not be checked
3 changes: 2 additions & 1 deletion features/settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: Update application settings
And I wait for the ajax response
Then I should see "Changes successfully saved"

@todo @javascript @settings-email
@javascript @settings-email @todo
Scenario: Successfully change E-Mail Notifications Settings
Given I go to email template settings page
When I check "receive E-Mail alert"
Expand All @@ -28,6 +28,7 @@ Feature: Update application settings
| Invitation mail text | Invitation mail |
| Accept mail text | Accept mail text |
| Rejection mail text | Rejection mail text |
And I scroll "#yk-footer" into view
And I press "Save"
And I wait for the ajax response
Then I should see "Changes successfully saved"
9 changes: 9 additions & 0 deletions module/Behat/src/ApplicationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ public function iApplyAJob($title)
$url = '/en/apply/'.$job->getApplyId();
$this->visit($url);
}

/**
* @Given I visit job categories
*/
public function visitJobsCategories()
{
$url = '/en/admin/jobs/categories';
$this->visit($url);
}
}
41 changes: 41 additions & 0 deletions module/Behat/src/CoreContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Behat\MinkExtension\Context\MinkContext;
use Behat\MinkExtension\Context\RawMinkContext;
use Core\Repository\RepositoryService;
use Jobs\Repository\Categories;
use Zend\Mvc\Application;


Expand All @@ -29,13 +30,26 @@ class CoreContext extends RawMinkContext
*/
protected $minkContext;

static private $jobCategoryChecked = false;

/**
* @BeforeScenario
* @param BeforeScenarioScope $scope
*/
public function gatherContexts(BeforeScenarioScope $scope)
{
$this->minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
if(false === static::$jobCategoryChecked){
/* @var Categories $catRepo */
$catRepo = $this->getRepositories()->get('Jobs/Category');
$all = $catRepo->findAll();
if(count($all) <= 1){
$catRepo->createDefaultCategory('professions');
$catRepo->createDefaultCategory('industries');
$catRepo->createDefaultCategory('employmentTypes');
}
static::$jobCategoryChecked = true;
}
}

/**
Expand Down Expand Up @@ -262,4 +276,31 @@ public function iClickOn()
{

}

/**
* Click some text
*
* @When /^I click on the text "([^"]*)"$/
*/
public function iClickOnTheText($text)
{
$session = $this->getSession();
$element = $session->getPage()->find(
'xpath',
$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]')
);
if(null === $element){
$element = $session->getPage()->find(
'named',
array('id',$text)
);
}
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
}

$element->click();

}

}
34 changes: 21 additions & 13 deletions module/Behat/src/JobContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,26 @@ public function iHaveAJobWithTheFollowing($status,TableNode $fields)
}
$job->setStatus(Status::ACTIVE);

if(isset($normalizedField['location'])){
$this->setLocation($job,$normalizedField['location']);
}
if(isset($normalizedField['companyName'])){
//$job->setCompany($normalizedField['companyName']);
}
if(isset($normalizedField['professions'])){
$this->addProfessions($job,$normalizedField['professions']);
}

if(isset($normalizedField['industries'])){
$this->addIndustries($job,$normalizedField['industries']);
}

if(isset($normalizedField['location'])){
$this->setLocation($job,$normalizedField['location']);
}
if(isset($normalizedField['employmentTypes'])){
$types = $this->getCategories([$normalizedField['employmentTypes']]);
$type = array_shift($types);

$job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
}
if(isset($normalizedField['companyName'])){
$job->setCompany($normalizedField['companyName']);
$values = $job->getClassifications()->getEmploymentTypes()->getValues();
if(!is_array($values) || !in_array($type,$values)){
$job->getClassifications()->getEmploymentTypes()->getItems()->add($type);
}
}

$jobRepo->store($job);
Expand All @@ -284,19 +285,25 @@ private function setLocation(Job $job, $term)
$job->getLocations()->add($location);
}

private function addProfessions(Job $job,$terms)
private function addProfessions(Job &$job,$terms)
{
$professions = $this->getCategories($terms);
foreach($professions as $profession){
$job->getClassifications()->getProfessions()->getItems()->add($profession);
$values = $job->getClassifications()->getProfessions()->getValues();
if(!is_array($values) || !in_array($profession,$values)){
$job->getClassifications()->getProfessions()->getItems()->add($profession);
}
}
}

private function addIndustries(Job $job, $terms)
private function addIndustries(Job &$job, $terms)
{
$industries = $this->getCategories($terms);
foreach($industries as $industry){
$job->getClassifications()->getIndustries()->getItems()->add($industry);
$values = $job->getClassifications()->getIndustries()->getValues();
if(!is_array($values) || !in_array($industry,$values)){
$job->getClassifications()->getIndustries()->getItems()->add($industry);
}
}
}

Expand All @@ -318,6 +325,7 @@ private function getCategories(array $categories)
return $results->toArray();
}


/**
* @return Job
*/
Expand Down
Loading

0 comments on commit dce9eab

Please sign in to comment.