stack/apps/e2e/tests
BilalG1 e256be83ae
fix metrics test (#916)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- RECURSEML_SUMMARY:START -->
## High-level PR Summary
This PR fixes a test in the internal metrics endpoint by replacing a
simple wait timer with a more robust retry mechanism. Instead of waiting
for a fixed 3000ms delay to allow for asynchronous event logging, the PR
implements a `Result.retry` approach that attempts to fetch metrics up
to 5 times with exponential backoff, only proceeding when the metrics
response differs from the initial state. This change makes the test more
reliable by ensuring proper test conditions are met before assertions
are made rather than relying on an arbitrary timeout.

⏱️ Estimated Review Time: 5-15 minutes

<details>
<summary>💡 Review Order Suggestion</summary>

| Order | File Path |
|-------|-----------|
| 1 | `apps/e2e/tests/backend/endpoints/api/v1/internal-metrics.test.ts`
|
</details>



[![Need help? Join our
Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U)

<!-- RECURSEML_SUMMARY:END -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Improved backend metrics verification with a retry-based approach to
handle eventual consistency, reducing test flakiness.
* Replaced static waits with structured retries for faster, more
reliable execution.
* Strengthened assertions on metrics fields (e.g., totals and recent
activity) for clearer validation.
* Maintains checks to ensure anonymous users remain excluded from
metrics.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-24 15:32:03 -07:00
..
backend fix metrics test (#916) 2025-09-24 15:32:03 -07:00
general Reduce test flakeyness (#517) 2025-03-07 13:34:50 -08:00
js Convex implementation (#913) 2025-09-24 19:16:45 +00:00
global-setup.ts Disallow trailing spaces 2024-07-14 10:35:33 -07:00
globals.d.ts Upgrade backend to Next.js 15 (#360) 2024-12-10 00:11:13 -08:00
helpers.ts Increase mailbox wait timeout 2025-09-19 17:45:00 -07:00
setup.ts JWKS endpoint now uses base64url 2024-10-11 17:09:24 -07:00
snapshot-serializer.ts Snake case JWT claims 2025-09-14 15:42:15 -07:00