URS-008 · Restrict Reps from Editing Accounts Outside Territory
Status: PASS · Duration: 56s · Run Date: April 21, 2026
Test Scenarios
Section titled “Test Scenarios”Step 1: Rep login
Section titled “Step 1: Rep login”
Step 2: Rep accounts list
Section titled “Step 2: Rep accounts list”
Step 3: In-territory account (read-only)
Section titled “Step 3: In-territory account (read-only)”

Step 4: Out-of-territory account (restricted)
Section titled “Step 4: Out-of-territory account (restricted)”
Step 5: Admin can edit (comparison)
Section titled “Step 5: Admin can edit (comparison)”


Recordings
Section titled “Recordings”step 01 rep login
Section titled “step 01 rep login”step 02 rep accounts list
Section titled “step 02 rep accounts list”step 03 rep in territory account
Section titled “step 03 rep in territory account”step 04 rep out of territory account
Section titled “step 04 rep out of territory account”step 05 admin can edit
Section titled “step 05 admin can edit”Database Validations
Section titled “Database Validations”Rep has Sales Representative role
Section titled “Rep has Sales Representative role”Bob Kauffman should have the Sales Representative role (not admin) for this test
SELECT u.email, u.name, r.name as role_name, r.id as role_id FROM users u JOIN user_roles ur ON ur.user_id = u.id JOIN roles r ON r.id = ur.role_id WHERE u.id = $1 AND ur.organization_id = $2| name | role_name | role_id | |
|---|---|---|---|
| bob.kauffman@stellartech.com | Bob Kauffman | Sales Representative | d2e3f4a5-b6c7-8901-def0-123456789abc |
Rep assigned to in-territory account
Section titled “Rep assigned to in-territory account”Bob Kauffman should have an active assignment to the BOSS account
SELECT sa.name as account_name, saua.active, saua.representative_type FROM sales_account_user_assignments saua JOIN sales_accounts sa ON sa.id = saua.sales_account_id WHERE saua.user_id = $1 AND saua.sales_account_id = $2 AND saua.active = true| account_name | active | representative_type |
|---|---|---|
| BOSS Surgical Account Request | true | salesperson |
Rep NOT assigned to out-of-territory account
Section titled “Rep NOT assigned to out-of-territory account”Bob Kauffman should NOT have an assignment to the Connecticut Ortho account
SELECT sa.name as account_name, saua.active FROM sales_account_user_assignments saua JOIN sales_accounts sa ON sa.id = saua.sales_account_id WHERE saua.user_id = $1 AND saua.sales_account_id = $2 AND saua.active = trueNo rows returned.
Sales Rep role lacks manage permission
Section titled “Sales Rep role lacks manage permission”The Sales Representative role should NOT have the sales_accounts:manage permission
SELECT p.permission FROM permissions p WHERE p.actor_id = $1 AND p.permission = 'sales_accounts:manage'No rows returned.
Admin role has manage permission
Section titled “Admin role has manage permission”The Admin role should have the sales_accounts:manage permission
SELECT p.permission FROM permissions p WHERE p.actor_id = $1 AND p.permission = 'sales_accounts:manage'| permission |
|---|
| sales_accounts:manage |
Admin user has Admin role
Section titled “Admin user has Admin role”Dan Distributor should have the Admin role for comparison
SELECT u.email, u.name, r.name as role_name, r.id as role_id FROM users u JOIN user_roles ur ON ur.user_id = u.id JOIN roles r ON r.id = ur.role_id WHERE u.id = $1 AND ur.organization_id = $2| name | role_name | role_id | |
|---|---|---|---|
| dan.distributor@stellartech.com | Dan Distributor | StellarTech Admin | 40e1f2a3-b4c5-6789-4567-890123456789 |