Skip to content

Feature Request: Multi-Actor Test Support for Concurrent User Sessions #991

Open

Description

@syntaxsdev

Preface

I am willing to build this. Wondering if the community is enticed or open about it.

Problem

When testing modern web applications with social/collaborative features, tests often require multiple authenticated users interacting with each other. For example:

  • User A sends a message to User B
  • User B checks their inbox and sees User A's message
  • User B replies
  • User A receives the reply notification

Currently, Tavern's stage-based execution model assumes a single authentication context per test. While you can technically swap headers between stages, this approach is awkward and doesn't scale well for complex multi-user scenarios.

Proposed Solution

Introduce an actors concept that allows defining multiple authenticated contexts:

  actors:                                                                                                                                                                                                                                                                                                            
    user_a:                                                                                                                                                                                                                                                                                                          
      headers:                                                                                                                                                                                                                                                                                                       
        Authorization: "Bearer {user_a_token}"                                                                                                                                                                                                                                                                       
    user_b:                                                                                                                                                                                                                                                                                                          
      headers:                                                                                                                                                                                                                                                                                                       
        Authorization: "Bearer {user_b_token}"                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                     
  stages:                                                                                                                                                                                                                                                                                                            
    - name: User A sends message                                                                                                                                                                                                                                                                                     
      actor: user_a                                                                                                                                                                                                                                                                                                  
      request:                                                                                                                                                                                                                                                                                                       
        url: "{base_url}/messaging/send"                                                                                                                                                                                                                                                                             
        method: POST                                                                                                                                                                                                                                                                                                 
        json:                                                                                                                                                                                                                                                                                                        
          to: !actor user_b.id                                                                                                                                                                                                                                                                                       
          body: "Hello"                                                                                                                                                                                                                                                                                              
      response:                                                                                                                                                                                                                                                                                                      
        status_code: 200                                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                     
    - name: User B checks inbox                                                                                                                                                                                                                                                                                      
      actor: user_b                                                                                                                                                                                                                                                                                                  
      request:                                                                                                                                                                                                                                                                                                       
        url: "{base_url}/messaging/inbox"                                                                                                                                                                                                                                                                            
        method: GET                                                                                                                                                                                                                                                                                                  
      response:                                                                                                                                                                                                                                                                                                      
        status_code: 200                                                                                                                                                                                                                                                                                             
        json:                                                                                                                                                                                                                                                                                                        
          messages:                                                                                                                                                                                                                                                                                                  
            - from: !actor user_a.id                                                                                                                                                                                                                                                                                 

Key Benefits

  1. Clarity because each stage explicitly declares which actor performs the action
  2. Maintainability because actor credentials defined once, referenced everywhere
  3. Could later support parallel stage execution for true concurrency testing

Use Cases This Would Enable

  • Messaging/chat applications
  • Marketplace transactions (buyer/seller flows)
  • Social features (follow/unfollow, likes, comments)
  • Collaborative editing
  • Permission/visibility testing

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions