@webship-js/magento-steps 2.0.1 → 2.0.2
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/README.md +126 -3
- package/package.json +3 -2
- package/scripts/build-site.sh +10 -1
- package/tests/features/02-admin-menu-pages.feature +1 -0
- package/tests/features/06-admin-categories.feature +1 -0
- package/tests/features/07-admin-orders.feature +1 -0
- package/tests/features/11-admin-configuration-cache.feature +2 -1
- package/tests/features/21-storefront-search.feature +9 -0
- package/tests/features/22-storefront-product-cart.feature +1 -0
- package/tests/features/23-storefront-checkout.feature +3 -0
- package/tests/features/25-storefront-wishlist-compare-contact.feature +4 -0
package/README.md
CHANGED
|
@@ -25,6 +25,101 @@ carries the name of the platform.
|
|
|
25
25
|
The pack is for **Magento Open Source**, the community edition. It needs no
|
|
26
26
|
account, no access key and no paid or external service.
|
|
27
27
|
|
|
28
|
+
## From nothing to a green run
|
|
29
|
+
|
|
30
|
+
What the machine needs: Docker, [DDEV](https://ddev.com), git, python3, curl, and Node.js 20 or later with npm. PHP, the database and the search engine run in DDEV's containers; the store needs about 2 GB of memory and 5 GB of disk (see [The test store](#the-test-store)).
|
|
31
|
+
|
|
32
|
+
**1. The store.** The pack's own build script (the one CI runs) installs Magento Open Source with its sample data in a DDEV project and creates the accounts of [Test users](#test-users). It takes a few minutes, more the first time it downloads the packages.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git clone https://github.com/webship/magento-steps.git
|
|
36
|
+
SITE_DIR="$PWD/magento-site" magento-steps/scripts/build-site.sh
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The store answers at `https://magentosteps.ddev.site` and its admin panel at `https://magentosteps.ddev.site/admin`.
|
|
40
|
+
|
|
41
|
+
**2. A test project.**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
mkdir magento-tests && cd magento-tests
|
|
45
|
+
npm init -y
|
|
46
|
+
npm install --save-dev webship-js @webship-js/magento-steps
|
|
47
|
+
npx init-webship-js
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`npx init-webship-js` writes `cucumber.js`, `playwright.config.ts`, the `tests/` folders with a first feature and the `npm test` scripts, and installs Chromium. npm usually runs it already when it installs webship-js; a second run changes nothing.
|
|
51
|
+
|
|
52
|
+
**3. `cucumber.js`.** Replace the file with the wiring of the pack: the step files of webship-js and of the pack, the address of the store, the admin path, and the accounts (the JSON of [Test users](#test-users)).
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
module.exports = {
|
|
56
|
+
default: {
|
|
57
|
+
requireModule: ['tsx/cjs'],
|
|
58
|
+
require: [
|
|
59
|
+
'node_modules/webship-js/tests/step-definitions/**/*.js',
|
|
60
|
+
'node_modules/@webship-js/magento-steps/tests/step-definitions/*.js',
|
|
61
|
+
'tests/step-definitions/**/*.js',
|
|
62
|
+
],
|
|
63
|
+
paths: ['tests/features/**/*.feature'],
|
|
64
|
+
format: ['@cucumber/pretty-formatter', 'json:tests/reports/cucumber_report.json'],
|
|
65
|
+
worldParameters: {
|
|
66
|
+
launchUrl: process.env.LAUNCH_URL || 'https://magentosteps.ddev.site',
|
|
67
|
+
adminPath: 'admin',
|
|
68
|
+
// `When I rebuild the invalid indexes` runs this command in siteDir (the folder of the store).
|
|
69
|
+
reindexCommand: 'ddev exec php bin/magento indexer:reindex',
|
|
70
|
+
siteDir: '../magento-site',
|
|
71
|
+
// The waits webship-js adds around each page, scenario and step (milliseconds).
|
|
72
|
+
minWaitTime: { page: 3000, before_scenario: 0, after_scenario: 0, before_step: 0, after_step: 0 },
|
|
73
|
+
users: {
|
|
74
|
+
admin: { username: 'admin', password: 'Admin123456789!' },
|
|
75
|
+
sales: { username: 'sales', password: 'Sales123456789!' },
|
|
76
|
+
customer: { email: 'customer@example.com', password: 'Customer123456789!', name: 'Casey Customer' },
|
|
77
|
+
shopper: { email: 'shopper@example.com', password: 'Shopper123456789!', name: 'Sam Shopper' },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**4. A first feature**, `tests/features/first-run.feature`:
|
|
85
|
+
|
|
86
|
+
```gherkin
|
|
87
|
+
Feature: First run
|
|
88
|
+
Scenario: An administrator logs in to the admin panel
|
|
89
|
+
Given I am logged in to the admin panel as "admin"
|
|
90
|
+
Then the admin page title should be "Dashboard"
|
|
91
|
+
|
|
92
|
+
Scenario: A visitor searches the store
|
|
93
|
+
Given I am on the homepage
|
|
94
|
+
When I search the store for "yoga"
|
|
95
|
+
Then I should see the product "Cronus Yoga Pant" in the product list
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**5. Run it.**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm test
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
A green first run prints every step, then the summary (the starter feature of `npx init-webship-js` and the two scenarios above, passed) and the HTML report it wrote:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
3 scenarios (3 passed)
|
|
108
|
+
7 steps (7 passed)
|
|
109
|
+
0m17.010s (executing steps: 0m16.968s)
|
|
110
|
+
[webship-js] HTML report → …/magento-tests/tests/reports/cucumber_report.html
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
From there, copy the features of [`tests/features/`](tests/features/) (they also ship in the package, under `node_modules/@webship-js/magento-steps/tests/features/`): together they use every step of the pack.
|
|
114
|
+
|
|
115
|
+
### What the suite tests
|
|
116
|
+
|
|
117
|
+
The features of this repository run every step of the pack against the sample-data store, in CI on every change (the admin lane, the storefront lane, and the assertions that must fail): logging in to and out of the admin panel as an administrator and as a restricted user, refused logins and what the restricted role may and may not open, the menu and the named pages, both kinds of grid (keyword search, filters, sorting, paging, page size, actions), products (validation; a simple product created, shown in the store, changed and removed; images; a configurable product read), the category tree (a subcategory added and removed), orders from the checkout through invoice, shipment, hold, credit memo and cancel, customers and their addresses and groups, cart price rules with a coupon used in the cart, pages and blocks, the configuration, the cache and the indexes, reviews and newsletter subscribers from the store to the admin panel; and in the store: the menu and categories, layered navigation, sorting, list and grid modes, paging, search with its suggestions, the product page with options and quantity, the mini cart and the cart (update, estimate, coupon, empty), the checkout as a guest and as a customer, the customer account (login, logout, registration, the account pages, the address book), the wish list, the comparison list and the contact form.
|
|
118
|
+
|
|
119
|
+
Every step of the pack runs in a feature, and every assertion with a `not` runs both ways but one: `I should not see the last placed order in the orders grid` cannot be true on a working store (the step clears the grid's filters and searches the order the scenario placed, which the store always lists).
|
|
120
|
+
|
|
121
|
+
Not tested: the paid edition and its features, payment gateways and carrier services, the Page Builder stage, multiple websites, stores, currencies and languages, other themes, the mobile menu, moving a category, bundle, grouped, virtual and downloadable products, creating an order in the admin panel, tax rules, and e-mail (it goes to DDEV's Mailpit and no step reads it). What a run leaves on the store: its four orders (the platform cannot delete an order; see [Accounts](#accounts)), the carts of its visitors and customers (the store keeps a cart until its own clean-up of old carts, a cron job that does not run on the test store), the search terms the visitors typed (they feed the search suggestions), and, after the first run, the other fields of the General configuration section, which the admin panel stores the first time the section is saved.
|
|
122
|
+
|
|
28
123
|
## Requirements
|
|
29
124
|
|
|
30
125
|
- Node.js 20 or later
|
|
@@ -269,7 +364,28 @@ feature never creates or deletes one of them.
|
|
|
269
364
|
|
|
270
365
|
A customer that a scenario registers is content: the scenario removes it
|
|
271
366
|
(`Given there is no customer "…"`). Orders cannot be deleted in the admin
|
|
272
|
-
panel: every run leaves
|
|
367
|
+
panel: every run leaves four orders behind, the one taken through its life
|
|
368
|
+
closed, one cancelled, and the two of the checkout feature pending.
|
|
369
|
+
|
|
370
|
+
## Test users
|
|
371
|
+
|
|
372
|
+
The accounts this repository's suite logs in as, exactly as `cucumber.js`
|
|
373
|
+
lists them in `worldParameters.users` (the default values; `ADMIN_USER`,
|
|
374
|
+
`ADMIN_PASSWORD`, `SALES_USER`, `SALES_PASSWORD`, `CUSTOMER_EMAIL`,
|
|
375
|
+
`CUSTOMER_PASSWORD`, `SHOPPER_EMAIL` and `SHOPPER_PASSWORD` replace them).
|
|
376
|
+
[`scripts/build-site.sh`](scripts/build-site.sh) creates them on the local test
|
|
377
|
+
store, and CI does the same on the runner: the installer creates `admin`,
|
|
378
|
+
[`scripts/site-accounts.php`](scripts/site-accounts.php) the three others. They
|
|
379
|
+
are placeholder credentials of that throwaway store, not of any real one.
|
|
380
|
+
|
|
381
|
+
```json
|
|
382
|
+
{
|
|
383
|
+
"admin": { "username": "admin", "password": "Admin123456789!" },
|
|
384
|
+
"sales": { "username": "sales", "password": "Sales123456789!" },
|
|
385
|
+
"customer": { "email": "customer@example.com", "password": "Customer123456789!", "name": "Casey Customer" },
|
|
386
|
+
"shopper": { "email": "shopper@example.com", "password": "Shopper123456789!", "name": "Sam Shopper" }
|
|
387
|
+
}
|
|
388
|
+
```
|
|
273
389
|
|
|
274
390
|
## The test store
|
|
275
391
|
|
|
@@ -369,11 +485,18 @@ npm run test:admin # the admin panel lane
|
|
|
369
485
|
npm run test:storefront # the storefront lane
|
|
370
486
|
npm run test:must-fail # every false statement must fail with a helpful message
|
|
371
487
|
npm run test:examples # the JSDoc examples and the feature steps against the patterns
|
|
488
|
+
npm run test:paths # a feature or a scenario named on the command line runs alone
|
|
372
489
|
npm run test:dry # undefined and ambiguous steps
|
|
373
490
|
```
|
|
374
491
|
|
|
375
|
-
|
|
376
|
-
|
|
492
|
+
`npx cucumber-js tests/features/21-storefront-search.feature` runs one feature
|
|
493
|
+
and `npx cucumber-js tests/features/21-storefront-search.feature:<line>` one
|
|
494
|
+
scenario (the line of its `Scenario:`); the paths of `cucumber.js` are left out
|
|
495
|
+
when the command line names any. `FEATURES=tests/features/a.feature,tests/features/b.feature npm test`
|
|
496
|
+
runs a subset too.
|
|
497
|
+
|
|
498
|
+
The suite leaves the site as it found it, apart from its orders and carts (see
|
|
499
|
+
[What the suite tests](#what-the-suite-tests)): run it twice in a row.
|
|
377
500
|
|
|
378
501
|
`BROWSER=firefox npm test` runs the suite in Firefox (`npx playwright install
|
|
379
502
|
firefox` once). Use it on a machine where other container projects start and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webship-js/magento-steps",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Cucumber step definitions for testing Magento Open Source stores with webship-js: the admin panel (session, menu, grids, forms, catalog, orders, customers, cart price rules, content, configuration, cache and index, permissions) and the storefront (catalog, layered navigation, search, product page, cart, checkout, customer account, wish list, compare, reviews, newsletter).",
|
|
5
5
|
"main": "tests/step-definitions/magento.steps.js",
|
|
6
6
|
"files": [
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"test:webkit": "BROWSER=webkit cucumber-js --config cucumber.js",
|
|
24
24
|
"test:headed": "HEADLESS=false cucumber-js --config cucumber.js",
|
|
25
25
|
"test:examples": "node tests/check-examples.js",
|
|
26
|
+
"test:paths": "node tests/check-paths.js",
|
|
26
27
|
"generate-reports": "generate-reports"
|
|
27
28
|
},
|
|
28
29
|
"keywords": [
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"tsx": "^4.23.0",
|
|
63
|
-
"webship-js": "^2.0.
|
|
64
|
+
"webship-js": "^2.0.12"
|
|
64
65
|
},
|
|
65
66
|
"overrides": {
|
|
66
67
|
"@cucumber/cucumber": "^12"
|
package/scripts/build-site.sh
CHANGED
|
@@ -89,9 +89,18 @@ ddev start </dev/null
|
|
|
89
89
|
SITE_URL="$(ddev describe -j | python3 -c "import json,sys; print(json.load(sys.stdin)['raw']['primary_url'])")"
|
|
90
90
|
|
|
91
91
|
step "Packages from $MIRROR_URL"
|
|
92
|
+
# The project template first, the packages second. `ddev composer
|
|
93
|
+
# create-project` without --no-install runs its own `composer install` and,
|
|
94
|
+
# before it, checks each option of the command with a `composer install
|
|
95
|
+
# --dry-run`; with DDEV 1.24 that check never returns for this project (the
|
|
96
|
+
# dry run lists some 400 packages) and the build stops after the template is
|
|
97
|
+
# in place. A rebuild that stopped there finds composer.json without vendor/.
|
|
92
98
|
if [ ! -f composer.json ]; then
|
|
93
99
|
ddev composer create-project </dev/null --repository-url="$MIRROR_URL" \
|
|
94
|
-
"magento/project-community-edition:$MAGENTO_VERSION" . --no-interaction --prefer-dist
|
|
100
|
+
"magento/project-community-edition:$MAGENTO_VERSION" . --no-interaction --prefer-dist --no-install
|
|
101
|
+
fi
|
|
102
|
+
if [ ! -f vendor/autoload.php ]; then
|
|
103
|
+
ddev composer install </dev/null --no-interaction --prefer-dist
|
|
95
104
|
fi
|
|
96
105
|
|
|
97
106
|
# Modules a test store never installs. They are left out at install time (not
|
|
@@ -20,6 +20,7 @@ Feature: Admin panel menu and pages
|
|
|
20
20
|
Scenario: A menu item opens its page
|
|
21
21
|
When I open the "Catalog > Products" admin menu item
|
|
22
22
|
Then the admin page title should be "Products"
|
|
23
|
+
But the admin page title should not be "Dashboard"
|
|
23
24
|
When I open the "Sales > Orders" admin menu item
|
|
24
25
|
Then the admin page title should be "Orders"
|
|
25
26
|
When I open the "Dashboard" admin menu item
|
|
@@ -17,6 +17,7 @@ Feature: Categories in the admin panel
|
|
|
17
17
|
Scenario: Selecting a category opens its form
|
|
18
18
|
When I select the "Gear" category in the tree
|
|
19
19
|
Then the "Category Name" form field should be "Gear"
|
|
20
|
+
But the "Category Name" form field should not be "Bags"
|
|
20
21
|
And the "Enable Category" form field should be "on"
|
|
21
22
|
|
|
22
23
|
@critical
|
|
@@ -34,6 +34,7 @@ Feature: Orders, from the checkout to the back office
|
|
|
34
34
|
Then I should see the last placed order in the orders grid
|
|
35
35
|
When I open the last placed order in the admin panel
|
|
36
36
|
Then the order status should be "Pending"
|
|
37
|
+
But the order status should not be "Complete"
|
|
37
38
|
And I should see "gail.guest@example.com"
|
|
38
39
|
And I should see "Flat Rate - Fixed"
|
|
39
40
|
And I should see "Check / Money order"
|
|
@@ -17,7 +17,8 @@ Feature: Configuration, cache and index state
|
|
|
17
17
|
# A saved setting invalidates cache types: the suite reads the state and flushes.
|
|
18
18
|
And some cache types should be invalidated
|
|
19
19
|
When I flush the cache
|
|
20
|
-
Then
|
|
20
|
+
Then I should see a success message
|
|
21
|
+
And no cache type should be invalidated
|
|
21
22
|
Given I am on the "general" configuration section
|
|
22
23
|
When I set the "Store Name" configuration field of "Store Information" to ""
|
|
23
24
|
And I save the form
|
|
@@ -13,6 +13,15 @@ Feature: Searching the store
|
|
|
13
13
|
And I should see the product "Cronus Yoga Pant" in the product list
|
|
14
14
|
But I should not see the product "Joust Duffle Bag" in the product list
|
|
15
15
|
|
|
16
|
+
# A link followed with the webship-js step: the settled wait makes sure the
|
|
17
|
+
# scripts of the new page are loaded before the next step.
|
|
18
|
+
Scenario: A link of the footer leads to the advanced search
|
|
19
|
+
Given I am on the homepage
|
|
20
|
+
When I follow "Advanced Search"
|
|
21
|
+
And I wait for the page to settle
|
|
22
|
+
Then the breadcrumbs should be "Home > Catalog Advanced Search"
|
|
23
|
+
And I should see "Search Settings"
|
|
24
|
+
|
|
16
25
|
Scenario: A search by SKU finds the product
|
|
17
26
|
Given I am on the homepage
|
|
18
27
|
When I search the store for "24-MB01"
|
|
@@ -65,4 +65,5 @@ Feature: The product page and the cart
|
|
|
65
65
|
And I go to the cart
|
|
66
66
|
And I apply the coupon "NOT-A-CODE"
|
|
67
67
|
Then I should see the error message "is not valid."
|
|
68
|
+
But I should not see the success message "You used coupon code"
|
|
68
69
|
And the cart order total should be "$34.00"
|
|
@@ -42,6 +42,9 @@ Feature: The checkout
|
|
|
42
42
|
Then I should see the order confirmation
|
|
43
43
|
And I should see "gary.guest@example.com"
|
|
44
44
|
And the mini cart should show 0 items
|
|
45
|
+
# A guest's order belongs to no account.
|
|
46
|
+
Given I am logged in as the customer "customer"
|
|
47
|
+
Then my order history should not list the last placed order
|
|
45
48
|
|
|
46
49
|
Scenario: A customer orders with a saved address
|
|
47
50
|
Given I am logged in as the customer "shopper"
|
|
@@ -40,6 +40,10 @@ Feature: The wish list, the comparison list and the contact form
|
|
|
40
40
|
Then I should see the field error "This is a required field." for "Name"
|
|
41
41
|
And I should see the field error "This is a required field." for "Email"
|
|
42
42
|
And I should not see a success message
|
|
43
|
+
When I fill in the "Email" store field with "gail.guest@example.com"
|
|
44
|
+
And I press the "Submit" store button
|
|
45
|
+
Then I should see the field error "This is a required field." for "Name"
|
|
46
|
+
But I should not see the field error "This is a required field." for "Email"
|
|
43
47
|
|
|
44
48
|
Scenario: The contact form is sent
|
|
45
49
|
Given I am on "/contact/"
|