chore: import upstream snapshot with attribution
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
// Using a mock type since this is a test - don't import complex frontend types
|
||||
interface ScanResult {
|
||||
path: string;
|
||||
success: boolean;
|
||||
issues: Array<{ severity: string; message: string }>;
|
||||
rawOutput: string;
|
||||
files_scanned?: number;
|
||||
scannedFiles?: number;
|
||||
}
|
||||
|
||||
describe('Model Audit Critical Findings Fix', () => {
|
||||
it('should correctly count critical severity issues', () => {
|
||||
const mockScanResults: ScanResult = {
|
||||
path: '/test/path',
|
||||
success: true,
|
||||
issues: [
|
||||
{ severity: 'critical', message: 'Critical issue 1' },
|
||||
{ severity: 'critical', message: 'Critical issue 2' },
|
||||
{ severity: 'error', message: 'Error issue 1' },
|
||||
{ severity: 'warning', message: 'Warning issue 1' },
|
||||
{ severity: 'info', message: 'Info issue 1' },
|
||||
],
|
||||
rawOutput: '',
|
||||
};
|
||||
|
||||
// Test the critical/error counting logic
|
||||
const criticalAndErrorCount = mockScanResults.issues.filter(
|
||||
(i) => i.severity === 'error' || i.severity === 'critical',
|
||||
).length;
|
||||
|
||||
expect(criticalAndErrorCount).toBe(3); // 2 critical + 1 error
|
||||
|
||||
const warningCount = mockScanResults.issues.filter((i) => i.severity === 'warning').length;
|
||||
|
||||
expect(warningCount).toBe(1);
|
||||
|
||||
const infoCount = mockScanResults.issues.filter((i) => i.severity === 'info').length;
|
||||
|
||||
expect(infoCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should correctly filter issues when selectedSeverity is error', () => {
|
||||
const mockScanResults: ScanResult = {
|
||||
path: '/test/path',
|
||||
success: true,
|
||||
issues: [
|
||||
{ severity: 'critical', message: 'Critical issue 1' },
|
||||
{ severity: 'error', message: 'Error issue 1' },
|
||||
{ severity: 'warning', message: 'Warning issue 1' },
|
||||
{ severity: 'info', message: 'Info issue 1' },
|
||||
],
|
||||
rawOutput: '',
|
||||
};
|
||||
|
||||
const selectedSeverity = 'error';
|
||||
|
||||
// Test the filtering logic from SecurityFindings.tsx
|
||||
const filteredIssues = mockScanResults.issues.filter((issue) => {
|
||||
if (!selectedSeverity && issue.severity === 'debug') {
|
||||
return false;
|
||||
}
|
||||
if (!selectedSeverity) {
|
||||
return true;
|
||||
}
|
||||
// Handle critical/error mapping
|
||||
if (selectedSeverity === 'error') {
|
||||
return issue.severity === 'error' || issue.severity === 'critical';
|
||||
}
|
||||
return issue.severity === selectedSeverity;
|
||||
});
|
||||
|
||||
expect(filteredIssues).toHaveLength(2); // Should include both critical and error
|
||||
expect(filteredIssues.every((i) => i.severity === 'critical' || i.severity === 'error')).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it('should only show critical/error issues when filtering by error severity', () => {
|
||||
const mockScanResults: ScanResult = {
|
||||
path: '/test/path',
|
||||
success: true,
|
||||
issues: [
|
||||
{ severity: 'critical', message: 'Critical issue 1' },
|
||||
{ severity: 'critical', message: 'Critical issue 2' },
|
||||
{ severity: 'warning', message: 'Warning issue 1' },
|
||||
{ severity: 'info', message: 'Info issue 1' },
|
||||
],
|
||||
rawOutput: '',
|
||||
};
|
||||
|
||||
const selectedSeverity = 'error';
|
||||
|
||||
const filteredIssues = mockScanResults.issues.filter((issue) => {
|
||||
if (!selectedSeverity && issue.severity === 'debug') {
|
||||
return false;
|
||||
}
|
||||
if (!selectedSeverity) {
|
||||
return true;
|
||||
}
|
||||
// Handle critical/error mapping
|
||||
if (selectedSeverity === 'error') {
|
||||
return issue.severity === 'error' || issue.severity === 'critical';
|
||||
}
|
||||
return issue.severity === selectedSeverity;
|
||||
});
|
||||
|
||||
expect(filteredIssues).toHaveLength(2); // Should only show the 2 critical issues
|
||||
expect(filteredIssues.every((i) => i.severity === 'critical')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
// Using a mock type since this is a test - don't import complex frontend types
|
||||
interface ScanResult {
|
||||
path: string;
|
||||
success: boolean;
|
||||
issues: Array<{ severity: string; message: string }>;
|
||||
rawOutput: string;
|
||||
files_scanned?: number;
|
||||
scannedFiles?: number;
|
||||
}
|
||||
|
||||
describe('Model Audit Scanned Files Fix', () => {
|
||||
it('should correctly display files_scanned when scannedFiles is undefined', () => {
|
||||
const mockScanResults: ScanResult = {
|
||||
path: '/test/path',
|
||||
success: true,
|
||||
issues: [{ severity: 'critical', message: 'Critical issue 1' }],
|
||||
rawOutput: '',
|
||||
files_scanned: 5, // CLI outputs this field
|
||||
// scannedFiles: undefined, // UI was looking for this field
|
||||
};
|
||||
|
||||
// Test the logic that should be used in ScanStatistics.tsx
|
||||
const fileCount = mockScanResults.files_scanned ?? mockScanResults.scannedFiles ?? 0;
|
||||
|
||||
expect(fileCount).toBe(5);
|
||||
});
|
||||
|
||||
it('should prefer scannedFiles over files_scanned if both are present', () => {
|
||||
const mockScanResults: ScanResult = {
|
||||
path: '/test/path',
|
||||
success: true,
|
||||
issues: [],
|
||||
rawOutput: '',
|
||||
files_scanned: 3,
|
||||
scannedFiles: 7, // This should take precedence
|
||||
};
|
||||
|
||||
// Test the logic that should be used in ScanStatistics.tsx
|
||||
const fileCount = mockScanResults.files_scanned ?? mockScanResults.scannedFiles ?? 0;
|
||||
|
||||
expect(fileCount).toBe(3); // files_scanned should be checked first
|
||||
});
|
||||
|
||||
it('should fallback to 0 when neither field is present', () => {
|
||||
const mockScanResults: ScanResult = {
|
||||
path: '/test/path',
|
||||
success: true,
|
||||
issues: [],
|
||||
rawOutput: '',
|
||||
// Neither files_scanned nor scannedFiles present
|
||||
};
|
||||
|
||||
const fileCount = mockScanResults.files_scanned ?? mockScanResults.scannedFiles ?? 0;
|
||||
|
||||
expect(fileCount).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user