{
  "ursId": "URS-007",
  "title": "Account Creation with Required Fields",
  "timestamp": "2026-04-21T05:57:31.394Z",
  "durationMs": 99585,
  "config": {
    "inboxUrl": "http://localhost:61241",
    "dbHost": "localhost",
    "dbPort": 61242,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Login as distributor admin",
      "status": "pass",
      "description": "Step 1: Login as distributor admin",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-01-logged-in.png"
      ],
      "explanation": "Establishes that a distributor admin can authenticate and reach the authenticated application. This user holds the sales_accounts:create permission required to access the account creation form. Verifying successful login confirms the entry-point prerequisite for the creation flow.",
      "expectedAuditActions": [
        "user_log:user:login"
      ]
    },
    {
      "name": "Step 2: Navigate to account creation form",
      "status": "pass",
      "description": "Step 2: Navigate to account creation form",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-02-sales-accounts-list.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-02-new-account-form.png"
      ],
      "explanation": "Confirms the \"New Account\" entry point on the Sales Accounts list is functional and navigates to the multi-step creation wizard. The list page and the creation form header are both captured as evidence that the routing from list to wizard is working correctly."
    },
    {
      "name": "Step 3: Validation error when facility name is missing",
      "status": "pass",
      "description": "Step 3: Validation error when facility name is missing",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-03-validation-errors-step2.png"
      ],
      "explanation": "Proves the system enforces the facility name and sales representative as required fields on Step 2 of the account creation wizard. Clicking Next without filling either field triggers two distinct validation errors, and the form does not advance to the next step."
    },
    {
      "name": "Step 4: Validation error when shipping address is missing",
      "status": "pass",
      "description": "Step 4: Validation error when shipping address is missing",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-04-address-validation-errors.png"
      ],
      "explanation": "Proves the system enforces shipping address as a required field on Step 3. After filling the facility name and assigning a sales rep, advancing without providing street, city, state, and zip triggers a \"Shipping address is required\" validation error."
    },
    {
      "name": "Step 5: Validation error when primary contact is missing",
      "status": "pass",
      "description": "Step 5: Validation error when primary contact is missing",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-05-contact-validation-errors.png"
      ],
      "explanation": "Proves the system enforces the billing contact fields (name, email, phone) as required on Step 4. After providing a valid shipping address, attempting to advance with an empty billing contact section triggers three separate validation errors — one for each required field."
    },
    {
      "name": "Step 6: Fill all required fields and submit",
      "status": "pass",
      "description": "Step 6: Fill all required fields and submit",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-06-account-details-filled.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-06-shipping-address-filled.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-06-billing-contact-filled.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-06-pricing-defaults.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-06-review.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-06-success-screen.png"
      ],
      "explanation": "Demonstrates the complete happy-path account creation flow. All required fields are provided across the six-step wizard (facility name, sales rep, shipping address, shipping contact, billing contact, and pricing). Submission completes with a success confirmation, proving that the system accepts and persists a fully completed account.",
      "expectedAuditActions": [
        "user_log:sales_account:created"
      ]
    },
    {
      "name": "Step 7: Verify account appears in the accounts list",
      "status": "pass",
      "description": "Step 7: Verify account appears in the accounts list",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-07-account-in-list.png"
      ],
      "explanation": "Confirms the newly created account is persisted and visible in the Sales Accounts list. Searching for the facility name and finding the matching row demonstrates that the form submission created a real database record that is queryable and displayed in the UI."
    },
    {
      "name": "Step 8: Verify account detail page shows all fields",
      "status": "pass",
      "description": "Step 8: Verify account detail page shows all fields",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/screenshots/step-08-account-detail.png"
      ],
      "explanation": "Confirms the facility name and shipping address entered during creation are correctly stored and rendered on the account detail page. Opening the account and verifying the heading and address text proves end-to-end persistence of the required fields through the creation wizard."
    }
  ],
  "dbValidations": [
    {
      "name": "Account created with required facility name",
      "query": "SELECT id, name, status,\n                             manufacturer_organization_id, distributor_organization_id,\n                             shipping_location_id, billing_contact_id, shipping_contact_id,\n                             created_at\n                        FROM sales_accounts\n                       WHERE name = $1\n                         AND manufacturer_organization_id = $2\n                         AND distributor_organization_id = $3",
      "status": "pass",
      "rows": [
        {
          "id": "019dae9e-b4a4-78bd-a629-b8e038abb167",
          "name": "ZuriMED Test Facility (URS-007)",
          "status": "proposed",
          "manufacturer_organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "distributor_organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "shipping_location_id": "019dae9e-b49e-7d1d-96eb-c07f2eccebd5",
          "billing_contact_id": "019dae9e-b4a1-7204-a0f4-325068e9a5a1",
          "shipping_contact_id": "019dae9e-b4a0-70fd-a11e-0a611fc9bb22",
          "created_at": "2026-04-21T05:58:49.747Z"
        }
      ],
      "assertion": "sales_accounts row with name \"ZuriMED Test Facility (URS-007)\" should exist and be linked to ZuriMED (manufacturer) and StellarTech (distributor)"
    },
    {
      "name": "Shipping address persisted with required fields",
      "query": "SELECT id, name, street_address, city, state, zip, country, active\n                         FROM real_world_locations\n                        WHERE id = $1",
      "status": "pass",
      "rows": [
        {
          "id": "019dae9e-b49e-7d1d-96eb-c07f2eccebd5",
          "name": "ZuriMED Test Facility (URS-007)",
          "street_address": "123 Medical Drive",
          "city": "Springfield",
          "state": "IL",
          "zip": "62701",
          "country": "US",
          "active": true
        }
      ],
      "assertion": "real_world_locations row referenced by shipping_location_id should contain street \"123 Medical Drive\", city \"Springfield\", state \"IL\", zip \"62701\""
    },
    {
      "name": "Primary contact persisted with required name",
      "query": "SELECT id, name, organization_id, active\n                        FROM contacts\n                       WHERE id = $1",
      "status": "pass",
      "rows": [
        {
          "id": "019dae9e-b4a1-7204-a0f4-325068e9a5a1",
          "name": "John Smith",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "active": true
        }
      ],
      "assertion": "contacts row referenced by billing_contact_id should have name \"John Smith\""
    },
    {
      "name": "Primary contact email saved",
      "query": "SELECT id, contact_id, type, value\n                      FROM contact_items\n                     WHERE contact_id = $1\n                       AND type = 'email'",
      "status": "pass",
      "rows": [
        {
          "id": "019dae9e-b4a2-7f62-80f8-874ff8034157",
          "contact_id": "019dae9e-b4a1-7204-a0f4-325068e9a5a1",
          "type": "email",
          "value": "john.smith@zurimed-test-facility.example.com"
        }
      ],
      "assertion": "contact_items row with type='email' should exist for the billing contact, value=john.smith@zurimed-test-facility.example.com"
    },
    {
      "name": "Primary contact phone saved",
      "query": "SELECT id, contact_id, type, value\n                      FROM contact_items\n                     WHERE contact_id = $1\n                       AND type = 'phone'",
      "status": "pass",
      "rows": [
        {
          "id": "019dae9e-b4a2-7f62-80f8-875056305fc3",
          "contact_id": "019dae9e-b4a1-7204-a0f4-325068e9a5a1",
          "type": "phone",
          "value": "+15551234567"
        }
      ],
      "assertion": "contact_items row with type='phone' should exist for the billing contact (standardized to +15551234567)"
    },
    {
      "name": "Shipping contact persisted with required name",
      "query": "SELECT id, name, organization_id, active\n                                FROM contacts\n                               WHERE id = $1",
      "status": "pass",
      "rows": [
        {
          "id": "019dae9e-b4a0-70fd-a11e-0a611fc9bb22",
          "name": "John Smith",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "active": true
        }
      ],
      "assertion": "contacts row referenced by shipping_contact_id should have name \"John Smith\""
    },
    {
      "name": "Shipping contact email saved",
      "query": "SELECT id, contact_id, type, value\n                              FROM contact_items\n                             WHERE contact_id = $1\n                               AND type = 'email'",
      "status": "pass",
      "rows": [
        {
          "id": "019dae9e-b4a1-7204-a0f4-324e20dcf2d6",
          "contact_id": "019dae9e-b4a0-70fd-a11e-0a611fc9bb22",
          "type": "email",
          "value": "john.smith@zurimed-test-facility.example.com"
        }
      ],
      "assertion": "contact_items row with type='email' should exist for the shipping contact, value=john.smith@zurimed-test-facility.example.com"
    },
    {
      "name": "Sales rep assigned to the new account",
      "query": "SELECT sales_account_id, user_id, active, representative_type\n                           FROM sales_account_user_assignments\n                          WHERE sales_account_id = $1\n                            AND user_id = $2\n                            AND active = true",
      "status": "pass",
      "rows": [
        {
          "sales_account_id": "019dae9e-b4a4-78bd-a629-b8e038abb167",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "active": true,
          "representative_type": "salesperson"
        }
      ],
      "assertion": "sales_account_user_assignments should have an active row linking Bob Kauffman to the new account"
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z",
  "auditStartTime": "2026-04-21T05:57:29.416Z",
  "auditEventEvidence": [
    {
      "createdAt": "2026-04-21T05:57:37.499Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:57:44.367Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:57:52.753Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:58:01.491Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:58:12.994Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:58:30.573Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:58:49.791Z",
      "eventType": "user_log",
      "action": "sales_account:created",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019dae9e-b4a4-78bd-a629-b8e038abb167",
      "secondaryObjectId": null,
      "payload": {
        "status": "proposed",
        "autoApproved": false,
        "salesAccountName": "ZuriMED Test Facility (URS-007)",
        "distributorOrganizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "manufacturerOrganizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      },
      "route": "/sales-accounts/new",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:58:57.720Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-21T05:59:06.033Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    }
  ],
  "auditQuery": "SELECT\n    ae.created_at,\n    ae.event_type,\n    ae.action,\n    ae.user_id,\n    u.email AS user_email,\n    ae.organization_id,\n    o.name AS organization_name,\n    ae.object_id,\n    ae.secondary_object_id,\n    ae.payload,\n    ae.route,\n    ae.trace_id\n  FROM audit_events ae\n  LEFT JOIN users u ON u.id = ae.user_id\n  LEFT JOIN organizations o ON o.id = ae.organization_id\n  WHERE ae.created_at >= $1\n    AND ae.organization_id = ANY($2::uuid[])\n  ORDER BY ae.created_at ASC",
  "videoPaths": [
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-01-login.webm",
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-02-navigate-to-form.webm",
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-03-facility-name-required.webm",
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-04-address-required.webm",
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-05-contact-required.webm",
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-06-submit-success.webm",
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-07-account-in-list.webm",
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-007-account-creation/2026-04-21T05-57-31-393Z/videos/step-08-account-detail.webm"
  ]
}