Skip to content

MongoDB Infrastructure: Future Work Plan

Overview

This document consolidates future work items for the MongoDB Testing Infrastructure feature that are explicitly deferred to follow-up PRs. These items enhance but are not required for the core functionality delivered in PR #2234.

Related Documentation:


Summary of Deferred Work Items

Work Item Effort Priority Source Documentation
E2E Test Suite 5-8 days Medium technical-plan.md#phase-5
Environment UI Indicator 2-3 days Medium seed-data-quality-analysis.md#part-10
Database Switching for Previews 3-5 days Low seed-data-quality-analysis.md#part-11
Migration Framework 3-5 days Low technical-plan.md#phase-4

Work Item 1: E2E Test Suite

Goal

Create end-to-end tests that validate the complete user workflow from login through data export, running against staging or preview environments.

Scope

Category Tests to Include
Authentication Login flow, session handling, logout
Project Management Create project, add members, configure stages
Search Upload Upload references, monitor progress, view results
Screening Screen studies, bulk decisions, agreement calculation
Annotation Create questions, annotate studies, export data
Data Export Generate exports, download files

Technical Approach

┌──────────────────────────────────────────────────────────────────┐
│                     E2E Testing Architecture                      │
├──────────────────────────────────────────────────────────────────┤
│                                                                   │
│  ┌─────────────────┐     ┌─────────────────────────────────────┐ │
│  │   Playwright    │────▶│  Staging/Preview Environment        │ │
│  │   Test Suite    │     │  (syrf_staging or syrf_pr_N)        │ │
│  └─────────────────┘     └─────────────────────────────────────┘ │
│         │                               │                         │
│         │                               │                         │
│  ┌──────▼──────────┐           ┌────────▼────────────────────┐   │
│  │ Test Data       │           │ Seeded Database             │   │
│  │ Assertions      │           │ - Known investigator        │   │
│  └─────────────────┘           │ - Known project             │   │
│                                │ - Known studies             │   │
│                                └─────────────────────────────┘   │
└──────────────────────────────────────────────────────────────────┘

Test Categories

// Test trait for filtering
[Trait("Category", "E2E")]
[Trait("Environment", "Staging")]
public class ProjectWorkflowE2ETests { }

Implementation Steps

  1. Set up Playwright project (1 day)
  2. Add Playwright package to solution
  3. Configure test project with proper authentication
  4. Set up CI workflow job for E2E tests

  5. Authentication tests (1 day)

  6. Login with seeded test user
  7. Session persistence
  8. Logout and re-login

  9. Core workflow tests (3-4 days)

  10. Project creation and configuration
  11. Search upload and monitoring
  12. Study screening workflow
  13. Annotation and data export

  14. CI Integration (1 day)

  15. Add E2E job to pr-tests.yml (optional, on-demand)
  16. Run against staging nightly
  17. Report generation

CI Workflow Addition

# .github/workflows/e2e-tests.yml
name: E2E Tests

on:
  schedule:
    - cron: '0 4 * * *'  # Nightly at 4am
  workflow_dispatch:
    inputs:
      environment:
        description: 'Target environment'
        required: true
        default: 'staging'
        type: choice
        options:
          - staging
          - pr-preview

jobs:
  e2e-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install Playwright
        run: npx playwright install --with-deps chromium

      - name: Run E2E Tests
        run: npx playwright test
        env:
          BASE_URL: ${{ inputs.environment == 'staging' && 'https://staging.syrf.org.uk' || format('https://pr-{0}.syrf.org.uk', github.event.inputs.pr_number) }}
          TEST_USER_EMAIL: ${{ secrets.E2E_TEST_USER_EMAIL }}
          TEST_USER_PASSWORD: ${{ secrets.E2E_TEST_USER_PASSWORD }}

      - name: Upload Test Results
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: playwright-report
          path: playwright-report/

Seed Data Requirements

