Skip to content

Commit a2ed3bb

Browse files
authored
Merge pull request #379 from ASU/7.x-dev
WEBSPARK-1523 - asu_isearch additional Behat test coverage
2 parents 8d4934e + 0b053f9 commit a2ed3bb

File tree

6 files changed

+297
-7
lines changed

6 files changed

+297
-7
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
[
2+
{
3+
"eid": "1111111",
4+
"asuriteId": "asurite1",
5+
"lastName": "Webspark",
6+
"firstName": "Sparky",
7+
"middleName": "",
8+
"displayName": "Sparky Webspark",
9+
"preferredFirstName": "",
10+
"affiliations": [
11+
"Employee"
12+
],
13+
"affiliationsFacet": [
14+
"Employee"
15+
],
16+
"emailAddress": "[email protected]",
17+
"addressLine1": "5555 Webspark Test",
18+
"addressLine2": "",
19+
"addressLine3": "",
20+
"city": "Tempe",
21+
"postalCode": "55555",
22+
"titleSource": [
23+
"titles"
24+
],
25+
"titles": [
26+
"Customized Drupal Developer Senior"
27+
],
28+
"departments": [
29+
"Applications and Design"
30+
],
31+
"departmentsFacet": [
32+
"Applications and Design"
33+
],
34+
"deptids": [
35+
"2163"
36+
],
37+
"vpAreas": [
38+
"U01"
39+
],
40+
"emplClasses": [
41+
"University Staff"
42+
],
43+
"simplifiedEmplClasses": [
44+
"University Staff"
45+
],
46+
"psDeptids": [
47+
"U0106004"
48+
],
49+
"jobCampuses": [
50+
"TEMPE"
51+
],
52+
"mailCodes": [
53+
"6312"
54+
],
55+
"locations": [
56+
"TEMPE"
57+
],
58+
"employeeTypes": [
59+
"University Staff"
60+
],
61+
"managers": [
62+
0
63+
],
64+
"primaryTitle": "Drupal Developer Senior",
65+
"workingTitle": "Super Drupal Developer Senior",
66+
"primaryDepartment": "DEV Applications and Design",
67+
"primaryEmplClass": "University Staff",
68+
"primarySimplifiedEmplClass": "University Staff",
69+
"primaryMailCode": "6312",
70+
"primaryDeptid": "DEV Applications and Design",
71+
"primaryJobCampus": "TEMPE",
72+
"primaryiSearchDepartmentAffiliation": "Applications and Design",
73+
"photoUrl": "",
74+
"photoPermission": "private",
75+
"photoPreference": "suncard",
76+
"bio": "\u003Cp\u003EThis is a mock bio.\u0026nbsp;\u003C\/p\u003E",
77+
"website": "",
78+
"facebook": "",
79+
"twitter": "",
80+
"googlePlus": "",
81+
"linkedin": "",
82+
"teachingWebsite": "",
83+
"fax": "",
84+
"researchWebsite": "",
85+
"employeeWeight": [
86+
"0"
87+
],
88+
"imageUrls": [
89+
""
90+
],
91+
"_version_": 1638562985797484544,
92+
"profileNid": "999999",
93+
"affilWeight": [
94+
999
95+
],
96+
"affilHide": [
97+
0
98+
],
99+
"departmentTitleRanks": [
100+
null
101+
],
102+
"departmentTitleRanksWeight": [
103+
null
104+
],
105+
"departmentTitleRanksTenure": [
106+
0
107+
],
108+
"departmentTitleRanksTids": [
109+
null
110+
],
111+
"researchActivity": "<ul>\r\n\t<li class=\"first\"><a href=\"/asu-people/testvalue\">behat test value</a><a href=\"https://www.asu.edu/\">ASU</a></li>\r\n</ul>"
112+
}
113+
]
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
[
2+
{
3+
"eid": "1111111",
4+
"asuriteId": "asurite1",
5+
"lastName": "Webspark",
6+
"firstName": "Sparky",
7+
"middleName": "",
8+
"displayName": "Sparky Webspark",
9+
"preferredFirstName": "",
10+
"affiliations": [
11+
"Employee"
12+
],
13+
"affiliationsFacet": [
14+
"Employee"
15+
],
16+
"emailAddress": "[email protected]",
17+
"addressLine1": "5555 Webspark Test",
18+
"addressLine2": "",
19+
"addressLine3": "",
20+
"city": "Tempe",
21+
"postalCode": "55555",
22+
"titleSource": [
23+
"workingTitle"
24+
],
25+
"titles": [
26+
"Drupal Developer Senior"
27+
],
28+
"departments": [
29+
"Applications and Design"
30+
],
31+
"departmentsFacet": [
32+
"Applications and Design"
33+
],
34+
"deptids": [
35+
"2163"
36+
],
37+
"vpAreas": [
38+
"U01"
39+
],
40+
"emplClasses": [
41+
"University Staff"
42+
],
43+
"simplifiedEmplClasses": [
44+
"University Staff"
45+
],
46+
"psDeptids": [
47+
"U0106004"
48+
],
49+
"jobCampuses": [
50+
"TEMPE"
51+
],
52+
"mailCodes": [
53+
"6312"
54+
],
55+
"locations": [
56+
"TEMPE"
57+
],
58+
"employeeTypes": [
59+
"University Staff"
60+
],
61+
"managers": [
62+
0
63+
],
64+
"primaryTitle": "Drupal Developer Senior",
65+
"workingTitle": "Super Drupal Developer Senior",
66+
"primaryDepartment": "DEV Applications and Design",
67+
"primaryEmplClass": "University Staff",
68+
"primarySimplifiedEmplClass": "University Staff",
69+
"primaryMailCode": "6312",
70+
"primaryDeptid": "DEV Applications and Design",
71+
"primaryJobCampus": "TEMPE",
72+
"primaryiSearchDepartmentAffiliation": "Applications and Design",
73+
"photoUrl": "",
74+
"photoPermission": "private",
75+
"photoPreference": "suncard",
76+
"bio": "\u003Cp\u003EThis is a mock bio.\u0026nbsp;\u003C\/p\u003E",
77+
"website": "",
78+
"facebook": "",
79+
"twitter": "",
80+
"googlePlus": "",
81+
"linkedin": "",
82+
"teachingWebsite": "",
83+
"fax": "",
84+
"researchWebsite": "",
85+
"employeeWeight": [
86+
"0"
87+
],
88+
"imageUrls": [
89+
""
90+
],
91+
"_version_": 1638562985797484544,
92+
"profileNid": "999999",
93+
"affilWeight": [
94+
999
95+
],
96+
"affilHide": [
97+
0
98+
],
99+
"departmentTitleRanks": [
100+
null
101+
],
102+
"departmentTitleRanksWeight": [
103+
null
104+
],
105+
"departmentTitleRanksTenure": [
106+
0
107+
],
108+
"departmentTitleRanksTids": [
109+
null
110+
],
111+
"researchActivity": "<ul>\r\n\t<li class=\"first\"><a href=\"/asu-people/testvalue\">behat test value</a><a href=\"https://www.asu.edu/\">ASU</a></li>\r\n</ul>"
112+
}
113+
]

