1
|
|
|
<?php |
2
|
|
|
namespace Page; |
3
|
|
|
|
4
|
|
|
use Codeception\Util\Locator; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* MessagesAdmin |
8
|
|
|
* Selectors/References to elements in the Messages Admin Pages |
9
|
|
|
* |
10
|
|
|
* @package Page |
11
|
|
|
* @author Darren Ethier |
12
|
|
|
* @since 1.0.0 |
13
|
|
|
*/ |
14
|
|
|
class MessagesAdmin extends CoreAdmin |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Context slug for the admin messages context. |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
const ADMIN_CONTEXT_SLUG = 'admin'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Context slug for the primary attendee messages context |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee'; |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Status reference for the EEM_Message::status_sent status. |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
const MESSAGE_STATUS_SENT = 'MSN'; |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Message type slug for the Payment Failed message type |
39
|
|
|
*/ |
40
|
|
|
const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed'; |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Selector for the Global Messages "Send on same request" field in the Messages Settings tab. |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = |
48
|
|
|
'#global_messages_settings-do-messages-on-same-request'; |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Selector for the Global Messages Settings submit button in the Messages Settings tab. |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit'; |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* This is the container where active message types for a messenger are found/dragged to. |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types'; |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Locator for the context switcher selector on the Message Template Editor page. |
67
|
|
|
* @var string |
68
|
|
|
*/ |
69
|
|
|
const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select"; |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Locator for the context switcher submit button in the Message Template Editor page. |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt"; |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Locator for the dialog container used for housing viewed messages in the message activity list table. |
81
|
|
|
* @var string |
82
|
|
|
*/ |
83
|
|
|
const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content'; |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Returns the selector for the on/off toggle for context on the message template editor. |
88
|
|
|
*/ |
89
|
|
|
const MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE = |
90
|
|
|
"//div[@class='activate_context_on_off_toggle_container']/div[@class='switch']/label"; |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $additional_params Any additional request parameters for the generated url should be included as |
96
|
|
|
* a string. |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
|
|
public static function messageActivityListTableUrl($additional_params = '') |
100
|
|
|
{ |
101
|
|
|
return self::adminUrl('espresso_messages', 'default', $additional_params); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param string $additional_params Any additional request parameters for the generated url should be included as |
107
|
|
|
* a string. |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
|
|
public static function defaultMessageTemplateListTableUrl($additional_params = '') |
111
|
|
|
{ |
112
|
|
|
return self::adminUrl('espresso_messages', 'global_mtps', $additional_params); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param string $additional_params Any additional request parameters for the generated url should be included as |
118
|
|
|
* a string. |
119
|
|
|
* @return string |
120
|
|
|
*/ |
121
|
|
|
public static function customMessageTemplateListTableUrl($additional_params = '') |
122
|
|
|
{ |
123
|
|
|
return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return string |
129
|
|
|
*/ |
130
|
|
|
public static function messageSettingsUrl() |
131
|
|
|
{ |
132
|
|
|
return self::adminUrl('espresso_messages', 'settings'); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
|
136
|
|
|
|
137
|
|
|
public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger( |
138
|
|
|
$message_type_slug, |
139
|
|
|
$messenger_slug = 'email' |
140
|
|
|
) { |
141
|
|
|
return "#$message_type_slug-messagetype-$messenger_slug"; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param string $message_type_slug |
147
|
|
|
* @param string $context |
148
|
|
|
* @return string |
149
|
|
|
*/ |
150
|
|
|
public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
151
|
|
|
{ |
152
|
|
|
return $context |
153
|
|
|
? '.' . $message_type_slug . '-' . $context . '-edit-link' |
154
|
|
|
: '.' . $message_type_slug . '-edit-link'; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters. |
160
|
|
|
* |
161
|
|
|
* @param $field |
162
|
|
|
* @param $message_type_label |
163
|
|
|
* @param string $message_status |
164
|
|
|
* @param string $messenger |
165
|
|
|
* @param string $context |
166
|
|
|
* @param string $table_cell_content_for_field |
167
|
|
|
* @param int $number_in_set It's possible that the given parameters could match multiple items in the view. |
168
|
|
|
* This allows you to indicate which item from the set to match. If this is set to 0 |
169
|
|
|
* then all matches for the locator will be returned. |
170
|
|
|
* @return string |
171
|
|
|
* @throws \InvalidArgumentException |
172
|
|
|
*/ |
173
|
|
|
public static function messagesActivityListTableCellSelectorFor( |
174
|
|
|
$field, |
175
|
|
|
$message_type_label, |
176
|
|
|
$message_status = self::MESSAGE_STATUS_SENT, |
177
|
|
|
$messenger = 'Email', |
178
|
|
|
$context = 'Event Admin', |
179
|
|
|
$table_cell_content_for_field = '', |
180
|
|
|
$number_in_set = 1 |
181
|
|
|
) { |
182
|
|
|
$selector = "//tbody[@id='the-list']"; |
183
|
|
|
$selector .= "//tr[contains(@class, 'msg-status-$message_status')]" |
184
|
|
|
. "//td[contains(@class, 'message_type') and text()='$message_type_label']"; |
185
|
|
|
if ($messenger) { |
186
|
|
|
$selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']"; |
187
|
|
|
} |
188
|
|
|
$selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']"; |
189
|
|
|
$selector .= $table_cell_content_for_field |
190
|
|
|
? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']" |
191
|
|
|
: "/ancestor::tr/td[contains(@class, 'column-$field')]"; |
192
|
|
|
return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Selector for the Create Custom button found in the message template list table. |
198
|
|
|
* @param string $message_type_label |
199
|
|
|
* @param string $messenger_label |
200
|
|
|
* @return string |
201
|
|
|
*/ |
202
|
|
|
public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label) |
203
|
|
|
{ |
204
|
|
|
$selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']" |
205
|
|
|
. "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]" |
206
|
|
|
. "//ancestor::tr/td/a[@class='button button-small']"; |
207
|
|
|
return $selector; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to |
213
|
|
|
* the FIRST match (which will be the latest message sent if the table is default sorted). |
214
|
|
|
* |
215
|
|
|
* @param string $message_type_label The visible message type label for the row you want to match |
216
|
|
|
* @param string $message_status The status of the message for the row you want to match. |
217
|
|
|
* @param string $messenger The visible messenger label for the row you want to match. |
218
|
|
|
* @param string $context The visible context label for the row you want to match. |
219
|
|
|
* @param int $number_in_set It's possible that the given parameters could match multiple items in the |
220
|
|
|
* view. This allows you to indicate which item from the set to match. |
221
|
|
|
* @return string |
222
|
|
|
* @throws \InvalidArgumentException |
223
|
|
|
*/ |
224
|
|
View Code Duplication |
public static function messagesActivityListTableViewButtonSelectorFor( |
225
|
|
|
$message_type_label, |
226
|
|
|
$message_status = self::MESSAGE_STATUS_SENT, |
227
|
|
|
$messenger = 'Email', |
228
|
|
|
$context = 'Event Admin', |
229
|
|
|
$number_in_set = 1 |
230
|
|
|
) { |
231
|
|
|
$selector = self::messagesActivityListTableCellSelectorFor( |
232
|
|
|
'action', |
233
|
|
|
$message_type_label, |
234
|
|
|
$message_status, |
235
|
|
|
$messenger, |
236
|
|
|
$context, |
237
|
|
|
'', |
238
|
|
|
$number_in_set |
239
|
|
|
); |
240
|
|
|
$selector .= "/a/span[contains(@class, 'ee-message-action-link-view')" |
241
|
|
|
. " and not(contains(@class, 'ee-message-action-link-view_transaction'))]"; |
242
|
|
|
return $selector; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Locator for the delete action link for a message item in the message activity list table. |
248
|
|
|
* Note: The link is not visible by default, so the column would need hovered over for the link to appear. |
249
|
|
|
* |
250
|
|
|
* @param $message_type_label |
251
|
|
|
* @param string $message_status |
252
|
|
|
* @param string $messenger |
253
|
|
|
* @param string $context |
254
|
|
|
* @param int $number_in_set |
255
|
|
|
* @return string |
256
|
|
|
* @throws \InvalidArgumentException |
257
|
|
|
*/ |
258
|
|
View Code Duplication |
public static function messagesActivityListTableDeleteActionSelectorFor( |
259
|
|
|
$message_type_label, |
260
|
|
|
$message_status = self::MESSAGE_STATUS_SENT, |
261
|
|
|
$messenger = 'Email', |
262
|
|
|
$context = 'Event Admin', |
263
|
|
|
$number_in_set = 1 |
264
|
|
|
) { |
265
|
|
|
$selector = self::messagesActivityListTableCellSelectorFor( |
266
|
|
|
'to', |
267
|
|
|
$message_type_label, |
268
|
|
|
$message_status, |
269
|
|
|
$messenger, |
270
|
|
|
$context, |
271
|
|
|
'', |
272
|
|
|
$number_in_set |
273
|
|
|
); |
274
|
|
|
$selector .= "/div/span[@class='delete']/a"; |
275
|
|
|
return $selector; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
|
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* Returns the input selector for a given field in the message template editor. |
282
|
|
|
* Assumes one is already viewing the Message Template Editor. |
283
|
|
|
* @param string $field |
284
|
|
|
* @return string |
285
|
|
|
*/ |
286
|
|
|
public static function messageInputFieldSelectorFor($field) |
287
|
|
|
{ |
288
|
|
|
return "//div[@id='post-body']//input[@id='$field-content']"; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* Wrapper for self::messageInputFieldSelectorFor('to') that takes care of getting the input for the To field. |
294
|
|
|
*/ |
295
|
|
|
public static function messageTemplateToFieldSelector() |
296
|
|
|
{ |
297
|
|
|
return self::messageInputFieldSelectorFor('to'); |
298
|
|
|
} |
299
|
|
|
} |