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

Code before:

    // 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 "Continue where you left off" section is NOT available.
    await loggedInUser.expectContinueFromWhereYouLeftSectionInRedesignedDashboardToBePresent(
      false
    );

    // Verify "Learn Something New" section is visible.
    await loggedInUser.expectLearnSomethingNewSectionInRedesignedDashboardToBePresent();

    // Click on "Progress" tab and verify it's empty.
    await loggedInUser.navigateToProgressSection();
    await loggedInUser.expectProgressSectionToBeEmptyInNewLD();
  });

  it('should land on navbar', async function () {
    // User should still be logged in from previous test and on learner dashboard.
    // Navigate to learner dashboard to ensure we're on a page with navbar.
    // In redesigned dashboard, mobile home section selector doesn't exist,
    // so we navigate directly to the dashboard.
    await loggedInUser.navigateToLearnerDashboard();

    // Check if "Learn", "About", and "Get Involved" works properly.
    await loggedInUser.expectNavbarToWorkProperly();

    // Check if profile dropdown works properly.
    await loggedInUser.clickOnProfileDropdown();
    await loggedInUser.expectProfileDropdownToContainElementWithContent(
      'loggedInUser'
    );
  });
  afterAll(async function () {
    await UserFactory.closeAllBrowsers();
    await loggedInUser.closeBrowser();
  });
});


Review comment (suggestion):
The method `navigateToSignUpPage` navigates directly using the signup page url. However, as per CUJ, we need to click on "Sign In" button to navigate to the login page.

Code after:
    await curriculumAdmin.createAndPublishTopic(
      'Test Topic',
      'Test Skill',
      'Test Skill'
    );

    await curriculumAdmin.createAndPublishClassroom(
      'Math',
      'math',
      'Test Topic'
    );

    await curriculumAdmin.addStoryToTopic(
      'Test Story',
      'test-story',
      'Test Topic'
    );
    await curriculumAdmin.addChapter('Chapter 1', explorationId);
    await curriculumAdmin.saveStoryDraft();
    await curriculumAdmin.publishStoryDraft();
  }, 600000);

  it('should be able to login and see Learner Dashboard', async function () {
    // Click on "Sign In" button and fill email.
    await loggedInUser.openBrowser();
    await loggedInUser.navigateToSignUpPage();

    // 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.