Skip to content

Commit f2a4a34

Browse files
authored
Merge pull request #210 from Kit/update-wp-browser-v4
Tests: Upgrade `wp-browser` to version 4
2 parents 810f483 + 8ca2a94 commit f2a4a34

File tree

79 files changed

+1017
-969
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1017
-969
lines changed

.distignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.github
33
/.scripts
44
/.wordpress-org
5+
/log
56
/tests
67
/vendor/autoload.php
78
/vendor/composer

.env.dist.testing

+31-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1-
TEST_SITE_DB_DSN=mysql:host=localhost;dbname=test
2-
TEST_SITE_DB_HOST=localhost
3-
TEST_SITE_DB_NAME=test
4-
TEST_SITE_DB_USER=root
5-
TEST_SITE_DB_PASSWORD=root
6-
TEST_SITE_TABLE_PREFIX=wp_
7-
TEST_SITE_ADMIN_USERNAME=admin
8-
TEST_SITE_ADMIN_PASSWORD=password
9-
TEST_SITE_ADMIN_EMAIL="[email protected]"
10-
TEST_SITE_WP_ADMIN_PATH=/wp-admin
11-
WP_ROOT_FOLDER="/var/www/html"
12-
TEST_DB_NAME=test
13-
TEST_DB_HOST=localhost
14-
TEST_DB_USER=root
15-
TEST_DB_PASSWORD=root
1+
# The path to the WordPress root directory, the one containing the wp-load.php file.
2+
# This can be a relative path from the directory that contains the codeception.yml file,
3+
# or an absolute path.
4+
WORDPRESS_ROOT_DIR=/var/www/html
5+
6+
# Tests will require a MySQL database to run.
7+
# The database will be created if it does not exist.
8+
# Do not use a database that contains important data!
9+
WORDPRESS_DB_URL=mysql://root:root@localhost:3306/test
10+
11+
# The Integration suite will use this table prefix for the WordPress tables.
1612
TEST_TABLE_PREFIX=wp_
17-
TEST_SITE_WP_URL=http://127.0.0.1
18-
TEST_SITE_WP_DOMAIN=127.0.0.1
19-
13+
14+
# This table prefix used by the WordPress site in end-to-end tests.
15+
WORDPRESS_TABLE_PREFIX=wp_
16+
17+
# The URL and domain of the WordPress site used in end-to-end tests.
18+
WORDPRESS_URL=http://127.0.0.1
19+
WORDPRESS_DOMAIN=127.0.0.1
20+
WORDPRESS_ADMIN_PATH=/wp-admin
21+
22+
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
23+
WORDPRESS_ADMIN_USER=admin
24+
WORDPRESS_ADMIN_PASSWORD=password
25+
26+
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
27+
CHROMEDRIVER_HOST=localhost
28+
CHROMEDRIVER_PORT=9515
29+
30+
# The user agents used in end-to-end tests.
2031
TEST_SITE_HTTP_USER_AGENT=HeadlessChrome
2132
TEST_SITE_HTTP_USER_AGENT_MOBILE=HeadlessChromeMobile
33+
34+
# Kit specific variables.
2235
CONVERTKIT_API_FORM_NAME="WooCommerce Product Form"
2336
CONVERTKIT_API_FORM_ID="2765149"
2437
CONVERTKIT_API_LEGACY_FORM_NAME="Legacy Form"

.env.example

