Compare commits

..

2 Commits

Author SHA1 Message Date
姚章浩 ad86bf93be ci(qa): 用签名镜像安装浏览器依赖
build / build (push) Successful in 3m58s
首轮 CI 在 Ubuntu 系统依赖下载和配置阶段超时。临时 CI 容器通过隔离的 APT 镜像配置完成安装并通过 Chromium DOM 冒烟。
2026-11-22 20:05:53 +08:00
姚章浩 5d00715c3a test(qa): 加入目录规则浏览器回归和暂存门禁
build / build (push) Failing after 7m7s
在 QA 虚拟机通过 Chromium 复跑和本地提交检查,并验证必填校验失效会触发失败。Gitea 将浏览器回归纳入必需检查。
2026-11-22 19:57:24 +08:00
19 changed files with 430 additions and 8 deletions
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu
# Keep the configured global checks when this checkout opts into repository hooks.
global_hooks=$(git config --global --path --get core.hooksPath || :)
if [ -n "$global_hooks" ] && [ -x "$global_hooks/pre-commit" ] &&
[ ! "$global_hooks/pre-commit" -ef "$0" ]; then
"$global_hooks/pre-commit"
fi
exec make test-changed
+2
View File
@@ -6,6 +6,8 @@
/web/node_modules/
/web/dist/
/web/tsconfig.tsbuildinfo
/web/test-results/
/web/playwright-report/
# Local runtime
.env
+14 -1
View File
@@ -27,7 +27,20 @@ BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
verify:
$(PY) scripts/ci_checks.py
.PHONY: qa qa-doctor qa-self-test
.PHONY: qa qa-doctor qa-self-test tests-e2e tests-e2e-ci test-changed test-tooling
tests-e2e:
npm --prefix web run test:e2e -- $(E2E)
# The hosted CI job container is disposable and starts without Chromium's system libraries.
tests-e2e-ci: export PLAYWRIGHT_BROWSERS_PATH ?= /opt/citools-cache/playwright
tests-e2e-ci:
sh scripts/ci_install_chromium.sh
$(MAKE) tests-e2e
test-changed:
$(PY) scripts/test_changed.py
test-tooling: qa-self-test
$(PY) -m unittest discover -s scripts -p test_test_changed.py -v
qa:
$(PY) scripts/qa_env.py run
qa-doctor:
+17 -2
View File
@@ -11,7 +11,7 @@ make qa-doctor
KG_QA_SHA='<完整提交 SHA>' make qa
```
`make qa-doctor` 检查工具链、HiFox 机器在线状态、OMP 模型调用、测试库身份和已安装的迁移。`make qa` 安装锁定依赖,在专用测试库上通过 API 初始化和迁移,随后核对完整迁移序列、API 就绪状态、Web 首页及 Vite 健康代理。通过后执行 Go 和 Vitest 测试,结束时关闭本次启动的服务。每次运行的服务日志保存在 `~/.local/state/knowledge-governance/qa/`。需要提交前完整门禁时执行 `make verify`。
`make qa-doctor` 检查工具链、HiFox 机器在线状态、OMP 模型调用、测试库身份和已安装的迁移。`make qa` 安装锁定依赖,在专用测试库上通过 API 初始化和迁移,随后核对完整迁移序列、API 就绪状态、Web 首页及 Vite 健康代理。通过后执行 Go、Vitest 和 Chromium 浏览器测试,结束时关闭本次启动的服务。每次运行的服务日志保存在 `~/.local/state/knowledge-governance/qa/`。需要提交前完整门禁时执行 `make verify`。
初次配置由负责人在 QA 虚拟机准备 `~/.config/knowledge-governance/`。以下示例使用虚构的 RDS 主机名。
@@ -128,4 +128,19 @@ TEST_DATABASE_URL="postgresql://${PGUSER}@${PGHOST}:${PGPORT}/${PGDATABASE}?sslm
go test -count=1 -v ./internal/platform/postgres -run '^TestUISettingsActivationRetiresPreviousRevisionIntegration$'
```
检查输出出现目标用例的 `PASS`。用例被跳过或没有匹配时,应补齐配置或纠正用例名后重跑。前端 Vitest 负责组件与业务逻辑检查,浏览器 E2E 应单独执行并按 Feature 保存证据。提测记录至少包括完整提交 SHA、执行命令、退出码,以及失败用例的日志或浏览器截图。
检查输出出现目标用例的 `PASS`。如果用例被跳过或没有匹配,补齐配置或修正用例名后重跑。提测记录包含完整提交 SHA、执行命令、退出码及失败证据。
## 5. 浏览器回归与提交前检查
浏览器用例、固定数据和独立 Vite 配置位于 `web/e2e/`,Playwright 版本由前端锁文件固定。第一次运行先执行 `make deps-install`,再在 QA 机的 `web/` 目录用 `npm exec -- playwright install chromium` 下载对应浏览器。已有浏览器缓存时测试本身可以离线运行。
```bash
make tests-e2e
make tests-e2e E2E=scope-rules.spec.ts
python3 scripts/test_changed.py --list
make test-changed
```
`make tests-e2e` 在 `127.0.0.1:4175` 启动夹具页并用 Chromium 检查目录规则。夹具页加载真实 React 编辑器并拦截 API 请求到固定的内存数据。覆盖保存和刷新读回、显示 HTTP 403、展示子目录与兄弟目录各自的继承来源。后端角色权限由 Go 测试覆盖,规则持久化和继承语义由 PostgreSQL 集成测试覆盖。失败截图与 trace 保存在 `web/test-results/`。
在独立克隆中可运行 `git config --local core.hooksPath .githooks` 启用仓内提交钩子。钩子先运行可用的全局提交检查,再运行 `make test-changed`。该入口读暂存差异,能定位时只跑修改的测试文件或 Go 包,遇到生产源码或公共依赖改动时扩大到相关套件。对已有仓库自定义钩子的克隆,应在现有钩子中调用 `make test-changed`。`make verify` 继续作为完整提交门禁,Gitea CI 将 Chromium 用例纳入必需检查。本地使用 `make tests-e2e` 直接运行。
+13
View File
@@ -241,6 +241,16 @@ func TestAuthRBACMatrix(t *testing.T) {
t.Fatalf("viewer write = %d", rec.Code)
}
for _, method := range []string{http.MethodPut, http.MethodDelete} {
result := httptest.NewRecorder()
request := httptest.NewRequest(method, "/api/v1/scope-rules", nil)
request.AddCookie(viewer)
handler.ServeHTTP(result, request)
if result.Code != http.StatusForbidden {
t.Fatalf("viewer %s scope rules = %d, want %d", method, result.Code, http.StatusForbidden)
}
}
// engineer may create batches but not authorize production
rec = httptest.NewRecorder()
req = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", strings.NewReader(`{"name":"x"}`))
@@ -417,6 +427,9 @@ func TestClassifyRoleMatrix(t *testing.T) {
http.MethodPost + " /api/v1/release-batches/rb-1/seal": roleEngineer,
http.MethodPost + " /api/v1/test-publications/start": roleEngineer,
http.MethodGet + " /api/v1/release-plan": roleViewer,
http.MethodGet + " /api/v1/scope-rules": roleViewer,
http.MethodPut + " /api/v1/scope-rules": roleEngineer,
http.MethodDelete + " /api/v1/scope-rules": roleEngineer,
}
for key, want := range cases {
fields := strings.Fields(key)
+12 -2
View File
@@ -249,6 +249,8 @@ def checks() -> list[Check]:
[g, "test", "-count=1", "-json", "./..."], env=env, judge=judge_go_tests),
Check("tests-web", "前端测试(vitest,必须真跑)",
[py3, "scripts/ci_checks.py", "--internal-web-test"], env=env),
Check("tests-e2e", "Chromium 浏览器回归(CI 必需)", ["make", "tests-e2e-ci"],
env=env, required_in=("ci",), note="本地用 make tests-e2e,复用已安装的浏览器"),
Check("contracts", "版本与变更记录契约(不许 SKIP;开发构建不许自称正式版)",
[py3, "scripts/ci_checks.py", "--internal-contracts", g], env=env),
Check("version", "CHANGELOG 与版本记录(四类小节无空栏目 + 正式 tag 与提交内版本一致)",
@@ -356,8 +358,7 @@ def cmd_internal_web_test() -> int:
def cmd_internal_contracts(go: str) -> int:
"""版本契约:结构 + 注入身份必须**真 PASS**(SKIP 判红),
并且**开发构建不许自称正式版**(负例:标成 release ⇒ 必须红)。"""
qa_rc = subprocess.run(py("-m", "unittest", "discover", "-s", "scripts", "-p", "test_qa_env.py", "-v"),
cwd=ROOT).returncode
qa_rc = subprocess.run(["make", "test-tooling"], cwd=ROOT).returncode
if qa_rc:
return qa_rc
snapshot_rc = subprocess.run(py("scripts/development_snapshot.py","--self-test"),cwd=ROOT).returncode
@@ -442,6 +443,7 @@ CHECK_MANIFEST: dict[str, tuple[str, ...]] = {
"build-web": ("local", "ci"),
"tests-go": ("local", "ci"),
"tests-web": ("local", "ci"),
"tests-e2e": ("ci",),
"contracts": ("local", "ci"),
"version": ("local", "ci"),
"security-secrets": ("local", "ci"),
@@ -635,6 +637,14 @@ def main(argv: list[str]) -> int:
print(f"\n── [{c.id}] {c.title} ──\n {'✅' if status == SUCCESS else ('⏭️' if status == SKIPPED else '❌')} {reason}")
continue
if args.profile not in c.required_in:
reason = f"{args.profile} 档案不要求此项。{c.note}".strip()
results.append({"id": c.id, "title": c.title, "required_in": list(c.required_in),
"status": SKIPPED, "reason": reason, "command": "",
"exit_code": None, "duration_s": 0})
print(f"\n── [{c.id}] {c.title} ──\n ⏭️ {reason}")
continue
print(f"\n── [{c.id}] {c.title} ──")
print(" $ " + " ".join(c.argv))
t0 = time.time()
+25
View File
@@ -0,0 +1,25 @@
#!/bin/sh
set -eu
if [ ! -f /.dockerenv ]; then
printf '%s\n' 'Chromium provisioning requires the disposable CI container. Use make tests-e2e here.' >&2
exit 1
fi
# Scope mirror settings to this command, keeping the runner image and its apt sources intact.
. /etc/os-release
if [ "$ID:$VERSION_CODENAME" != ubuntu:noble ]; then
printf '%s\n' 'Chromium provisioning expects Ubuntu 24.04.' >&2
exit 1
fi
apt_scope=$(mktemp -d)
trap 'rm -f "$apt_scope/ubuntu.list" "$apt_scope/apt.conf"; rmdir "$apt_scope"' EXIT
mirror=https://mirrors.aliyun.com/ubuntu/
for suite in noble noble-updates noble-security; do
printf 'deb [signed-by=/usr/share/keyrings/ubuntu-archive-keyring.gpg] %s %s main universe\n' "$mirror" "$suite"
done > "$apt_scope/ubuntu.list"
printf 'Dir::Etc::sourcelist "%s/ubuntu.list";\nDir::Etc::sourceparts "-";\nAcquire::Retries "2";\nAcquire::https::Timeout "15";\n' "$apt_scope" > "$apt_scope/apt.conf"
export APT_CONFIG="$apt_scope/apt.conf"
export DEBIAN_FRONTEND=noninteractive
export PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT=90000
timeout 360s npm --prefix web exec -- playwright install --with-deps --only-shell chromium
+1 -1
View File
@@ -316,7 +316,7 @@ def qa_run(commit, env, db_env, versions, state):
wait_service(web, WEB_PORT, '/', 'html', web_log)
wait_service(web, WEB_PORT, '/health', 'ok', web_log)
report('services', 'API /readyz、Web 首页与 Vite /health 代理通过')
run_step(['make', 'tests-go', 'tests-web'], 'tests', env, 300)
run_step(['make', 'tests-go', 'tests-web', 'tests-e2e'], 'tests', env, 300)
check_checkout(commit)
if api.poll() is not None or web.poll() is not None or not probe(WEB_PORT, '/health', 'ok'):
raise QAError(f'服务在测试期间失去健康状态,日志目录 {log_dir}')
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env python3
"""Select verification commands for staged changes."""
import argparse
from pathlib import Path, PurePosixPath
import re
import shlex
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[1]
def select_commands(paths, removed=()):
removed = set(removed)
full_go = full_web = browser = tooling = False
go_packages, web_tests = set(), set()
for name in paths:
path = PurePosixPath(name)
if name.startswith('docs/') or path.suffix == '.md':
continue
if name.startswith('web/e2e/') or name == 'web/playwright.config.ts':
browser = True
elif name.startswith('web/'):
if (name not in removed and name.startswith('web/src/') and
re.fullmatch(r'[\w./-]+\.test\.[jt]sx?', name)):
web_tests.add(str(path.relative_to('web')))
else:
full_web = browser = True
elif name.startswith(('scripts/', '.githooks/')) or name == 'Makefile':
tooling = full_go = full_web = browser = True
elif path.name.endswith('_test.go') and name not in removed:
go_packages.add('./' + path.parent.as_posix())
elif path.suffix == '.go' or name in ('go.mod', 'go.sum') or name.startswith(('internal/', 'cmd/')):
full_go = True
else:
full_go = full_web = browser = True
commands = []
if tooling:
commands.append(['make', 'test-tooling'])
if full_go:
commands.append(['make', 'tests-go'])
elif go_packages:
commands.append(['go', 'test', '-count=1', *sorted(go_packages)])
if full_web:
commands.append(['make', 'tests-web'])
elif web_tests:
commands.append(['npm', '--prefix', 'web', 'test', '--', *sorted(web_tests)])
if browser:
commands.append(['make', 'tests-e2e'])
return commands
def staged_names(*args):
result = subprocess.check_output(['git', 'diff', '--cached', '--no-renames', '--name-only', '-z', *args], cwd=ROOT)
return [name for name in result.decode('utf-8', errors='surrogateescape').split('\0') if name]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--list', action='store_true', help='print selected commands only')
args = parser.parse_args()
commands = select_commands(staged_names(), staged_names('--diff-filter=D'))
if not commands:
print('暂无需要执行测试的暂存文件')
return 0
if not args.list:
unstaged = subprocess.check_output(['git', 'diff', '--name-only', '-z'], cwd=ROOT)
paths = [name for name in unstaged.decode('utf-8', errors='surrogateescape').split('\0') if name]
if select_commands(paths):
print('还有未暂存的代码或配置,先整理工作区后再检查暂存改动', file=sys.stderr)
return 1
for cmd in commands:
print(shlex.join(cmd), flush=True)
if not args.list:
code = subprocess.run(cmd, cwd=ROOT, check=False).returncode
if code:
return code
return 0
if __name__ == '__main__':
sys.exit(main())
+31
View File
@@ -0,0 +1,31 @@
import unittest
from test_changed import select_commands
class SelectionTests(unittest.TestCase):
def test_documentation_only(self):
self.assertEqual(select_commands(['docs/DEVELOPMENT_AND_TESTING.md']), [])
def test_go_test_only_selects_its_package(self):
self.assertEqual(select_commands(['internal/governance/a_test.go']),
[['go', 'test', '-count=1', './internal/governance']])
def test_go_source_and_migration_fall_back_to_suite(self):
for name in ('internal/governance/model.go', 'internal/platform/postgres/migrations/0099_qa.up.sql'):
self.assertEqual(select_commands([name]), [['make', 'tests-go']])
def test_frontend_test_only_selects_its_file(self):
self.assertEqual(select_commands(['web/src/scopeRules.test.ts']),
[['npm', '--prefix', 'web', 'test', '--', 'src/scopeRules.test.ts']])
def test_shared_frontend_code_covers_browser_suite(self):
self.assertEqual(select_commands(['web/src/scopeRules.ts']),
[['make', 'tests-web'], ['make', 'tests-e2e']])
def test_e2e_only_runs_browser_suite(self):
self.assertEqual(select_commands(['web/e2e/scope-rules.spec.ts']), [['make', 'tests-e2e']])
def test_unsafe_unknown_paths_fall_back_to_all_relevant_suites(self):
self.assertEqual(select_commands(['new-runtime.conf']),
[['make', 'tests-go'], ['make', 'tests-web'], ['make', 'tests-e2e']])
+2
View File
@@ -1,4 +1,6 @@
node_modules/
dist/
test-results/
playwright-report/
*.tsbuildinfo
package-lock.json
+11
View File
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<title>目录范围规则测试</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./scope-rules.tsx"></script>
</body>
</html>
+128
View File
@@ -0,0 +1,128 @@
import { expect, test, type Page } from '@playwright/test'
import { document as sample } from '../src/documentFixture'
import type { ScopeRule, ScopeRuleDecision } from '../src/scopeRules'
const cases = [
{ id: 'parent', directory_path: '产品', title: '总览.pdf' },
{ id: 'child', directory_path: '产品/手册', title: '手册.pdf' },
{ id: 'sibling', directory_path: '产品/固件', title: '固件.pdf' },
]
const existing: ScopeRule = {
target_type: 'directory',
connection_id: 'pp-1',
directory_path: '产品',
visibility: 'external',
reason: '父目录已公开',
updated_by: 'QA工程师',
updated_at: sample.updated_at,
}
async function scopeFixture(page: Page, canWrite = true) {
const rules = new Map<string, ScopeRule>([['产品', existing]])
const changes: ScopeRuleDecision[] = []
await page.route('**/*', async (route) => {
const request = route.request()
const url = new URL(request.url())
if (url.hostname !== '127.0.0.1' || url.port !== '4175') return route.abort()
if (url.pathname === '/api/v1/scope-rules') {
if (request.method() === 'GET' && url.searchParams.get('connection_id') === 'pp-1') {
return route.fulfill({ json: { data: [...rules.values()] } })
}
if (request.method() === 'PUT') {
const input = request.postDataJSON() as ScopeRuleDecision
changes.push(input)
if (!canWrite) return route.fulfill({ status: 403, json: { error: 'forbidden' } })
if (
input.target_type !== 'directory' ||
input.connection_id !== 'pp-1' ||
!cases.some((item) => item.directory_path === input.directory_path) ||
!request.headers()['idempotency-key'] ||
!input.reason.trim()
) {
return route.fulfill({ status: 400, json: { error: 'invalid fixture input' } })
}
const rule = { ...existing, ...input }
rules.set(input.directory_path, rule)
return route.fulfill({ json: { data: rule } })
}
}
if (url.pathname === '/api/v1/source-items' && request.method() === 'GET') {
const items = cases.map((item) => {
const rule = rules.get(item.directory_path) ?? rules.get('产品')!
return {
...sample,
...item,
visibility: rule.visibility,
visibility_origin: 'directory_rule',
scope_rule_path: rule.directory_path,
}
})
return route.fulfill({ json: { data: items, summary: { total: items.length }, offset: 0, limit: 100 } })
}
if (url.pathname.startsWith('/api/'))
return route.fulfill({ status: 404, json: { error: 'unexpected fixture request' } })
return route.continue()
})
await page.goto('/e2e/scope-rules.html')
return changes
}
function openDirectory(page: Page, name: string) {
return page
.getByRole('complementary', { name: '来源目录' })
.getByRole('button', { name: new RegExp(`^▸ ${name} \\d+$`) })
.click()
}
async function saveInternal(page: Page) {
const editor = page.getByRole('region', { name: '对内对外范围设置' })
await editor.getByLabel('拟修改为').selectOption('internal')
await expect(editor.getByRole('button', { name: '保存范围' })).toBeDisabled()
await editor.getByLabel('判断原因').fill(' 仅供内部使用 ')
await editor.getByRole('button', { name: '保存范围' }).click()
}
test('编辑器保存目录范围并在刷新后读回', async ({ page }) => {
const changes = await scopeFixture(page)
await openDirectory(page, '产品/手册')
await saveInternal(page)
await expect(page.getByText('当前设置:对内')).toBeVisible()
expect(changes).toEqual([
{
target_type: 'directory',
connection_id: 'pp-1',
directory_path: '产品/手册',
source_item_id: '',
visibility: 'internal',
reason: '仅供内部使用',
},
])
await page.reload()
await openDirectory(page, '产品/手册')
await expect(page.getByText('当前设置:对内')).toBeVisible()
await expect(page.getByRole('row', { name: /手册.pdf/ })).toContainText('继承目录设置:产品/手册')
})
test('编辑器显示只读拒绝并保留原规则', async ({ page }) => {
const changes = await scopeFixture(page, false)
await openDirectory(page, '产品/手册')
await saveInternal(page)
await expect(page.getByRole('alert')).toHaveText('保存范围规则失败(HTTP 403)')
expect(changes).toHaveLength(1)
await page.reload()
await openDirectory(page, '产品/手册')
await expect(page.getByText('当前没有本级设置')).toBeVisible()
await expect(page.getByRole('row', { name: /手册.pdf/ })).toContainText('继承目录设置:产品')
})
test('编辑器刷新并显示子目录规则和兄弟目录的继承来源', async ({ page }) => {
await scopeFixture(page)
await openDirectory(page, '产品/手册')
await saveInternal(page)
await expect(page.getByRole('row', { name: /手册.pdf/ })).toContainText('继承目录设置:产品/手册')
await openDirectory(page, '产品/固件')
const sibling = page.getByRole('row', { name: /固件.pdf/ })
await expect(sibling).toContainText('对外')
await expect(sibling).toContainText('继承目录设置:产品')
})
+4
View File
@@ -0,0 +1,4 @@
import { createRoot } from 'react-dom/client'
import { DocumentWorkbench } from '../src/DocumentWorkbench'
createRoot(document.getElementById('root')!).render(<DocumentWorkbench mode="directory" connections={[]} />)
+4
View File
@@ -0,0 +1,4 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({ plugins: [react()], publicDir: false })
+46
View File
@@ -14,6 +14,7 @@
"remark-gfm": "4.0.1"
},
"devDependencies": {
"@playwright/test": "1.65.1",
"@types/react": "19.1.10",
"@types/react-dom": "19.1.7",
"@vitejs/plugin-react": "5.0.1",
@@ -814,6 +815,22 @@
"node": "^22.20 || ^24.12 || >=25"
}
},
"node_modules/@playwright/test": {
"version": "1.65.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz",
"integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.65.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@rolldown/pluginutils": {
"version": "1.0.0-beta.32",
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.32.tgz",
@@ -2887,6 +2904,35 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/playwright": {
"version": "1.65.1",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz",
"integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.65.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=20"
}
},
"node_modules/playwright-core": {
"version": "1.65.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz",
"integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=20"
}
},
"node_modules/postcss": {
"version": "8.5.26",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
+3 -1
View File
@@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"dev": "vite --host 0.0.0.0",
"test": "vitest run",
"test": "vitest run --exclude 'e2e/**'",
"test:e2e": "playwright test",
"build": "tsc -b && vite build",
"typecheck": "tsc -b --pretty false",
"format": "prettier --write .",
@@ -18,6 +19,7 @@
"remark-gfm": "4.0.1"
},
"devDependencies": {
"@playwright/test": "1.65.1",
"@types/react": "19.1.10",
"@types/react-dom": "19.1.7",
"@vitejs/plugin-react": "5.0.1",
+23
View File
@@ -0,0 +1,23 @@
import { defineConfig } from '@playwright/test'
export default defineConfig({
testDir: './e2e',
workers: 1,
retries: 0,
forbidOnly: true,
timeout: 15000,
expect: { timeout: 5000 },
use: {
browserName: 'chromium',
baseURL: 'http://127.0.0.1:4175',
serviceWorkers: 'block',
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
},
webServer: {
command: 'vite --config e2e/vite.config.ts --host 127.0.0.1 --port 4175 --strictPort',
url: 'http://127.0.0.1:4175/e2e/scope-rules.html',
reuseExistingServer: false,
timeout: 20000,
},
})
+1 -1
View File
@@ -17,5 +17,5 @@
"jsx": "react-jsx",
"types": ["vitest/globals", "vite/client"]
},
"include": ["src", "vite.config.ts"]
"include": ["src", "e2e", "vite.config.ts", "playwright.config.ts"]
}