Skip to content

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Nov 11, 2025

This PR adds two utility functions for testing the profile envelope: validateProfilePayloadMetadata and validateProfile. As More tests are going to be added, I don't want to copy-paste the same tests over and over.

Part of #17279

@s1gr1d s1gr1d requested review from Lms24 and andreiborza November 11, 2025 14:45
'fibonacci',
],
// Should be at least 20ms based on our setTimeout(21) in the test
minSampleDurationMs: 20,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Reduced duration validation allows regressions.

The duration validation changed from 200ms to 20ms during refactoring. The original test checked expect(durationSec).toBeGreaterThan(0.2) where durationSec was in seconds (0.2s = 200ms), but the refactored version passes minSampleDurationMs: 20 (20ms), making the test 10x less strict and potentially allowing performance regressions to pass.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should actually be 20, so it was wrong before

'largeSum',
],
// Test that profile duration makes sense (should be > 20ms based on test setup
minSampleDurationMs: 20,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Compromised performance test allows regressions.

The duration validation changed from 200ms to 20ms during refactoring. The original test checked expect(durationSec).toBeGreaterThan(0.2) where durationSec was in seconds (0.2s = 200ms), but the refactored version passes minSampleDurationMs: 20 (20ms), making the test 10x less strict and potentially allowing performance regressions to pass.

Fix in Cursor Fix in Web

Comment on lines +68 to +72
],
// Should be at least 20ms based on our setTimeout(21) in the test
minSampleDurationMs: 20,
isChunkFormat: true,
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: minSampleDurationMs for chunk format tests is incorrectly set to 20ms, a 10x reduction from 200ms.
Severity: MEDIUM | Confidence: 1.00

🔍 Detailed Analysis

The minSampleDurationMs threshold for chunk format tests has been incorrectly reduced from 200ms to 20ms. Previously, expect(durationSec).toBeGreaterThan(0.2) (0.2 seconds) was used, but the new minSampleDurationMs: 20 value, when compared against durationMs (converted from seconds), sets the threshold to 20ms. This 10x reduction significantly weakens the test's ability to detect issues with profile duration capture. The accompanying comment "Should be at least 20ms based on our setTimeout(21) in the test" is misleading for these tests.

💡 Suggested Fix

Set minSampleDurationMs to 200 for chunk format tests to restore the original 200ms duration threshold.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_multiple-chunks/test.ts#L68-L72

Potential issue: The `minSampleDurationMs` threshold for chunk format tests has been
incorrectly reduced from 200ms to 20ms. Previously,
`expect(durationSec).toBeGreaterThan(0.2)` (0.2 seconds) was used, but the new
`minSampleDurationMs: 20` value, when compared against `durationMs` (converted from
seconds), sets the threshold to 20ms. This 10x reduction significantly weakens the
test's ability to detect issues with profile duration capture. The accompanying comment
"Should be at least 20ms based on our setTimeout(21) in the test" is misleading for
these tests.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s1gr1d I think was unintentionally set to 200ms before, what is the expected testcase?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should be 20 actually :D

@s1gr1d s1gr1d enabled auto-merge (squash) November 11, 2025 15:04
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not the biggest fan of these extracted assertion helpers. Mainly because these helpers usually become increasingly "versatile" (read "complex") and ending up with branches in assertions is always a bit hard to grasp. I personally take a bit of repetition over it.

That being said, I can see the value here so feel free to merge anyway.

@s1gr1d s1gr1d merged commit a36b672 into develop Nov 11, 2025
52 checks passed
@s1gr1d s1gr1d deleted the sig/profiling-test-utils branch November 11, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants