# Validation Report: URS-007

**Title:** Account Creation with Required Fields
**Date:** 2026-04-21T05:57:31.394Z
**Duration:** 99.6s
**Overall Status:** ✅ PASS

## Environment

- **Inbox URL:** http://localhost:61241
- **Database:** localhost:61242/cc_repinbox_dev

## Setup

Status: ✅ PASS

## Test Steps

Each step below corresponds to one Playwright test that ran sequentially. Screenshots and video recordings provide visual evidence of the UI behaviour.

### 1. Step 1: Login as distributor admin — ✅ PASS

**What this step proves:**

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.

**Audit events generated by this step:**

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-21 05:57:37Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-21 05:57:44Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-21 05:57:52Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-21 05:58:01Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-21 05:58:12Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-21 05:58:30Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-21 05:58:57Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-21 05:59:06Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |

**Screenshots:**

![step 01 logged in](screenshots/step-01-logged-in.png)

---

### 2. Step 2: Navigate to account creation form — ✅ PASS

**What this step proves:**

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.

**Screenshots:**

![step 02 sales accounts list](screenshots/step-02-sales-accounts-list.png)

![step 02 new account form](screenshots/step-02-new-account-form.png)

---

### 3. Step 3: Validation error when facility name is missing — ✅ PASS

**What this step proves:**

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.

**Screenshots:**

![step 03 validation errors step2](screenshots/step-03-validation-errors-step2.png)

---

### 4. Step 4: Validation error when shipping address is missing — ✅ PASS

**What this step proves:**

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.

**Screenshots:**

![step 04 address validation errors](screenshots/step-04-address-validation-errors.png)

---

### 5. Step 5: Validation error when primary contact is missing — ✅ PASS

**What this step proves:**

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.

**Screenshots:**

![step 05 contact validation errors](screenshots/step-05-contact-validation-errors.png)

---

### 6. Step 6: Fill all required fields and submit — ✅ PASS

**What this step proves:**

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.

**Audit events generated by this step:**

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-21 05:58:49Z | user_log | sales_account:created | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |

**Screenshots:**

![step 06 account details filled](screenshots/step-06-account-details-filled.png)

![step 06 shipping address filled](screenshots/step-06-shipping-address-filled.png)

![step 06 billing contact filled](screenshots/step-06-billing-contact-filled.png)

![step 06 pricing defaults](screenshots/step-06-pricing-defaults.png)

![step 06 review](screenshots/step-06-review.png)

![step 06 success screen](screenshots/step-06-success-screen.png)

---

### 7. Step 7: Verify account appears in the accounts list — ✅ PASS

**What this step proves:**

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.

**Screenshots:**

![step 07 account in list](screenshots/step-07-account-in-list.png)

---

### 8. Step 8: Verify account detail page shows all fields — ✅ PASS

**What this step proves:**

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.

**Screenshots:**

![step 08 account detail](screenshots/step-08-account-detail.png)

---

## Database Validations

The following SQL queries ran against the application database after the Playwright scenarios completed. Each query asserts a specific condition that proves the feature under test persisted its data correctly.

### Account created with required facility name — ✅ PASS

**Assertion:** sales_accounts row with name "ZuriMED Test Facility (URS-007)" should exist and be linked to ZuriMED (manufacturer) and StellarTech (distributor)

```sql
SELECT id, name, status,
                             manufacturer_organization_id, distributor_organization_id,
                             shipping_location_id, billing_contact_id, shipping_contact_id,
                             created_at
                        FROM sales_accounts
                       WHERE name = $1
                         AND manufacturer_organization_id = $2
                         AND distributor_organization_id = $3
```

| id | name | status | manufacturer_organization_id | distributor_organization_id | shipping_location_id | billing_contact_id | shipping_contact_id | created_at |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 019dae9e-b4a4-78bd-a629-b8e038abb167 | ZuriMED Test Facility (URS-007) | proposed | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 | 019dae9e-b49e-7d1d-96eb-c07f2eccebd5 | 019dae9e-b4a1-7204-a0f4-325068e9a5a1 | 019dae9e-b4a0-70fd-a11e-0a611fc9bb22 | Tue Apr 21 2026 00:58:49 GMT-0500 (Central Daylight Time) |

### Shipping address persisted with required fields — ✅ PASS

**Assertion:** real_world_locations row referenced by shipping_location_id should contain street "123 Medical Drive", city "Springfield", state "IL", zip "62701"

```sql
SELECT id, name, street_address, city, state, zip, country, active
                         FROM real_world_locations
                        WHERE id = $1
```

| id | name | street_address | city | state | zip | country | active |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 019dae9e-b49e-7d1d-96eb-c07f2eccebd5 | ZuriMED Test Facility (URS-007) | 123 Medical Drive | Springfield | IL | 62701 | US | true |

### Primary contact persisted with required name — ✅ PASS

**Assertion:** contacts row referenced by billing_contact_id should have name "John Smith"

```sql
SELECT id, name, organization_id, active
                        FROM contacts
                       WHERE id = $1
```

| id | name | organization_id | active |
| --- | --- | --- | --- |
| 019dae9e-b4a1-7204-a0f4-325068e9a5a1 | John Smith | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | true |

### Primary contact email saved — ✅ PASS

**Assertion:** contact_items row with type='email' should exist for the billing contact, value=john.smith@zurimed-test-facility.example.com

```sql
SELECT id, contact_id, type, value
                      FROM contact_items
                     WHERE contact_id = $1
                       AND type = 'email'
```

| id | contact_id | type | value |
| --- | --- | --- | --- |
| 019dae9e-b4a2-7f62-80f8-874ff8034157 | 019dae9e-b4a1-7204-a0f4-325068e9a5a1 | email | john.smith@zurimed-test-facility.example.com |

### Primary contact phone saved — ✅ PASS

**Assertion:** contact_items row with type='phone' should exist for the billing contact (standardized to +15551234567)

```sql
SELECT id, contact_id, type, value
                      FROM contact_items
                     WHERE contact_id = $1
                       AND type = 'phone'
```

| id | contact_id | type | value |
| --- | --- | --- | --- |
| 019dae9e-b4a2-7f62-80f8-875056305fc3 | 019dae9e-b4a1-7204-a0f4-325068e9a5a1 | phone | +15551234567 |

### Shipping contact persisted with required name — ✅ PASS

**Assertion:** contacts row referenced by shipping_contact_id should have name "John Smith"

```sql
SELECT id, name, organization_id, active
                                FROM contacts
                               WHERE id = $1
```

| id | name | organization_id | active |
| --- | --- | --- | --- |
| 019dae9e-b4a0-70fd-a11e-0a611fc9bb22 | John Smith | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | true |

### Shipping contact email saved — ✅ PASS

**Assertion:** contact_items row with type='email' should exist for the shipping contact, value=john.smith@zurimed-test-facility.example.com

```sql
SELECT id, contact_id, type, value
                              FROM contact_items
                             WHERE contact_id = $1
                               AND type = 'email'
```

| id | contact_id | type | value |
| --- | --- | --- | --- |
| 019dae9e-b4a1-7204-a0f4-324e20dcf2d6 | 019dae9e-b4a0-70fd-a11e-0a611fc9bb22 | email | john.smith@zurimed-test-facility.example.com |

### Sales rep assigned to the new account — ✅ PASS

**Assertion:** sales_account_user_assignments should have an active row linking Bob Kauffman to the new account

```sql
SELECT sales_account_id, user_id, active, representative_type
                           FROM sales_account_user_assignments
                          WHERE sales_account_id = $1
                            AND user_id = $2
                            AND active = true
```

| sales_account_id | user_id | active | representative_type |
| --- | --- | --- | --- |
| 019dae9e-b4a4-78bd-a629-b8e038abb167 | 17b8c9d0-e1f2-3456-1234-567890123456 | true | salesperson |

## Audit Log Events

Every row written to `audit_events` while this test was running (scoped to the demo organizations). Provides compliance evidence that user actions are traced end-to-end (URS-003).

**Capture window start:** 2026-04-21T05:57:29.416Z

<details><summary>Query used to capture events</summary>

```sql
SELECT
    ae.created_at,
    ae.event_type,
    ae.action,
    ae.user_id,
    u.email AS user_email,
    ae.organization_id,
    o.name AS organization_name,
    ae.object_id,
    ae.secondary_object_id,
    ae.payload,
    ae.route,
    ae.trace_id
  FROM audit_events ae
  LEFT JOIN users u ON u.id = ae.user_id
  LEFT JOIN organizations o ON o.id = ae.organization_id
  WHERE ae.created_at >= $1
    AND ae.organization_id = ANY($2::uuid[])
  ORDER BY ae.created_at ASC
```
</details>

9 event(s) captured:

| Time | Type | Action | User | Org | Object ID | Performed | Reason |
|------|------|--------|------|-----|-----------|-----------|--------|
| 2026-04-21 05:57:37Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-21 05:57:44Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-21 05:57:52Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-21 05:58:01Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-21 05:58:12Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-21 05:58:30Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-21 05:58:49Z | user_log | sales_account:created | dan.distributor@stellartech.com | StellarTech Medical Solutions | 019dae9e-b4a4-78bd-a629-b8e038abb167 | — |  |
| 2026-04-21 05:58:57Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-21 05:59:06Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |

## Video Evidence

Screencast recordings capture the full browser session for each test step, including annotated chapter overlays that identify what is being tested.

- [videos/step-01-login.webm](videos/step-01-login.webm)
- [videos/step-02-navigate-to-form.webm](videos/step-02-navigate-to-form.webm)
- [videos/step-03-facility-name-required.webm](videos/step-03-facility-name-required.webm)
- [videos/step-04-address-required.webm](videos/step-04-address-required.webm)
- [videos/step-05-contact-required.webm](videos/step-05-contact-required.webm)
- [videos/step-06-submit-success.webm](videos/step-06-submit-success.webm)
- [videos/step-07-account-in-list.webm](videos/step-07-account-in-list.webm)
- [videos/step-08-account-detail.webm](videos/step-08-account-detail.webm)
