|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace hipanel\modules\ticket\tests\acceptance\client; |
|
4
|
|
|
|
|
5
|
|
|
use Codeception\Scenario; |
|
6
|
|
|
use hipanel\helpers\Url; |
|
7
|
|
|
use hipanel\modules\ticket\tests\_support\Page\ticket\Create; |
|
8
|
|
|
use hipanel\modules\ticket\tests\_support\Page\ticket\Index; |
|
9
|
|
|
use hipanel\modules\ticket\tests\_support\Page\ticket\View; |
|
10
|
|
|
use hipanel\tests\_support\Page\IndexPage; |
|
11
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Input; |
|
12
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Select2; |
|
13
|
|
|
use hipanel\tests\_support\Step\Acceptance\Client; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class TicketCest |
|
17
|
|
|
* |
|
18
|
|
|
* @author Dmytro Naumenko <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class TicketCest |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var string|int |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $ticket_id; |
|
26
|
|
|
|
|
27
|
|
|
private IndexPage $index; |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
public function _before(Client $I): void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->index = new IndexPage($I); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function ensureIndexPageWorks(Client $I): void |
|
35
|
|
|
{ |
|
36
|
|
|
$I->login(); |
|
37
|
|
|
$I->needPage(Url::to('@ticket')); |
|
38
|
|
|
$I->see('Tickets', 'h1'); |
|
39
|
|
|
$I->seeLink('Create ticket', Url::to('@ticket/create')); |
|
40
|
|
|
$this->ensureICanSeeAdvancedSearchBox($I); |
|
41
|
|
|
$this->ensureICanSeeBulkSearchBox(); |
|
42
|
|
|
(new Index($I))->ensurePageWorks(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
private function ensureICanSeeAdvancedSearchBox(Client $I): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->index->containsFilters([ |
|
48
|
|
|
Input::asAdvancedSearch($I, 'Subject or 1st message'), |
|
49
|
|
|
Select2::asAdvancedSearch($I, 'Status'), |
|
50
|
|
|
Select2::asAdvancedSearch($I, 'Topics'), |
|
51
|
|
|
]); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
private function ensureICanSeeBulkSearchBox(): void |
|
55
|
|
|
{ |
|
56
|
|
|
$this->index->containsBulkButtons([ |
|
57
|
|
|
'Close', |
|
58
|
|
|
]); |
|
59
|
|
|
$this->index->containsColumns([ |
|
60
|
|
|
'Subject', |
|
61
|
|
|
'Answers', |
|
62
|
|
|
]); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function ensureICanNavigateToCreateTicketPage(Client $I): void |
|
66
|
|
|
{ |
|
67
|
|
|
(new Index($I))->ensureThatICanNavigateToCreateTicketPage(); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function ensureICanCreateTicket(Client $I): void |
|
71
|
|
|
{ |
|
72
|
|
|
$this->ticket_id = (new Create($I))->createTicket( |
|
73
|
|
|
'Test ticket (' . date('Y-m-d H:i') . ')', |
|
74
|
|
|
'This is a test ticket created by automated testing system. Ignore it, please.', |
|
75
|
|
|
'VDS' |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function ensureISeeCreatedTicketOnIndexPage(Client $I, Scenario $scenario): void |
|
80
|
|
|
{ |
|
81
|
|
|
if (!isset($this->ticket_id)) { |
|
82
|
|
|
$scenario->incomplete('Ticket ID must be filled to run this test'); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
$index = new Index($I); |
|
86
|
|
|
$index->hasLinkToTicket($this->ticket_id); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function ensureICanCommentTicket(Client $I, Scenario $scenario) |
|
90
|
|
|
{ |
|
91
|
|
|
if (!isset($this->ticket_id)) { |
|
92
|
|
|
$scenario->incomplete('Ticket ID must be filled to run this test'); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
$view = new View($I, $this->ticket_id); |
|
96
|
|
|
$view->visitTicket(); |
|
97
|
|
|
$view->postComment('This is a test comment. Ignore it, please.'); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function ensureICanChangeTicketState(Client $I, Scenario $scenario): void |
|
101
|
|
|
{ |
|
102
|
|
|
if (!isset($this->ticket_id)) { |
|
103
|
|
|
$scenario->incomplete('Ticket ID must be filled to run this test'); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
$view = new View($I, $this->ticket_id); |
|
107
|
|
|
$view->visitTicket(); |
|
108
|
|
|
$view->closeTicket(); |
|
109
|
|
|
|
|
110
|
|
|
$I->openNewTab(); |
|
111
|
|
|
$index = new Index($I); |
|
112
|
|
|
$index->ensureTicketClosed($this->ticket_id); |
|
113
|
|
|
$I->closeTab(); |
|
114
|
|
|
|
|
115
|
|
|
$view->openTicket(); |
|
116
|
|
|
$view->closeTicket(); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|