openedx / openedx/frontend-app-learning

`Course.test.jsx` tests passing when they shouldn't

Open Beginner friendly
#1,669 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
70
Forks
335
Avg merge
1d 17h
Merged PRs (30d)
35

Description

When working on the React 18 upgrade I ran into some issues with tests in Course.test.jsx.

I did a bit of investigating, and found the issue started with https://github.com/openedx/frontend-app-learning/pull/1391

I added screen.debug() calls into the it('loads learning sequence test, and found that on 99a44dda3773424c221cca04e7a68046dbbbe5a7 we get the expected output, but on 71c2a31 and later we get

    <body>
      <div>
        <div
          class="py-5 justify-content-center align-items-start text-center container-fluid"
          data-testid="error-page"
        >
          <div
            class="row"
          >
            <div
              class="col"
            >
              <p
                class="text-muted"
              >
                An unexpected error occurred. Please click the button below to refresh the page.
              </p>
              <button
                class="btn btn-primary"
                type="button"
              >
                Try again
              </button>
            </div>
          </div>
        </div>
      </div>
    </body>

The test passes despite this because the checks are being wrapped in a waitFor that is not being awaited.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Course.test.jsx and the it('loads learning sequence') test. Inspect the checks wrapped in waitFor and verify the asynchronous assertion is awaited. Run the relevant test file; done means the test fails when the error page is rendered instead of passing incorrectly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.