+31-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1-
TEST_SITE_DB_DSN=mysql:host=localhost;dbname=test
2-
TEST_SITE_DB_HOST=localhost
3-
TEST_SITE_DB_NAME=test
4-
TEST_SITE_DB_USER=root
5-
TEST_SITE_DB_PASSWORD=root
6-
TEST_SITE_TABLE_PREFIX=wp_
7-
TEST_SITE_ADMIN_USERNAME=admin
8-
TEST_SITE_ADMIN_PASSWORD=password
9-
TEST_SITE_ADMIN_EMAIL="[email protected]"
10-
TEST_SITE_WP_ADMIN_PATH=/wp-admin
11-
WP_ROOT_FOLDER="/Users/tim/Local Sites/convertkit/app/public"
12-
TEST_DB_NAME=test
13-
TEST_DB_HOST=localhost
14-
TEST_DB_USER=root
15-
TEST_DB_PASSWORD=root
1+
# The path to the WordPress root directory, the one containing the wp-load.php file.
2+
# This can be a relative path from the directory that contains the codeception.yml file,
3+
# or an absolute path.
4+
WORDPRESS_ROOT_DIR=/var/www/html
5+
6+
# Tests will require a MySQL database to run.
7+
# The database will be created if it does not exist.
8+
# Do not use a database that contains important data!
9+
WORDPRESS_DB_URL=mysql://root:root@localhost:3306/test
10+
11+
# The Integration suite will use this table prefix for the WordPress tables.
1612
TEST_TABLE_PREFIX=wp_
17-
TEST_SITE_WP_URL=http://convertkit.local
18-
TEST_SITE_WP_DOMAIN=convertkit.local
19-
TEST_SITE_ADMIN_EMAIL=[email protected]
13+
14+
# This table prefix used by the WordPress site in end-to-end tests.
15+
WORDPRESS_TABLE_PREFIX=wp_
16+
17+
# The URL and domain of the WordPress site used in end-to-end tests.
18+
WORDPRESS_URL=http://127.0.0.1
19+
WORDPRESS_DOMAIN=127.0.0.1
20+
WORDPRESS_ADMIN_PATH=/wp-admin
21+
22+
# The username and password of the administrator user of the WordPress site used in end-to-end tests.
23+
WORDPRESS_ADMIN_USER=admin
24+
WORDPRESS_ADMIN_PASSWORD=password
25+
26+
# The host and port of the ChromeDriver server that will be used in end-to-end tests.
27+
CHROMEDRIVER_HOST=localhost
28+
CHROMEDRIVER_PORT=9515
29+
30+
# The user agents used in end-to-end tests.
2031
TEST_SITE_HTTP_USER_AGENT=HeadlessChrome
2132
TEST_SITE_HTTP_USER_AGENT_MOBILE=HeadlessChromeMobile
33+
34+
# Kit specific variables.
2235
STRIPE_TEST_PUBLISHABLE_KEY=
2336
STRIPE_TEST_SECRET_KEY=
2437
CONVERTKIT_API_KEY_NO_DATA=

.github/workflows/test-backward-compat.yml

+4-11
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ jobs:
5454
fail-fast: false
5555
matrix:
5656
wp-versions: [ 'latest' ] #[ '6.1.1', 'latest' ]
57-
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] #[ '7.4', '8.0', '8.1' ]
57+
php-versions: [ '8.1', '8.2', '8.3' ] #[ '7.4', '8.0', '8.1' ]
5858

5959
# Folder names within the 'tests' folder to run tests in parallel.
6060
test-groups: [
61-
'acceptance/backward-compat'
61+
'EndToEnd/backward-compat'
6262
]
6363

6464
# Steps to install, configure and run tests
@@ -121,7 +121,7 @@ jobs:
121121
# env.INSTALL_PLUGINS is a list of Plugin slugs, space separated e.g. contact-form-7 woocommerce.
122122
# We activate the Plugins so that any directories they create are added now, before we later set
123123
# directory permissions in this action.
124-
# These Plugins won't be active when Codeception's acceptance tests run, as Codeception copies
124+
# These Plugins won't be active when Codeception's End to End tests run, as Codeception copies
125125
# the tests/_data/dump.sql, which has no active Plugins specified.
126126
- name: Install Free Third Party WordPress Plugins
127127
working-directory: ${{ env.ROOT_DIR }}
@@ -279,14 +279,7 @@ jobs:
279279
working-directory: ${{ env.PLUGIN_DIR }}
280280
run: php vendor/bin/codecept build
281281

282-
# Run Codeception WPUnit Tests on the PHP 7.4 instance before the acceptance/general acceptance tests.
283-
# We run these once to avoid hitting API rate limits.
284-
- name: Run tests/wpunit
285-
if: ${{ matrix.php-versions == '7.4' && matrix.test-groups == 'acceptance/general' }}
286-
working-directory: ${{ env.PLUGIN_DIR }}
287-
run: php vendor/bin/codecept run tests/wpunit --fail-fast
288-
289-
# Run Codeception Acceptance Tests.
282+
# Run Codeception End to End Tests.
290283
- name: Run tests/${{ matrix.test-groups }}
291284
working-directory: ${{ env.PLUGIN_DIR }}
292285
run: php vendor/bin/codecept run tests/${{ matrix.test-groups }} --fail-fast

.github/workflows/test.yml

+13-13
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ jobs:
5454
fail-fast: false
5555
matrix:
5656
wp-versions: [ 'latest' ] #[ '6.1.1', 'latest' ]
57-
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] #[ '7.4', '8.0', '8.1' ]
57+
php-versions: [ '8.1', '8.2', '8.3' ] #[ '7.4', '8.0', '8.1' ]
5858

5959
# Folder names within the 'tests' folder to run tests in parallel.
6060
test-groups: [
61-
'acceptance/general',
62-
'acceptance/integrations',
63-
'acceptance/purchase-data',
64-
'acceptance/settings',
65-
'acceptance/subscribe',
66-
'acceptance/sync-past-orders'
61+
'EndToEnd/general',
62+
'EndToEnd/integrations',
63+
'EndToEnd/purchase-data',
64+
'EndToEnd/settings',
65+
'EndToEnd/subscribe',
66+
'EndToEnd/sync-past-orders'
6767
]
6868

