# Test Case: Approval Queue (APPR-002, APPR-003, APPR-006)

> **Test ID**: APR-TEST-001
> **Priority**: P1
> **Estimated Time**: 15 minutes
> **Test Environment**: NexusCRM (https://nexuscrm.pingcap.com)
> **Last Updated**: 2026-03-29

---

## 1. Test Overview

This test case verifies the core functionality of the Approval Queue feature, including:
- Approval record display (record name, object type, submission time, comments)
- Approve action
- Reject action
- Reassign action

**Known Issues Being Tested:**
| Issue ID | Description | Severity |
|----------|-------------|----------|
| APPR-002 | Record column shows "Unknown" instead of actual record names | High |
| APPR-003 | Object column shows "Record" instead of actual object type | High |
| APPR-006 | Comments column shows "—" instead of actual comments | Medium |

---

## 2. Prerequisites

### 2.1 Environment Requirements
1. **Browser**: Chrome (latest version)
2. **Network**: Access to `https://nexuscrm.pingcap.com`
3. **Account**: Valid NexusCRM test account

### 2.2 Test Data Setup
- At least one pending approval record in the queue
- If none exist, contact development team to create test data

### 2.3 Login Steps
1. Open browser and navigate to: `https://nexuscrm.pingcap.com`
2. Login with test account credentials
3. Confirm successful login before proceeding

---

## 3. Test Steps

### TC-001: Approval Queue Default View

**Objective**: Verify the default display of the approval queue page

| Step | Action | Expected Result | Actual Result | Pass/Fail |
|------|--------|-----------------|---------------|-----------|
| 1 | After login, click **"Approvals"** menu item in the left sidebar | Page navigates to `/approvals`, page loads successfully | | |
| 2 | Observe the Pending count at the top of the page | Displays pending count (e.g., "275 pending") | | |
| 3 | Check table column headers | Displays 5 columns: **Record**, **Object**, **Submitted**, **Comments**, **Actions** | | |
| 4 | Check **Record** column data | ❌ **Current Issue**: All records show "Unknown" (should show record names like Quote #, Account Name) | | FAIL |
| 5 | Check **Object** column data | ❌ **Current Issue**: All records show "Record" (should show object types like Quote, Account) | | FAIL |
| 6 | Check **Comments** column data | ❌ **Current Issue**: All records show "—" (should show comments submitted) | | FAIL |
| 7 | Check **Submitted** column data | Displays submission timestamps (e.g., "Mar 28, 2026, 01:05 PM") | | PASS |
| 8 | Check **Actions** column data | Each row displays three buttons: **Approve**, **Reject**, **Reassign** | | |
| 9 | Check left sidebar badge | Displays "99+ Approvals 275" (note formatting issue: no spaces) | | |

**Screenshots Required**:
- `queue_default_view.png` - Full queue view showing all columns and data
- Screenshot should clearly show 275 pending items and column headers

**Reference Screenshot**: `screenshots/approvals/queue_default_view.png`

---

### TC-002: Approve Action

**Objective**: Verify the Approve action dialog and submission flow

| Step | Action | Expected Result | Actual Result | Pass/Fail |
|------|--------|-----------------|---------------|-----------|
| 1 | On the queue page from TC-001, click **"Approve"** button on the first row | Confirmation dialog appears | | |
| 2 | Check dialog title | Displays **"Approve Request"** | | |
| 3 | Check dialog content | Displays confirmation text (e.g., "Are you sure you want to approve this approval request?") | | |
| 4 | Check comment input field | Displays text input area with placeholder "Add any comments..." | | |
| 5 | Check buttons | Displays **Cancel** and **Approve** buttons | | |
| 6 | Click **Cancel** button | Dialog closes, record remains in queue | | |
| 7 | Click **"Approve"** button again | Dialog reopens | | |
| 8 | (Optional) Enter comment: "Approved for testing" | Text successfully entered | | |
| 9 | Click **Approve** button | Record removed from queue, Pending count decrements by 1 | | |

**Reference Screenshot**: `screenshots/approvals/approve_dialog.png`

---

### TC-003: Reject Action

**Objective**: Verify the Reject action dialog and submission flow

| Step | Action | Expected Result | Actual Result | Pass/Fail |
|------|--------|-----------------|---------------|-----------|
| 1 | On the queue page, click **"Reject"** button on a record | Confirmation dialog appears | | |
| 2 | Check dialog title | Displays **"Reject Request"** | | |
| 3 | Check dialog content | Displays confirmation text | | |
| 4 | Check comment input field | Displays text input area (reject typically requires comment) | | |
| 5 | Check buttons | Displays **Cancel** and **Reject** buttons | | |
| 6 | Enter comment: "Rejected for testing - does not meet requirements" | Text successfully entered | | |
| 7 | Click **Cancel** button | Dialog closes, record remains in queue | | |
| 8 | Click **"Reject"** button again, enter comment, then click **Reject** | Record removed from queue | | |

**Reference Screenshot**: `screenshots/approvals/reject_dialog.png`

---

### TC-004: Reassign Action

**Objective**: Verify the Reassign action user selection functionality

| Step | Action | Expected Result | Actual Result | Pass/Fail |
|------|--------|-----------------|---------------|-----------|
| 1 | On the queue page, click **"Reassign"** button on a record | User selection dialog appears | ❌ **Current Issue**: Dialog does not open | FAIL |
| 2 | Check user picker | Should display selectable user list or search box | ❌ Cannot verify | |
| 3 | Select a user and confirm | Record approver is updated | ❌ Cannot verify | |

**Known Issue**:
- Clicking Reassign button does not open the dialog
- Likely caused by JavaScript error or missing component

**Reference Screenshot**: `screenshots/approvals/reassign_dialog.png`

---

### TC-005: Approval Processes Configuration Page

**Objective**: Verify the approval process configuration page display

| Step | Action | Expected Result | Actual Result | Pass/Fail |
|------|--------|-----------------|---------------|-----------|
| 1 | Navigate to: `/setup/approval-processes` | Page loads successfully | | |
| 2 | Observe table column headers | Displays: **Process Name**, **API Name**, **Object**, **Pending**, **Last Modified**, **Actions** | | |
| 3 | Check total process count | Displays total count (e.g., "204 processes") | | |
| 4 | Check process status display | Status (Active/Inactive/Obsolete) shown inline in Process Name column | | |
| 5 | Observe top action buttons | Displays: **Search: All**, **IZ**, **Collapse**, **New Approval Process**, **All Objects** | | |

**Reference Screenshot**: `screenshots/approvals/approval_processes_list.png`

---

### TC-006: End-to-End Submit and Approve (Optional)

**Objective**: Verify the complete submit → approve flow

**Prerequisites**:
- A Quote or custom object record with an active approval process
- Current user has submit permission

| Step | Action | Expected Result | Actual Result | Pass/Fail |
|------|--------|-----------------|---------------|-----------|
| 1 | Navigate to Quote detail page | Quote page loads successfully | | |
| 2 | Click **"Submit for Approval"** button | Submission dialog appears | | |
| 3 | Enter comment: "Test approval submission" | Text successfully entered | | |
| 4 | Confirm submission | Record submitted successfully, approval chain displayed | | |
| 5 | Return to Approval Queue page | Newly submitted record appears in queue | | |
| 6 | Check **Comments** column for new record | Should display "Test approval submission" | | |
| 7 | Check left sidebar badge count | Count should increment by 1 | | |
| 8 | Approve the record | Record removed from queue, badge count decrements by 1 | | |

**Screenshots Required** (Optional - requires test data):
- `submit_dialog.png` - Submission dialog (requires Quote with approval process)
- `queue_after_submit.png` - Queue view after submission
- `badge_sync.png` - Badge sync before/after comparison

**Note**: These screenshots require a Quote or custom object record with an active approval process. If test data is not available, this test case can be skipped.

---

## 4. Screenshot Checklist

| # | Description | Filename | Status |
|---|-------------|----------|--------|
| 1 | Approval Queue default view (275 items) | `screenshots/approvals/queue_default_view.png` | ✅ Captured |
| 2 | Approve dialog | `screenshots/approvals/approve_dialog.png` | ✅ Captured |
| 3 | Reject dialog | `screenshots/approvals/reject_dialog.png` | ✅ Captured |
| 4 | Reassign attempt | `screenshots/approvals/reassign_dialog.png` | ✅ Captured |
| 5 | Approval Processes list (204 processes) | `screenshots/approvals/approval_processes_list.png` | ✅ Captured |
| 6 | Queue columns closeup | `screenshots/approvals/queue_columns_closeup.png` | ❌ Not captured |
| 7 | Submit dialog | `screenshots/approvals/submit_dialog.png` | ⚠️ Requires test data (Quote with approval process) |
| 8 | Badge sync before/after | `screenshots/approvals/badge_sync.png` | ⚠️ Requires test data |

**Screenshot Storage Location**: `tests/contract/scenarios/chrome/screenshots/approvals/`

---

## 5. Known Issues Summary

| # | Issue Description | Impact | Severity | Status |
|---|-------------------|--------|----------|--------|
| APPR-002 | Record column shows "Unknown" instead of actual record names | All approval records | High | Reproduced |
| APPR-003 | Object column shows "Record" instead of object type | All approval records | High | Reproduced |
| APPR-006 | Comments column shows "—" instead of actual comments | All approval records | Medium | Reproduced |
| BUG-001 | Reassign button click does not open dialog | Reassign functionality | Medium | Reproduced |
| UI-001 | Sidebar badge text formatting: "99+Approvals275" (no spaces) | User experience | Low | Noted |

---

## 6. A/B Comparison Notes (Salesforce Sandbox)

When running A/B comparison against Salesforce Sandbox as the oracle:

| Aspect | Salesforce (Expected) | NexusCRM (Current) |
|--------|----------------------|---------------------|
| Record column | Shows actual record names | "Unknown" |
| Object column | Shows actual object types | "Record" |
| Comments column | Shows actual comments | "—" |
| Approve dialog | Works correctly | Works correctly |
| Reject dialog | Works correctly | Works correctly |
| Reassign dialog | Shows user picker | Does not open |

**Test Recommendation**: Execute identical operations in both environments with the same test data and document differences.

---

## 7. Test Execution Log

| Date | Tester | Environment | Result | Notes |
|------|--------|-------------|--------|-------|
| 2026-03-29 | Claude (dev-browser) | NexusCRM | Partial Pass | Completed TC-001 through TC-005, captured 5 screenshots |

---

## 8. Related Test Scenarios

| Scenario ID | Scenario Name | Related Issue |
|-------------|---------------|---------------|
| APPR-002 | Approval Queue record name display | This test case |
| APPR-003 | Approval Queue object type display | This test case |
| APPR-006 | Approval Queue comments display | This test case |
| APPR-005 | Sidebar badge sync | TBD |
| APPR-004 | Approval chain display | TBD |

---

## 9. Appendix: dev-browser Automated Test Script

```javascript
// Approval Queue automated test script
const page = await browser.getPage("main");

// 1. Navigate to approval queue page
await page.goto("https://nexuscrm.pingcap.com/approvals");
await page.waitForTimeout(3000); // Wait for page load

// 2. Get queue state
const queueState = await page.evaluate(() => {
  return {
    headers: Array.from(document.querySelectorAll('th')).map(th => th.textContent.trim()),
    rowCount: document.querySelectorAll('tbody tr').length,
    firstRow: Array.from(document.querySelector('tbody tr')?.querySelectorAll('td') || [])
      .map(td => td.textContent.trim())
  };
});

console.log("Headers:", queueState.headers);
console.log("Row count:", queueState.rowCount);
console.log("First row:", queueState.firstRow);

// 3. Take screenshot
const screenshotPath = await saveScreenshot(
  await page.screenshot(),
  "approvals/queue_default_view.png"
);
console.log("Screenshot saved:", screenshotPath);

// 4. Test Approve action
const approveButton = await page.$('button:contains("Approve")');
if (approveButton) {
  await approveButton.click();
  await page.waitForTimeout(1000);

  // Check if dialog opens
  const dialogVisible = await page.$('div:contains("Approve Request")');
  console.log("Approve dialog:", dialogVisible ? "Opened successfully" : "Failed to open");

  // Screenshot
  const dialogPath = await saveScreenshot(
    await page.screenshot(),
    "approvals/approve_dialog.png"
  );
  console.log("Dialog screenshot:", dialogPath);
}
```

---

## 10. Version Information

| Item | Value |
|------|-------|
| NexusCRM Version | v1772440647784 (2026-03-02) |
| Test Framework | Chrome Exploration Framework |
| Browser Automation | dev-browser + Playwright |
| Document Version | 1.1 |
