chore: 补上 E2E 测试脚手架(wp-env + Playwright) #44

Merged
feibisi merged 1 commit from chore/e2e-harness into main 2026-07-28 00:23:15 +08:00
5 changed files with 5189 additions and 0 deletions

13
.wp-env.json Normal file
View file

@ -0,0 +1,13 @@
{
"core": "https://wordpress.org/latest.zip",
"plugins": [
"."
],
"themes": [],
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": false
},
"testsEnvironment": false
}

5136
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

23
package.json Normal file
View file

@ -0,0 +1,23 @@
{
"name": "wpslug",
"version": "1.2.1",
"description": "文派素格 🍤WPSlug.com更友好美观的 WordPress 文章、页面、媒体别名 slug ,支持拼音和翻译等自动生成。",
"scripts": {
"test": "playwright test",
"wp-env:start": "wp-env start",
"wp-env:stop": "wp-env stop",
"wp-env:destroy": "wp-env destroy",
"e2e": "playwright test"
},
"repository": {
"type": "git",
"url": "ssh://git@feicode.com:2222/WenPai-org/wpslug.git"
},
"keywords": [],
"author": "",
"license": "GPL-2.0-or-later",
"devDependencies": {
"@playwright/test": "^1.58.2",
"@wordpress/env": "^11.2.0"
}
}

10
playwright.config.js Normal file
View file

@ -0,0 +1,10 @@
const { defineConfig } = require('@playwright/test');

module.exports = defineConfig({
testDir: 'tests/E2E',
timeout: 60 * 1000,
use: {
baseURL: 'http://localhost:8888',
headless: true,
},
});

View file

@ -0,0 +1,7 @@
const { test, expect } = require('@playwright/test');

test('wp-admin login page loads', async ({ page }) => {
await page.goto('/wp-login.php');
await expect(page).toHaveTitle(/Log In|WordPress/i);
await expect(page.locator('#loginform')).toBeVisible();
});