6969
# Steps to install, configure and run tests
@@ -126,7 +126,7 @@ jobs:
126126
# env.INSTALL_PLUGINS is a list of Plugin slugs, space separated e.g. contact-form-7 woocommerce.
127127
# We activate the Plugins so that any directories they create are added now, before we later set
128128
# directory permissions in this action.
129-
# These Plugins won't be active when Codeception's acceptance tests run, as Codeception copies
129+
# These Plugins won't be active when Codeception's End to End tests run, as Codeception copies
130130
# the tests/_data/dump.sql, which has no active Plugins specified.
131131
- name: Install Free Third Party WordPress Plugins
132132
working-directory: ${{ env.ROOT_DIR }}
@@ -284,14 +284,14 @@ jobs:
284284
working-directory: ${{ env.PLUGIN_DIR }}
285285
run: php vendor/bin/codecept build
286286

287-
# Run Codeception WPUnit Tests on the PHP 7.4 instance before the acceptance/general acceptance tests.
287+
# Run Codeception Integration Tests on the PHP 8.1 instance before the EndToEnd/general tests.
288288
# We run these once to avoid hitting API rate limits.
289-
- name: Run tests/wpunit
290-
if: ${{ matrix.php-versions == '7.4' && matrix.test-groups == 'acceptance/general' }}
289+
- name: Run tests/Integration
290+
if: ${{ matrix.php-versions == '8.1' && matrix.test-groups == 'EndToEnd/general' }}
291291
working-directory: ${{ env.PLUGIN_DIR }}
292-
run: php vendor/bin/codecept run tests/wpunit --fail-fast
292+
run: php vendor/bin/codecept run tests/Integration --fail-fast
293293

294-
# Run Codeception Acceptance Tests.
294+
# Run Codeception End to End Tests.
295295
- name: Run tests/${{ matrix.test-groups }}
296296
working-directory: ${{ env.PLUGIN_DIR }}
297297
run: php vendor/bin/codecept run tests/${{ matrix.test-groups }} --fail-fast

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
.env.testing
44
codeception.yml
55
composer.lock
6+
log
67
log.txt
78
phpstan.neon
89
tests/_output
10+
tests/_wordpress
11+
tests/Support/_generated
912
vendor
1013
*.zip

codeception.dist.yml

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1+
namespace: Tests
2+
support_namespace: Support
13
paths:
24
tests: tests
35
output: tests/_output
4-
data: tests/_data
5-
support: tests/_support
6+
data: tests/Support/Data
7+
support: tests/Support
68
envs: tests/_envs
7-
settings:
8-
error_level: E_ALL & ~E_STRICT & ~E_DEPRECATED
99
actor_suffix: Tester
1010
extensions:
1111
enabled:
1212
- Codeception\Extension\RunFailed
1313
commands:
14-
- Codeception\Command\GenerateWPUnit
15-
- Codeception\Command\GenerateWPRestApi
16-
- Codeception\Command\GenerateWPRestController
17-
- Codeception\Command\GenerateWPRestPostTypeController
18-
- Codeception\Command\GenerateWPAjax
19-
- Codeception\Command\GenerateWPCanonical
20-
- Codeception\Command\GenerateWPXMLRPC
14+
- lucatume\WPBrowser\Command\RunOriginal
15+
- lucatume\WPBrowser\Command\RunAll
16+
- lucatume\WPBrowser\Command\GenerateWPUnit
17+
- lucatume\WPBrowser\Command\DbExport
18+
- lucatume\WPBrowser\Command\DbImport
19+
- lucatume\WPBrowser\Command\MonkeyCachePath
20+
- lucatume\WPBrowser\Command\MonkeyCacheClear
21+
- lucatume\WPBrowser\Command\DevStart
22+
- lucatume\WPBrowser\Command\DevStop
23+
- lucatume\WPBrowser\Command\DevInfo
24+
- lucatume\WPBrowser\Command\DevRestart
25+
- lucatume\WPBrowser\Command\ChromedriverUpdate
2126
params:
2227
- .env.dist.testing

composer.json

