Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 29 additions & 8 deletions .cursor/commands/fixture-schema-reference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Fixture Schema Reference

## Overview

Quick reference for the YAML fixture schema structure, valid values, and common patterns.

## Schema Structure
Expand All @@ -27,6 +28,7 @@ incidents: array # Required: Array of incident objects
## Valid Values

### Components

- `monitoring` - Monitoring infrastructure
- `storage` - Storage systems
- `network` - Network components
Expand All @@ -37,22 +39,26 @@ incidents: array # Required: Array of incident objects
- `Others` - Other components

### Layers

- `core` - Core OpenShift components
- `Others` - Non-core components

### Severities

- `critical` - Critical alerts
- `warning` - Warning alerts
- `info` - Informational alerts

### Duration Format

- Pattern: `^\d+[smhd]$`
- Examples: `"30m"`, `"2h"`, `"7d"`, `"1h"`
- Units: `s` (seconds), `m` (minutes), `h` (hours), `d` (days)

## Common Alert Names

### Monitoring Component

```yaml
- name: "AlertmanagerReceiversNotConfigured"
namespace: "openshift-monitoring"
Expand All @@ -76,6 +82,7 @@ incidents: array # Required: Array of incident objects
```

### Storage Component

```yaml
- name: "KubePersistentVolumeFillingUp"
namespace: "openshift-storage"
Expand All @@ -91,6 +98,7 @@ incidents: array # Required: Array of incident objects
```

### Network Component

```yaml
- name: "NetworkLatencyHigh"
namespace: "openshift-network"
Expand All @@ -102,6 +110,7 @@ incidents: array # Required: Array of incident objects
```

### Compute Component

```yaml
- name: "NodeNotReady"
namespace: "openshift-machine-api"
Expand All @@ -115,66 +124,78 @@ incidents: array # Required: Array of incident objects
## Timeline Patterns

### Simple Ongoing Incident

```yaml
timeline:
start: "2h" # Started 2 hours ago
start: "2h" # Started 2 hours ago
```

### Resolved Incident

```yaml
timeline:
start: "4h" # Started 4 hours ago
end: "1h" # Resolved 1 hour ago
start: "4h" # Started 4 hours ago
end: "1h" # Resolved 1 hour ago
```

### Severity Escalation

```yaml
timeline:
start: "3h" # Started 3 hours ago
start: "3h" # Started 3 hours ago
severityChanges:
- time: "3h" # Started as warning
- time: "3h" # Started as warning
severity: "warning"
- time: "1h" # Escalated to critical 1 hour ago
- time: "1h" # Escalated to critical 1 hour ago
severity: "critical"
```

## Validation Rules

### Required Fields

- Root: `name`, `description`, `incidents`
- Incident: `id`, `component`, `layer`, `alerts`
- Alert: `name`, `namespace`, `severity`
- Timeline: `start`

### Format Constraints

- Incident ID: Pattern `^[a-zA-Z0-9-_]+$`
- Duration: Pattern `^\d+[smhd]$`
- Component/Layer/Severity: Must be valid enum values

### Array Constraints

- Incidents: `minItems: 0`
- Alerts: `minItems: 1` per incident

## Usage in Tests

```typescript
// Load YAML fixture
cy.mockIncidentFixture('cypress/fixtures/incident-scenarios/critical-monitoring-issues.yaml');
cy.mockIncidentFixture(
"cypress/fixtures/incidents/scenarios/critical-monitoring-issues.yaml",
);

// Load JSON fixture (backward compatibility)
cy.mockIncidentFixture('cypress/fixtures/incident-scenarios/some-scenario.json');
cy.mockIncidentFixture(
"cypress/fixtures/incidents/scenarios/some-scenario.json",
);
```

## Validation Tools

### CLI Validation

```bash
cd web/cypress/support/incidents_prometheus_query_mocks
node validate-fixtures.js --all
node validate-fixtures.js specific-file.yaml
```

### Schema Files

- Schema: `web/cypress/support/incidents_prometheus_query_mocks/fixture-schema.json`
- Validator: `web/cypress/support/incidents_prometheus_query_mocks/schema-validator.ts`
- CLI Tool: `web/cypress/support/incidents_prometheus_query_mocks/validate-fixtures.js`
Expand Down
14 changes: 7 additions & 7 deletions .cursor/commands/generate-regression-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Generate automated regression tests from test documentation in [`docs/incident_d

