Skip to content

ENG-217: Add Playwright E2E testing skill for Copilot#16480

Closed
nihal467 wants to merge 12 commits into
developfrom
ENG-217/playwright-skill
Closed

ENG-217: Add Playwright E2E testing skill for Copilot#16480
nihal467 wants to merge 12 commits into
developfrom
ENG-217/playwright-skill

Conversation

@nihal467

@nihal467 nihal467 commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

Adds a Copilot Playwright skill at .github/skills/playwright/SKILL.md — a single reference for writing E2E tests in CARE.

Contents

  • When to use E2E vs unit/component tests
  • Setup, run, debug, and report commands
  • File organization (mirror routes, camelCase)
  • 18 critical rules (deterministic fixture IDs, authenticated storageState, no .skip(), no random selection from lists, faker for created data, etc.)
  • Form-testing checklist
  • Patterns: Radix portal combobox, cascading combobox guard, Promise.all listener-before-action ordering, API setup via beforeEach with fail-fast, multi-role tests with try/finally context cleanup, file uploads with real fixtures, delete with double-confirm

Closes

ENG-217

@nihal467 nihal467 requested review from a team and Copilot June 25, 2026 07:31
@nihal467 nihal467 self-assigned this Jun 25, 2026
@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit d85a708
🔍 Latest deploy log https://app.netlify.com/projects/care-ohc/deploys/6a3cec1d72e2c000082a59ab
😎 Deploy Preview https://deploy-preview-16480.preview.ohc.network
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown

⚠️ Merge Checklist Incomplete

Thank you for your contribution! To help us review your PR efficiently, please complete the merge checklist in your PR description.

Your PR will be reviewed once you have marked the appropriate checklist items.

To update the checklist:

  • Change - [ ] to - [x] for completed items
  • Only check items that are relevant to your PR
  • Leave items unchecked if they don't apply

The checklist helps ensure code quality, testing coverage, and documentation are properly addressed.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a Playwright skill document for CARE that covers E2E scope, setup and run commands, test layout and naming, execution rules, debugging patterns, advanced interaction techniques, and test independence guidance.

Changes

Playwright skill documentation

Layer / File(s) Summary
Scope and setup
.github/skills/playwright/SKILL.md
Defines the skill metadata, when to use Playwright E2E tests, how to install and run them, and where to read the shared project reference guide.
Structure and conventions
.github/skills/playwright/SKILL.md
Specifies the required navigation-mirroring folder structure, naming conventions, canonical test structure, and role-based storage states.
Rules and checklists
.github/skills/playwright/SKILL.md
Lists shared helpers, stable-test rules, senior QA guidance, and the form-testing checklist.
Debugging and advanced patterns
.github/skills/playwright/SKILL.md
Adds failure triage guidance, selector and interaction patterns, upload and destructive-action examples, and network mocking patterns.
Independence rules
.github/skills/playwright/SKILL.md
Defines multi-user role testing, test independence expectations, and encounter-limit handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is on-topic and useful, but it does not follow the required template sections or merge checklist. Add the Proposed Changes section with issue reference, include the tagging line, and complete the Merge Checklist items from the template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the added Playwright E2E skill for Copilot and matches the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ENG-217/playwright-skill

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

🎭 Playwright Test Results

Status: ⏭️ Skipped

No test-related files were changed in this PR.

