Skip to content

Commit

Permalink
Adapt test to test for new scroll behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
badkeyy committed Nov 12, 2024
1 parent 3ca663e commit ec2ee11
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
(onSubmit)="loadPotentialComplaint()"
/>
</div>
<div #complaintScrollpoint></div>
}
<div #complaintScrollpoint></div>
@if (complaint) {
<div class="row">
<jhi-complaint-request class="col-12 col-md-6" [complaint]="complaint" [maxComplaintTextLimit]="course?.maxComplaintTextLimit!" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ export class ComplaintsStudentViewComponent implements OnInit {
*/
openComplaintForm(complainType: ComplaintType): void {
this.formComplaintType = complainType;
// Wait for the view to update
this.cdr.detectChanges();
this.cdr.detectChanges(); // Wait for the view to update
this.scrollToComplaint();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('ComplaintsStudentViewComponent', () => {
expect(component.formComplaintType).toBe(ComplaintType.COMPLAINT);
// Wait for setTimeout to execute
tick();
expect(scrollIntoViewMock).toHaveBeenCalledWith({ behavior: 'smooth' });
expect(scrollIntoViewMock).toHaveBeenCalledWith({ behavior: 'smooth', block: 'end' });
}));

it('should be visible on test run', fakeAsync(() => {
Expand Down Expand Up @@ -273,7 +273,7 @@ describe('ComplaintsStudentViewComponent', () => {

expect(component.formComplaintType).toBe(ComplaintType.COMPLAINT);
tick(); // Wait for update to happen
expect(scrollIntoViewMock).toHaveBeenCalledWith({ behavior: 'smooth' });
expect(scrollIntoViewMock).toHaveBeenCalledWith({ behavior: 'smooth', block: 'end' });
}));

it('should set complaint type MORE_FEEDBACK and scroll to complaint form when pressing complaint', fakeAsync(() => {
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('ComplaintsStudentViewComponent', () => {

expect(component.formComplaintType).toBe(ComplaintType.MORE_FEEDBACK);
tick(); // Wait for update to happen
expect(scrollIntoViewMock).toHaveBeenCalledWith({ behavior: 'smooth' });
expect(scrollIntoViewMock).toHaveBeenCalledWith({ behavior: 'smooth', block: 'end' });
}));

it('should not be available if before or at assessment due date', fakeAsync(() => {
Expand Down

0 comments on commit ec2ee11

Please sign in to comment.