+2-9
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,12 @@
77
"convertkit/convertkit-wordpress-libraries": "2.0.6"
88
},
99
"require-dev": {
10-
"lucatume/wp-browser": "<3.5",
11-
"codeception/module-asserts": "^1.3",
12-
"codeception/module-phpbrowser": "^1.0",
13-
"codeception/module-webdriver": "^1.0",
14-
"codeception/module-db": "^1.0",
15-
"codeception/module-filesystem": "^1.0",
16-
"codeception/module-cli": "^1.0",
17-
"codeception/util-universalframework": "^1.0",
1810
"php-webdriver/webdriver": "^1.0",
1911
"wp-coding-standards/wpcs": "^3.0.0",
2012
"phpstan/phpstan": "^1.0 || ^2.0",
2113
"szepeviktor/phpstan-wordpress": "^1.0 || ^2.0",
22-
"wp-cli/wp-cli-bundle": "2.11"
14+
"wp-cli/wp-cli": "^2.11",
15+
"lucatume/wp-browser": "^3.0 || ^4.0"
2316
},
2417
"minimum-stability": "dev",
2518
"prefer-stable": true,

tests/EndToEnd.suite.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Integration suite configuration
2+
#
3+
# Run integration and "WordPress unit" tests.
4+
5+
# Remember to call `vendor/bin/codecept build` after editing this file.
6+
7+
actor: EndToEndTester
8+
bootstrap: _bootstrap.php
9+
modules:
10+
enabled:
11+
# wp-browser supplied classes, which provide WordPress specific functions
12+
- lucatume\WPBrowser\Module\WPWebDriver
13+
- lucatume\WPBrowser\Module\WPDb
14+
- lucatume\WPBrowser\Module\WPFilesystem
15+
- lucatume\WPBrowser\Module\WPLoader
16+
- lucatume\WPBrowser\Module\WPCLI
17+
18+
# Codeception supplied classes, which provide assertions and filesystem functions
19+
- \Codeception\Module\Asserts
20+
- \Codeception\Module\Filesystem
21+
22+
# Our helper classes, which contain functions used across multiple tests.
23+
# If you created a new file in tests/Support/Helper, add its namespace and class below,
24+
- \Tests\Support\Helper\Email
25+
- \Tests\Support\Helper\KitAPI
26+
- \Tests\Support\Helper\Plugin
27+
- \Tests\Support\Helper\Select2
28+
- \Tests\Support\Helper\ThirdPartyPlugin
29+
- \Tests\Support\Helper\WooCommerce
30+
- \Tests\Support\Helper\WPAssets
31+
- \Tests\Support\Helper\WPBulkEdit
32+
- \Tests\Support\Helper\WPGutenberg
33+
- \Tests\Support\Helper\WPMetabox
34+
- \Tests\Support\Helper\WPQuickEdit
35+
- \Tests\Support\Helper\Xdebug
36+
config:
37+
lucatume\WPBrowser\Module\WPCLI:
38+
path: '%WORDPRESS_ROOT_DIR%'
39+
throw: true
40+
lucatume\WPBrowser\Module\WPWebDriver:
41+
url: '%WORDPRESS_URL%'
42+
adminUsername: '%WORDPRESS_ADMIN_USER%'
43+
adminPassword: '%WORDPRESS_ADMIN_PASSWORD%'
44+
adminPath: '%WORDPRESS_ADMIN_PATH%'
45+
browser: chrome
46+
host: '%CHROMEDRIVER_HOST%'
47+
port: '%CHROMEDRIVER_PORT%'
48+
path: '/wd/hub'
49+
window_size: 1920x1080
50+
capabilities:
51+
"goog:chromeOptions":
52+
args:
53+
- "--disable-gpu"
54+
- "--disable-dev-shm-usage"
55+
- "--proxy-server='direct://'"
56+
- "--proxy-bypass-list=*"
57+
- "--no-sandbox"
58+
- "--user-agent=%TEST_SITE_HTTP_USER_AGENT%"
59+
prefs:
60+
download.default_directory: '%WORDPRESS_ROOT_DIR%'
61+
lucatume\WPBrowser\Module\WPDb:
62+
dbUrl: '%WORDPRESS_DB_URL%'
63+
dump: 'tests/Support/Data/dump.sql'
64+
#import the dump before the tests; this means the test site database will be repopulated before the tests.
65+
populate: true
66+
# re-import the dump between tests; this means the test site database will be repopulated between the tests.
67+
cleanup: false
68+
reconnect: false
69+
url: '%WORDPRESS_URL%'
70+
urlReplacement: true
71+
tablePrefix: '%WORDPRESS_TABLE_PREFIX%'
72+
lucatume\WPBrowser\Module\WPFilesystem:
73+
wpRootFolder: '%WORDPRESS_ROOT_DIR%'
74+
lucatume\WPBrowser\Module\WPLoader:
75+
loadOnly: true
76+
wpRootFolder: '%WORDPRESS_ROOT_DIR%'
77+
dbUrl: '%WORDPRESS_DB_URL%'
78+
domain: '%WORDPRESS_DOMAIN%'
79+

tests/EndToEnd/_bootstrap.php

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

0 commit comments

Comments
 (0)