Repository: oppia/oppia
File: core/templates/pages/exploration-player-page/current-lesson-player/learner-experience/tutor-card.component.spec.ts (TypeScript)

Code before:
    expect(console.error).toHaveBeenCalledWith(
      'User is logged out setting default chapters count'
    );
  }));

  it('should set chapterCount = 0 and log error for other errors', fakeAsync(() => {
    const error500 = {status: 500, message: 'Internal Server Error'};

    componentInstance.displayedCard = mockDisplayedCard;

    spyOn(
      chapterProgressService,
      'updateCompletedChaptersCount'
    ).and.returnValue(Promise.reject(error500));
    spyOn(console, 'error').and.stub();

    spyOnProperty(
      conversationFlowService,
      'onOppiaFeedbackAvailable',
      'get'
    ).and.returnValue(new Subject<void>());

    spyOn(
      componentInstance,
      'setNextMilestoneAndCheckIfProgressBarIsShown'
    ).and.returnValue(false);
    spyOn(componentInstance, 'isOnTerminalCard').and.returnValue(false);

    fixture.detectChanges();
    tick();

    expect(componentInstance.completedChaptersCount).toBe(0);
    expect(console.error).toHaveBeenCalledWith(
      'Error loading the chapter count',
      error500
    );
  }));

  it('should correctly initialize state and progress bar after async chapter count update', fakeAsync(() => {
    const expectedCount = 5;
    const expectedShouldShowProgressBar = true;
    componentInstance.displayedCard = mockDisplayedCard;

    spyOn(
      chapterProgressService,
      'updateCompletedChaptersCount'
    ).and.returnValue(Promise.resolve());
    spyOn(chapterProgressService, 'getCompletedChaptersCount').and.returnValue(
      expectedCount
    );
    spyOn(

Review comment (suggestion):


```suggestion
expect(componentInstance.shouldShowProgressBar).toBe(false);
```
Since we are no longer using calling this method.

Code after:

  it('should refresh displayed card on changes', fakeAsync(() => {
    let updateDisplayedCardSpy = spyOn(
      componentInstance,
      'updateDisplayedCard'
    );
    spyOn(componentInstance, 'isOnTerminalCard');
    const changes: SimpleChanges = {
      displayedCard: {
        previousValue: false,
        currentValue: true,
        firstChange: false,
        isFirstChange: () => false,
      },
    };
    componentInstance.ngOnChanges(changes);
    expect(updateDisplayedCardSpy).toHaveBeenCalled();
    expect(componentInstance.isOnTerminalCard).toHaveBeenCalled();
  }));

  it('should handle multiple calls when ngOnChanges runs before ngAfterViewInit', fakeAsync(() => {
    spyOn(componentInstance, 'updateDisplayedCard');
    spyOn(componentInstance, 'isOnTerminalCard').and.returnValue(true);
    spyOn(componentInstance, 'triggerCelebratoryAnimation');
    componentInstance.animationHasPlayedOnce = false;
    componentInstance.inStoryMode = true;
    const changes: SimpleChanges = {
      displayedCard: {
        previousValue: false,
        currentValue: true,
        firstChange: false,
        isFirstChange: () => false,
      },
    };

    componentInstance.ngOnChanges(changes);
    componentInstance.ngAfterViewInit();
    expect(componentInstance.updateDisplayedCard).toHaveBeenCalled();
    tick();
    expect(componentInstance.triggerCelebratoryAnimation).toHaveBeenCalledTimes(
      1
    );
  }));

  it('should trigger celebratory animation once when on last card and ngAfterViewInit runs before ngOnChanges', fakeAsync(() => {
    spyOn(componentInstance, 'updateDisplayedCard');
    spyOn(componentInstance, 'isOnTerminalCard').and.returnValue(true);
    spyOn(componentInstance, 'triggerCelebratoryAnimation');
    componentInstance.animationHasPlayedOnce = false;
    componentInstance.inStoryMode = true;
    const changes: SimpleChanges = {