1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Oro\Bundle\NoteBundle\Tests\Selenium\Pages; |
4
|
|
|
|
5
|
|
|
use Oro\Bundle\TestFrameworkBundle\Pages\AbstractPageEntity; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Notes |
9
|
|
|
* |
10
|
|
|
* @package Oro\Bundle\NoteBundle\Pages\Objects |
11
|
|
|
* @method Notes openNotes(string $bundlePath) |
12
|
|
|
* {@inheritdoc} |
13
|
|
|
*/ |
14
|
|
|
class Notes extends AbstractPageEntity |
15
|
|
|
{ |
16
|
|
|
/** @var \PHPUnit_Extensions_Selenium2TestCase_Element */ |
17
|
|
|
protected $tagName; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @return $this |
21
|
|
|
*/ |
22
|
|
View Code Duplication |
public function addNote() |
23
|
|
|
{ |
24
|
|
|
if ($this->isElementPresent("//div[@class='pull-right']//a[@class='btn dropdown-toggle']")) { |
25
|
|
|
$this->runActionInGroup('Add note'); |
26
|
|
|
} else { |
27
|
|
|
$this->test->byXPath( |
28
|
|
|
"//div[@class='pull-right title-buttons-container']//a[@id='add-entity-note-button']" |
29
|
|
|
)->click(); |
30
|
|
|
$this->waitForAjax(); |
31
|
|
|
$this->assertElementPresent( |
32
|
|
|
"//div[contains(@class,'ui-dialog-titlebar')]". |
33
|
|
|
"/span[normalize-space(.)='Add note']", |
34
|
|
|
'Add Note window is not opened' |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return $this; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $note |
43
|
|
|
* @return $this |
44
|
|
|
*/ |
45
|
|
View Code Duplication |
public function setNoteMessage($note) |
46
|
|
|
{ |
47
|
|
|
$this->test->waitUntil( |
48
|
|
|
function (\PHPUnit_Extensions_Selenium2TestCase $testCase) { |
49
|
|
|
return $testCase->execute( |
50
|
|
|
[ |
51
|
|
|
'script' => 'return tinyMCE.activeEditor.initialized', |
52
|
|
|
'args' => [], |
53
|
|
|
] |
54
|
|
|
); |
55
|
|
|
}, |
56
|
|
|
intval(MAX_EXECUTION_TIME) |
57
|
|
|
); |
58
|
|
|
|
59
|
|
|
$this->test->execute( |
60
|
|
|
[ |
61
|
|
|
'script' => sprintf('tinyMCE.activeEditor.setContent(\'%s\')', $note), |
62
|
|
|
'args' => [], |
63
|
|
|
] |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return $this |
71
|
|
|
*/ |
72
|
|
|
public function saveNote() |
73
|
|
|
{ |
74
|
|
|
$this->test->byXPath("//div[@class='widget-actions-section']//button[@type='submit']")->click(); |
75
|
|
|
$this->waitForAjax(); |
76
|
|
|
|
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return $this |
82
|
|
|
*/ |
83
|
|
|
public function addNoteButtonAvailable() |
84
|
|
|
{ |
85
|
|
|
if ($this->isElementPresent("//div[@class='pull-right']//a[@class='btn dropdown-toggle']")) { |
86
|
|
|
$this->checkActionInGroup(['Add note']); |
87
|
|
|
} else { |
88
|
|
|
$this->assertElementPresent( |
89
|
|
|
"//div[@class='pull-right title-buttons-container']//a[@id='add-entity-note-button']", |
90
|
|
|
'Add Note button not available' |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return $this |
99
|
|
|
*/ |
100
|
|
|
public function addNoteButtonNotAvailable() |
101
|
|
|
{ |
102
|
|
|
if ($this->isElementPresent("//div[@class='pull-right']//a[@class='btn dropdown-toggle']")) { |
103
|
|
|
$this->checkActionInGroup(['Add note'], false); |
104
|
|
|
} else { |
105
|
|
|
$this->assertElementNotPresent( |
106
|
|
|
"//div[@class='pull-right title-buttons-container']//a[@id='add-entity-note-button']", |
107
|
|
|
'Add Note button is available' |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param string $note |
116
|
|
|
* @return $this |
117
|
|
|
*/ |
118
|
|
|
public function checkNote($note) |
119
|
|
|
{ |
120
|
|
|
$this->verifyActivity('Note', $note); |
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Method implements Update and Delete actions for Notes activity |
126
|
|
|
* @param $note |
127
|
|
|
* @param $action |
128
|
|
|
* @return $this |
129
|
|
|
*/ |
130
|
|
|
public function noteAction($note, $action) |
131
|
|
|
{ |
132
|
|
|
$actionMenu = "//*[@class='container-fluid accordion']" . |
133
|
|
|
"[//*[@class='message-item message'][contains(., '{$note}')]]" . |
134
|
|
|
"//div[@class='actions']//a[contains(., '...')]"; |
135
|
|
|
$selectedAction = |
136
|
|
|
"//*[@class='container-fluid accordion']" . |
137
|
|
|
"[//*[@class='message-item message'][contains(., '{$note}')]]" . |
138
|
|
|
"//div[@class='actions']//a[contains(., '{$action}')]"; |
139
|
|
|
|
140
|
|
|
$this->test->moveto($this->test->byXPath($actionMenu)); |
141
|
|
|
$this->test->byXPath($selectedAction)->click(); |
142
|
|
|
|
143
|
|
|
switch ($action) { |
144
|
|
|
case 'Update Note': |
145
|
|
|
$this->assertElementPresent( |
146
|
|
|
"//div[contains(@class,'ui-dialog-titlebar')]". |
147
|
|
|
"/span[normalize-space(.)='{$note}']", |
148
|
|
|
'Update Note window is not opened' |
149
|
|
|
); |
150
|
|
|
break; |
151
|
|
|
case 'Delete Note': |
152
|
|
|
$this->test->byXpath( |
153
|
|
|
"//div[div[contains(., 'Delete Confirmation')]]//a[text()='Yes, Delete']" |
154
|
|
|
)->click(); |
155
|
|
|
break; |
156
|
|
|
} |
157
|
|
|
$this->waitForAjax(); |
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|