Skip to content

Commit e373d07

Browse files
Merge pull request #4800 from linuxfoundation/unicron-4762-cypress-apis-test-coverage-12
Fix the test coverage with Copilot CLI
2 parents 488243d + e6a73ce commit e373d07

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

tests/functional/cypress/e2e/v4/signatures.cy.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
467467
validate_200_Status(response);
468468
let list = response.body.emailApprovalList;
469469
if (list != null) {
470-
for (let i = 0; i <= list.length; i++) {
470+
for (let i = 0; i < list.length; i++) {
471471
expect(list[i]).to.not.equal(emailApprovalList);
472472
}
473473
}
@@ -515,7 +515,7 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
515515
validate_200_Status(response);
516516
let list = response.body.githubOrgApprovalList;
517517
if (list != null) {
518-
for (let i = 0; i <= list.length; i++) {
518+
for (let i = 0; i < list.length; i++) {
519519
expect(list[i]).to.not.equal(gitOrgApprovalList);
520520
}
521521
}
@@ -538,14 +538,17 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
538538
}).then((response) => {
539539
validate_200_Status(response);
540540
let list = response.body.githubUsernameApprovalList;
541-
for (let i = 0; i <= list.length; i++) {
541+
let found = false;
542+
for (let i = 0; i < list.length; i++) {
542543
if (list[i] === gitUsernameApprovalList) {
543544
expect(list[i]).to.eql(gitUsernameApprovalList);
545+
found = true;
544546
break;
545-
} else if (i == list.length) {
546-
expect(list[i]).to.eql(gitUsernameApprovalList);
547547
}
548548
}
549+
if (!found) {
550+
expect.fail('GitHub Username not found in approval list');
551+
}
549552
});
550553
});
551554

@@ -566,7 +569,7 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
566569
validate_200_Status(response);
567570
let list = response.body.githubUsernameApprovalList;
568571
if (list != null) {
569-
for (let i = 0; i <= list.length; i++) {
572+
for (let i = 0; i < list.length; i++) {
570573
expect(list[i]).to.not.equal(gitUsernameApprovalList);
571574
}
572575
}
@@ -589,14 +592,17 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
589592
}).then((response) => {
590593
validate_200_Status(response);
591594
let list = response.body.gitlabUsernameApprovalList;
592-
for (let i = 0; i <= list.length; i++) {
595+
let found = false;
596+
for (let i = 0; i < list.length; i++) {
593597
if (list[i] === gitUsernameApprovalList) {
594598
expect(list[i]).to.eql(gitUsernameApprovalList);
599+
found = true;
595600
break;
596-
} else if (i == list.length) {
597-
expect(list[i]).to.eql(gitUsernameApprovalList);
598601
}
599602
}
603+
if (!found) {
604+
expect.fail('GitLab Username not found in approval list');
605+
}
600606
});
601607
});
602608

@@ -617,7 +623,7 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
617623
validate_200_Status(response);
618624
let list = response.body.gitlabUsernameApprovalList;
619625
if (list != null) {
620-
for (let i = 0; i <= list.length; i++) {
626+
for (let i = 0; i < list.length; i++) {
621627
expect(list[i]).to.not.equal(gitUsernameApprovalList);
622628
}
623629
}
@@ -640,14 +646,17 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
640646
}).then((response) => {
641647
validate_200_Status(response);
642648
let list = response.body.gitlabOrgApprovalList;
643-
for (let i = 0; i <= list.length; i++) {
649+
let found = false;
650+
for (let i = 0; i < list.length; i++) {
644651
if (list[i] === gitLabOrgApprovalList) {
645652
expect(list[i]).to.eql(gitLabOrgApprovalList);
653+
found = true;
646654
break;
647-
} else if (i == list.length) {
648-
expect(list[i]).to.eql(gitLabOrgApprovalList);
649655
}
650656
}
657+
if (!found) {
658+
expect.fail('GitLab Org not found in approval list');
659+
}
651660
});
652661
});
653662

@@ -668,7 +677,7 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
668677
validate_200_Status(response);
669678
let list = response.body.gitlabOrgApprovalList;
670679
if (list != null) {
671-
for (let i = 0; i <= list.length; i++) {
680+
for (let i = 0; i < list.length; i++) {
672681
expect(list[i]).to.not.equal(gitLabOrgApprovalList);
673682
}
674683
}
@@ -691,14 +700,17 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
691700
}).then((response) => {
692701
validate_200_Status(response);
693702
let list = response.body.domainApprovalList;
694-
for (let i = 0; i <= list.length; i++) {
703+
let found = false;
704+
for (let i = 0; i < list.length; i++) {
695705
if (list[i] === domainApprovalList) {
696706
expect(list[i]).to.eql(domainApprovalList);
707+
found = true;
697708
break;
698-
} else if (i == list.length) {
699-
expect(list[i]).to.eql(domainApprovalList);
700709
}
701710
}
711+
if (!found) {
712+
expect.fail('Domain not found in approval list');
713+
}
702714
});
703715
});
704716

@@ -719,7 +731,7 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
719731
validate_200_Status(response);
720732
let list = response.body.domainApprovalList;
721733
if (list != null) {
722-
for (let i = 0; i <= list.length; i++) {
734+
for (let i = 0; i < list.length; i++) {
723735
expect(list[i]).to.not.equal(domainApprovalList);
724736
}
725737
}

0 commit comments

Comments
 (0)