-
Notifications
You must be signed in to change notification settings - Fork 173
/
candidate_profileTest.php
139 lines (135 loc) · 4.28 KB
/
candidate_profileTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* Candidate_profile automated integration tests
*
* PHP Version 7
*
* @category Test
* @package Loris
* @author Alexandra Livadas <alexandra.livadas@mail.mcgill.ca>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://github.com/aces/Loris
*/
use Facebook\WebDriver\WebDriverBy;
require_once __DIR__
. "/../../../test/integrationtests/LorisIntegrationTestWithCandidate.class.inc";
/**
* CandidateProfileIntegrationTest
*
* @category Test
* @package Loris
* @author Alexandra Livadas <alexandra.livadas@mail.mcgill.ca>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://github.com/aces/Loris
*/
class CandidateProfileIntegrationTest extends LorisIntegrationTestWithCandidate
{
/**
* Tests that the page loads
*
* @return void
*/
function testCandidateProfileDoespageLoad()
{
$this->safeGet($this->url . "/candidate_profile/900000/");
$bodyText
= $this->safeFindElement(WebDriverBy::cssSelector("#breadcrumbs"))
->getText();
$this->assertStringContainsString(
"Candidate Dashboard 900000 / TST0001",
$bodyText
);
$this->assertStringNotContainsString(
"You do not have access to this page.",
$bodyText
);
$this->assertStringNotContainsString(
"An error occured while loading the page.",
$bodyText
);
}
/**
* Test that the page does not load if the user's study site does not
* match the candidate's
*
* @return void
*/
function testCandidateProfileWithoutSitePermissions()
{
$this->resetStudySite();
$this->changeStudySite();
$this->setupPermissions(["data_entry"]);
$this->safeGet($this->url . "/candidate_profile/900000/");
$bodyText
= $this->safeFindElement(WebDriverBy::cssSelector("body"))
->getText();
$this->assertStringContainsString("Permission Denied", $bodyText);
$this->resetPermissions();
$this->resetStudySite();
}
/**
* Test that the page does not load if the user's project does not
* match the candidate's
*
* @return void
*/
function testCandidateProfileWithoutProjectPermissions()
{
$this->resetUserProject();
$this->changeUserProject();
$this->setupPermissions(["data_entry"]);
$this->safeGet($this->url . "/candidate_profile/900000/");
$bodyText
= $this->safeFindElement(WebDriverBy::cssSelector("body"))
->getText();
$this->assertStringContainsString("Permission Denied", $bodyText);
$this->resetPermissions();
$this->resetUserProject();
}
/**
* Test that the page instrument link works on card 2 section
*
* @return void
*/
function testCandidateProfileInstrumentLink1()
{
$this->safeGet($this->url . "/candidate_profile/900000/");
$this->safeFindElement(
WebDriverBy::cssSelector(
"#card2 > div:nth-child(1) >".
"div:nth-child(1)>div:nth-child(1)>div:nth-child(1)>div:nth-".
"child(1)> div:nth-child(2) > h4:nth-child(1) > a:nth-child(1)"
)
)->click();
$bodyText
= $this->safeFindElement(WebDriverBy::cssSelector("body"))
->getText();
$this->assertStringContainsString(
"Behavioural Battery of Instruments",
$bodyText
);
}
/**
* Test that the page instrument link works on card 1 section
*
* @return void
*/
function testCandidateProfileInstrumentLink2()
{
$this->safeGet($this->url . "/candidate_profile/900000/");
$this->safeFindElement(
WebDriverBy::cssSelector(
"#card0 > div:nth-child(1) >".
"div:nth-child(1)>div:nth-child(1)>dl:nth-child(1)>div:nth-".
"child(9)>dd:nth-child(2) > div:nth-child(1) > a:nth-child(1)"
)
)->click();
$bodyText
= $this->safeFindElement(WebDriverBy::cssSelector("body"))
->getText();
$this->assertStringContainsString(
"Behavioural Battery of Instruments",
$bodyText
);
}
}