E2E tests require predictable data. The DatabaseSeeder already creates:

Entity Seed ID Purpose
Investigator SeedDataConstants.InvestigatorId Login user for E2E
Project SeedDataConstants.ProjectId Target project
Studies Deterministic IDs Screening/annotation targets

Auth0 Requirement: Create a test user in Auth0 with known credentials for E2E login.


Work Item 2: Environment UI Indicator

Goal

Provide clear visual indication when users are in non-production environments to prevent confusion between test data and real data.

Design (From seed-data-quality-analysis.md Part 10)

User Experience Flow:

┌─────────────────────────────────────────────────────────────┐
│ First Visit to Non-Production                               │
│                                                              │
│  ┌────────────────────────────────────────────────────────┐ │
│  │ ⚠️ STAGING | Click for environment details            │ │  ◀─ Slim Banner
│  └────────────────────────────────────────────────────────┘ │
│                          │                                   │
│                          ▼ (click)                           │
│  ┌────────────────────────────────────────────────────────┐ │
│  │        Environment Information Dialog                   │ │
│  │  ─────────────────────────────────────────────────────  │ │
│  │  Environment: [STAGING badge]                           │ │
│  │  Database: syrf_staging                                 │ │
│  │  Data Sampled: Dec 27, 2025 3:00 AM                    │ │
│  │  ─────────────────────────────────────────────────────  │ │
│  │  Note: This is not production. Data may be reset.      │ │
│  │                                                         │ │
│  │  [Keep Banner Visible]  [Dismiss & Collapse]           │ │
│  └────────────────────────────────────────────────────────┘ │
│                          │                                   │
│                          ▼ (dismiss)                         │
│                                          ┌───────┐           │
│                                          │ STG ● │           │  ◀─ Minimal Indicator
│                                          └───────┘           │
└─────────────────────────────────────────────────────────────┘

Implementation Steps

  1. Backend API enhancement (0.5 day)
  2. Add databaseName to /api/application/info
  3. Add prNumber for preview environments
  4. Add dataSource with sampling metadata

  5. Environment banner component (1 day)

  6. Create EnvironmentBannerComponent
  7. Implement collapsible behavior with sessionStorage
  8. Style with environment-specific colors

  9. Environment dialog component (0.5 day)

  10. Create EnvironmentDialogComponent
  11. Display database name, PR number, sampling info
  12. Implement dismiss/collapse actions

  13. Integration (0.5 day)

  14. Add to app.component.html
  15. Wire up ConfigService for environment info
  16. Test in all environments

Files to Modify

File Change
ApplicationController.cs Add database name to info endpoint
app.component.html Add banner and compact indicator
app.component.ts Add state management, dialog trigger
app.component.scss Add styles
New: environment-warning-dialog.component.ts Dialog component

Color Scheme

Environment Banner Color Text
Production (not shown) -
Staging #ff9800 (orange) White
Preview #2196f3 (blue) White
Development #e91e63 (pink) White

Work Item 3: Database Switching for Preview Environments

Goal

Allow developers to configure which data source a PR preview uses:

  • Seed only (default): Fast, predictable, minimal
  • Sample production: Real data scenarios, performance testing
  • Hybrid: Seed base + sampled additions

Configuration Approaches

## Description
This PR adds new screening workflow improvements...