Tests are skipped when changes don't affect:

  • tests/**
  • src/**
  • package.json
  • playwright.config.ts

Run: #9774

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: d85a708
Status: ✅  Deploy successful!
Preview URL: https://4ed273af.care-preview-a7w.pages.dev
Branch Preview URL: https://eng-217-playwright-skill.care-preview-a7w.pages.dev

View logs

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a new Copilot Playwright skill at .github/skills/playwright/SKILL.md to standardise E2E test authoring across CARE contributors.

  • Defines file-organisation conventions, 18 critical rules (faker usage, deterministic fixture IDs, no custom data-testid, flakiness avoidance, etc.), and a form-testing checklist.
  • Provides copy-safe code patterns for common scenarios: API-response verification, cascading comboboxes, multi-role workflows, network mocking, and eventually-consistent assertions — all previously-flagged issues in these patterns have been corrected.

Confidence Score: 5/5

This is a documentation-only change adding a Copilot skill guide; it ships no runnable application code and cannot break the product.

All previously-reviewed code-example bugs (toPass callback, infinite combobox loop, portal-scoped option query, missing facilityId) have been fixed. The only remaining note is a hardcoded name string in an API-setup snippet that contradicts the skill's own faker rule, but this does not affect production behaviour.

No files require special attention.

Important Files Changed

Filename Overview
.github/skills/playwright/SKILL.md New Copilot skill document for Playwright E2E testing; content is well-structured and the previously-flagged issues (toPass pattern, cascading combobox loop, portal scoping, facilityId reference) have all been addressed. One minor example inconsistency: hardcoded entity name in the Direct API Calls snippet contradicts Rule 1.

Reviews (10): Last reviewed commit: "docs: invoke API setup helper inside bef..." | Re-trigger Greptile

Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new GitHub Copilot skill (playwright) intended to guide contributors (and agents) in writing, debugging, and running Playwright E2E tests for the CARE frontend, including conventions, rules, and copy/paste patterns.

Changes:

  • Adds a comprehensive Playwright E2E testing skill document with setup commands, organization conventions, and rules.
  • Provides reusable patterns for API verification, selectors, form testing, flakiness triage, and multi-role workflows.

Comment thread .github/skills/playwright/SKILL.md Outdated
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md Outdated

@nihal467 nihal467 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the AI review comments in follow-up commit 0938810.

What was updated in .github/skills/playwright/SKILL.md:

  • Clarified faker rule to allow fixture-backed constants for known values.
  • Made serial example align with repo style using test.describe.configure({ mode: "serial" }).
  • Fixed undefined placeholders in copy/paste snippets:
    • Added getFacilityId() usage in direct API setup and multi-role examples.
    • Defined scope in the data-slot command-input snippet.
  • Fixed expect.toPass() pattern to use expect(...).toBeVisible() so retries work correctly.
  • Added iteration guard (MAX_CASCADES) to cascading-combobox pattern to prevent infinite loops.
  • Updated file upload example to real fixture paths that exist in repo.
  • Updated “Keep Tests Independent” wording to match serial configuration style.

Thanks for the review — these were good catches and are now reflected in the doc.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/skills/playwright/SKILL.md:
- Line 190: Remove the self-edit guidance from the Playwright skill text in
SKILL.md: the “Continuously improve this skill” item should not tell the agent
to update its own instruction file during normal use. Edit that section to keep
improvement suggestions external, and make the wording in the skill’s numbered
guidance explicit that updates to SKILL.md must come through a separate
human-reviewed PR or maintainer-approved process rather than self-modification.
- Around line 173-185: Update the Playwright skill guidance to narrow the
`faker` recommendation: the current rule in the skills doc overstates “always
use faker,” which conflicts with deterministic assertions and the existing
constants guidance. Revise the bullet tied to `faker` so it says to use `faker`
only for generated inputs where the exact value does not matter, while keeping
fixed literals/constants for cases that need stable assertions; adjust the
wording in the same section alongside the deterministic fixture ID and constants
rules for consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5d4c0332-d07b-4b2f-9bb2-7061b7820160

📥 Commits

Reviewing files that changed from the base of the PR and between f8a2f09 and a598fc5.

📒 Files selected for processing (1)
  • .github/skills/playwright/SKILL.md

Comment thread .github/skills/playwright/SKILL.md Outdated
Comment thread .github/skills/playwright/SKILL.md Outdated
Comment thread .github/skills/playwright/SKILL.md Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/skills/playwright/SKILL.md (1)

190-190: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Remove the self-edit instruction.

Still present: this tells the agent to update SKILL.md from within the skill itself, recreating the self-modification risk flagged earlier. Keep updates external and human-reviewed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/skills/playwright/SKILL.md at line 190, Remove the self-edit
guidance from the Playwright skill instructions in SKILL.md so the skill no
longer tells the agent to update itself; specifically, delete the “Continuously
improve this skill” item and keep any future skill updates outside the skill
file, with human review. Preserve the rest of the Playwright workflow content
unchanged.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/skills/playwright/SKILL.md:
- Around line 399-405: The option lookup in the cascade loop is scoped
incorrectly: `combobox.getByRole("option")` only searches inside the combobox
subtree and can miss the popup. Update the `MAX_CASCADES` iteration logic in the
`comboboxes` loop to click the combobox and then query the opened `listbox` for
the option, using the existing `region.getByRole("combobox")` flow and replacing
the option search on the `combobox` with a popup-scoped query.

---

Duplicate comments:
In @.github/skills/playwright/SKILL.md:
- Line 190: Remove the self-edit guidance from the Playwright skill instructions
in SKILL.md so the skill no longer tells the agent to update itself;
specifically, delete the “Continuously improve this skill” item and keep any
future skill updates outside the skill file, with human review. Preserve the
rest of the Playwright workflow content unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 470207b6-8d2e-481c-a978-464d0e317a51

📥 Commits

Reviewing files that changed from the base of the PR and between a598fc5 and 0938810.

📒 Files selected for processing (1)
  • .github/skills/playwright/SKILL.md

Comment thread .github/skills/playwright/SKILL.md Outdated
Copilot AI review requested due to automatic review settings June 25, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.

Comment thread .github/skills/playwright/SKILL.md Outdated
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Copilot AI review requested due to automatic review settings June 25, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread .github/skills/playwright/SKILL.md Outdated
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/skills/playwright/SKILL.md:
- Around line 336-345: The createAccountViaApi helper currently returns parsed
JSON without verifying the fetch result, so failed setup calls can be mistaken
for valid data. Update createAccountViaApi to inspect the Response before
calling res.json(), and fail immediately on non-OK responses with a clear error
that includes the status and any response text. Keep the check localized to
createAccountViaApi so the setup path in SKILL.md cannot continue with bad seed
data.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 751cdc75-2a04-4068-874c-86384bd32af3

📥 Commits

Reviewing files that changed from the base of the PR and between ba08dcf and b58c422.

📒 Files selected for processing (1)
  • .github/skills/playwright/SKILL.md

Comment thread .github/skills/playwright/SKILL.md
Copilot AI review requested due to automatic review settings June 25, 2026 08:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread .github/skills/playwright/SKILL.md Outdated
Copilot AI review requested due to automatic review settings June 25, 2026 08:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread .github/skills/playwright/SKILL.md
Comment thread .github/skills/playwright/SKILL.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/skills/playwright/SKILL.md (1)

525-558: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Close the contexts in finally.

If any step/assertion throws, both adminContext.close() and nurseContext.close() are skipped, which can leave browser contexts hanging and make later tests flaky.

♻️ Proposed fix
 test("Admin assigns task, nurse sees it", async ({ browser }) => {
   const facilityId = getFacilityId();
 
   // Admin context
   const adminContext = await browser.newContext({
     storageState: "tests/.auth/user.json",
   });
-  const adminPage = await adminContext.newPage();
-
-  await test.step("Admin creates assignment", async () => {
-    await adminPage.goto(`/facility/${facilityId}/...`);
-    // ... admin actions
-  });
-  await adminContext.close();
+  try {
+    const adminPage = await adminContext.newPage();
+    await test.step("Admin creates assignment", async () => {
+      await adminPage.goto(`/facility/${facilityId}/...`);
+      // ... admin actions
+    });
+  } finally {
+    await adminContext.close();
+  }
 
   // Nurse context
   const nurseContext = await browser.newContext({
     storageState: "tests/.auth/nurse.json",
   });
-  const nursePage = await nurseContext.newPage();
-
-  await test.step("Nurse verifies assignment", async () => {
-    await nursePage.goto(`/facility/${facilityId}/...`);
-    await expect(nursePage.getByText("Assigned Task")).toBeVisible();
-  });
-  await nurseContext.close();
+  try {
+    const nursePage = await nurseContext.newPage();
+    await test.step("Nurse verifies assignment", async () => {
+      await nursePage.goto(`/facility/${facilityId}/...`);
+      await expect(nursePage.getByText("Assigned Task")).toBeVisible();
+    });
+  } finally {
+    await nurseContext.close();
+  }
 });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/skills/playwright/SKILL.md around lines 525 - 558, The multi-user
Playwright example leaves adminContext and nurseContext open if any step fails,
because the close calls happen after the assertions. Wrap the admin and nurse
context usage in try/finally blocks (or a single outer finally) so both browser
contexts are always closed even when a step in the test using
browser.newContext(), adminPage, or nursePage throws.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In @.github/skills/playwright/SKILL.md:
- Around line 525-558: The multi-user Playwright example leaves adminContext and
nurseContext open if any step fails, because the close calls happen after the
assertions. Wrap the admin and nurse context usage in try/finally blocks (or a
single outer finally) so both browser contexts are always closed even when a
step in the test using browser.newContext(), adminPage, or nursePage throws.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1f0827a0-7c8d-4a59-9840-ce7becc44977

📥 Commits

Reviewing files that changed from the base of the PR and between b58c422 and c4bdbdf.

📒 Files selected for processing (1)
  • .github/skills/playwright/SKILL.md

Copilot AI review requested due to automatic review settings June 25, 2026 08:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread .github/skills/playwright/SKILL.md Outdated
@nihal467

Copy link
Copy Markdown
Member Author

Relocated this skill to the central skills repo: ohcnetwork/skills#2

This PR is left open for now in case we want the skill auto-loaded from care_fe/.github/skills/playwright/SKILL.md (VS Code Copilot picks it up from the workspace). Close whichever path the team prefers.

@nihal467 nihal467 closed this Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants