Skip to content

Commit cb426de

Browse files
Fix buildConsoleReplay test parameter order regression (#2168)
## Summary Fixes the failing `buildConsoleReplay.test.js` tests by correcting the parameter order in test calls. ## Problem Commit c3a0225 (Phase 5: Add Pro Node Renderer Package to workspace #2069) incorrectly changed test calls from: ```javascript buildConsoleReplay(undefined, 0, 'abc123') // correct ``` to: ```javascript buildConsoleReplay(0, undefined, 'abc123') // incorrect ``` The function signature is `buildConsoleReplay(customConsoleHistory, numberOfMessagesToSkip, nonce)`, so passing `0` as the first parameter caused: 1. `customConsoleHistory = 0` instead of `undefined` 2. Nullish coalescing `0 ?? console.history` returns `0` (not `console.history`) 3. `!Array.isArray(0)` returns `true`, causing early return of `''` ## Fix Restored the correct parameter order in 3 test calls (lines 81, 90, 115). ## Test plan - [x] `pnpm jest tests/buildConsoleReplay.test.js` - All 14 tests pass Fixes #2167 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated test cases for console replay functionality to reflect refined argument patterns while maintaining existing validation expectations. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 14fa12a commit cb426de

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/react-on-rails/tests/buildConsoleReplay.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);
7878

7979
it('buildConsoleReplay adds nonce attribute when provided', () => {
8080
console.history = [{ arguments: ['test message'], level: 'log' }];
81-
const actual = buildConsoleReplay(0, undefined, 'abc123');
81+
const actual = buildConsoleReplay(undefined, 0, 'abc123');
8282

8383
expect(actual).toContain('nonce="abc123"');
8484
expect(actual).toContain('<script id="consoleReplayLog" nonce="abc123">');
@@ -87,7 +87,7 @@ console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);
8787

8888
it('buildConsoleReplay returns empty string when no console messages', () => {
8989
console.history = [];
90-
const actual = buildConsoleReplay(0, undefined, 'abc123');
90+
const actual = buildConsoleReplay(undefined, 0, 'abc123');
9191

9292
expect(actual).toEqual('');
9393
});
@@ -112,7 +112,7 @@ console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);
112112
console.history = [{ arguments: ['test'], level: 'log' }];
113113
// Attempt attribute injection attack
114114
const maliciousNonce = 'abc123" onload="alert(1)';
115-
const actual = buildConsoleReplay(0, undefined, maliciousNonce);
115+
const actual = buildConsoleReplay(undefined, 0, maliciousNonce);
116116

117117
// Should strip dangerous characters (quotes, parens, spaces)
118118
// = is kept as it's valid in base64, but the quotes are stripped making it harmless

0 commit comments

Comments
 (0)