Skip to content

test(api): the browser suite is not held to the API's read quota - #515

Merged
samuelmbabhazi merged 1 commit into
mainfrom
test/browser-suite-api-quota
Nov 26, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
test/browser-suite-api-quota

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

The browser fixture gives the API a throttle that lets the api attempt through, the read quota of 300 requests a minute per account and 600 per network. Every other limit applies as in production: login, registration, mail, MFA and token proofs.

  • BrowserSuiteThrottle (in src/testing/) extends PrismaIdentityThrottle. It answers api with an allowed decision and passes every other attempt to the real store.
  • integrationApp accepts a provider override by class ({ token, useClass }), next to the existing override by value, so Nest builds the throttle with its dependencies.
  • browserApp puts that override first, and a test's own overrides still come after it.

Why

tenant.browser.spec.ts › creates scoped tokens the API accepts, and revokes a project token failed intermittently:

Each failure was a different 15-second wait: the Create API token button, #token-project and #token-organization.

I logged every API request and every 429 of the file:

  • What is refused. The failing run got a 429 on GET /api/v1/organizations. The token form's organization list stayed empty, and Playwright waited for an option that never came. Passing runs got their 429s on requests the page retries.
  • Why. Each step of the test reloads the whole application with goto, and each load reads about ten resources. The owner's page made 409 requests in its busiest minute, against a quota of 300 per account. All pages together made 576 from 127.0.0.1, plus the test's own context.request calls, against 600 per network.

The browser suite checks screens, not the quota, and a person cannot click at that rate. The quota keeps its own integration tests (identity-throttle.integration.spec.ts, api-token-authentication.integration.spec.ts). The only 429 a browser test checks, in security.browser.spec.ts, is simulated by intercepting the response in the browser, and is unaffected.

How it was tested

  • tenant.browser.spec.ts, four runs in a row: 13/13 each time. Before the change, the same command failed one run in three, then one in four.
  • The whole browser suite: 28/28.
  • api:typecheck and api:lint pass.

Security considerations

Test code only: the production throttle and its policy are unchanged. Credential limits still apply in the browser suite.

Each step of a browser test reloads the whole application, and the owner's page then read 409 times in a minute, from the one address every simulated user shares, against a quota of 300 per account and 600 per network. Whichever read came past the quota was refused with a 429; when it was the organization list of the token form, the test waited for an option that never came (seen on main at b425efe and twice on #512, and locally one run in three or four).

The browser fixture replaces the throttle with one that lets the 'api' attempt through and keeps every credential limit. The quota keeps its own tests in identity-throttle.integration.spec.ts.

Signed-off-by: samuel mbabhazi <[email protected]>
@samuelmbabhazi samuelmbabhazi added bug Something isn't working track:control-plane labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 661f966 and 42f3d0d.

Files selected for processing: 3

  • apps/api/src/testing/browser-app.ts
  • apps/api/src/testing/browser-suite-throttle.ts
  • apps/api/src/testing/integration-app.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@samuelmbabhazi
samuelmbabhazi merged commit 01017d6 into main Nov 26, 2026
27 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the test/browser-suite-api-quota branch November 26, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working track:control-plane

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant