Agent Skillsbtcpayserver/btcpayserver › playwright-test-patterns

playwright-test-patterns

GitHub

提供BTCPayServer中Playwright测试的编写与重构指南,涵盖页面对象模型(PMO)使用、选择器封装及避免过度设计。

.agents/skills/playwright-test-patterns/SKILL.md btcpayserver/btcpayserver

Trigger Scenarios

编写Playwright UI测试 重构现有Playwright测试代码

Install

npx skills add btcpayserver/btcpayserver --skill playwright-test-patterns -g -y
More Options

Non-standard path

npx skills add https://github.com/btcpayserver/btcpayserver/tree/master/.agents/skills/playwright-test-patterns -g -y

Use without installing

npx skills use btcpayserver/btcpayserver@playwright-test-patterns

指定 Agent (Claude Code)

npx skills add btcpayserver/btcpayserver --skill playwright-test-patterns -a claude-code -g -y

安装 repo 全部 skill

npx skills add btcpayserver/btcpayserver --all -g -y

预览 repo 内 skill

npx skills add btcpayserver/btcpayserver --list

SKILL.md

Frontmatter
{
    "name": "playwright-test-patterns",
    "description": "Use when writing or refactoring Playwright tests in BTCPayServer. Covers PMO\/Page Model Object usage, selector encapsulation, and avoiding over-engineering."
}

Playwright Test Patterns

Use these patterns when writing or refactoring Playwright tests in BTCPayServer.

Page Model Objects

  • Creating Page Model Objects (PMOs) is encouraged when test code repeats UI interactions or assertions.
  • PMOs should make tests more readable by exposing user-level actions and assertions.
  • PMOs should hide repeated selector logic from test bodies.
  • PMOs should expose methods such as AssertSearchText(value) or SelectDateRangePreset(name) instead of requiring repeated Expect(...).ToHave... calls at test call sites.
  • PMOs should use stable selector hooks, preferably BEM class selectors for frontend components.

Avoid Over-Engineering

  • Do not create a PMO when the tested UI is very local to one test class and unlikely to be reused elsewhere.
  • For page-specific controls used only in one test class, prefer small local helpers inside the test class.
  • Keep PMOs focused on reusable components or page flows.
  • Do not add abstraction layers that only wrap one obvious Playwright call unless it meaningfully improves readability or removes repetition.

Selector Guidance

  • Prefer BEM class selectors for reusable UI hooks.
  • Avoid direct ids in Playwright tests for reusable components when BEM hooks exist.
  • Keep page-specific selectors near the page-specific test or PMO.
  • When a selector is used in multiple tests, consider moving it behind a PMO action or assertion.

Refactoring Existing Tests

  • Prefer modifying or extending an existing relevant test over writing a new test.
  • Add a new test only when no existing scenario naturally covers the behavior or when combining scenarios would make the test unclear.
  • First identify repeated interaction/assertion sequences.
  • Move repeated sequences into a PMO when they represent reusable component or page behavior.
  • Keep one-off logic in the test if abstraction would obscure the scenario.
  • Run the relevant test or test project build after refactoring Playwright selectors or PMOs.

Running And Debugging Tests

  • Before debugging BTCPay Server or running tests, start the test dependencies by running docker-compose up -d dev from the BTCPayServer.Tests directory.

Version History

  • 3f770d0 Current 2026-08-28 23:30

    新增运行和调试测试的步骤说明,提示使用docker-compose启动依赖。

  • fbf761f 2026-08-20 12:02

Same Skill Collection

.agents/skills/bem-conventions/SKILL.md
.agents/skills/btcpayserver-changelog/SKILL.md
.agents/skills/btcpayserver-migrations/SKILL.md
.agents/skills/btcpayserver-pr-descriptions/SKILL.md

Metadata

Files
0
Version
3f770d0
Hash
96e22089
Indexed
2026-08-20 12:02

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-03 20:36
浙ICP备14020137号-1 $bản đồ khách truy cập$