Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"403 Forbidden" Jest tests are failing #603

Closed
JohnAlbin opened this issue Nov 21, 2023 · 1 comment
Closed

"403 Forbidden" Jest tests are failing #603

JohnAlbin opened this issue Nov 21, 2023 · 1 comment
Assignees
Labels
area: next-drupal bug Something isn't working

Comments

@JohnAlbin
Copy link
Contributor

Package containing the bug

next-drupal (NPM package)

Describe the bug

Jest tests in the CI started failing last week. PRs without any changes to next-drupal were passing on November 13. And those same kind of PRs started failing on November 14. No changes have been made to the main branch since November 4.

So it is very curious why tests that were passing are now failing when the code hasn't changed. It must mean that something changed on the tests server has changed? Running tests against a live server instance is a bad idea.

Expected behavior

Jest tests to

Steps to reproduce:

  1. Create a PR with a git commit that used the --allow-empty flag so there are no code changes. For example, WIP: run tests on main branch #594
  2. 😢

Additional context

These are the tests that are failing.

$ jest packages/next-drupal
PASS packages/next-drupal-query/tests/index.test.ts
PASS packages/next-drupal/tests/crud.test.ts (17.848 s)
FAIL packages/next-drupal/tests/client.test.ts (22.17 s)

These are the same 3 tests that have always failed when I try running Jest locally #533. I do not understand why they were always passing in the CI until a few days ago.

  ● getResource › it throws an error if revision access if forbidden

    expect(received).rejects.toThrow(expected)

    Expected substring: "403 Forbidden
    The current user is not allowed to GET the selected resource. The user does not have access to the requested version."
    Received message:   "401 Unauthorized
    No authentication credentials provided."

  ● getResourceByPath › it throws an error if revision access if forbidden

    expect(received).rejects.toThrow(expected)

    Expected substring: "403 Forbidden
    The current user is not allowed to GET the selected resource. The user does not have access to the requested version."
    Received message:   "401 Unauthorized
    No authentication credentials provided."

  ● getResourceFromContext › it throws an error if revision access if forbidden

    expect(received).rejects.toThrow(expected)

    Expected substring: "403 Forbidden
    The current user is not allowed to GET the selected resource. The user does not have access to the requested version."
    Received message:   "401 Unauthorized
    No authentication credentials provided."
@JohnAlbin
Copy link
Contributor Author

These are failing again. The test server seems to return a 403 or 401 error depending on a race condition while being pelted with requests???

I'm replacing the tests with a mocked response that always returns a 403.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: next-drupal bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant