Repository: oppia/oppia
File: core/tests/puppeteer-acceptance-tests/specs/logged-in-learner/goes-through-the-sign-in-flow.spec.ts (TypeScript)

Code before:

    // Enter email to proceed to username page.
    // The enterEmail function will click "Sign In" and verify username field is visible.
    await loggedInUser.enterEmail('logged_in_user@example.com');

    // Fill an invalid username and verify error message.
    await loggedInUser.typeInvalidUsernameInUsernameInput('invalid@user!');

    // Verify error message with clear instructions is shown.
    await loggedInUser.expectUsernameError(
      'Usernames can only have alphanumeric characters.'
    );

    // Clear the invalid username and sign in with valid username.
    await loggedInUser.clearUsernameInput();
    await loggedInUser.signInWithUsername('loggedInUser');

    // Verify learner is redirected to Learner Dashboard.
    await loggedInUser.expectToBeOnLearnerDashboardPage();

    // Verify welcome message with username.
    await loggedInUser.expectGreetingToHaveNameOfUser('loggedInUser');

    // Verify "Continue where you left off" section is NOT available.
    await loggedInUser.expectContinueFromWhereYouLeftSectionInRedesignedDashboardToBePresent(
      false
    );

    // Verify "Learn Something New" section is visible.
    // Note: For a new user, the section may be empty (no untracked topics yet).
    // The section will show lessons once the user has untracked topics.
    await loggedInUser.expectLearnSomethingNewSectionInRedesignedDashboardToBePresent();

    // Click on "Progress" tab and verify it's empty.
    await loggedInUser.navigateToProgressSection();
    await loggedInUser.expectProgressSectionToBeEmptyInNewLD();
  });
  afterAll(async function () {
    await UserFactory.closeAllBrowsers();
    await loggedInUser.closeBrowser();
  });
});


Review comment (suggestion):
This is correct; however, can you also add steps that try to enter a username with Admin in it? i.e. "TopicAdmin". It should still return an error, though a different one.

Code after:

    // Enter email to proceed to username page.
    // The enterEmailAndProceedToNextPage function will click "Sign In" and verify username field is visible.
    await loggedInUser.enterEmailAndProceedToNextPage(
      'logged_in_user@example.com'
    );

    // Fill an invalid username and verify error message.
    await loggedInUser.typeInvalidUsernameInUsernameInput('invalid@user!');

    // Verify error message with clear instructions is shown.
    await loggedInUser.expectUsernameError(
      'Usernames can only have alphanumeric characters.'
    );

    // Clear the invalid username and try username with "Admin" in it.
    await loggedInUser.clearUsernameInput();
    await loggedInUser.typeInvalidUsernameInUsernameInput('TopicAdmin');

    // Verify different error message for username with "Admin".
    await loggedInUser.expectUsernameError(
      "User names with 'admin' are reserved."
    );

    // Clear the invalid username and sign in with valid username.
    await loggedInUser.clearUsernameInput();
    await loggedInUser.signInWithUsername('loggedInUser');

    // Verify learner is redirected to Learner Dashboard.
    await loggedInUser.expectToBeOnLearnerDashboardPage();

    // Verify welcome message with username.
    await loggedInUser.expectGreetingToHaveNameOfUser('loggedInUser');

    // Verify "Continue where you left off" section is NOT available.
    await loggedInUser.expectContinueFromWhereYouLeftSectionInRedesignedDashboardToBePresent(
      false
    );

    // Verify "Learn Something New" section is visible and shows Chapter 1.
    await loggedInUser.expectLearnSomethingNewSectionInRedesignedDashboardToBePresent();
    await loggedInUser.expectChapterToBePresentInLearnSomethingNewSection(
      'Chapter 1'
    );

    // Click on "Progress" tab and verify it's empty.
    await loggedInUser.navigateToProgressSection();
    await loggedInUser.expectProgressSectionToBeEmptyInNewLD();
  });
  afterAll(async function () {
    await UserFactory.closeAllBrowsers();