Skip to content

Commit ed9fadb

Browse files
authored
Merge pull request #15644 from rancher/gha-portpr-18558644291-1
[backport v2.12.4] Ensure Compliance --> Profile list loads when profiles contain `skipTests: []`
2 parents 30f430c + a1831e3 commit ed9fadb

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import ComplianceProfile from '@shell/models/compliance.cattle.io.clusterscanprofile';
2+
3+
describe('class: ComplianceProfile', () => {
4+
describe('getter: numberTestsSkipped', () => {
5+
it('should return 0 if skipTests is not present in spec', () => {
6+
const complianceProfile = new ComplianceProfile({ spec: {} });
7+
8+
expect(complianceProfile.numberTestsSkipped).toBe(0);
9+
});
10+
11+
it('should return 0 if skipTests is null', () => {
12+
const complianceProfile = new ComplianceProfile({ spec: { skipTests: null } });
13+
14+
expect(complianceProfile.numberTestsSkipped).toBe(0);
15+
});
16+
17+
it('should return 0 if skipTests is an empty array', () => {
18+
const complianceProfile = new ComplianceProfile({ spec: { skipTests: [] } });
19+
20+
expect(complianceProfile.numberTestsSkipped).toBe(0);
21+
});
22+
23+
it('should return the correct number of skipped tests', () => {
24+
const tests = ['test-1', 'test-2', 'test-3'];
25+
const complianceProfile = new ComplianceProfile({ spec: { skipTests: tests } });
26+
27+
expect(complianceProfile.numberTestsSkipped).toBe(tests.length);
28+
});
29+
});
30+
});

shell/models/compliance.cattle.io.clusterscanprofile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class ComplianceProfile extends SteveModel {
1111
get numberTestsSkipped() {
1212
const { skipTests = [] } = this.spec;
1313

14-
return skipTests.length;
14+
return skipTests?.length || 0;
1515
}
1616

1717
get benchmarkVersionLink() {

0 commit comments

Comments
 (0)