Repository: freeCodeCamp/freeCodeCamp
File: e2e/exam-started-show.spec.ts (TypeScript)

Code before:
    const headerTitle = page.getByTestId('exam-show-title');
    const prevQuestionBtn = page.getByRole('button', {
      name: translations.buttons['previous-question']
    });
    const exitButton = page.getByRole('button', {
      name: translations.buttons['exit-exam']
    });
    const nextBtn = page.getByRole('button', {
      name: translations.buttons['next-question']
    });
    const finishExamBtn = page.getByRole('button', {
      name: translations.buttons['finish-exam']
    });
    for (let i = 1; i < 6; i++) {
      await expect(headerTitle).toBeVisible();
      await expect(headerTitle).toContainText(
        intro['foundational-c-sharp-with-microsoft'].blocks[
          'foundational-c-sharp-with-microsoft-certification-exam'
        ].title
      );

      await expect(page.getByTestId('exam-show-question-time')).toContainText(
        translations.learn.exam.time.split(':')[0]
      );
      await expect(
        page.getByText('Question ' + String(i) + ' of 5')
      ).toBeVisible();

      await expect(prevQuestionBtn).toBeVisible();
      if (i != 1) {
        await expect(prevQuestionBtn).toBeEnabled();
      } else {
        await expect(prevQuestionBtn).not.toBeEnabled();
      }
      for (let j = 0; j < 5; j++) {
        // 4 answers
        await page.getByTestId('exam-answer-label-' + String(j)).check();
      }
      await expect(exitButton).toBeVisible();
      await expect(exitButton).toBeEnabled();
      if (i < 5) {
        await expect(finishExamBtn).not.toBeVisible();
        await expect(nextBtn).toBeVisible();
        await nextBtn.click();
      } else {
        await expect(finishExamBtn).toBeEnabled();
        await expect(finishExamBtn).toBeVisible();
        await expect(nextBtn).not.toBeVisible();
      }
    }
  });

Review comment (suggestion):
```suggestion
        page.getByText(`Question ${i} of 5`)
```

Code after:
      name: translations.buttons['next-question']
    });
    const finishExamBtn = page.getByRole('button', {
      name: translations.buttons['finish-exam']
    });
    for (let i = 0; i < QUESTION_COUNT; i++) {
      await expect(headerTitle).toBeVisible();
      await expect(headerTitle).toContainText(
        intro['foundational-c-sharp-with-microsoft'].blocks[
          'foundational-c-sharp-with-microsoft-certification-exam'
        ].title
      );

      await expect(page.getByTestId('exam-show-question-time')).toContainText(
        translations.learn.exam.time.split(':')[0]
      );
      await expect(
        page.getByText(`Question ${i + 1} of ${QUESTION_COUNT}`)
      ).toBeVisible();
      await expect(prevQuestionBtn).toBeVisible();
      if (i != 0) {
        await expect(prevQuestionBtn).toBeEnabled();
      } else {
        await expect(prevQuestionBtn).not.toBeEnabled();
      }
      await page.getByRole('radio').first().check({ force: true });
      await expect(exitButton).toBeVisible();
      await expect(exitButton).toBeEnabled();
      if (i < QUESTION_COUNT - 1) {
        await expect(finishExamBtn).not.toBeVisible();
        await expect(nextBtn).toBeVisible();
        await nextBtn.click();
      } else {
        await expect(finishExamBtn).toBeEnabled();
        await expect(finishExamBtn).toBeVisible();
        await expect(nextBtn).not.toBeVisible();
      }
    }
  });

  test('The page has correct navigation back flow', async ({ page }) => {
    const headerTitle = page.getByTestId('exam-show-title');
    await expect(headerTitle).toBeVisible();
    await expect(headerTitle).toContainText(
      intro['foundational-c-sharp-with-microsoft'].blocks[
        'foundational-c-sharp-with-microsoft-certification-exam'
      ].title
    );
    await expect(page.getByTestId('exam-show-question-time')).toContainText(
      translations.learn.exam.time.split(':')[0]
    );