Real Holochain Data Strategy for E2E Testing

Overview

This document outlines the comprehensive strategy for getting real Holochain data in E2E tests, moving away from mocked data to test against actual Holochain DNA operations.

Strategy Components

1. Multi-Layered Data Seeding Architecture

Level 1: Infrastructure Data

  • Service Types: 8 realistic categories (Web Development, Graphic Design, Marketing, etc.)
  • Mediums of Exchange: 8 exchange types (USD, EUR, Pay it Forward, Skill Exchange, etc.)
  • Admin Users: Network administrators for service type approval and system management

Level 2: User Ecosystem Data

  • 25 Diverse Users: Different roles (advocates/creators), skills, locations, time zones
  • 8 Organizations: Various membership structures and purposes
  • User-Organization Relationships: Realistic coordinator and member relationships

Level 3: Marketplace Data

  • 15 Realistic Requests: Properly linked to service types and mediums of exchange
  • 20 Realistic Offers: Matching ecosystem needs with proper relationships
  • Cross-references: Proper linking between all entities

2. Implementation Architecture

ui/tests/e2e/
├── fixtures/
│   ├── realistic-data-generator.ts    # Faker.js-powered data generation
│   └── holochain-data-seeder.ts       # Holochain DNA seeding service
├── utils/
│   └── holochain-setup.ts             # Enhanced conductor management
└── specs/
    └── user-journeys/
        └── complete-offer-request-flow.spec.ts  # Example E2E test

Key Features

Realistic Data Generation

  • Faker.js Integration: Generates realistic names, emails, locations, companies
  • Skill-Based Relationships: Users have relevant skills for their service offerings
  • Geographic Diversity: Users from different time zones and locations worldwide
  • Realistic Business Data: Organizations with proper email domains, URLs, descriptions
  • Edge Case Coverage: Various data combinations for thorough testing

Holochain Integration

  • Isolated Conductor Instances: Each test suite gets a fresh conductor
  • Proper DNA Seeding: Data is created through actual Holochain zome calls
  • Real Relationships: Service types, mediums of exchange properly linked to offers/requests
  • Admin Workflow: Admin users created first to approve service types
  • Dependency Management: Data seeded in proper order (admins → service types → users → offers/requests)

Test Infrastructure

  • Enhanced Setup: HolochainE2ESetup class manages conductor lifecycle
  • Data Seeding Service: HolochainDataSeeder populates DNA with realistic data
  • Test Isolation: Each test suite starts with clean state
  • Helper Functions: Easy access to seeded data for test assertions

Usage Examples

Basic Test Setup

test.describe("Real Holochain Data Tests", () => {
  let seededData: SeededData;

  test.beforeAll(async () => {
    const setup = await setupGlobalHolochain();
    seededData = setup.seededData;
  });

  test.afterAll(async () => {
    await cleanupGlobalHolochain();
  });

  test("can browse real offers", async ({ page }) => {
    await page.goto("/offers");

    // Verify real offers are displayed
    await expect(page.locator('[data-testid="offer-card"]')).toHaveCount(
      seededData.offers.length,
    );

    // Test with actual seeded data
    const firstOffer = seededData.offers[0];
    await expect(page.locator(`text=${firstOffer.data.title}`)).toBeVisible();
  });
});

Testing Data Relationships

test("service type filtering works with real data", async ({ page }) => {
  const webDevServiceType = seededData.serviceTypes.find(
    (st) => st.data.name === "Web Development",
  );

  await page.click(`text=${webDevServiceType.data.name}`);

  // Verify only offers linked to this service type are shown
  const linkedOffers = seededData.offers.filter((offer) =>
    offer.serviceTypeHashes.includes(webDevServiceType.actionHash),
  );

  await expect(page.locator('[data-testid="offer-card"]')).toHaveCount(
    linkedOffers.length,
  );
});

Benefits

1. Real Data Validation

  • Tests actual Holochain DNA operations, not mocks
  • Validates real data relationships and constraints
  • Catches integration issues between frontend and Holochain

2. Comprehensive Coverage

  • Tests complete user journeys with realistic data
  • Validates search, filtering, and relationship functionality
  • Covers admin workflows and permissions

3. Maintainable Tests

  • Centralized data generation and seeding
  • Easy to add new test scenarios
  • Clear separation between data setup and test logic

4. CI/CD Ready

  • Isolated test environments
  • Proper cleanup and teardown
  • Configurable for different environments

Configuration

Playwright Configuration

export default defineConfig({
  testDir: "./tests/e2e",
  fullyParallel: false, // Disable for Holochain
  workers: 1, // Single worker to avoid conflicts
  timeout: 60000, // Increased for Holochain operations
  // ... other config
});

Package.json Scripts

{
  "scripts": {
    "test:e2e:holochain": "cross-env UI_PORT=5173 TAURI_DEV=true playwright test tests/e2e/specs",
    "test:e2e:holochain:debug": "cross-env UI_PORT=5173 TAURI_DEV=true playwright test tests/e2e/specs --debug"
  }
}

Running the Tests

Development

# Run E2E tests with real Holochain data
bun run test:e2e:holochain

# Debug mode
bun run test:e2e:holochain:debug

# UI mode for interactive debugging
bun run test:e2e:ui

CI/CD Integration

The tests are designed to run in CI environments with:

  • Proper timeout configurations
  • Single worker execution
  • Comprehensive cleanup
  • JUnit reporting for integration

Data Seeding Details

Generated Data Volumes

  • 25 Users: Mix of advocates and creators with diverse skills
  • 8 Organizations: Different industries and sizes
  • 8 Service Types: Major service categories with tags
  • 8 Mediums of Exchange: Traditional and alternative currencies
  • 15 Requests: Realistic needs with proper linkage
  • 20 Offers: Services matching the ecosystem

Data Quality Features

  • Realistic Names: Generated using faker.js
  • Valid Emails: Proper domain structures
  • Geographic Diversity: Multiple time zones and locations
  • Skill Matching: Users have relevant skills for their offerings
  • Business Logic: Proper relationships between entities

Future Enhancements

  1. Performance Testing: Add load testing with large datasets
  2. Multi-Agent Testing: Test with multiple concurrent users
  3. Organization Workflows: Enhanced organization management testing
  4. Advanced Search: Complex search and filtering scenarios
  5. Real-time Updates: Test live data updates and synchronization

Conclusion

This strategy provides a robust foundation for E2E testing with real Holochain data, ensuring that tests validate actual system behavior rather than mocked interactions. The comprehensive data seeding approach creates realistic test scenarios that closely mirror production usage patterns.