|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Spryker Commerce OS. |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types = 1); |
|
9
|
|
|
|
|
10
|
|
|
namespace PyzTest\Zed\NavigationGui\Presentation; |
|
11
|
|
|
|
|
12
|
|
|
use Faker\Factory; |
|
13
|
|
|
use PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester; |
|
14
|
|
|
use PyzTest\Zed\NavigationGui\PageObject\NavigationCreatePage; |
|
15
|
|
|
use PyzTest\Zed\NavigationGui\PageObject\NavigationDeletePage; |
|
16
|
|
|
use PyzTest\Zed\NavigationGui\PageObject\NavigationPage; |
|
17
|
|
|
use PyzTest\Zed\NavigationGui\PageObject\NavigationUpdatePage; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Auto-generated group annotations |
|
21
|
|
|
* |
|
22
|
|
|
* @group PyzTest |
|
23
|
|
|
* @group Zed |
|
24
|
|
|
* @group NavigationGui |
|
25
|
|
|
* @group Presentation |
|
26
|
|
|
* @group NavigationCRUDCest |
|
27
|
|
|
* Add your own group annotations below this line |
|
28
|
|
|
*/ |
|
29
|
|
|
class NavigationCRUDCest |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @var int |
|
33
|
|
|
*/ |
|
34
|
|
|
public const ELEMENT_TIMEOUT = 5; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
|
|
public function _before(NavigationGuiPresentationTester $i): void |
|
42
|
|
|
{ |
|
43
|
|
|
$i->amZed(); |
|
44
|
|
|
$i->amLoggedInUser(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i |
|
49
|
|
|
* |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testICanCreateReadUpdateAndDeleteNavigation(NavigationGuiPresentationTester $i): void |
|
53
|
|
|
{ |
|
54
|
|
|
$i->amOnPage(NavigationCreatePage::URL); |
|
55
|
|
|
|
|
56
|
|
|
$idNavigation = $this->create($i); |
|
57
|
|
|
|
|
58
|
|
|
$this->read($i); |
|
59
|
|
|
|
|
60
|
|
|
$i->wait(10); |
|
61
|
|
|
|
|
62
|
|
|
$this->update($i, $idNavigation); |
|
63
|
|
|
|
|
64
|
|
|
# Somehow $this->update() influences on this $this->delete() so the test becomes flickery. |
|
65
|
|
|
$i->wait(10); |
|
66
|
|
|
|
|
67
|
|
|
$this->delete($i, $idNavigation); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i |
|
72
|
|
|
* |
|
73
|
|
|
* @return int |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function create(NavigationGuiPresentationTester $i): int |
|
76
|
|
|
{ |
|
77
|
|
|
$i->wantTo('Create navigation.'); |
|
78
|
|
|
$i->expect('Navigation is persisted in Zed.'); |
|
79
|
|
|
|
|
80
|
|
|
$i->setNameField('Acceptance navigation (1)'); |
|
81
|
|
|
$i->setKeyField(Factory::create()->slug); |
|
82
|
|
|
$i->checkIsActiveField(true); |
|
83
|
|
|
$i->submitNavigationForm(); |
|
84
|
|
|
$i->seeCurrentUrlEquals(NavigationPage::URL); |
|
85
|
|
|
|
|
86
|
|
|
return (int)$i->seeSuccessMessage(NavigationCreatePage::MESSAGE_SUCCESS); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i |
|
91
|
|
|
* |
|
92
|
|
|
* @return void |
|
93
|
|
|
*/ |
|
94
|
|
|
protected function read(NavigationGuiPresentationTester $i): void |
|
95
|
|
|
{ |
|
96
|
|
|
$i->wantTo('See navigation list.'); |
|
97
|
|
|
$i->expect('Navigation table is shown and not empty'); |
|
98
|
|
|
|
|
99
|
|
|
$i->waitForElementVisible(NavigationPage::PAGE_LIST_TABLE_XPATH, static::ELEMENT_TIMEOUT); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i |
|
104
|
|
|
* @param int $idNavigation |
|
105
|
|
|
* |
|
106
|
|
|
* @return void |
|
107
|
|
|
*/ |
|
108
|
|
|
protected function update(NavigationGuiPresentationTester $i, int $idNavigation): void |
|
109
|
|
|
{ |
|
110
|
|
|
$i->wantTo('Update existing navigation.'); |
|
111
|
|
|
$i->expect('Navigation is persisted in Zed'); |
|
112
|
|
|
|
|
113
|
|
|
$i->amOnPage(sprintf(NavigationUpdatePage::URL, $idNavigation)); |
|
114
|
|
|
$i->setNameField('Acceptance navigation (1) - edited'); |
|
115
|
|
|
$i->checkIsActiveField(false); |
|
116
|
|
|
$i->submitNavigationForm(); |
|
117
|
|
|
$i->seeCurrentUrlEquals(NavigationPage::URL); |
|
118
|
|
|
$i->seeSuccessMessage(NavigationUpdatePage::MESSAGE_SUCCESS); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param \PyzTest\Zed\NavigationGui\NavigationGuiPresentationTester $i |
|
123
|
|
|
* @param int $idNavigation |
|
124
|
|
|
* |
|
125
|
|
|
* @return void |
|
126
|
|
|
*/ |
|
127
|
|
|
protected function delete(NavigationGuiPresentationTester $i, int $idNavigation): void |
|
128
|
|
|
{ |
|
129
|
|
|
$i->wantTo('Delete navigation.'); |
|
130
|
|
|
$i->expect('Navigation is removed from Zed.'); |
|
131
|
|
|
|
|
132
|
|
|
$i->amOnPage(sprintf(NavigationDeletePage::URL, $idNavigation)); |
|
133
|
|
|
$i->submitDeleteNavigationForm(); |
|
134
|
|
|
$i->seeCurrentUrlEquals(NavigationPage::URL); |
|
135
|
|
|
$i->seeSuccessMessage(NavigationDeletePage::MESSAGE_SUCCESS); |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|