@@ -156,7 +156,7 @@ describe('Command Logging and Monitoring Prose Tests', function () {
156
156
} ) ;
157
157
} ) ;
158
158
159
- context ( 'Truncation with multi-byte codepoints' , function ( ) {
159
+ context . skip ( 'Truncation with multi-byte codepoints' , function ( ) {
160
160
/*
161
161
A specific test case is not provided here due to the allowed variations in truncation logic
162
162
as well as varying extended JSON whitespace usage.
@@ -169,6 +169,7 @@ describe('Command Logging and Monitoring Prose Tests', function () {
169
169
where the max length falls in the middle of a multi-byte codepoint are handled gracefully.
170
170
*/
171
171
172
+ const maxDocLength = 39 ;
172
173
beforeEach ( async function ( ) {
173
174
writable = {
174
175
buffer : [ ] ,
@@ -185,7 +186,7 @@ describe('Command Logging and Monitoring Prose Tests', function () {
185
186
mongodbLogComponentSeverities : {
186
187
command : 'debug'
187
188
} ,
188
- mongodbLogMaxDocumentLength : 50
189
+ mongodbLogMaxDocumentLength : maxDocLength
189
190
}
190
191
) ;
191
192
} ) ;
@@ -195,9 +196,12 @@ describe('Command Logging and Monitoring Prose Tests', function () {
195
196
} ) ;
196
197
197
198
it ( 'should handle unicode codepoints in middle and end of truncation gracefully' , async function ( ) {
199
+ const multibyteUnicode = '\uD801\uDC37' ;
200
+ const firstByteChar = multibyteUnicode . charCodeAt ( 0 ) ;
201
+ const secondByteChar = multibyteUnicode . charCodeAt ( 1 ) ;
198
202
const docs : Array < Document > = [
199
203
{
200
- x : '\u2603\u2603\u2603\u2603'
204
+ x : ` ${ multibyteUnicode } ${ multibyteUnicode } ${ multibyteUnicode } ${ multibyteUnicode } `
201
205
}
202
206
] ;
203
207
@@ -206,12 +210,25 @@ describe('Command Logging and Monitoring Prose Tests', function () {
206
210
const insertManyCommandStarted = writable . buffer [ 0 ] ;
207
211
expect ( insertManyCommandStarted ?. message ) . to . equal ( 'Command started' ) ;
208
212
expect ( insertManyCommandStarted ?. command ) . to . be . a ( 'string' ) ;
209
- expect ( insertManyCommandStarted ?. command ?. length ) . to . equal ( 50 + ELLIPSES_LENGTH ) ;
213
+ // maxDocLength - 1 because stringified response should be rounded down due to ending mid-codepoint
214
+ expect ( insertManyCommandStarted ?. command ?. length ) . to . equal (
215
+ maxDocLength - 1 + ELLIPSES_LENGTH
216
+ ) ;
217
+
218
+ // multi-byte codepoint in middle of truncated string
219
+ expect ( insertManyCommandStarted ?. command . charCodeAt ( maxDocLength - 1 ) ) . to . equal (
220
+ firstByteChar
221
+ ) ;
222
+ expect ( insertManyCommandStarted ?. command . charCodeAt ( maxDocLength - 1 ) ) . to . equal (
223
+ secondByteChar
224
+ ) ;
210
225
211
226
const insertManyCommandSucceeded = writable . buffer [ 1 ] ;
212
227
expect ( insertManyCommandSucceeded ?. message ) . to . equal ( 'Command succeeded' ) ;
213
228
expect ( insertManyCommandSucceeded ?. reply ) . to . be . a ( 'string' ) ;
214
- expect ( insertManyCommandSucceeded ?. reply ?. length ) . to . be . at . most ( 50 + ELLIPSES_LENGTH ) ;
229
+ expect ( insertManyCommandSucceeded ?. reply ?. length ) . to . be . at . most (
230
+ maxDocLength + ELLIPSES_LENGTH
231
+ ) ;
215
232
} ) ;
216
- } ) ;
233
+ } ) . skipReason = 'todo(NODE-5839)' ;
217
234
} ) ;
0 commit comments