Skip to content

Commit

Permalink
Resolve Bug in First Release Approval Button
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Jul 24, 2024
1 parent 92037f6 commit ee9da9e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,25 @@
</ng-template>
</li>
<li class="list-group-item text-center">
<ng-container *ngIf="!reviewIsApproved && preferredApprovers.includes(userProfile?.userName!); else reviewApprovalHidden">
<span class="small text-muted">Approves First Release of the package</span>
<div class="d-grid gap-2">
<button class="btn btn-success" type="button"
(click)="handleReviewApprovalAction()"
pTooltip="Package name must be approved before first preview release of a new package."
tooltipPosition="bottom">
Approve First Release
</button>
</div>
<span class="small mt-2 text-muted">First Release Approval Pending</span>
<ng-container *ngIf="reviewIsApproved; else reviewIsNotApproved">
<span class="small text-muted mt-1" id="first-release-approval-message">Approved for First Release By: <a href="{{webAppUrl}}Assemblies/Profile/{{reviewApprover}}">{{reviewApprover}}</a></span>
</ng-container>
<ng-template #reviewApprovalHidden>
<span class="small text-muted mt-1">
Approved for First Release By: <a href="{{webAppUrl}}Assemblies/Profile/{{reviewApprover}}">{{reviewApprover}}</a>
</span>
<ng-template #reviewIsNotApproved>
<div *ngIf="preferredApprovers.includes(userProfile?.userName!); else userIsNotAPreferedApprover">
<span class="small text-muted">Approves First Release of the package</span>
<div class="d-grid gap-2">
<button class="btn btn-success" type="button" id="first-release-approval-button"
(click)="handleReviewApprovalAction()"
pTooltip="Package name must be approved before first preview release of a new package."
tooltipPosition="bottom">
Approve First Release
</button>
</div>
<span class="small mt-2 text-muted" id="first-release-approval-message">First Release Approval Pending</span>
</div>
</ng-template>
<ng-template #userIsNotAPreferedApprover>
<span class="small mt-2 text-muted" id="first-release-approval-message">First Release Approval Pending</span>
</ng-template>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,43 @@ describe('ReviewPageOptionsComponent', () => {
});
fixture = TestBed.createComponent(ReviewPageOptionsComponent);
component = fixture.componentInstance;

fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

describe('First Release Approval Button', () => {
it('should disable first release approval button when review is approved', () => {
component.reviewIsApproved = true;
fixture.detectChanges();
const button = fixture.nativeElement.querySelector('#first-release-approval-button');
expect(button).not.toBeTruthy();
const message : HTMLElement = fixture.nativeElement.querySelector('#first-release-approval-message');
expect(message.textContent?.startsWith("Approved for First Release By:")).toBeTruthy()
});
it('should disable first release approval button when review is not approved and user is not an approver', () => {
component.reviewIsApproved = false;
component.userProfile = new UserProfile();
component.userProfile.userName = "test-user-1";
component.preferredApprovers = ["test-user-2"]
fixture.detectChanges();
const button = fixture.nativeElement.querySelector('#first-release-approval-button');
expect(button).not.toBeTruthy();
const message : HTMLElement = fixture.nativeElement.querySelector('#first-release-approval-message');
expect(message.textContent).toEqual("First Release Approval Pending");
});
it('should enable first release approval button when review is not approved and user is an approver', () => {
component.reviewIsApproved = false;
component.userProfile = new UserProfile();
component.userProfile.userName = "test-user";
component.preferredApprovers = ["test-user"]
fixture.detectChanges();
const button = fixture.nativeElement.querySelector('#first-release-approval-button');
expect(button).toBeTruthy();
const message : HTMLElement = fixture.nativeElement.querySelector('#first-release-approval-message');
expect(message.textContent).toEqual("First Release Approval Pending");
});
});
});

0 comments on commit ee9da9e

Please sign in to comment.