|
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\Tax\Presentation; |
|
11
|
|
|
|
|
12
|
|
|
use PyzTest\Zed\Tax\PageObject\TaxRateCreatePage; |
|
13
|
|
|
use PyzTest\Zed\Tax\PageObject\TaxRateListPage; |
|
14
|
|
|
use PyzTest\Zed\Tax\TaxPresentationTester; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Auto-generated group annotations |
|
18
|
|
|
* |
|
19
|
|
|
* @group PyzTest |
|
20
|
|
|
* @group Zed |
|
21
|
|
|
* @group Tax |
|
22
|
|
|
* @group Presentation |
|
23
|
|
|
* @group TaxRateCreateCest |
|
24
|
|
|
* Add your own group annotations below this line |
|
25
|
|
|
*/ |
|
26
|
|
|
class TaxRateCreateCest |
|
27
|
|
|
{ |
|
28
|
|
|
public function _before(TaxPresentationTester $i): void |
|
29
|
|
|
{ |
|
30
|
|
|
$i->amZed(); |
|
31
|
|
|
$i->amLoggedInUser(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testCreateValidTaxRateShouldShowSuccessMessage(TaxPresentationTester $i): void |
|
35
|
|
|
{ |
|
36
|
|
|
$i->wantTo('Create valid tax rate.'); |
|
37
|
|
|
$i->expect('Tax rate is successfully created'); |
|
38
|
|
|
|
|
39
|
|
|
$i->createTaxRate(TaxRateCreatePage::TAX_RATE_VALID); |
|
40
|
|
|
$i->seeMatches(TaxRateCreatePage::MESSAGE_SUCCESSFUL_ALERT_CREATION, 'div.alert-success'); |
|
41
|
|
|
|
|
42
|
|
|
$i->removeTaxRateFromDatabase(TaxRateCreatePage::TAX_RATE_VALID); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testCreateInvalidTaxRateShouldShowErrorMessages(TaxPresentationTester $i): void |
|
46
|
|
|
{ |
|
47
|
|
|
$i->wantTo('Create invalid tax rate'); |
|
48
|
|
|
$i->expect('Error messages are displayed. Tax rate is not created'); |
|
49
|
|
|
|
|
50
|
|
|
$i->createTaxRate(TaxRateCreatePage::TAX_RATE_INVALID); |
|
51
|
|
|
$i->seeErrorMessages(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testBackToListOfTaxRatesShouldOpenTaxRateListPageWithoutSaving(TaxPresentationTester $i): void |
|
55
|
|
|
{ |
|
56
|
|
|
$i->wantTo('Create valid tax rate and back to list of tax rates'); |
|
57
|
|
|
$i->expect('List of tax rates is opened, tax rate is not created'); |
|
58
|
|
|
|
|
59
|
|
|
$i->createTaxRateWithoutSaving(TaxRateCreatePage::TAX_RATE_VALID_NOT_CREATED); |
|
60
|
|
|
$i->click(TaxRateCreatePage::SELECTOR_LIST_OF_TAX_RATES_BUTTON); |
|
61
|
|
|
|
|
62
|
|
|
$i->dontSeeMatches(TaxRateCreatePage::MESSAGE_SUCCESSFUL_ALERT_CREATION, 'div.alert-success'); |
|
63
|
|
|
|
|
64
|
|
|
$i->searchForTaxRate(TaxRateCreatePage::TAX_RATE_VALID_NOT_CREATED); |
|
65
|
|
|
|
|
66
|
|
|
$i->waitForText(TaxRateListPage::MESSAGE_EMPTY_TABLE, 10); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function testCreateTaxRateWhichAlreadyExistsShouldShowErrorMessage(TaxPresentationTester $i): void |
|
70
|
|
|
{ |
|
71
|
|
|
$i->wantTo('Create tax rate which already exists'); |
|
72
|
|
|
$i->expect('Error message is displayed on attempt to create one and the same Tax Rate'); |
|
73
|
|
|
|
|
74
|
|
|
$i->createTaxRate(TaxRateCreatePage::TAX_RATE_VALID); |
|
75
|
|
|
|
|
76
|
|
|
$i->wait(2); |
|
77
|
|
|
|
|
78
|
|
|
$i->createTaxRate(TaxRateCreatePage::TAX_RATE_VALID); |
|
79
|
|
|
$i->see(TaxRateCreatePage::ERROR_MESSAGE_TAX_RATE_ALREADY_EXISTS); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function testCreateAlreadyExistedTaxRateShouldShowErrorMessage(TaxPresentationTester $i): void |
|
83
|
|
|
{ |
|
84
|
|
|
$i->wantTo('Create tax rate which already exists'); |
|
85
|
|
|
$i->expect('Error message is displayed on attempt to create one and the same Tax Rate'); |
|
86
|
|
|
|
|
87
|
|
|
$i->createOneAndTheSameTaxRate(TaxRateCreatePage::TAX_RATE_VALID); |
|
88
|
|
|
|
|
89
|
|
|
$i->wait(2); |
|
90
|
|
|
|
|
91
|
|
|
$i->see(TaxRateCreatePage::ERROR_MESSAGE_TAX_RATE_ALREADY_EXISTS); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function _after(TaxPresentationTester $i): void |
|
95
|
|
|
{ |
|
96
|
|
|
$i->removeTaxRateFromDatabase(TaxRateCreatePage::TAX_RATE_VALID); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|