Skip to content

test: cover sending mail through smtp end to end with playwright - #7

Merged
vitormattos merged 3 commits into
test/integration-harnessfrom
test/e2e-playwright
Sep 26, 2026
Merged

vitormattos merged 3 commits into
test/integration-harnessfrom
test/e2e-playwright

Conversation

@YvesCesar

Copy link
Copy Markdown
Member

Stacked on #5.

The plugin's job only shows when mail leaves WordPress and reaches an SMTP server, which the PHPUnit suites cannot see: there, PHPMailer is replaced by a mock. This adds a Playwright suite that sends real mail through the plugin.

Stack

tests/E2E/docker-compose.yml starts WordPress 7.1 (PHP 8.3) on :8889, MariaDB and Mailpit. Mailpit only accepts SMTP clients that log in as mailer with the password pa'ss, so a password that gets altered on the way breaks delivery instead of going unnoticed. tests/E2E/support/setup.sh installs WordPress, activates the plugin and saves the SMTP settings through WP-CLI. The tests read the delivered mail from the Mailpit API on :8026.

npm run env:start, npm run test:e2e and npm run env:stop, as in the README.

Flows covered

tests/E2E/WpSimpleSmtp.spec.ts:

  • Mail WordPress sends on its own: a lost password request arrives in Mailpit from Simple SMTP <noreply@example.org>.
  • Test email: an admin sends it from the settings page, sees the success notice, and it arrives.
  • Password with a quote: an admin saves the settings twice; the password field still shows pa'ss and the test email still authenticates and arrives.

Checked that the suite fails when it should: with the plugin deactivated all three fail; with a wrong password in smtp_pass all three fail, which confirms Mailpit enforces the login; without the wp_unslash() on save only the quote test fails.

CI

playwright.yml runs the suite in Chromium on every pull request, reports through the github reporter and uploads the HTML report as an artifact kept for 7 days. The plugin has no runtime dependencies, so the job needs neither PHP nor Composer.

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@vitormattos
vitormattos merged commit 5fb4062 into test/integration-harness Sep 26, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants