Skip to content
e2e-role-test logo

E2E Role-Based Testing Skill

e2e-role-test

Execute comprehensive role-based E2E testing with Playwright, testing all user flows for each role

SKILL.md

Full skill instructions

E2E Role-Based Testing Skill

Overview

This skill executes comprehensive role-based E2E testing using Playwright MCP. It tests all pages and flows for each user role, verifying proper access control and role-specific functionality.

Standard Test Plan Location

Plan file: tests/​e2e-test-plan.md

This skill reads role definitions and test credentials from the test plan at tests/​e2e-test-plan.md. If the plan file doesn't exist, the calling command should invoke the e2e-test-plan skill first to generate it.

Purpose

Ensure that:

  • Each user role can access appropriate resources
  • Unauthorized access is properly blocked
  • Role-specific features work correctly
  • Cross-role security is maintained

Workflow

Step 0: Test Plan Verification (REQUIRED FIRST)

CRITICAL: Before testing roles, verify the test plan exists.

  1. Check for Test Plan

    • Look for tests/​e2e-test-plan.md
    • If the file exists, read the "User Roles" and "Test Credentials" sections
    • If the file does NOT exist, STOP and report that the plan must be generated first
  2. Read Role Information from Plan

    • Extract role names and descriptions
    • Extract test credentials for each role
    • Extract role-resource access matrix
    • Use this information for testing

Step 1: Prepare Role Testing

  1. Identify All Roles

    • List all user roles in the system
    • Note the role hierarchy
    • Map permissions per role
  2. Prepare Test Users

    • Identify login credentials for each role
    • Ensure test users exist
    • Note any role-switching mechanisms
  3. Map Role-Resource Matrix

    | Resource | Guest | User | Admin |
    |----------|-------|------|-------|
    | /​home | Yes | Yes | Yes |
    | /​dashboard | No | Yes | Yes |
    | /​admin | No | No | Yes |
    

Step 2: Guest Role Testing

Test unauthenticated access:

  1. Public Pages

    browser_navigate to each public page
    browser_snapshot to verify content
    Confirm: Page loads correctly
    
  2. Protected Page Blocking

    browser_navigate to protected page
    browser_snapshot to check result
    Confirm: Redirect to login OR 403 page
    
  3. Guest-Specific Features

    Test: Registration form accessible
    Test: Login form accessible
    Test: Password reset accessible
    

Step 3: Authenticated Role Testing

For EACH authenticated role:

  1. Login as Role

    browser_navigate to /​login
    browser_fill_form with role credentials:
      - fields: [
          { name: "Email", type: "textbox", ref: "[email-input-ref]", value: "[email protected]" },
          { name: "Password", type: "textbox", ref: "[password-input-ref]", value: "password" }
        ]
    browser_click on submit button
    browser_wait_for dashboard or success indicator
    browser_snapshot to verify logged in
    
  2. Test Accessible Pages

    For each page this role SHOULD access:
      browser_navigate to page URL
      browser_snapshot
      browser_console_messages to check for errors
      Verify: Page content loads correctly
      Verify: Role-specific elements present
    
  3. Test Blocked Pages

    For each page this role should NOT access:
      browser_navigate to page URL
      browser_snapshot
      Verify: 403 error OR redirect occurs
      Verify: No unauthorized data exposed
    
  4. Test Role-Specific Actions

    For each action this role can perform:
      Navigate to action page
      Perform the action
      Verify success
    
    For each action this role CANNOT perform:
      Attempt the action
      Verify it's blocked
    
  5. Logout

    browser_click logout button
    browser_wait_for login page
    browser_snapshot to confirm logged out
    

Step 4: Role-Specific Flow Testing

User Role Flows
## User Role Tests

### Profile Management
1. Navigate to /​profile
2. Verify can view own profile
3. Edit profile information
4. Save changes
5. Verify changes persisted

### Data Access
1. Navigate to /​my-data
2. Verify can see own data only
3. Cannot see other users' data
4. Can create new data
5. Can edit own data
6. Can delete own data

### Restricted Areas
1. Cannot access /​admin
2. Cannot access /​admin/​users
3. Cannot modify other users
Admin Role Flows
## Admin Role Tests

### User Management
1. Navigate to /​admin/​users
2. View all users list
3. Create new user
4. Edit existing user
5. Delete user (not self)
6. Change user roles

### System Settings
1. Access settings page
2. Modify configurations
3. Save changes
4. Verify persistence

### Admin-Only Features
1. Access reports
2. View audit logs
3. Manage permissions