### 3. Check/Create Fixtures

**Fixture location**: `web/cypress/fixtures/incident-scenarios/`
**Fixture location**: `web/cypress/fixtures/incidents/scenarios/`

**Naming convention**: `XX-descriptive-name.yaml` (e.g., `13-tooltip-positioning-scenarios.yaml`)

Expand Down Expand Up @@ -108,7 +108,7 @@ describe("Regression: [Section Name]", () => {
cy.log("Navigate to Observe → Incidents");
incidentsPage.goTo();
cy.log("[Brief description of scenario being loaded]");
cy.mockIncidentFixture("incident-scenarios/XX-scenario-name.yaml");
cy.mockIncidentFixture("incidents/scenarios/XX-scenario-name.yaml");
});

it("1. [First test case description]", () => {
Expand Down Expand Up @@ -355,7 +355,7 @@ incidentsPage.toggleFilter("Critical");

**Scenario A - No fixture exists**:

1. Search for similar fixtures in `web/cypress/fixtures/incident-scenarios/`
1. Search for similar fixtures in `web/cypress/fixtures/incidents/scenarios/`
2. Prompt with options:
```
No fixture found. Required: [list requirements]
Expand Down Expand Up @@ -549,7 +549,7 @@ describe("Regression: Tooltip Positioning", () => {
incidentsPage.goTo();
cy.log("Loading tooltip positioning test scenarios");
cy.mockIncidentFixture(
"incident-scenarios/13-tooltip-positioning-scenarios.yaml",
"incidents/scenarios/13-tooltip-positioning-scenarios.yaml",
);
});

Expand Down Expand Up @@ -634,7 +634,7 @@ describe("Regression: Tooltip Positioning", () => {
**AI Actions**:

1. Parse Section 1 from testing_flows_ui.md
2. Note: Fixture `7-comprehensive-filtering-test-scenarios.yaml` already exists
2. Note: Fixture `comprehensive-filtering-test-scenarios.yaml` already exists
3. **Design comprehensive flow**: Instead of separate tests for each filter type, create complete filtering workflows
- Flow 1: User applies multiple filters in sequence, verifies each step, then clears all
- Flow 2: User changes time range while filters are active, verifies data updates
Expand All @@ -648,8 +648,8 @@ Provide:
1. **Test file path and name**: Full path to generated test file
2. **Test file content**: Complete TypeScript test file
3. **Fixture status**:
- If existing: "Using fixture: incident-scenarios/X-name.yaml"
- If new: "Created fixture: incident-scenarios/X-name.yaml" + YAML content
- If existing: "Using fixture: incidents/scenarios/X-name.yaml"
- If new: "Created fixture: incidents/scenarios/X-name.yaml" + YAML content
4. **Page object changes**: If any elements/methods need to be added, list them with implementation
5. **Validation status**: Confirm all checklist items passed

Expand Down
31 changes: 26 additions & 5 deletions .cursor/commands/validate-incident-fixtures.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,107 @@
# Validate Incident Fixtures

## Overview

Validate existing YAML incident fixture files against the JSON Schema to ensure they are properly structured and will work correctly in tests.

## Process

### 1. Locate Fixture Files
- Check `web/cypress/fixtures/incident-scenarios/` directory

- Check `web/cypress/fixtures/incidents/scenarios/` directory
- Identify all `.yaml` and `.yml` files
- Also validate any `.json` fixture files for backward compatibility

### 2. Run Schema Validation

Use the validation tool to check each fixture:

```bash
cd web/cypress/support/incidents_prometheus_query_mocks
node validate-fixtures.js --all
```

### 3. Analyze Results

For each fixture file:

- ✅ **Valid**: Fixture passes all schema validation
- ❌ **Invalid**: Identify specific validation errors
- 🔧 **Fixable**: Determine if errors can be automatically corrected

### 4. Fix Validation Issues

Common issues and fixes:

#### Missing Required Fields

- Add missing `name`, `description`, or `incidents` fields
- Ensure all incidents have required `id`, `component`, `layer`, `alerts`

#### Invalid Duration Format

- Fix duration strings to use format: `"2h"`, `"30m"`, `"7d"`
- Remove invalid formats like `"2 hours"`, `"30 minutes"`

#### Invalid Enum Values

- **Components**: Use only valid values (monitoring, storage, network, etc.)
- **Layers**: Use only `"core"` or `"Others"`
- **Severities**: Use only `"critical"`, `"warning"`, or `"info"`

#### YAML Syntax Errors

- Fix indentation issues
- Correct quote usage
- Ensure proper array formatting

#### Alert Structure Issues

- Ensure alerts have `name`, `namespace`, `severity`
- Verify alert names are realistic OpenShift alert names
- Check namespace formats match OpenShift conventions

## Validation Checklist

### Schema Compliance

- [ ] All required fields present
- [ ] Valid component enum values
- [ ] Valid layer enum values
- [ ] Valid layer enum values
- [ ] Valid severity enum values
- [ ] Proper duration format
- [ ] Correct YAML syntax

### Content Quality

- [ ] Realistic alert names
- [ ] Proper OpenShift namespaces
- [ ] Logical timeline values
- [ ] Descriptive scenario names
- [ ] Clear descriptions

### Test Readiness

- [ ] Fixtures can be loaded without errors
- [ ] Schema validation passes
- [ ] Ready for use in Cypress tests

## Common Fixes

### Fix Duration Format

```yaml
# Before
start: "2 hours ago"
end: "30 minutes ago"

# After
start: "2h" # Started 2 hours ago
end: "30m" # Resolved 30 minutes ago
# After
start: "2h" # Started 2 hours ago
end: "30m" # Resolved 30 minutes ago
```

### Fix Component Names

```yaml
# Before
component: "monitoring-system"
Expand All @@ -94,6 +111,7 @@ component: "monitoring"
```

### Fix Alert Structure

```yaml
# Before
alerts:
Expand All @@ -110,13 +128,16 @@ alerts:
```

## Output

Provide:

1. **Validation Summary**: List of all fixtures and their validation status
2. **Error Details**: Specific validation errors for any failed fixtures
3. **Fix Suggestions**: Recommended changes for invalid fixtures
4. **Corrected Fixtures**: Updated YAML content for any fixtures that need fixes

## Tools Available

- Schema validator: `web/cypress/support/incidents_prometheus_query_mocks/schema-validator.ts`
- CLI validator: `web/cypress/support/incidents_prometheus_query_mocks/validate-fixtures.js`
- JSON Schema: `web/cypress/support/incidents_prometheus_query_mocks/fixture-schema.json`
8 changes: 4 additions & 4 deletions .cursor/rules/incidents-testing-guidelines.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Development guidelines for Incidents page Cypress tests"
globs:
- "web/cypress/e2e/incidents/**/*.cy.ts"
- "web/cypress/views/incidents-page.ts"
- "web/cypress/fixtures/incident-scenarios/**/*.yaml"
- "web/cypress/fixtures/incidents/scenarios/**/*.yaml"
---

# Incidents Testing Development Guidelines
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('Regression: <Section Name>', () => {
cy.log('Navigate to Observe → Incidents');
incidentsPage.goTo();
cy.log('Brief description of scenario');
cy.mockIncidentFixture('incident-scenarios/XX-name.yaml');
cy.mockIncidentFixture('incidents/scenarios/XX-name.yaml');
});

it('1. Test case description', () => {
Expand Down Expand Up @@ -239,14 +239,14 @@ it('2. Existing test', () => {
## Fixture Management

### Fixture Location and Naming
- Location: `web/cypress/fixtures/incident-scenarios/`
- Location: `web/cypress/fixtures/incidents/scenarios/`
- Pattern: `XX-descriptive-name.yaml`
- Examples: `13-tooltip-positioning-scenarios.yaml`

### Fixture Usage in Tests
```typescript
// Preferred: Single scenario per test file
cy.mockIncidentFixture('incident-scenarios/13-tooltip-positioning-scenarios.yaml');
cy.mockIncidentFixture('incidents/scenarios/13-tooltip-positioning-scenarios.yaml');

// For empty state
cy.mockIncidents([]);
Expand Down
Loading