profiles/openasu/modules/custom/webspark_test/behat/behat.common.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
default:
22
suites:
33
default:
4-
#paths:
5-
# features: 'features'
4+
paths:
5+
features: '%paths.base%/features'
66
filters:
77
tags: "~@chrome"
88
contexts:

profiles/openasu/modules/custom/webspark_test/behat/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"require": {
3-
"drupal/drupal-extension": "3.2.2"
3+
"behat/behat": "~3.5.0",
4+
"drupal/drupal-extension": "~3.4.0",
5+
"behat/mink-extension": "~2.3.1"
46
},
57
"config": {
68
"bin-dir": "bin/"

profiles/openasu/modules/custom/webspark_test/behat/features/asu_directory_import.feature

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ Feature: Import iSearch Profiles
22
Background:
33
Given I am logged in as a user with the "administrator" role
44

5-
@javascript @api
5+
@javascript @api @asu_isearch
66
Scenario: Run an import, then add directory panel with imported profiles
77
Given I am at "/admin/content/isearch/configure"
88
When I click on the element "label" which has property "data-reactid" with value ".1.1"
99
And I press the "Browse" button
10-
And I click on the element "li" which has property "dept_nid" with value "1344"
10+
And I click the '[dept_nid="1359"] a.jqtree-toggler' element
11+
And I click the '[dept_nid="1569"] a.jqtree-toggler' element
12+
And I click on the element "li" which has property "dept_nid" with value "2163"
1113
And I click on the text " Include sub-departments?" in the "label" tag
1214
And I press the "Submit" button
1315
And I press the "Save configuration" button
16+
And I mock the migration source "asu_isearch.test_mock_one.json"
1417
And I click "Import iSearch Profiles"
1518
And I fill in "edit-isearch-import-limit-value" with "50"
1619
And I press the "Begin import" button
@@ -27,7 +30,9 @@ Feature: Import iSearch Profiles
2730
And I click "Add new pane"
2831
And I click "Add ASU Directory Panel"
2932
And I press the "Browse" button
30-
And I click on the element "li" which has property "dept_nid" with value "1344"
33+
And I click the '[dept_nid="1359"] a.jqtree-toggler' element
34+
And I click the '[dept_nid="1569"] a.jqtree-toggler' element
35+
And I click on the element "li" which has property "dept_nid" with value "2163"
3136
And I click on the text " Include sub-departments?" in the "label" tag
3237
And I press the "Submit" button
3338
And I click on the element "a" which has property "href" with value "#edit-field-asu-directory-items-und-0-horizontal-tabs-advanced"
@@ -36,4 +41,33 @@ Feature: Import iSearch Profiles
3641
And I press the "Save as custom" button
3742
And I click on the text "View" in the "a" tag
3843
And I click on the text "ALL" in the "li" tag
39-
Then I should not see "No employees found."
44+
Then I should see "Customized Drupal Developer Senior"
45+
46+
@javascript @api @asu_isearch
47+
Scenario: Run an import to update profiles, then load updated profile
48+
Given I am at "/admin/content/isearch/import"
49+
And I run drush "vset isearch_local_lock 1"
50+
When I mock the migration source "asu_isearch.test_mock_one.json"
51+
And I fill in "edit-isearch-import-limit-value" with "50"
52+
And I press the "Begin import" button
53+
And I wait for 30 seconds
54+
Then I should see "Processed"
55+
When I am at "/content/sparky-webspark"
56+
Then I should see "Sparky Webspark"
57+
And I should see "Customized Drupal Developer Senior"
58+
And I should see "This is a mock bio."
59+
When I click on the element "a" which has property "id" with value "ui-id-2"
60+
Then I should see the "a" element with the "href" attribute set to "https://isearch.asu.edu/asu-people/testvalue" in the "Content" region
61+
And I should see the "a" element with the "href" attribute set to "https://www.asu.edu/" in the "Content" region
62+
When I am at "/admin/content/isearch/import"
63+
When I mock the migration source "asu_isearch.test_mock_two.json"
64+
And I fill in "edit-isearch-import-limit-value" with "50"
65+
And I press the "Begin import" button
66+
And I wait for 30 seconds
67+
Then I should see "Updated"
68+
When I am at "/content/sparky-webspark"
69+
Then I should see "Super Drupal Developer Senior"
70+
When I run drush "vset isearch_local_lock 0"
71+
And I am at "/content/sparky-webspark"
72+
Then I should see "Profile not found."
73+

profiles/openasu/modules/custom/webspark_test/behat/features/bootstrap/FeatureContext.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Define application features from the specific context.
1212
*/
1313
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
14+
1415
/**
1516
* Initializes context.
1617
* Every scenario gets its own context object.
@@ -22,4 +23,31 @@ public function __construct() {
2223
// Initialize your context here
2324
}
2425

26+
/**
27+
* @When I mock the migration source :arg1
28+
*/
29+
public function iMockTheMigrationSource($arg1) {
30+
$path = $this->getMinkParameter('files_path') . '/' . $arg1;
31+
$file_contents = file_get_contents($path);
32+
$file = file_save_data( $file_contents, "private://isearch/feeds/asu_isearch_master.json", FILE_EXISTS_REPLACE );
33+
34+
if (!$file) {
35+
throw new \Exception('Migration mocking failed at '.__FUNCTION__);
36+
}
37+
}
38+
39+
/**
40+
* @When I click the :arg1 element
41+
*/
42+
public function iClickTheElement($selector)
43+
{
44+
$page = $this->getSession()->getPage();
45+
$element = $page->find('css', $selector);
46+
47+
if (empty($element)) {
48+
throw new Exception("No html element found for the selector ('$selector')");
49+
}
50+
51+
$element->click();
52+
}
2553
}

0 commit comments

Comments
 (0)