Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
340a986
Replace moment with dayjs
johnsimons Nov 18, 2025
8a9a3b2
Initial checkin for the Platform Capabilities section on the dashboard
warwickschroeder Nov 20, 2025
c45fb38
Remove unused styles
warwickschroeder Nov 20, 2025
0a3f5a4
Change help URL
warwickschroeder Nov 20, 2025
9b4a696
Add a banner to the All Messages view if no successful messages
warwickschroeder Nov 20, 2025
19cde03
Update naming for view data button
warwickschroeder Nov 20, 2025
53f7900
Update icon on All Messages page
warwickschroeder Nov 20, 2025
d5ae6cd
Remove concept of Partially Available
warwickschroeder Nov 20, 2025
fd94271
Update message constants
warwickschroeder Nov 20, 2025
74b3e27
Remove unused styles
warwickschroeder Nov 20, 2025
f6792ba
WIP
warwickschroeder Nov 21, 2025
b6fabc5
WIP - Clean and change the way config is grabbed
warwickschroeder Nov 24, 2025
14f115c
Update capability cards WIP
warwickschroeder Nov 25, 2025
f22e4c4
WIP - add promo modal pages
warwickschroeder Nov 25, 2025
ae0fe39
WIP - audit wizard promo
warwickschroeder Nov 25, 2025
a31b243
Update auditing and monitoring promo pages
warwickschroeder Nov 26, 2025
031d66e
Finish initial audit and monitoring promo work
warwickschroeder Nov 26, 2025
dfd8bc5
Add error instance capability
warwickschroeder Nov 26, 2025
df57dfd
Clean styling
warwickschroeder Nov 26, 2025
a25ec6a
Remove additional monitoring instance config
warwickschroeder Nov 26, 2025
2c70a6a
Add new mocked endpoints for new and updated stores
warwickschroeder Nov 26, 2025
c7d4692
Move styles into component files.
warwickschroeder Nov 28, 2025
cf634b9
Fix issues caused by master branch refactoring
warwickschroeder Dec 2, 2025
90f810d
Revert to master for specific files
warwickschroeder Dec 2, 2025
ea148cf
Support remote servicecontrol instances. Now will cache remotes. Add …
warwickschroeder Dec 4, 2025
40880a7
Add tests for capability cards
warwickschroeder Dec 4, 2025
cdb5b66
Update based off feedback
warwickschroeder Dec 18, 2025
d709237
Update from feedback - only a single error instance
warwickschroeder Dec 18, 2025
a8caef7
Add tests for platform capability cards
warwickschroeder Dec 18, 2025
658bdbb
Refactor, clean, consolidate
warwickschroeder Dec 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,10 @@ src/scaffolding.config

# Visual Studio Code
.vscode

# AI
.claude
CLAUDE.md

# local testing
.local
195 changes: 195 additions & 0 deletions docs/frontend/audit-capability-card.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
# Audit Capability Card Testing Guide

This document describes the audit capability card component, its various states, and how to test them both manually and automatically.

## Overview

The Audit Capability Card displays on the ServicePulse dashboard and shows the status of the auditing feature. The card's status depends on:

1. Whether audit instances are configured
2. Whether audit instances are available (online)
3. Whether successful messages exist (endpoints configured for auditing)
4. Whether the ServiceControl version supports the "All Messages" feature (>= 6.6.0)

## Card States

| Status | Condition | Badge | Action Button |
|--------------------------|--------------------------------------------------|-------------|---------------|
| Instance Not Configured | No audit instances configured | - | Get Started |
| Unavailable | All audit instances offline | Unavailable | Learn More |
| Degraded | Some audit instances offline | Degraded | - |
| Endpoints Not Configured | Instance available but no messages OR SC < 6.6.0 | - | Learn More |
| Available | Instance available with messages AND SC >= 6.6.0 | Available | View Messages |

## Manual Testing with Mock Scenarios

### Prerequisites

```bash
cd src/Frontend
npm install
```

### Running the Dev Server with Mocks

```bash
npm run dev:mocks
```

This starts the dev server at `http://localhost:5173` with MSW (Mock Service Worker) intercepting API calls.

### Switching Between Scenarios

Set the `VITE_MOCK_SCENARIO` environment variable before running the dev server:

```bash
# Linux/macOS
VITE_MOCK_SCENARIO=audit-available npm run dev:mocks

# Windows CMD
set VITE_MOCK_SCENARIO=audit-available && npm run dev:mocks

# Windows PowerShell
$env:VITE_MOCK_SCENARIO="audit-available"; npm run dev:mocks
```

Open the browser console to see available scenarios.

#### Available Audit Scenarios

| Scenario | Status | Badge | Button | Description | Indicators |
|----------------------------|--------------------------|-------------|---------------|------------------------------------------------------------------------------------------------------|-------------------------------------------|
| `audit-no-instance` | Instance Not Configured | - | Get Started | "A ServiceControl Audit instance has not been configured..." | None |
| `audit-unavailable` | Unavailable | Unavailable | Learn More | "All ServiceControl Audit instances are configured but not responding..." | Instance: ❌ |
| `audit-degraded` | Partially Unavailable | Degraded | - | "Some ServiceControl Audit instances are not responding." | Instance 1: ✅, Instance 2: ❌, Messages: ✅ |
| `audit-available` | Available | Available | View Messages | "All ServiceControl Audit instances are available and endpoints have been configured..." | Instance: ✅, Messages: ✅ |
| `audit-old-sc-version` | Endpoints Not Configured | - | Learn More | "A ServiceControl Audit instance is connected but no successful messages..." | Instance: ✅, Messages: ⚠️ (SC < 6.6.0) |
| `audit-no-messages` | Endpoints Not Configured | - | Learn More | "A ServiceControl Audit instance is connected but no successful messages have been processed yet..." | Instance: ✅, Messages: ⚠️ |
| `audit-multiple-instances` | Available | Available | View Messages | "All ServiceControl Audit instances are available..." | Instance 1: ✅, Instance 2: ✅, Messages: ✅ |