Step 5: Cross-Role Security Tests

  1. Session Hijacking Prevention

    Login as User A
    Copy session info
    Try to access User B data
    Verify: Access denied
    
  2. Privilege Escalation Prevention

    Login as regular user
    Attempt admin actions directly
    Verify: Actions blocked
    
  3. IDOR Testing

    Login as User A
    Note resource ID
    Try accessing other user's resource by ID
    Verify: Access denied or own data shown
    

Test Patterns

Role Login Pattern

// Using Playwright MCP tools
async function loginAsRole(role, credentials) {
  // Navigate to login
  browser_navigate({ url: "/​login" });

  // Fill login form
  browser_fill_form({
    fields: [
      { name: "Email", type: "textbox", ref: "[email-ref]", value: credentials.email },
      { name: "Password", type: "textbox", ref: "[password-ref]", value: credentials.password }
    ]
  });

  // Submit
  browser_click({ element: "Login button", ref: "[submit-ref]" });

  // Wait for dashboard
  browser_wait_for({ text: "Dashboard" });

  // Verify
  browser_snapshot();
}

Access Verification Pattern

async function verifyAccess(url, shouldHaveAccess) {
  browser_navigate({ url });
  const snapshot = browser_snapshot();

  if (shouldHaveAccess) {
    // Should see page content
    verify(snapshot.contains(expectedContent));
  } else {
    // Should see 403 or redirect
    verify(snapshot.contains("Access Denied") || currentUrl === "/​login");
  }
}

Role Matrix Test Pattern

const roleMatrix = {
  guest: {
    canAccess: ["/", "/​about", "/​login", "/​register"],
    cannotAccess: ["/​dashboard", "/​profile", "/​admin"]
  },
  user: {
    canAccess: ["/", "/​about", "/​dashboard", "/​profile"],
    cannotAccess: ["/​admin", "/​admin/​users"]
  },
  admin: {
    canAccess: ["/", "/​about", "/​dashboard", "/​profile", "/​admin", "/​admin/​users"],
    cannotAccess: []
  }
};

for (const [role, permissions] of Object.entries(roleMatrix)) {
  loginAsRole(role);

  for (const url of permissions.canAccess) {
    verifyAccess(url, true);
  }

  for (const url of permissions.cannotAccess) {
    verifyAccess(url, false);
  }

  logout();
}

Output Format

Role Test Results

# Role-Based Test Results

## Guest Role
### Accessible Pages
- [x] Home (/) - Passed
- [x] About (/​about) - Passed
- [x] Login (/​login) - Passed
- [x] Register (/​register) - Passed

### Blocked Pages
- [x] Dashboard (/​dashboard) - Correctly redirects to /​login
- [x] Profile (/​profile) - Correctly redirects to /​login
- [x] Admin (/​admin) - Correctly redirects to /​login

## User Role ([email protected])
### Login
- [x] Can login successfully
- [x] Redirected to dashboard

### Accessible Pages
- [x] Dashboard (/​dashboard) - Passed
- [x] Profile (/​profile) - Passed
- [x] Settings (/​settings) - Passed

### Blocked Pages
- [x] Admin (/​admin) - Correctly shows 403
- [x] User Management (/​admin/​users) - Correctly shows 403

### Role-Specific Actions
- [x] Can edit own profile
- [x] Can view own data
- [x] Cannot view other users' data
- [x] Cannot access admin features

### Logout
- [x] Logout successful

## Admin Role ([email protected])
### Login
- [x] Can login successfully
- [x] Redirected to admin dashboard

### Full Access
- [x] All pages accessible
- [x] Can manage users
- [x] Can access settings
- [x] Can view reports

### Admin Actions
- [x] Can create users
- [x] Can edit users
- [x] Can delete users
- [x] Can change roles

## Security Tests
- [x] Session isolation verified
- [x] No privilege escalation possible
- [x] IDOR protection verified

## Summary
| Role | Pages Tested | Passed | Failed |
|------|--------------|--------|--------|
| Guest | 7 | 7 | 0 |
| User | 10 | 10 | 0 |
| Admin | 15 | 15 | 0 |

Total: 32 tests, 32 passed, 0 failed

Best Practices

  1. Test Every Role - Never skip a role
  2. Test Both Access and Denial - Verify can AND cannot access
  3. Clean Session Between Roles - Logout before testing next role
  4. Document Credentials - Keep test credentials in the plan
  5. Check Console Errors - Look for JavaScript errors on each page
  6. Verify Visual Elements - Use snapshots to verify content
  7. Test Edge Cases - Empty states, large data, etc.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View