@webship-js/magento-steps 0.0.0-stage → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +405 -2
- package/package.json +66 -4
- package/scripts/build-site.sh +190 -0
- package/scripts/site-accounts.php +119 -0
- package/tests/features/01-admin-session.feature +35 -0
- package/tests/features/02-admin-menu-pages.feature +54 -0
- package/tests/features/03-admin-permissions.feature +51 -0
- package/tests/features/04-admin-grids.feature +97 -0
- package/tests/features/05-admin-products.feature +87 -0
- package/tests/features/06-admin-categories.feature +44 -0
- package/tests/features/07-admin-orders.feature +95 -0
- package/tests/features/08-admin-customers.feature +55 -0
- package/tests/features/09-admin-cart-price-rules.feature +49 -0
- package/tests/features/10-admin-content.feature +63 -0
- package/tests/features/11-admin-configuration-cache.feature +46 -0
- package/tests/features/12-admin-reviews-newsletter.feature +66 -0
- package/tests/features/20-storefront-catalog.feature +64 -0
- package/tests/features/21-storefront-search.feature +40 -0
- package/tests/features/22-storefront-product-cart.feature +68 -0
- package/tests/features/23-storefront-checkout.feature +65 -0
- package/tests/features/24-storefront-customer.feature +93 -0
- package/tests/features/25-storefront-wishlist-compare-contact.feature +50 -0
- package/tests/features/90-assertions-must-fail.feature +165 -0
- package/tests/fixtures/pixel.png +0 -0
- package/tests/step-definitions/README.md +36 -0
- package/tests/step-definitions/magento-admin-content.steps.js +818 -0
- package/tests/step-definitions/magento-admin.steps.js +856 -0
- package/tests/step-definitions/magento-helpers.js +992 -0
- package/tests/step-definitions/magento-storefront.steps.js +1797 -0
- package/tests/step-definitions/magento.steps.js +158 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Steps shared by the admin panel and the storefront: the messages, the
|
|
4
|
+
// confirmation dialogs and the "settled" wait.
|
|
5
|
+
//
|
|
6
|
+
// The admin panel has its own step files: magento-admin.steps.js (session,
|
|
7
|
+
// pages, menu, grids, forms) and magento-admin-content.steps.js (catalog,
|
|
8
|
+
// orders, customers, configuration, cache and index, clean-up). The storefront
|
|
9
|
+
// is in magento-storefront.steps.js.
|
|
10
|
+
//
|
|
11
|
+
// Steps that webship-js already covers with its generic click, fill and see
|
|
12
|
+
// vocabulary are not duplicated here; see README.md of this folder.
|
|
13
|
+
//
|
|
14
|
+
// Every assertion waits on its locator (the assertion is the wait), and every
|
|
15
|
+
// failure is a friendly error with a hint instead of a raw Playwright timeout
|
|
16
|
+
// stack.
|
|
17
|
+
|
|
18
|
+
const { When, Then } = require('@cucumber/cucumber');
|
|
19
|
+
const { friendly } = require('webship-js/tests/step-definitions/webship');
|
|
20
|
+
const {
|
|
21
|
+
budget,
|
|
22
|
+
clean,
|
|
23
|
+
literal,
|
|
24
|
+
settle,
|
|
25
|
+
assertPresence,
|
|
26
|
+
messages,
|
|
27
|
+
messagesSeen,
|
|
28
|
+
dialog,
|
|
29
|
+
answerDialog,
|
|
30
|
+
} = require('./magento-helpers');
|
|
31
|
+
|
|
32
|
+
const MESSAGE_HINT = 'A message shows after an action reloads the page or finishes its request. Check the type (success, error, warning, notice) and the exact text; the message area is `#messages` in the admin panel and `.page.messages` on the storefront.';
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Messages
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Assert a message of a given type with a given text is (or is not) on the
|
|
40
|
+
* page. Works in the admin panel and on the storefront. The text may be a part
|
|
41
|
+
* of the message.
|
|
42
|
+
*
|
|
43
|
+
* Example #1: Then I should see the success message "You saved the product."
|
|
44
|
+
* Example #2: Then I should see the error message "is not valid."
|
|
45
|
+
* Example #3: And I should not see the error message "This is a required field."
|
|
46
|
+
* Example #4: Then we should see the success message "You added Joust Duffle Bag to your shopping cart."
|
|
47
|
+
* Example #5: Then should see the notice message "Your search returned no results."
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
Then(/^(I |we )*should( not)* see the (success|error|warning|notice) message "([^"]*)"$/, async function (pronounCase, notCase, type, wanted) {
|
|
51
|
+
await assertPresence(messages(this, type, wanted), notCase, {
|
|
52
|
+
label: `the ${type} message "${wanted}"`,
|
|
53
|
+
hint: MESSAGE_HINT,
|
|
54
|
+
timeout: notCase ? 3000 : budget(this),
|
|
55
|
+
found: () => messagesSeen(this),
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Assert a message of a given type is (or is not) on the page, whatever its
|
|
61
|
+
* text.
|
|
62
|
+
*
|
|
63
|
+
* Example #1: Then I should see a success message
|
|
64
|
+
* Example #2: Then I should not see an error message
|
|
65
|
+
* Example #3: And I should see an error message
|
|
66
|
+
* Example #4: Then we should not see a warning message
|
|
67
|
+
* Example #5: Then should see a notice message
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
Then(/^(I |we )*should( not)* see (?:a|an) (success|error|warning|notice) message$/, async function (pronounCase, notCase, type) {
|
|
71
|
+
await assertPresence(messages(this, type), notCase, {
|
|
72
|
+
label: `a ${type} message`,
|
|
73
|
+
hint: MESSAGE_HINT,
|
|
74
|
+
timeout: notCase ? 3000 : budget(this),
|
|
75
|
+
found: () => messagesSeen(this),
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Confirmation dialogs
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Assert the open confirmation dialog shows a text ("Are you sure you want to
|
|
85
|
+
* delete this category?").
|
|
86
|
+
*
|
|
87
|
+
* Example #1: Then I should see the confirmation "Are you sure you want to delete this category?"
|
|
88
|
+
* Example #2: Then I should see the confirmation "You haven't selected any items!"
|
|
89
|
+
* Example #3: And I should see the confirmation "Are you sure you want to delete this address?"
|
|
90
|
+
* Example #4: Then we should see the confirmation "Delete items"
|
|
91
|
+
* Example #5: Then should see the confirmation "Are you sure you want to delete the selected customers?"
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
Then(/^(I |we )*should see the confirmation "([^"]*)"$/, async function (pronounCase, text) {
|
|
95
|
+
await assertPresence(dialog(this).filter({ hasText: literal(text) }), null, {
|
|
96
|
+
label: `a confirmation dialog with "${text}"`,
|
|
97
|
+
hint: 'The dialog opens after an action that asks for a confirmation. Check its text.',
|
|
98
|
+
timeout: budget(this),
|
|
99
|
+
found: async () => {
|
|
100
|
+
const box = dialog(this);
|
|
101
|
+
return (await box.count()) ? `the dialog "${clean(await box.innerText())}"` : 'no dialog';
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Press OK in the open confirmation dialog and wait for the action to finish.
|
|
108
|
+
*
|
|
109
|
+
* Example #1: When I confirm the action
|
|
110
|
+
* Example #2: And I confirm the action
|
|
111
|
+
* Example #3: When we confirm the action
|
|
112
|
+
* Example #4: When confirm the action
|
|
113
|
+
* Example #5: And we confirm the action
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
When(/^(I |we )*confirm the action$/, async function (pronounCase) {
|
|
117
|
+
await answerDialog(this, true);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Press Cancel in the open confirmation dialog: the action does not run.
|
|
122
|
+
*
|
|
123
|
+
* Example #1: When I dismiss the confirmation
|
|
124
|
+
* Example #2: And I dismiss the confirmation
|
|
125
|
+
* Example #3: When we dismiss the confirmation
|
|
126
|
+
* Example #4: When dismiss the confirmation
|
|
127
|
+
* Example #5: And we dismiss the confirmation
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
When(/^(I |we )*dismiss the confirmation$/, async function (pronounCase) {
|
|
131
|
+
await answerDialog(this, false);
|
|
132
|
+
if (await dialog(this).count()) {
|
|
133
|
+
throw friendly({ message: 'The confirmation dialog is still open after pressing Cancel.', hint: 'Another dialog may have opened on top of it.' });
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// The settled wait
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Wait until the page is settled: its scripts are loaded, its components are
|
|
143
|
+
* initialised, no request is in flight and no loading mask shows. The steps of
|
|
144
|
+
* this pack do it themselves; this step is for after a generic webship-js
|
|
145
|
+
* click or press.
|
|
146
|
+
*
|
|
147
|
+
* Example #1: When I wait for the page to settle
|
|
148
|
+
* Example #2: And I wait for the page to settle
|
|
149
|
+
* Example #3: When we wait for the page to settle
|
|
150
|
+
* Example #4: When wait for the page to settle
|
|
151
|
+
* Example #5: And we wait for the page to settle
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
154
|
+
When(/^(I |we )*wait for the page to settle$/, async function (pronounCase) {
|
|
155
|
+
// A click made by the step before may still be about to start its request.
|
|
156
|
+
await this.page.waitForEvent('framenavigated', { timeout: 800 }).catch(() => null);
|
|
157
|
+
await settle(this);
|
|
158
|
+
});
|