**Indicator Legend:** ✅ = Available/Success, ❌ = Unavailable/Error, ⚠️ = Warning/Not Configured

### Adding New Scenarios

1. Add a scenario precondition to `src/Frontend/test/preconditions/platformCapabilities.ts`:

```typescript
export const scenarioMyScenario = async ({ driver }: SetupFactoryOptions) => {
await driver.setUp(precondition.serviceControlWithMonitoring);
// Add scenario-specific preconditions here
};
```

2. Create a new file in `src/Frontend/test/mocks/scenarios/` (e.g., `my-scenario.ts`):

```typescript
import { setupWorker } from "msw/browser";
import { Driver } from "../../driver";
import { makeMockEndpoint, makeMockEndpointDynamic } from "../../mock-endpoint";
import * as precondition from "../../preconditions";

export const worker = setupWorker();
const mockEndpoint = makeMockEndpoint({ mockServer: worker });
const mockEndpointDynamic = makeMockEndpointDynamic({ mockServer: worker });

const makeDriver = (): Driver => ({
goTo() { throw new Error("Not implemented"); },
mockEndpoint,
mockEndpointDynamic,
setUp(factory) { return factory({ driver: this }); },
disposeApp() { throw new Error("Not implemented"); },
});

const driver = makeDriver();

export const setupComplete = (async () => {
await driver.setUp(precondition.scenarioMyScenario);
})();
```

1. Register it in `src/Frontend/test/mocks/scenarios/index.ts`:

```typescript
const scenarios: Record<string, () => Promise<ScenarioModule>> = {
// ... existing scenarios
"my-scenario": () => import("./my-scenario"),
};
```

## Automated Tests

### Test Files

| File | Type | Description |
|------------------------------------------------------------------------------------|-------------|-----------------------------------------|
| `src/Frontend/test/specs/platformcapabilities/audit-capability-card.spec.ts` | Application | End-to-end tests for the card component |
| `src/Frontend/test/specs/platformcapabilities/auditing-capability-helpers.spec.ts` | Unit | Tests for helper functions |

### Running Automated Tests

From the `src/Frontend` directory:

```bash
# Run all audit capability tests
npx vitest run test/specs/platformcapabilities/audit-capability-card.spec.ts

# Run helper function unit tests
npx vitest run test/specs/platformcapabilities/auditing-capability-helpers.spec.ts

# Run all platform capability tests
npx vitest run test/specs/platformcapabilities/
```

### Test Coverage

#### Application Tests (`audit-capability-card.spec.ts`)

| Rule | Test Case |
|---------------------------------|---------------------------------------------------------------|
| No audit instance configured | Shows "Get Started" button |
| Audit instance unavailable | Shows "Unavailable" status |
| Partially unavailable instances | Shows "Degraded" status |
| Available but no messages | Shows "Endpoints Not Configured" status |
| Available with messages | Shows "Available" status + "View Messages" button |
| ServiceControl < 6.6.0 | Shows "Endpoints Not Configured" (All Messages not supported) |
| Single instance indicator | Shows "Instance" label |
| Messages indicator | Shows "Messages" label when messages exist |
| Multiple instances | Shows numbered "Instance 1", "Instance 2" labels |

#### Unit Tests (`auditing-capability-helpers.spec.ts`)

| Function | Test Cases |
|-----------------------------------------|--------------------------------------------------------------------|
| `isAuditInstance` | Audit type, error type, unknown type, undefined type |
| `filterAuditInstances` | null, undefined, empty, mixed, no audit, all audit |
| `allAuditInstancesUnavailable` | null, undefined, empty, all unavailable, all online, mixed, single |
| `hasUnavailableAuditInstances` | null, undefined, empty, at least one, all, none |
| `hasAvailableAuditInstances` | null, undefined, empty, at least one, all, none |
| `hasPartiallyUnavailableAuditInstances` | null, undefined, empty, mixed, all online, all unavailable, single |

## Key Source Files

| File | Purpose |
|---------------------------------------------------------------------------------------|----------------------------------------|
| `src/Frontend/src/components/platformcapabilities/capabilities/AuditingCapability.ts` | Main composable and helper functions |
| `src/Frontend/src/components/audit/isAllMessagesSupported.ts` | Version check for All Messages feature |
| `src/Frontend/test/preconditions/platformCapabilities.ts` | Test preconditions and fixtures |
| `src/Frontend/test/mocks/scenarios/` | Manual testing scenarios |

## Troubleshooting

### Scenario not loading

1. Check the browser console for errors
2. Verify the scenario name matches exactly (case-sensitive)
3. Ensure MSW is enabled (look for "[MSW] Mocking enabled" in console)

### Tests failing

1. Run `npm run type-check` to verify TypeScript compilation
2. Check if preconditions are properly set up
3. Use `--reporter=verbose` for detailed test output:

```bash
npx vitest run test/specs/platformcapabilities/ --reporter=verbose
```
Loading