## Data Strategy
<!-- syrf-data-config -->
```yaml
data:
  strategy: hybrid           # seed-only | sample-only | hybrid | none
  sampleProjects: 3          # If sampling, how many projects
  includeAnnotations: false  # Include annotation data (slower)
#### Option B: PR Labels (Simpler)

| Label | Strategy | Use Case |
|-------|----------|----------|
| (no label) | `seed-only` | Default - most PRs |
| `data:hybrid` | Seed + sample | Integration testing |
| `data:sample-only` | Production sample | Performance testing |
| `data:sample-large` | Sample 10+ projects | Load testing |

### Implementation Steps

1. **Workflow parsing** (1 day)
   - Parse PR description for YAML config block
   - Fall back to label-based detection
   - Output strategy as workflow variable

2. **Sampling job** (2 days)
   - Create `ProductionSamplingJob` with curated project selection
   - Implement study limit controls
   - Create Kubernetes Job template

3. **Workflow integration** (1 day)
   - Add conditional job for sampling after deployment
   - Implement metadata tracking
   - Update PR status with data strategy

### Architecture

┌──────────────────────────────────────────────────────────────────┐ │ Data Strategy Flow │ ├──────────────────────────────────────────────────────────────────┤ │ │ │ PR Description/Labels │ │ │ │ │ ▼ │ │ ┌─────────────────┐ │ │ │ Parse Strategy │ │ │ └────────┬────────┘ │ │ │ │ │ ┌─────┴─────┬──────────────┬──────────────┐ │ │ ▼ ▼ ▼ ▼ │ │ seed-only sample-only hybrid none │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ │ │ Run Seeder Run Sampler Run Both Empty DB │ │ │ │ │ │ │ └───────────┴──────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ syrf_pr_{number} │ │ │ │ - Seeded data (if seed-only or hybrid) │ │ │ │ - Production sample (if sample-only or hybrid) │ │ │ └─────────────────────────────────────────────────────────────┘ │ └──────────────────────────────────────────────────────────────────┘

### Sampling Limits by Strategy

| Strategy | Max Projects | Max Studies/Project | Include Annotations |
|----------|--------------|--------------------|--------------------|
| `seed-only` | N/A | N/A | From seeder |
| `sample-only` | 5 | 500 | No |
| `hybrid` | 3 | 300 | No |
| `data:sample-large` | 10 | 1000 | Optional |

---

## Work Item 4: Migration Framework

### Goal

Enable safe schema evolution with versioned migrations that run before application startup.

### When Needed

This work is **only needed when**:
- Domain model changes require data transformation
- Field renames, type changes, or restructuring
- Currently no schema changes planned

### Components

1. **MigrationRunner** - Discovers and executes migrations in order
2. **IMigration interface** - Contract for individual migrations
3. **Helm init container** - Runs migrations before app starts
4. **Migration tracking** - Records applied migrations

### Implementation (Deferred)

See [technical-plan.md Phase 4](../features/mongodb-testing-strategy/technical-plan.md) for full specification.

---

## Recommended Implementation Order

┌─────────────────────────────────────────────────────────────────┐ │ Implementation Phases │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ Phase 1: Quick Wins (1-2 weeks after merge) │ │ ────────────────────────────────────────── │ │ • Environment UI Indicator (2-3 days) │ │ - High visibility for users │ │ - Prevents confusion │ │ - Independent of other work │ │ │ │ Phase 2: Testing Confidence (2-4 weeks after merge) │ │ ─────────────────────────────────────────────────── │ │ • E2E Test Suite (5-8 days) │ │ - Validates complete workflows │ │ - Catches integration issues │ │ - Runs nightly against staging │ │ │ │ Phase 3: Advanced Features (As Needed) │ │ ────────────────────────────────────── │ │ • Database Switching (3-5 days) │ │ - Only if seed data proves insufficient │ │ - Performance testing scenarios │ │ │ │ • Migration Framework (3-5 days) │ │ - Only when first schema change needed │ │ - Currently no changes planned │ │ │ └─────────────────────────────────────────────────────────────────┘

```


Decision Log

Date Decision Rationale
2025-12-27 Defer E2E tests to follow-up PR Core infrastructure complete, E2E adds value but not blocking
2025-12-27 Defer environment indicator to follow-up PR Good UX improvement but not critical path
2025-12-27 Defer database switching to as-needed Seed data may be sufficient for most testing
2025-12-27 Defer migration framework to as-needed No schema changes currently planned

References