@webship-js/magento-steps 0.0.0-stage → 2.0.0
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 +399 -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,190 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Builds the test site the suite runs against: Magento Open Source (the
|
|
3
|
+
# community edition) with its sample data, in one DDEV project, without any
|
|
4
|
+
# question asked, then creates the accounts named in cucumber.js.
|
|
5
|
+
#
|
|
6
|
+
# The packages come from the public Mage-OS mirror of the Magento Open Source
|
|
7
|
+
# packages (https://mirror.mage-os.org/): it serves the same releases as the
|
|
8
|
+
# vendor's repository without access keys, so the build needs no account.
|
|
9
|
+
#
|
|
10
|
+
# Settings (environment variables, all optional):
|
|
11
|
+
# MAGENTO_VERSION the release to install (default 2.4.9)
|
|
12
|
+
# PHP_VERSION the PHP version of the container (default 8.4)
|
|
13
|
+
# DB_VERSION the database of the container (default mariadb:11.4)
|
|
14
|
+
# OPENSEARCH_TAG the search engine image tag (default 3)
|
|
15
|
+
# PROJECT_NAME the DDEV project name (default magentosteps)
|
|
16
|
+
# SITE_DIR the project folder (default ../magento-site next to this repository)
|
|
17
|
+
# SAMPLE_DATA 1 installs the sample data, 0 leaves the catalog empty (default 1; the suite needs it)
|
|
18
|
+
# DEPLOY_MODE production or developer (default production)
|
|
19
|
+
# BACKEND_FRONTNAME the admin path (default admin)
|
|
20
|
+
# ADMIN_USER, ADMIN_PASSWORD the administrator (admin / Admin123456789!)
|
|
21
|
+
# SALES_USER, SALES_PASSWORD an admin with the "Sales" role only (sales / Sales123456789!)
|
|
22
|
+
# CUSTOMER_EMAIL, CUSTOMER_PASSWORD a customer with an address (customer@example.com / Customer123456789!)
|
|
23
|
+
# SHOPPER_EMAIL, SHOPPER_PASSWORD a second customer with an address (shopper@example.com / Shopper123456789!)
|
|
24
|
+
#
|
|
25
|
+
# The accounts are configuration: created once here, named in cucumber.js; a
|
|
26
|
+
# feature never creates or deletes one of them.
|
|
27
|
+
#
|
|
28
|
+
# What this build turns off, because a test site must not ask a person for a
|
|
29
|
+
# code or call anything outside:
|
|
30
|
+
# - two-factor authentication for admins (the modules Magento_TwoFactorAuth
|
|
31
|
+
# and Magento_AdminAdobeImsTwoFactorAuth are not installed). Never do this on a
|
|
32
|
+
# site that is on the internet.
|
|
33
|
+
# - the admin notification feed, the usage-data question, the release
|
|
34
|
+
# notification, the CAPTCHAs, the secret key in admin addresses.
|
|
35
|
+
# - the bundled payment gateway and data-export extensions, which make the
|
|
36
|
+
# storefront load scripts from outside servers even when not configured.
|
|
37
|
+
set -euo pipefail
|
|
38
|
+
|
|
39
|
+
MAGENTO_VERSION="${MAGENTO_VERSION:-2.4.9}"
|
|
40
|
+
PHP_VERSION="${PHP_VERSION:-8.4}"
|
|
41
|
+
DB_VERSION="${DB_VERSION:-mariadb:11.4}"
|
|
42
|
+
OPENSEARCH_TAG="${OPENSEARCH_TAG:-3}"
|
|
43
|
+
PROJECT_NAME="${PROJECT_NAME:-magentosteps}"
|
|
44
|
+
SAMPLE_DATA="${SAMPLE_DATA:-1}"
|
|
45
|
+
DEPLOY_MODE="${DEPLOY_MODE:-production}"
|
|
46
|
+
BACKEND_FRONTNAME="${BACKEND_FRONTNAME:-admin}"
|
|
47
|
+
ADMIN_USER="${ADMIN_USER:-admin}"
|
|
48
|
+
ADMIN_PASSWORD="${ADMIN_PASSWORD:-Admin123456789!}"
|
|
49
|
+
MIRROR_URL="${MIRROR_URL:-https://mirror.mage-os.org/}"
|
|
50
|
+
|
|
51
|
+
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
52
|
+
SITE_DIR="${SITE_DIR:-$(dirname "$REPO_DIR")/magento-site}"
|
|
53
|
+
mkdir -p "$SITE_DIR"
|
|
54
|
+
cd "$SITE_DIR"
|
|
55
|
+
|
|
56
|
+
step() { printf '\n=== %s (%s) ===\n' "$1" "$(date +%H:%M:%S)"; }
|
|
57
|
+
|
|
58
|
+
step "DDEV project"
|
|
59
|
+
ddev config </dev/null --project-name="$PROJECT_NAME" --project-type=magento2 --docroot=pub \
|
|
60
|
+
--upload-dirs=media --disable-settings-management \
|
|
61
|
+
--php-version="$PHP_VERSION" --database="$DB_VERSION"
|
|
62
|
+
|
|
63
|
+
# The search engine Magento requires, from the official DDEV add-on.
|
|
64
|
+
if [ ! -f .ddev/docker-compose.opensearch.yaml ]; then
|
|
65
|
+
if ! ddev add-on get ddev/ddev-opensearch; then
|
|
66
|
+
# An older DDEV than the add-on asks for: install the same add-on from a
|
|
67
|
+
# clone with the version constraint relaxed.
|
|
68
|
+
ADDON_DIR="$(mktemp -d)"
|
|
69
|
+
git clone -q --depth 1 https://github.com/ddev/ddev-opensearch.git "$ADDON_DIR"
|
|
70
|
+
sed -i '/^ddev_version_constraint:/d' "$ADDON_DIR/install.yaml"
|
|
71
|
+
ddev add-on get "$ADDON_DIR"
|
|
72
|
+
rm -rf "$ADDON_DIR"
|
|
73
|
+
fi
|
|
74
|
+
fi
|
|
75
|
+
printf 'OPENSEARCH_TAG=%s\n' "$OPENSEARCH_TAG" > .ddev/.env.opensearch
|
|
76
|
+
# A test site needs the engine, not its dashboards (another 1.5 GB image and a
|
|
77
|
+
# second Node process): the service is taken out of the add-on's compose file.
|
|
78
|
+
# The heap stays at the add-on's 512 MB.
|
|
79
|
+
python3 - <<'PY'
|
|
80
|
+
import re
|
|
81
|
+
path = '.ddev/docker-compose.opensearch.yaml'
|
|
82
|
+
text = open(path).read()
|
|
83
|
+
text = text.replace('#ddev-generated\n', '# From the ddev/ddev-opensearch add-on, without its dashboards service.\n', 1)
|
|
84
|
+
text = re.sub(r'\n opensearch-dashboards:.*?(?=\n web:)', '\n', text, flags=re.S)
|
|
85
|
+
open(path, 'w').write(text)
|
|
86
|
+
PY
|
|
87
|
+
ddev start </dev/null
|
|
88
|
+
|
|
89
|
+
SITE_URL="$(ddev describe -j | python3 -c "import json,sys; print(json.load(sys.stdin)['raw']['primary_url'])")"
|
|
90
|
+
|
|
91
|
+
step "Packages from $MIRROR_URL"
|
|
92
|
+
if [ ! -f composer.json ]; then
|
|
93
|
+
ddev composer create-project </dev/null --repository-url="$MIRROR_URL" \
|
|
94
|
+
"magento/project-community-edition:$MAGENTO_VERSION" . --no-interaction --prefer-dist
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# Modules a test store never installs. They are left out at install time (not
|
|
98
|
+
# disabled afterwards): a module disabled after the install leaves its database
|
|
99
|
+
# triggers behind, and the next order fails on a column that is gone.
|
|
100
|
+
# - two-factor authentication, and what asks the admin user questions or
|
|
101
|
+
# fetches a feed;
|
|
102
|
+
# - the payment gateway and data-export extensions bundled with the edition.
|
|
103
|
+
# They are not configured, yet with them every storefront page loads two
|
|
104
|
+
# scripts from the gateway's servers (for a message in the mini cart) and the
|
|
105
|
+
# checkout loads an asset of the payment provider. A test store calls nothing
|
|
106
|
+
# outside: the suite uses the offline methods (check / money order, flat
|
|
107
|
+
# rate, free shipping).
|
|
108
|
+
DISABLED_MODULES="Magento_AdminAdobeImsTwoFactorAuth,Magento_TwoFactorAuth,\
|
|
109
|
+
Magento_AdminNotification,Magento_AdminAnalytics,Magento_ReleaseNotification,\
|
|
110
|
+
PayPal_Braintree,PayPal_BraintreeCustomerBalance,PayPal_BraintreeGiftCard,PayPal_BraintreeGiftCardAccount,\
|
|
111
|
+
PayPal_BraintreeGiftWrapping,PayPal_BraintreeGraphQl,PayPal_BraintreeReward,\
|
|
112
|
+
Magento_PaymentServicesBase,Magento_PaymentServicesDashboard,Magento_PaymentServicesPaypal,\
|
|
113
|
+
Magento_PaymentServicesPaypalGraphQl,Magento_PaymentServicesSaaSExport,Magento_ServiceProxy,\
|
|
114
|
+
Magento_ServicesConnector,Magento_ServicesId,Magento_ServicesIdGraphQlServer,Magento_ServicesIdLayout,\
|
|
115
|
+
Magento_SaaSCommon,Magento_DataExporter,Magento_SalesDataExporter,Magento_StoreDataExporter"
|
|
116
|
+
|
|
117
|
+
step "Install"
|
|
118
|
+
# A rebuild starts from nothing: the old configuration and the generated files go.
|
|
119
|
+
rm -rf app/etc/env.php app/etc/config.php generated/code generated/metadata var/cache var/page_cache var/view_preprocessed pub/static/frontend pub/static/adminhtml pub/static/deployed_version.txt
|
|
120
|
+
ddev exec </dev/null "php bin/magento setup:install \
|
|
121
|
+
--disable-modules='$DISABLED_MODULES' \
|
|
122
|
+
--base-url='$SITE_URL/' --base-url-secure='$SITE_URL/' --use-secure=1 --use-secure-admin=1 --use-rewrites=1 \
|
|
123
|
+
--db-host=db --db-name=db --db-user=db --db-password=db \
|
|
124
|
+
--search-engine=opensearch --opensearch-host=opensearch --opensearch-port=9200 \
|
|
125
|
+
--opensearch-index-prefix=magento2 --opensearch-enable-auth=0 --opensearch-timeout=15 \
|
|
126
|
+
--backend-frontname='$BACKEND_FRONTNAME' \
|
|
127
|
+
--admin-user='$ADMIN_USER' --admin-password='$ADMIN_PASSWORD' \
|
|
128
|
+
--admin-email=admin@example.com --admin-firstname=Site --admin-lastname=Admin \
|
|
129
|
+
--language=en_US --currency=USD --timezone=UTC \
|
|
130
|
+
--session-save=files --cleanup-database --no-interaction"
|
|
131
|
+
|
|
132
|
+
if [ "$SAMPLE_DATA" = "1" ]; then
|
|
133
|
+
step "Sample data"
|
|
134
|
+
ddev exec </dev/null "php bin/magento sampledata:deploy --no-interaction"
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
ddev exec </dev/null "php bin/magento setup:upgrade --no-interaction"
|
|
138
|
+
|
|
139
|
+
step "Configuration"
|
|
140
|
+
set_conf() { ddev exec </dev/null "php bin/magento config:set '$1' '$2'"; }
|
|
141
|
+
set_conf admin/security/session_lifetime 31536000
|
|
142
|
+
set_conf admin/security/use_form_key 0
|
|
143
|
+
set_conf admin/security/admin_account_sharing 1
|
|
144
|
+
set_conf admin/security/password_is_forced 0
|
|
145
|
+
set_conf admin/security/password_lifetime 0
|
|
146
|
+
set_conf admin/security/lockout_failures 0
|
|
147
|
+
set_conf admin/captcha/enable 0
|
|
148
|
+
set_conf customer/captcha/enable 0
|
|
149
|
+
set_conf customer/password/lockout_failures 0
|
|
150
|
+
set_conf analytics/subscription/enabled 0
|
|
151
|
+
set_conf web/cookie/cookie_lifetime 86400
|
|
152
|
+
set_conf checkout/options/guest_checkout 1
|
|
153
|
+
set_conf carriers/flatrate/active 1
|
|
154
|
+
set_conf carriers/freeshipping/active 1
|
|
155
|
+
set_conf carriers/freeshipping/free_shipping_subtotal 0
|
|
156
|
+
set_conf payment/checkmo/active 1
|
|
157
|
+
set_conf catalog/review/allow_guest 1
|
|
158
|
+
set_conf web/cookie/cookie_restriction 0
|
|
159
|
+
|
|
160
|
+
step "Accounts"
|
|
161
|
+
ddev exec </dev/null "mkdir -p var/site-build"
|
|
162
|
+
cp "$REPO_DIR/scripts/site-accounts.php" var/site-build/site-accounts.php
|
|
163
|
+
ddev exec </dev/null "SALES_USER='${SALES_USER:-sales}' SALES_PASSWORD='${SALES_PASSWORD:-Sales123456789!}' \
|
|
164
|
+
CUSTOMER_EMAIL='${CUSTOMER_EMAIL:-customer@example.com}' CUSTOMER_PASSWORD='${CUSTOMER_PASSWORD:-Customer123456789!}' \
|
|
165
|
+
SHOPPER_EMAIL='${SHOPPER_EMAIL:-shopper@example.com}' SHOPPER_PASSWORD='${SHOPPER_PASSWORD:-Shopper123456789!}' \
|
|
166
|
+
php var/site-build/site-accounts.php"
|
|
167
|
+
|
|
168
|
+
step "Deploy mode: $DEPLOY_MODE"
|
|
169
|
+
if [ "$DEPLOY_MODE" = "production" ]; then
|
|
170
|
+
ddev exec </dev/null "php bin/magento deploy:mode:set production --skip-compilation"
|
|
171
|
+
ddev exec </dev/null "php -d memory_limit=2G bin/magento setup:di:compile"
|
|
172
|
+
ddev exec </dev/null "php -d memory_limit=2G bin/magento setup:static-content:deploy -f --jobs=2 en_US"
|
|
173
|
+
else
|
|
174
|
+
ddev exec </dev/null "php bin/magento deploy:mode:set developer"
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
step "Indexes, cron once, caches"
|
|
178
|
+
# Indexes update when something is saved, not by a schedule: no cron runs on a
|
|
179
|
+
# test site, and a product a scenario creates must reach the storefront at once.
|
|
180
|
+
ddev exec </dev/null "php bin/magento indexer:set-mode realtime"
|
|
181
|
+
ddev exec </dev/null "php bin/magento indexer:reindex"
|
|
182
|
+
ddev exec </dev/null "php bin/magento cron:run" || true
|
|
183
|
+
ddev exec </dev/null "php bin/magento cache:flush"
|
|
184
|
+
|
|
185
|
+
# Warm the two entry points so the first scenario does not pay for it.
|
|
186
|
+
curl -ksS -o /dev/null -w 'Storefront: HTTP %{http_code}\n' "$SITE_URL/"
|
|
187
|
+
curl -ksSL -o /dev/null -w 'Admin sign-in: HTTP %{http_code}\n' "$SITE_URL/$BACKEND_FRONTNAME/"
|
|
188
|
+
|
|
189
|
+
echo "LAUNCH_URL=$SITE_URL"
|
|
190
|
+
if [ -n "${GITHUB_ENV:-}" ]; then echo "LAUNCH_URL=$SITE_URL" >> "$GITHUB_ENV"; fi
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Creates the accounts the suite signs in with, once, on the test site:
|
|
4
|
+
* a restricted admin role and its user, and the customers with one address.
|
|
5
|
+
* Run by scripts/build-site.sh inside the web container:
|
|
6
|
+
*
|
|
7
|
+
* php scripts/site-accounts.php
|
|
8
|
+
*
|
|
9
|
+
* It is safe to run again: an account that exists is left as it is.
|
|
10
|
+
* The values come from the environment (see build-site.sh for the defaults).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
use Magento\Framework\App\Bootstrap;
|
|
14
|
+
|
|
15
|
+
require getcwd() . '/app/bootstrap.php';
|
|
16
|
+
|
|
17
|
+
$bootstrap = Bootstrap::create(BP, $_SERVER);
|
|
18
|
+
$om = $bootstrap->getObjectManager();
|
|
19
|
+
$om->get(\Magento\Framework\App\State::class)->setAreaCode('adminhtml');
|
|
20
|
+
|
|
21
|
+
$env = static function (string $name, string $default): string {
|
|
22
|
+
$value = getenv($name);
|
|
23
|
+
return ($value === false || $value === '') ? $default : $value;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// --- A restricted admin role: Sales only (orders, invoices, shipments, credit memos). ---
|
|
27
|
+
$roleName = $env('SALES_ROLE', 'Sales');
|
|
28
|
+
/** @var \Magento\Authorization\Model\ResourceModel\Role\Collection $roles */
|
|
29
|
+
$roles = $om->create(\Magento\Authorization\Model\ResourceModel\Role\CollectionFactory::class)->create();
|
|
30
|
+
$role = $roles->addFieldToFilter('role_name', $roleName)->addFieldToFilter('role_type', 'G')->getFirstItem();
|
|
31
|
+
if (!$role->getId()) {
|
|
32
|
+
$role = $om->create(\Magento\Authorization\Model\RoleFactory::class)->create();
|
|
33
|
+
$role->setRoleName($roleName)->setParentId(0)->setRoleType('G')->setUserType(2)->save();
|
|
34
|
+
$om->create(\Magento\Authorization\Model\RulesFactory::class)->create()
|
|
35
|
+
->setRoleId($role->getId())
|
|
36
|
+
->setResources([
|
|
37
|
+
'Magento_Backend::admin',
|
|
38
|
+
'Magento_Sales::sales',
|
|
39
|
+
'Magento_Sales::sales_operation',
|
|
40
|
+
'Magento_Sales::sales_order',
|
|
41
|
+
'Magento_Sales::actions',
|
|
42
|
+
'Magento_Sales::create',
|
|
43
|
+
'Magento_Sales::actions_view',
|
|
44
|
+
'Magento_Sales::email',
|
|
45
|
+
'Magento_Sales::reorder',
|
|
46
|
+
'Magento_Sales::actions_edit',
|
|
47
|
+
'Magento_Sales::cancel',
|
|
48
|
+
'Magento_Sales::review_payment',
|
|
49
|
+
'Magento_Sales::capture',
|
|
50
|
+
'Magento_Sales::invoice',
|
|
51
|
+
'Magento_Sales::creditmemo',
|
|
52
|
+
'Magento_Sales::hold',
|
|
53
|
+
'Magento_Sales::unhold',
|
|
54
|
+
'Magento_Sales::ship',
|
|
55
|
+
'Magento_Sales::comment',
|
|
56
|
+
'Magento_Sales::emails',
|
|
57
|
+
'Magento_Sales::sales_invoice',
|
|
58
|
+
'Magento_Sales::shipment',
|
|
59
|
+
'Magento_Sales::sales_creditmemo',
|
|
60
|
+
])
|
|
61
|
+
->saveRel();
|
|
62
|
+
echo "Created the admin role \"$roleName\".\n";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
$salesUser = $env('SALES_USER', 'sales');
|
|
66
|
+
$user = $om->create(\Magento\User\Model\UserFactory::class)->create()->loadByUsername($salesUser);
|
|
67
|
+
if (!$user->getId()) {
|
|
68
|
+
$user->setData([
|
|
69
|
+
'username' => $salesUser,
|
|
70
|
+
'firstname' => 'Sally',
|
|
71
|
+
'lastname' => 'Sales',
|
|
72
|
+
'email' => $env('SALES_EMAIL', 'sales@example.com'),
|
|
73
|
+
'password' => $env('SALES_PASSWORD', 'Sales123456789!'),
|
|
74
|
+
'interface_locale' => 'en_US',
|
|
75
|
+
'is_active' => 1,
|
|
76
|
+
]);
|
|
77
|
+
$user->setRoleId($role->getId())->save();
|
|
78
|
+
echo "Created the admin user \"$salesUser\" with the role \"$roleName\".\n";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// --- Customers, each with a default billing and shipping address. ---
|
|
82
|
+
$storeManager = $om->get(\Magento\Store\Model\StoreManagerInterface::class);
|
|
83
|
+
$websiteId = (int) $storeManager->getDefaultStoreView()->getWebsiteId();
|
|
84
|
+
$storeId = (int) $storeManager->getDefaultStoreView()->getId();
|
|
85
|
+
$customerRepository = $om->get(\Magento\Customer\Api\CustomerRepositoryInterface::class);
|
|
86
|
+
$accountManagement = $om->get(\Magento\Customer\Api\AccountManagementInterface::class);
|
|
87
|
+
$customerFactory = $om->get(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class);
|
|
88
|
+
$addressFactory = $om->get(\Magento\Customer\Api\Data\AddressInterfaceFactory::class);
|
|
89
|
+
$regionFactory = $om->get(\Magento\Customer\Api\Data\RegionInterfaceFactory::class);
|
|
90
|
+
$directoryRegion = $om->get(\Magento\Directory\Model\RegionFactory::class);
|
|
91
|
+
|
|
92
|
+
$customers = [
|
|
93
|
+
['CUSTOMER', 'customer@example.com', 'Customer123456789!', 'Casey', 'Customer', '100 Main Street', 'Austin', 'TX', '78701', '5125550100'],
|
|
94
|
+
['SHOPPER', 'shopper@example.com', 'Shopper123456789!', 'Sam', 'Shopper', '200 Market Street', 'San Francisco', 'CA', '94105', '4155550100'],
|
|
95
|
+
];
|
|
96
|
+
foreach ($customers as [$prefix, $email, $password, $first, $last, $street, $city, $regionCode, $postcode, $phone]) {
|
|
97
|
+
$email = $env($prefix . '_EMAIL', $email);
|
|
98
|
+
$password = $env($prefix . '_PASSWORD', $password);
|
|
99
|
+
try {
|
|
100
|
+
$customerRepository->get($email, $websiteId);
|
|
101
|
+
continue;
|
|
102
|
+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
|
|
103
|
+
// Not there yet: create it below.
|
|
104
|
+
}
|
|
105
|
+
$region = $directoryRegion->create()->loadByCode($regionCode, 'US');
|
|
106
|
+
$address = $addressFactory->create()
|
|
107
|
+
->setFirstname($first)->setLastname($last)
|
|
108
|
+
->setStreet([$street])->setCity($city)->setPostcode($postcode)
|
|
109
|
+
->setCountryId('US')->setTelephone($phone)
|
|
110
|
+
->setRegionId((int) $region->getId())
|
|
111
|
+
->setRegion($regionFactory->create()->setRegionId((int) $region->getId())->setRegion($region->getName())->setRegionCode($regionCode))
|
|
112
|
+
->setIsDefaultBilling(true)->setIsDefaultShipping(true);
|
|
113
|
+
$customer = $customerFactory->create()
|
|
114
|
+
->setEmail($email)->setFirstname($first)->setLastname($last)
|
|
115
|
+
->setWebsiteId($websiteId)->setStoreId($storeId)->setGroupId(1)
|
|
116
|
+
->setAddresses([$address]);
|
|
117
|
+
$accountManagement->createAccount($customer, $password);
|
|
118
|
+
echo "Created the customer $email.\n";
|
|
119
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@admin @session
|
|
2
|
+
Feature: Admin panel session
|
|
3
|
+
As a store administrator
|
|
4
|
+
I want to log in to and out of the admin panel
|
|
5
|
+
So that only the people with an account manage the store
|
|
6
|
+
|
|
7
|
+
@critical
|
|
8
|
+
Scenario: An administrator logs in and reaches the Dashboard
|
|
9
|
+
Given I am logged in to the admin panel as "admin"
|
|
10
|
+
Then I should be logged in to the admin panel as "admin"
|
|
11
|
+
And the admin page title should be "Dashboard"
|
|
12
|
+
And I should not see the access denied page
|
|
13
|
+
|
|
14
|
+
Scenario: A wrong password is refused with a message
|
|
15
|
+
When I log in to the admin panel with the username "admin" and the password "wrong-password"
|
|
16
|
+
Then I should see the error message "The account sign-in was incorrect or your account is disabled temporarily."
|
|
17
|
+
And I should not be logged in to the admin panel
|
|
18
|
+
|
|
19
|
+
Scenario: Logging out ends the session
|
|
20
|
+
Given I am logged in to the admin panel as "admin"
|
|
21
|
+
When I log out of the admin panel
|
|
22
|
+
Then I should see the success message "You have logged out."
|
|
23
|
+
And I should not be logged in to the admin panel
|
|
24
|
+
|
|
25
|
+
Scenario: A visitor who opens an admin page gets the sign-in form
|
|
26
|
+
Given I am not logged in to the admin panel
|
|
27
|
+
When I go to "/admin/catalog/product/"
|
|
28
|
+
Then I should see "Welcome, please sign in"
|
|
29
|
+
And I should not be logged in to the admin panel
|
|
30
|
+
|
|
31
|
+
Scenario: Logging in as another user replaces the session
|
|
32
|
+
Given I am logged in to the admin panel as "admin"
|
|
33
|
+
When I log in to the admin panel as "sales"
|
|
34
|
+
Then I should be logged in to the admin panel as "sales"
|
|
35
|
+
And I should not be logged in to the admin panel as "admin"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@admin @navigation
|
|
2
|
+
Feature: Admin panel menu and pages
|
|
3
|
+
As a store administrator
|
|
4
|
+
I want to reach every part of the admin panel from its menu
|
|
5
|
+
So that I find the page I need
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given I am logged in to the admin panel as "admin"
|
|
9
|
+
|
|
10
|
+
@critical
|
|
11
|
+
Scenario: The menu holds the parts of the admin panel
|
|
12
|
+
Then I should see the "Sales" admin menu
|
|
13
|
+
And I should see the "Catalog" admin menu
|
|
14
|
+
And I should see the "Customers" admin menu
|
|
15
|
+
And I should see the "Catalog > Products" admin menu
|
|
16
|
+
And I should see the "Sales > Orders" admin menu
|
|
17
|
+
And I should not see the "Catalog > Orders" admin menu
|
|
18
|
+
And I should not see the "Warehouse" admin menu
|
|
19
|
+
|
|
20
|
+
Scenario: A menu item opens its page
|
|
21
|
+
When I open the "Catalog > Products" admin menu item
|
|
22
|
+
Then the admin page title should be "Products"
|
|
23
|
+
When I open the "Sales > Orders" admin menu item
|
|
24
|
+
Then the admin page title should be "Orders"
|
|
25
|
+
When I open the "Dashboard" admin menu item
|
|
26
|
+
Then the admin page title should be "Dashboard"
|
|
27
|
+
|
|
28
|
+
Scenario Outline: A page is opened by its name
|
|
29
|
+
When I go to the "<page>" admin page
|
|
30
|
+
Then the admin page title should be "<title>"
|
|
31
|
+
And I should not see the access denied page
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
| page | title |
|
|
35
|
+
| products | Products |
|
|
36
|
+
| categories | Default Category (ID: 2) |
|
|
37
|
+
| orders | Orders |
|
|
38
|
+
| customers | Customers |
|
|
39
|
+
| customer groups | Customer Groups |
|
|
40
|
+
| cart price rules | Cart Price Rules |
|
|
41
|
+
| pages | Pages |
|
|
42
|
+
| blocks | Blocks |
|
|
43
|
+
| reviews | Reviews |
|
|
44
|
+
| newsletter subscribers | Newsletter Subscribers |
|
|
45
|
+
| configuration | Configuration |
|
|
46
|
+
| cache management | Cache Management |
|
|
47
|
+
| index management | Index Management |
|
|
48
|
+
|
|
49
|
+
Scenario: The buttons of a page open its forms
|
|
50
|
+
Given I am on the "pages" admin page
|
|
51
|
+
When I click the "Add New Page" page action
|
|
52
|
+
Then the admin page title should be "New Page"
|
|
53
|
+
When I click the "Back" page action
|
|
54
|
+
Then the admin page title should be "Pages"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@admin @permissions
|
|
2
|
+
Feature: What a restricted admin user can open
|
|
3
|
+
As a store owner
|
|
4
|
+
I want an admin user with the Sales role to see sales only
|
|
5
|
+
So that the catalog and the settings stay with the administrators
|
|
6
|
+
|
|
7
|
+
Scenario: The restricted user has the Sales menu only
|
|
8
|
+
Given I am logged in to the admin panel as "sales"
|
|
9
|
+
Then I should see the "Sales" admin menu
|
|
10
|
+
And I should see the "Sales > Orders" admin menu
|
|
11
|
+
And I should see the "Sales > Invoices" admin menu
|
|
12
|
+
But I should not see the "Catalog" admin menu
|
|
13
|
+
And I should not see the "Customers" admin menu
|
|
14
|
+
And I should not see the "Stores" admin menu
|
|
15
|
+
And I should not see the "System" admin menu
|
|
16
|
+
|
|
17
|
+
@critical
|
|
18
|
+
Scenario: The restricted user opens the orders
|
|
19
|
+
Given I am logged in to the admin panel as "sales"
|
|
20
|
+
When I go to the "orders" admin page
|
|
21
|
+
Then the admin page title should be "Orders"
|
|
22
|
+
And I should not see the access denied page
|
|
23
|
+
|
|
24
|
+
Scenario Outline: The restricted user is refused outside sales
|
|
25
|
+
Given I am logged in to the admin panel as "sales"
|
|
26
|
+
When I go to the "<page>" admin page
|
|
27
|
+
Then I should see the access denied page
|
|
28
|
+
And I should see "Sorry, you need permissions to view this content."
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
| page |
|
|
32
|
+
| dashboard |
|
|
33
|
+
| products |
|
|
34
|
+
| customers |
|
|
35
|
+
| cart price rules |
|
|
36
|
+
| pages |
|
|
37
|
+
| cache management |
|
|
38
|
+
| users |
|
|
39
|
+
|
|
40
|
+
Scenario: The restricted user is refused a configuration section
|
|
41
|
+
Given I am logged in to the admin panel as "sales"
|
|
42
|
+
When I go to the "general" configuration section
|
|
43
|
+
Then I should see the access denied page
|
|
44
|
+
|
|
45
|
+
Scenario: An administrator is not refused
|
|
46
|
+
Given I am logged in to the admin panel as "admin"
|
|
47
|
+
When I go to the "products" admin page
|
|
48
|
+
Then I should not see the access denied page
|
|
49
|
+
When I go to the "users" admin page
|
|
50
|
+
Then I should not see the access denied page
|
|
51
|
+
And the admin page title should be "Users"
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
@admin @grids
|
|
2
|
+
Feature: Admin grids
|
|
3
|
+
As a store administrator
|
|
4
|
+
I want to search, filter, sort and page the lists of the admin panel
|
|
5
|
+
So that I find a record among thousands
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given I am logged in to the admin panel as "admin"
|
|
9
|
+
|
|
10
|
+
@critical
|
|
11
|
+
Scenario: A keyword search finds a product
|
|
12
|
+
Given I am on the "products" admin page
|
|
13
|
+
When I search the grid for "Joust Duffle Bag"
|
|
14
|
+
Then the grid should show 1 record
|
|
15
|
+
And I should see the "Joust Duffle Bag" grid row
|
|
16
|
+
And the "SKU" column of the "Joust Duffle Bag" grid row should be "24-MB01"
|
|
17
|
+
And the "Price" column of the "Joust Duffle Bag" grid row should be "$34.00"
|
|
18
|
+
And the "Status" column of the "Joust Duffle Bag" grid row should be "Enabled"
|
|
19
|
+
And the "Type" column of the "Joust Duffle Bag" grid row should not be "Configurable Product"
|
|
20
|
+
When I clear the grid filters
|
|
21
|
+
Then the grid should have 20 rows
|
|
22
|
+
|
|
23
|
+
Scenario: The filters panel narrows the products
|
|
24
|
+
Given I am on the "products" admin page
|
|
25
|
+
When I filter the grid by "Name" with "Tank"
|
|
26
|
+
And I filter the grid by "Type" with "Configurable Product"
|
|
27
|
+
Then the grid should show 19 records
|
|
28
|
+
And the grid should have 19 rows
|
|
29
|
+
And I should see the "Tristan Endurance Tank" grid row
|
|
30
|
+
But I should not see the "Joust Duffle Bag" grid row
|
|
31
|
+
When I clear the grid filters
|
|
32
|
+
Then the grid should have 20 rows
|
|
33
|
+
|
|
34
|
+
Scenario: A grid opened by name forgets the filters of the last visit
|
|
35
|
+
Given I am on the "products" admin page
|
|
36
|
+
When I search the grid for "Joust Duffle Bag"
|
|
37
|
+
Then the grid should show 1 record
|
|
38
|
+
When I go to the "products" admin page
|
|
39
|
+
Then the grid should have 20 rows
|
|
40
|
+
|
|
41
|
+
Scenario: The products are sorted by a column
|
|
42
|
+
Given I am on the "products" admin page
|
|
43
|
+
When I filter the grid by "Name" with "Tank"
|
|
44
|
+
And I filter the grid by "Type" with "Configurable Product"
|
|
45
|
+
And I sort the grid by "Name" ascending
|
|
46
|
+
Then the grid should be sorted by "Name" ascending
|
|
47
|
+
When I sort the grid by "Name" descending
|
|
48
|
+
Then the grid should be sorted by "Name" descending
|
|
49
|
+
When I sort the grid by "ID" ascending
|
|
50
|
+
Then the grid should be sorted by "ID" ascending
|
|
51
|
+
And I clear the grid filters
|
|
52
|
+
|
|
53
|
+
Scenario: The products are paged
|
|
54
|
+
Given I am on the "products" admin page
|
|
55
|
+
When I sort the grid by "ID" ascending
|
|
56
|
+
Then the grid should be on page 1
|
|
57
|
+
When I go to the next page of the grid
|
|
58
|
+
Then the grid should be on page 2
|
|
59
|
+
And the grid should have 20 rows
|
|
60
|
+
When I go to page 5 of the grid
|
|
61
|
+
Then the grid should be on page 5
|
|
62
|
+
When I go to the previous page of the grid
|
|
63
|
+
Then the grid should be on page 4
|
|
64
|
+
When I go to page 1 of the grid
|
|
65
|
+
Then the grid should be on page 1
|
|
66
|
+
|
|
67
|
+
Scenario: The page size of a grid is changed and set back
|
|
68
|
+
Given I am on the "products" admin page
|
|
69
|
+
When I show 50 grid rows per page
|
|
70
|
+
Then the grid should have 50 rows
|
|
71
|
+
When I show 20 grid rows per page
|
|
72
|
+
Then the grid should have 20 rows
|
|
73
|
+
|
|
74
|
+
Scenario: A grid action without a selected row is refused
|
|
75
|
+
Given I am on the "products" admin page
|
|
76
|
+
When I run the "Delete" grid action
|
|
77
|
+
Then I should see the confirmation "You haven't selected any items!"
|
|
78
|
+
When I confirm the action
|
|
79
|
+
Then the confirmation should be closed
|
|
80
|
+
And the grid should have 20 rows
|
|
81
|
+
|
|
82
|
+
Scenario: The customers grid shows the group of a customer
|
|
83
|
+
Given I am on the "customers" admin page
|
|
84
|
+
When I search the grid for "customer@example.com"
|
|
85
|
+
Then the grid should show 1 record
|
|
86
|
+
And the "Group" column of the "customer@example.com" grid row should be "General"
|
|
87
|
+
And the "Name" column of the "customer@example.com" grid row should be "Casey Customer"
|
|
88
|
+
And I clear the grid filters
|
|
89
|
+
|
|
90
|
+
Scenario: An older grid is filtered by its column filters
|
|
91
|
+
Given I am on the "cart price rules" admin page
|
|
92
|
+
When I filter the grid by "Rule" with "20% OFF"
|
|
93
|
+
Then the grid should have 1 row
|
|
94
|
+
And I should see the "20% OFF Ever $200-plus purchase!*" grid row
|
|
95
|
+
But I should not see the "Buy 3 tee shirts and get the 4th free" grid row
|
|
96
|
+
When I clear the grid filters
|
|
97
|
+
Then I should see the "Buy 3 tee shirts and get the 4th free" grid row
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
@admin @catalog
|
|
2
|
+
Feature: Products in the admin panel
|
|
3
|
+
As a store administrator
|
|
4
|
+
I want to create, change and remove products
|
|
5
|
+
So that the catalog shows what the store sells
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given I am logged in to the admin panel as "admin"
|
|
9
|
+
|
|
10
|
+
Scenario: A product needs a name, a SKU and a price
|
|
11
|
+
Given I am on the "new product" admin page
|
|
12
|
+
When I save the form
|
|
13
|
+
Then I should see the form error "This is a required field." for the "Product Name" field
|
|
14
|
+
And I should see the form error "This is a required field." for the "SKU" field
|
|
15
|
+
And I should see the form error "This is a required field." for the "Price" field
|
|
16
|
+
And I should not see the form error "This is a required field." for the "Quantity" field
|
|
17
|
+
And the admin page title should be "New Product"
|
|
18
|
+
|
|
19
|
+
@critical
|
|
20
|
+
Scenario: A simple product is created, shown in the store, changed and removed
|
|
21
|
+
Given there is no product "WS-TEST-BAG"
|
|
22
|
+
And I am on the "new product" admin page
|
|
23
|
+
When I set the "Product Name" form field to "Webship Test Bag"
|
|
24
|
+
And I set the "SKU" form field to "WS-TEST-BAG"
|
|
25
|
+
And I set the "Price" form field to "12.50"
|
|
26
|
+
And I set the "Quantity" form field to "7"
|
|
27
|
+
And I choose "Bags" in the "Categories" form field
|
|
28
|
+
And I set the "Visibility" form field to "Catalog, Search"
|
|
29
|
+
And I open the "Images And Videos" form section
|
|
30
|
+
And I add the image "pixel.png" to the product gallery
|
|
31
|
+
Then the product gallery should have 1 image
|
|
32
|
+
When I save the form
|
|
33
|
+
Then I should see the success message "You saved the product."
|
|
34
|
+
And the admin page title should be "Webship Test Bag"
|
|
35
|
+
And the "SKU" form field should be "WS-TEST-BAG"
|
|
36
|
+
And the "Enable Product" form field should be "on"
|
|
37
|
+
And the "Visibility" form field should be "Catalog, Search"
|
|
38
|
+
# The storefront shows it at once: the indexes update when a product is saved.
|
|
39
|
+
When I go to "/webship-test-bag.html"
|
|
40
|
+
Then I should see "Webship Test Bag"
|
|
41
|
+
And the product price should be "$12.50"
|
|
42
|
+
And the breadcrumbs should be "Home > Webship Test Bag"
|
|
43
|
+
# Change the price and take it off the storefront.
|
|
44
|
+
When I open the product "WS-TEST-BAG" in the admin panel
|
|
45
|
+
And I set the "Price" form field to "15.00"
|
|
46
|
+
And I turn the "Enable Product" form switch off
|
|
47
|
+
And I save the form
|
|
48
|
+
Then I should see the success message "You saved the product."
|
|
49
|
+
And the "Enable Product" form field should be "off"
|
|
50
|
+
When I go to the "products" admin page
|
|
51
|
+
And I search the grid for "WS-TEST-BAG"
|
|
52
|
+
Then the "Status" column of the "WS-TEST-BAG" grid row should be "Disabled"
|
|
53
|
+
And the "Price" column of the "WS-TEST-BAG" grid row should be "$15.00"
|
|
54
|
+
# The grid action puts it back.
|
|
55
|
+
When I select the "WS-TEST-BAG" grid row
|
|
56
|
+
And I run the "Change status > Enable" grid action
|
|
57
|
+
Then I should see the success message "A total of 1 record(s) have been updated."
|
|
58
|
+
When I search the grid for "WS-TEST-BAG"
|
|
59
|
+
Then the "Status" column of the "WS-TEST-BAG" grid row should be "Enabled"
|
|
60
|
+
# Remove it with the grid action.
|
|
61
|
+
When I select the "WS-TEST-BAG" grid row
|
|
62
|
+
And I run the "Delete" grid action
|
|
63
|
+
Then I should see the confirmation "Delete items"
|
|
64
|
+
When I confirm the action
|
|
65
|
+
Then I should see the success message "A total of 1 record(s) have been deleted."
|
|
66
|
+
And there is no product "WS-TEST-BAG"
|
|
67
|
+
|
|
68
|
+
Scenario: A dismissed delete keeps the product
|
|
69
|
+
Given I am on the "products" admin page
|
|
70
|
+
When I search the grid for "24-MB01"
|
|
71
|
+
And I select the "24-MB01" grid row
|
|
72
|
+
And I run the "Delete" grid action
|
|
73
|
+
Then I should see the confirmation "Delete items"
|
|
74
|
+
When I dismiss the confirmation
|
|
75
|
+
Then the confirmation should be closed
|
|
76
|
+
And I should see the "Joust Duffle Bag" grid row
|
|
77
|
+
And I clear the grid filters
|
|
78
|
+
|
|
79
|
+
Scenario: A configurable product of the sample catalog is read
|
|
80
|
+
When I open the product "WS12" in the admin panel
|
|
81
|
+
Then the admin page title should be "Radiant Tee"
|
|
82
|
+
And the "Product Name" form field should be "Radiant Tee"
|
|
83
|
+
And the "SKU" form field should be "WS12"
|
|
84
|
+
And the "Enable Product" form field should be "on"
|
|
85
|
+
And the "Visibility" form field should be "Catalog, Search"
|
|
86
|
+
And I should see "Current Variations"
|
|
87
|
+
And I should see "Radiant Tee-XS-Blue"
|