@sentry/warden 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/find-bugs/SKILL.md +75 -0
- package/.agents/skills/vercel-react-best-practices/AGENTS.md +2934 -0
- package/.agents/skills/vercel-react-best-practices/SKILL.md +136 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/.claude/settings.json +57 -0
- package/.claude/settings.local.json +88 -0
- package/.claude/skills/agent-prompt/SKILL.md +54 -0
- package/.claude/skills/agent-prompt/references/agentic-patterns.md +94 -0
- package/.claude/skills/agent-prompt/references/anti-patterns.md +140 -0
- package/.claude/skills/agent-prompt/references/context-design.md +124 -0
- package/.claude/skills/agent-prompt/references/core-principles.md +75 -0
- package/.claude/skills/agent-prompt/references/model-guidance.md +118 -0
- package/.claude/skills/agent-prompt/references/output-formats.md +98 -0
- package/.claude/skills/agent-prompt/references/skill-structure.md +115 -0
- package/.claude/skills/agent-prompt/references/system-prompts.md +115 -0
- package/.claude/skills/notseer/SKILL.md +131 -0
- package/.claude/skills/skill-writer/SKILL.md +140 -0
- package/.claude/skills/testing-guidelines/SKILL.md +132 -0
- package/.claude/skills/warden-skill/SKILL.md +250 -0
- package/.claude/skills/warden-skill/references/config-schema.md +133 -0
- package/.dex/config.toml +2 -0
- package/.github/workflows/ci.yml +33 -0
- package/.github/workflows/release.yml +54 -0
- package/.github/workflows/warden.yml +40 -0
- package/AGENTS.md +89 -0
- package/CONTRIBUTING.md +60 -0
- package/LICENSE +105 -0
- package/README.md +43 -0
- package/SPEC.md +263 -0
- package/action.yml +87 -0
- package/assets/favicon.png +0 -0
- package/assets/warden-icon-bw.svg +5 -0
- package/assets/warden-icon-purple.png +0 -0
- package/assets/warden-icon-purple.svg +5 -0
- package/docs/.claude/settings.local.json +11 -0
- package/docs/astro.config.mjs +43 -0
- package/docs/package.json +19 -0
- package/docs/pnpm-lock.yaml +4000 -0
- package/docs/public/favicon.svg +5 -0
- package/docs/src/components/Code.astro +141 -0
- package/docs/src/components/PackageManagerTabs.astro +183 -0
- package/docs/src/components/Terminal.astro +212 -0
- package/docs/src/layouts/Base.astro +380 -0
- package/docs/src/pages/cli.astro +167 -0
- package/docs/src/pages/config.astro +394 -0
- package/docs/src/pages/guide.astro +449 -0
- package/docs/src/pages/index.astro +490 -0
- package/docs/src/styles/global.css +551 -0
- package/docs/tsconfig.json +3 -0
- package/docs/vercel.json +5 -0
- package/eslint.config.js +33 -0
- package/package.json +73 -0
- package/src/action/index.ts +1 -0
- package/src/action/main.ts +868 -0
- package/src/cli/args.test.ts +477 -0
- package/src/cli/args.ts +415 -0
- package/src/cli/commands/add.ts +447 -0
- package/src/cli/commands/init.test.ts +136 -0
- package/src/cli/commands/init.ts +132 -0
- package/src/cli/commands/setup-app/browser.ts +38 -0
- package/src/cli/commands/setup-app/credentials.ts +45 -0
- package/src/cli/commands/setup-app/manifest.ts +48 -0
- package/src/cli/commands/setup-app/server.ts +172 -0
- package/src/cli/commands/setup-app.ts +156 -0
- package/src/cli/commands/sync.ts +114 -0
- package/src/cli/context.ts +131 -0
- package/src/cli/files.test.ts +155 -0
- package/src/cli/files.ts +89 -0
- package/src/cli/fix.test.ts +310 -0
- package/src/cli/fix.ts +387 -0
- package/src/cli/git.test.ts +119 -0
- package/src/cli/git.ts +318 -0
- package/src/cli/index.ts +14 -0
- package/src/cli/main.ts +672 -0
- package/src/cli/output/box.ts +235 -0
- package/src/cli/output/formatters.test.ts +187 -0
- package/src/cli/output/formatters.ts +269 -0
- package/src/cli/output/icons.ts +13 -0
- package/src/cli/output/index.ts +44 -0
- package/src/cli/output/ink-runner.tsx +337 -0
- package/src/cli/output/jsonl.test.ts +347 -0
- package/src/cli/output/jsonl.ts +126 -0
- package/src/cli/output/reporter.ts +435 -0
- package/src/cli/output/tasks.ts +374 -0
- package/src/cli/output/tty.test.ts +117 -0
- package/src/cli/output/tty.ts +60 -0
- package/src/cli/output/verbosity.test.ts +40 -0
- package/src/cli/output/verbosity.ts +31 -0
- package/src/cli/terminal.test.ts +148 -0
- package/src/cli/terminal.ts +301 -0
- package/src/config/index.ts +3 -0
- package/src/config/loader.test.ts +313 -0
- package/src/config/loader.ts +103 -0
- package/src/config/schema.ts +168 -0
- package/src/config/writer.test.ts +119 -0
- package/src/config/writer.ts +84 -0
- package/src/diff/classify.test.ts +162 -0
- package/src/diff/classify.ts +92 -0
- package/src/diff/coalesce.test.ts +208 -0
- package/src/diff/coalesce.ts +133 -0
- package/src/diff/context.test.ts +226 -0
- package/src/diff/context.ts +201 -0
- package/src/diff/index.ts +4 -0
- package/src/diff/parser.test.ts +212 -0
- package/src/diff/parser.ts +149 -0
- package/src/event/context.ts +132 -0
- package/src/event/index.ts +2 -0
- package/src/event/schedule-context.ts +101 -0
- package/src/examples/examples.integration.test.ts +66 -0
- package/src/examples/index.test.ts +101 -0
- package/src/examples/index.ts +122 -0
- package/src/examples/setup.ts +25 -0
- package/src/index.ts +115 -0
- package/src/output/dedup.test.ts +419 -0
- package/src/output/dedup.ts +607 -0
- package/src/output/github-checks.test.ts +300 -0
- package/src/output/github-checks.ts +476 -0
- package/src/output/github-issues.ts +329 -0
- package/src/output/index.ts +5 -0
- package/src/output/issue-renderer.ts +197 -0
- package/src/output/renderer.test.ts +727 -0
- package/src/output/renderer.ts +217 -0
- package/src/output/stale.test.ts +375 -0
- package/src/output/stale.ts +155 -0
- package/src/output/types.ts +34 -0
- package/src/sdk/index.ts +1 -0
- package/src/sdk/runner.test.ts +806 -0
- package/src/sdk/runner.ts +1232 -0
- package/src/skills/index.ts +36 -0
- package/src/skills/loader.test.ts +300 -0
- package/src/skills/loader.ts +423 -0
- package/src/skills/remote.test.ts +704 -0
- package/src/skills/remote.ts +604 -0
- package/src/triggers/matcher.test.ts +277 -0
- package/src/triggers/matcher.ts +152 -0
- package/src/types/index.ts +194 -0
- package/src/utils/async.ts +18 -0
- package/src/utils/index.test.ts +84 -0
- package/src/utils/index.ts +50 -0
- package/tsconfig.json +25 -0
- package/vitest.config.ts +8 -0
- package/vitest.integration.config.ts +11 -0
- package/warden.toml +19 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
severityToAnnotationLevel,
|
|
4
|
+
findingsToAnnotations,
|
|
5
|
+
determineConclusion,
|
|
6
|
+
aggregateSeverityCounts,
|
|
7
|
+
} from './github-checks.js';
|
|
8
|
+
import type { Finding, SkillReport } from '../types/index.js';
|
|
9
|
+
|
|
10
|
+
describe('severityToAnnotationLevel', () => {
|
|
11
|
+
it('maps critical to failure', () => {
|
|
12
|
+
expect(severityToAnnotationLevel('critical')).toBe('failure');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('maps high to failure', () => {
|
|
16
|
+
expect(severityToAnnotationLevel('high')).toBe('failure');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('maps medium to warning', () => {
|
|
20
|
+
expect(severityToAnnotationLevel('medium')).toBe('warning');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('maps low to notice', () => {
|
|
24
|
+
expect(severityToAnnotationLevel('low')).toBe('notice');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('maps info to notice', () => {
|
|
28
|
+
expect(severityToAnnotationLevel('info')).toBe('notice');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('findingsToAnnotations', () => {
|
|
33
|
+
it('converts findings with location to annotations', () => {
|
|
34
|
+
const findings: Finding[] = [
|
|
35
|
+
{
|
|
36
|
+
id: 'f1',
|
|
37
|
+
severity: 'high',
|
|
38
|
+
title: 'Security Issue',
|
|
39
|
+
description: 'Details about the issue',
|
|
40
|
+
location: {
|
|
41
|
+
path: 'src/file.ts',
|
|
42
|
+
startLine: 10,
|
|
43
|
+
endLine: 15,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const annotations = findingsToAnnotations(findings);
|
|
49
|
+
|
|
50
|
+
expect(annotations).toHaveLength(1);
|
|
51
|
+
expect(annotations[0]).toEqual({
|
|
52
|
+
path: 'src/file.ts',
|
|
53
|
+
start_line: 10,
|
|
54
|
+
end_line: 15,
|
|
55
|
+
annotation_level: 'failure',
|
|
56
|
+
message: 'Details about the issue',
|
|
57
|
+
title: 'Security Issue',
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('uses startLine for end_line when endLine not provided', () => {
|
|
62
|
+
const findings: Finding[] = [
|
|
63
|
+
{
|
|
64
|
+
id: 'f1',
|
|
65
|
+
severity: 'medium',
|
|
66
|
+
title: 'Issue',
|
|
67
|
+
description: 'Details',
|
|
68
|
+
location: {
|
|
69
|
+
path: 'src/file.ts',
|
|
70
|
+
startLine: 25,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const annotations = findingsToAnnotations(findings);
|
|
76
|
+
|
|
77
|
+
expect(annotations[0]!.start_line).toBe(25);
|
|
78
|
+
expect(annotations[0]!.end_line).toBe(25);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('filters out findings without location', () => {
|
|
82
|
+
const findings: Finding[] = [
|
|
83
|
+
{
|
|
84
|
+
id: 'f1',
|
|
85
|
+
severity: 'high',
|
|
86
|
+
title: 'General Issue',
|
|
87
|
+
description: 'No location',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'f2',
|
|
91
|
+
severity: 'medium',
|
|
92
|
+
title: 'Located Issue',
|
|
93
|
+
description: 'Has location',
|
|
94
|
+
location: {
|
|
95
|
+
path: 'src/file.ts',
|
|
96
|
+
startLine: 5,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
const annotations = findingsToAnnotations(findings);
|
|
102
|
+
|
|
103
|
+
expect(annotations).toHaveLength(1);
|
|
104
|
+
expect(annotations[0]!.title).toBe('Located Issue');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('sorts by severity (most severe first)', () => {
|
|
108
|
+
const findings: Finding[] = [
|
|
109
|
+
{
|
|
110
|
+
id: 'f1',
|
|
111
|
+
severity: 'low',
|
|
112
|
+
title: 'Low',
|
|
113
|
+
description: 'Low severity',
|
|
114
|
+
location: { path: 'a.ts', startLine: 1 },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'f2',
|
|
118
|
+
severity: 'critical',
|
|
119
|
+
title: 'Critical',
|
|
120
|
+
description: 'Critical severity',
|
|
121
|
+
location: { path: 'b.ts', startLine: 2 },
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'f3',
|
|
125
|
+
severity: 'medium',
|
|
126
|
+
title: 'Medium',
|
|
127
|
+
description: 'Medium severity',
|
|
128
|
+
location: { path: 'c.ts', startLine: 3 },
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
const annotations = findingsToAnnotations(findings);
|
|
133
|
+
|
|
134
|
+
expect(annotations[0]!.title).toBe('Critical');
|
|
135
|
+
expect(annotations[1]!.title).toBe('Medium');
|
|
136
|
+
expect(annotations[2]!.title).toBe('Low');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('limits to 50 annotations', () => {
|
|
140
|
+
const findings: Finding[] = Array.from({ length: 60 }, (_, i) => ({
|
|
141
|
+
id: `f${i}`,
|
|
142
|
+
severity: 'info' as const,
|
|
143
|
+
title: `Finding ${i}`,
|
|
144
|
+
description: `Description ${i}`,
|
|
145
|
+
location: { path: `file${i}.ts`, startLine: i + 1 },
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
const annotations = findingsToAnnotations(findings);
|
|
149
|
+
|
|
150
|
+
expect(annotations).toHaveLength(50);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('filters by commentOn threshold', () => {
|
|
154
|
+
const findings: Finding[] = [
|
|
155
|
+
{
|
|
156
|
+
id: 'f1',
|
|
157
|
+
severity: 'critical',
|
|
158
|
+
title: 'Critical',
|
|
159
|
+
description: 'Critical issue',
|
|
160
|
+
location: { path: 'a.ts', startLine: 1 },
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 'f2',
|
|
164
|
+
severity: 'high',
|
|
165
|
+
title: 'High',
|
|
166
|
+
description: 'High issue',
|
|
167
|
+
location: { path: 'b.ts', startLine: 2 },
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: 'f3',
|
|
171
|
+
severity: 'medium',
|
|
172
|
+
title: 'Medium',
|
|
173
|
+
description: 'Medium issue',
|
|
174
|
+
location: { path: 'c.ts', startLine: 3 },
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: 'f4',
|
|
178
|
+
severity: 'low',
|
|
179
|
+
title: 'Low',
|
|
180
|
+
description: 'Low issue',
|
|
181
|
+
location: { path: 'd.ts', startLine: 4 },
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
// commentOn='high' should only include critical and high
|
|
186
|
+
const annotations = findingsToAnnotations(findings, 'high');
|
|
187
|
+
|
|
188
|
+
expect(annotations).toHaveLength(2);
|
|
189
|
+
expect(annotations.map((a) => a.title)).toEqual(['Critical', 'High']);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('returns all findings when commentOn is undefined', () => {
|
|
193
|
+
const findings: Finding[] = [
|
|
194
|
+
{
|
|
195
|
+
id: 'f1',
|
|
196
|
+
severity: 'critical',
|
|
197
|
+
title: 'Critical',
|
|
198
|
+
description: 'Critical issue',
|
|
199
|
+
location: { path: 'a.ts', startLine: 1 },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'f2',
|
|
203
|
+
severity: 'info',
|
|
204
|
+
title: 'Info',
|
|
205
|
+
description: 'Info issue',
|
|
206
|
+
location: { path: 'b.ts', startLine: 2 },
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
const annotations = findingsToAnnotations(findings, undefined);
|
|
211
|
+
|
|
212
|
+
expect(annotations).toHaveLength(2);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('determineConclusion', () => {
|
|
217
|
+
it('returns success for empty findings', () => {
|
|
218
|
+
expect(determineConclusion([], 'high')).toBe('success');
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('returns neutral when no failOn threshold', () => {
|
|
222
|
+
const findings: Finding[] = [
|
|
223
|
+
{ id: 'f1', severity: 'critical', title: 'Issue', description: 'Details' },
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
expect(determineConclusion(findings, undefined)).toBe('neutral');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('returns failure when findings meet threshold', () => {
|
|
230
|
+
const findings: Finding[] = [
|
|
231
|
+
{ id: 'f1', severity: 'high', title: 'High Issue', description: 'Details' },
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
expect(determineConclusion(findings, 'high')).toBe('failure');
|
|
235
|
+
expect(determineConclusion(findings, 'medium')).toBe('failure');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('returns neutral when findings below threshold', () => {
|
|
239
|
+
const findings: Finding[] = [
|
|
240
|
+
{ id: 'f1', severity: 'medium', title: 'Medium Issue', description: 'Details' },
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
expect(determineConclusion(findings, 'high')).toBe('neutral');
|
|
244
|
+
expect(determineConclusion(findings, 'critical')).toBe('neutral');
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('considers critical more severe than high', () => {
|
|
248
|
+
const findings: Finding[] = [
|
|
249
|
+
{ id: 'f1', severity: 'critical', title: 'Critical', description: 'Details' },
|
|
250
|
+
];
|
|
251
|
+
|
|
252
|
+
expect(determineConclusion(findings, 'high')).toBe('failure');
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
describe('aggregateSeverityCounts', () => {
|
|
257
|
+
it('counts findings by severity across reports', () => {
|
|
258
|
+
const reports: SkillReport[] = [
|
|
259
|
+
{
|
|
260
|
+
skill: 'skill-1',
|
|
261
|
+
summary: 'Summary 1',
|
|
262
|
+
findings: [
|
|
263
|
+
{ id: 'f1', severity: 'critical', title: 'A', description: 'D' },
|
|
264
|
+
{ id: 'f2', severity: 'high', title: 'B', description: 'D' },
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
skill: 'skill-2',
|
|
269
|
+
summary: 'Summary 2',
|
|
270
|
+
findings: [
|
|
271
|
+
{ id: 'f3', severity: 'high', title: 'C', description: 'D' },
|
|
272
|
+
{ id: 'f4', severity: 'medium', title: 'E', description: 'D' },
|
|
273
|
+
{ id: 'f5', severity: 'info', title: 'F', description: 'D' },
|
|
274
|
+
],
|
|
275
|
+
},
|
|
276
|
+
];
|
|
277
|
+
|
|
278
|
+
const counts = aggregateSeverityCounts(reports);
|
|
279
|
+
|
|
280
|
+
expect(counts).toEqual({
|
|
281
|
+
critical: 1,
|
|
282
|
+
high: 2,
|
|
283
|
+
medium: 1,
|
|
284
|
+
low: 0,
|
|
285
|
+
info: 1,
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('returns all zeros for empty reports', () => {
|
|
290
|
+
const counts = aggregateSeverityCounts([]);
|
|
291
|
+
|
|
292
|
+
expect(counts).toEqual({
|
|
293
|
+
critical: 0,
|
|
294
|
+
high: 0,
|
|
295
|
+
medium: 0,
|
|
296
|
+
low: 0,
|
|
297
|
+
info: 0,
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
});
|