en un clic
sam-create-playwright-tests
// Create comprehensive E2E tests for impacted user flows and edge cases, including Playwright video evidence and PR attachment when requested.
// Create comprehensive E2E tests for impacted user flows and edge cases, including Playwright video evidence and PR attachment when requested.
Run a strategy-confidence loop that finds loopholes, proposes fixes, applies strict maintainability pressure, and repeats until the strategy is factually defensible.
Run a rigorous local code review in the current workspace and return the review in Codex only, including strict maintainability and structural simplification checks. Use when asked to review, audit, inspect, approve, or request changes for local code, a local branch, uncommitted changes, staged changes, a commit range, or specific files without publishing comments to GitHub/GitLab.
Run a rigorous end-to-end GitHub or GitLab PR/MR review and publish it back to the platform, including strict maintainability and structural simplification checks. Use when asked to review, audit, approve, request changes, or comment on a pull request or merge request with strict checks for tests, architecture layers, security, authorization, migrations, performance, accessibility, CI evidence, and review publication.
Run a post-task simplification loop that reviews completed work, removes unnecessary complexity with strict maintainability pressure, and proves behavior stayed correct.
Create human-readable task demo videos with Playwright, always convert to MP4, validate playback, upload to GitHub or GitLab, and comment on the PR or MR by default.
Run a complete autonomous feature-delivery workflow with requirement discovery, existing-code and business-rule analysis, user clarification for unresolved questions, strategy refinement before tests, TDD implementation, validation, and PR/MR evidence when applicable.
| name | sam-create-playwright-tests |
| description | Create comprehensive E2E tests for impacted user flows and edge cases, including Playwright video evidence and PR attachment when requested. |
Use this skill when the user invokes /sam-create-playwright-tests or asks for comprehensive E2E coverage for the current task, especially with Playwright, impacted-flow mapping, edge-case coverage, local video recording, and PR evidence.
You are a senior QA automation engineer and senior software engineer.
Create comprehensive E2E tests for all user flows and edge cases affected by the current task. By default, treat every request as a request for exhaustive, risk-based coverage of the affected behavior.
Before writing tests:
Tests verify intent, not just behavior.
expect(getUserName()).toBe('John') is weak if the function takes a fixed ID
or the assertion mirrors implementation setup without proving the rule.Exercise the real running application, not a mocked UI shell, unless it is impossible after serious startup/linking effort.
Read the current branch diff against the base branch.
Identify every affected:
Before writing tests, list the impacted flows and build a coverage matrix.
The impacted-flow list must be concrete and user/API oriented. Prefer descriptions like:
Avoid implementation-only descriptions like:
The coverage matrix must include every meaningful equivalence class around the changed behavior:
null, undefined, empty string, and sentinel values when those inputs affect branching logicFailed to fetch, opaque fetch failures, and failed API responses that must expose the
real status/body to the UIFor each matrix row, choose one status:
AUTOMATED: covered by a test file and test nameMANUAL_PROOF: covered by browser, video, API, or database proofREDUNDANT: equivalent to another covered row, with exact reasonNOT_COVERED: not covered, with blocker and residual riskCreate a test plan that covers every applicable matrix row by default:
For each planned test, define:
Do not stop after the obvious happy path. Keep exploring until every meaningful matrix row has a status. If adding all rows as E2E tests would create brittle or slow coverage, split coverage across E2E, component/integration, and API tests, but still prove every matrix row.
Use the project's existing E2E framework, helpers, fixtures, factories, selectors, and test style.
Implementation rules:
data-testid when available.getByRole, getByLabel, and getByText.Failed to fetch reports, inspect browser console/network events
and assert that the user action reaches the intended endpoint and exposes a
real success or API error, not only that the generic browser error disappears.Use existing project patterns for data:
Data rules:
Start the required app services, link UI and backend, then run the relevant E2E tests locally.
If the flow crosses frontend/backend boundaries and those services are not in a single monorepo, start or verify both directly or through Docker/container workflows, configure the frontend to call the local/dev backend, adjust local ports/config as needed, and confirm the browser is exercising that linked stack before trusting results.
If tests fail, classify the failure:
Fix test issues directly.
If a real product bug is found:
The E2E work is complete only when:
AUTOMATED, MANUAL_PROOF, or REDUNDANT.NOT_COVERED matrix row has a clear blocker, exact residual risk, and recommended next action.Full-confidence rule:
FULL CONFIDENCE when every QA/acceptance criterion and every meaningful matrix row is automated, manually proven, or explicitly redundant; all affected local suites pass; linked frontend/backend services are exercised when the task crosses that boundary; and PR/MR evidence is attached when requested.FULL CONFIDENCE. State the exact confidence blocker instead.When video evidence is requested:
video: 'on', an env override, or the project's equivalent config.test-results/playwright-report/.artifacts/playwright-videos/gh
when possible, or to the GitLab Merge Request using glab when the repo is
on GitLab.gh extension or helper that uploads files as GitHub user attachments.glab api.GitHub/GitLab note:
gh pr comment posts text and does not reliably upload local files by itself.
If a helper such as gh image is available, use it to upload videos and extract the raw uploaded video URL from the returned markdown.
Upload every safe relevant video. If any video cannot be uploaded, report that specific file path, the upload command attempted, and the exact blocker.
Every video must have a short proof description immediately before the video. Use the format This video is proof that ... and describe the specific behavior shown, not a vague label like "E2E proof".
For GitHub, the comment must use the exact format that renders uploaded videos:
a raw https://github.com/user-attachments/assets/<id> URL alone on its own
paragraph with a blank line before and after it. Do not wrap GitHub
user-attachment video URLs in markdown image/link syntax. Example:
This video is proof that the school Camp Day Report excludes the regular scheduled student who has no final camp-day signup.
https://github.com/user-attachments/assets/9d67afa2-81f8-4aa1-9ca2-173a81b63d56
This video is proof that the report error state renders after a bounded 500 retry sequence.
https://github.com/user-attachments/assets/15b4d394-a607-4fb0-8417-50f3dc0b0c57
For GitLab, prefer .mp4 files because GitLab Markdown can render uploaded MP4 video attachments inline. Convert Playwright .webm output to .mp4 with a browser-compatible codec before upload:
mkdir -p .artifacts/playwright-mp4
ffmpeg -y -i .artifacts/playwright-videos/example.webm \
-c:v libx264 -pix_fmt yuv420p -movflags +faststart -an \
.artifacts/playwright-mp4/example.mp4
Upload each MP4 to the GitLab project with the Markdown Uploads API via glab. Use the project placeholder :id from inside the target repo, or pass an explicit project id/path when needed:
glab api -X POST projects/:id/uploads --form "file=@.artifacts/playwright-mp4/example.mp4"
In GitLab MR comments, paste the exact markdown field returned by the upload response immediately after its proof description. This exact field is required because it is the format GitLab renders inline. Example:
This video is proof that the school Camp Day Report CSV export contains only final camp-day signup students.

Do not manually build GitLab upload URLs from url, full_path, project ids, or repository paths. Manually constructed upload links often 404 or fail to render inline.
Do not commit videos into the repository for evidence. Keep them in local artifact directories such as .artifacts/playwright-videos/ and .artifacts/playwright-mp4/, upload them, and leave those artifact directories untracked.
After posting GitLab video evidence, re-read the MR note with glab api projects/:id/merge_requests/<iid>/notes/<note_id> and confirm it contains .mp4 upload markdown using /uploads/..., not /raw/..., /-/project/..., or committed artifact paths.
Also confirm each video markdown/link is preceded by a This video is proof that ... sentence explaining the exact behavior proven by that video.
For GitHub, re-read the PR comment with gh or gh api and confirm each
uploaded video appears as a raw https://github.com/user-attachments/assets/...
URL on its own paragraph, not a Markdown link, image, local path, or committed
artifact path.
Do not finish while a safe relevant video is only local and not uploaded, unless upload is blocked. If blocked, report that video as a blocker or limitation with the attempted command and exact error.
Do not promise inline video player rendering if the host changes behavior, but use each platform's expected format: raw uploaded URL for GitHub user attachments, exact Markdown Uploads API markdown for GitLab.
getByRole, getByLabel, getByText, and stable data-testid selectors.page.waitForTimeout.Report results in this order:
AUTOMATED, MANUAL_PROOF, REDUNDANT, and NOT_COVERED rowsIf blocked, report: