testomatio-editor-blocks 0.4.72 → 0.4.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -387,13 +387,21 @@ function serializeBlock(block, ctx, orderedIndex, stepIndex) {
|
|
|
387
387
|
}
|
|
388
388
|
if (stepData.length > 0) {
|
|
389
389
|
const dataLines = stepData.split(/\r?\n/);
|
|
390
|
+
let insideCodeFence = false;
|
|
390
391
|
dataLines.forEach((dataLine) => {
|
|
391
392
|
const trimmedLine = dataLine.trim();
|
|
392
|
-
if (trimmedLine.length
|
|
393
|
-
lines.push(` ${escapeStepContent(trimmedLine)}`);
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
393
|
+
if (trimmedLine.length === 0) {
|
|
396
394
|
lines.push(" ");
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
// Don't escape dots inside fenced code blocks (or on the fence lines
|
|
398
|
+
// themselves) — Markdown ignores backslash escapes there, so `\.`
|
|
399
|
+
// would render literally.
|
|
400
|
+
const isFence = trimmedLine.startsWith("```");
|
|
401
|
+
const content = insideCodeFence || isFence ? trimmedLine : escapeStepContent(trimmedLine);
|
|
402
|
+
lines.push(` ${content}`);
|
|
403
|
+
if (isFence) {
|
|
404
|
+
insideCodeFence = !insideCodeFence;
|
|
397
405
|
}
|
|
398
406
|
});
|
|
399
407
|
}
|
|
@@ -401,16 +409,23 @@ function serializeBlock(block, ctx, orderedIndex, stepIndex) {
|
|
|
401
409
|
if (normalizedExpected.length > 0) {
|
|
402
410
|
const expectedLines = normalizedExpected.split(/\r?\n/);
|
|
403
411
|
const label = "*Expected result*";
|
|
412
|
+
let insideCodeFence = false;
|
|
404
413
|
expectedLines.forEach((expectedLine, index) => {
|
|
405
414
|
const trimmedLine = expectedLine.trim();
|
|
406
415
|
if (trimmedLine.length === 0) {
|
|
407
416
|
return;
|
|
408
417
|
}
|
|
418
|
+
// As with step data, leave dots untouched inside fenced code blocks.
|
|
419
|
+
const isFence = trimmedLine.startsWith("```");
|
|
420
|
+
const content = insideCodeFence || isFence ? trimmedLine : escapeStepContent(trimmedLine);
|
|
409
421
|
if (index === 0) {
|
|
410
|
-
lines.push(` ${label}: ${
|
|
422
|
+
lines.push(` ${label}: ${content}`);
|
|
411
423
|
}
|
|
412
424
|
else {
|
|
413
|
-
lines.push(` ${
|
|
425
|
+
lines.push(` ${content}`);
|
|
426
|
+
}
|
|
427
|
+
if (isFence) {
|
|
428
|
+
insideCodeFence = !insideCodeFence;
|
|
414
429
|
}
|
|
415
430
|
});
|
|
416
431
|
}
|
package/package.json
CHANGED
|
@@ -1249,6 +1249,53 @@ describe("markdownToBlocks", () => {
|
|
|
1249
1249
|
);
|
|
1250
1250
|
});
|
|
1251
1251
|
|
|
1252
|
+
it("does not escape dots inside fenced code blocks in step data", () => {
|
|
1253
|
+
const stepData = [
|
|
1254
|
+
"```",
|
|
1255
|
+
"curl 'https://stable.testomat.io/api/runs/54?page=1&entry=' \\",
|
|
1256
|
+
" -H 'accept-language: en-US,en;q=0.9' \\",
|
|
1257
|
+
" -b 'gclau=1.1.1681594017.1781077572;'",
|
|
1258
|
+
"```",
|
|
1259
|
+
].join("\n");
|
|
1260
|
+
|
|
1261
|
+
const markdown = blocksToMarkdown([
|
|
1262
|
+
{
|
|
1263
|
+
id: "step1",
|
|
1264
|
+
type: "testStep",
|
|
1265
|
+
props: {
|
|
1266
|
+
stepTitle: "Run the request.",
|
|
1267
|
+
stepData,
|
|
1268
|
+
expectedResult: "",
|
|
1269
|
+
listStyle: "bullet",
|
|
1270
|
+
},
|
|
1271
|
+
content: undefined,
|
|
1272
|
+
children: [],
|
|
1273
|
+
},
|
|
1274
|
+
]);
|
|
1275
|
+
|
|
1276
|
+
expect(markdown).toBe(
|
|
1277
|
+
[
|
|
1278
|
+
// Title outside the fence is still escaped.
|
|
1279
|
+
"* Run the request\\.",
|
|
1280
|
+
// Dots inside the fence stay literal.
|
|
1281
|
+
" ```",
|
|
1282
|
+
" curl 'https://stable.testomat.io/api/runs/54?page=1&entry=' \\",
|
|
1283
|
+
" -H 'accept-language: en-US,en;q=0.9' \\",
|
|
1284
|
+
" -b 'gclau=1.1.1681594017.1781077572;'",
|
|
1285
|
+
" ```",
|
|
1286
|
+
].join("\n"),
|
|
1287
|
+
);
|
|
1288
|
+
|
|
1289
|
+
// Round-trip stays stable.
|
|
1290
|
+
const roundTrip = blocksToMarkdown(
|
|
1291
|
+
markdownToBlocks(["### Steps", "", markdown].join("\n")) as CustomEditorBlock[],
|
|
1292
|
+
);
|
|
1293
|
+
expect(roundTrip).toContain(
|
|
1294
|
+
" curl 'https://stable.testomat.io/api/runs/54?page=1&entry=' \\",
|
|
1295
|
+
);
|
|
1296
|
+
expect(roundTrip).toContain(" -b 'gclau=1.1.1681594017.1781077572;'");
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1252
1299
|
it("does not include content after a blank line in step data", () => {
|
|
1253
1300
|
const markdown = [
|
|
1254
1301
|
"### Steps",
|
|
@@ -469,12 +469,22 @@ function serializeBlock(
|
|
|
469
469
|
|
|
470
470
|
if (stepData.length > 0) {
|
|
471
471
|
const dataLines = stepData.split(/\r?\n/);
|
|
472
|
+
let insideCodeFence = false;
|
|
472
473
|
dataLines.forEach((dataLine: string) => {
|
|
473
474
|
const trimmedLine = dataLine.trim();
|
|
474
|
-
if (trimmedLine.length
|
|
475
|
-
lines.push(` ${escapeStepContent(trimmedLine)}`);
|
|
476
|
-
} else {
|
|
475
|
+
if (trimmedLine.length === 0) {
|
|
477
476
|
lines.push(" ");
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
// Don't escape dots inside fenced code blocks (or on the fence lines
|
|
480
|
+
// themselves) — Markdown ignores backslash escapes there, so `\.`
|
|
481
|
+
// would render literally.
|
|
482
|
+
const isFence = trimmedLine.startsWith("```");
|
|
483
|
+
const content =
|
|
484
|
+
insideCodeFence || isFence ? trimmedLine : escapeStepContent(trimmedLine);
|
|
485
|
+
lines.push(` ${content}`);
|
|
486
|
+
if (isFence) {
|
|
487
|
+
insideCodeFence = !insideCodeFence;
|
|
478
488
|
}
|
|
479
489
|
});
|
|
480
490
|
}
|
|
@@ -483,16 +493,24 @@ function serializeBlock(
|
|
|
483
493
|
if (normalizedExpected.length > 0) {
|
|
484
494
|
const expectedLines = normalizedExpected.split(/\r?\n/);
|
|
485
495
|
const label = "*Expected result*";
|
|
496
|
+
let insideCodeFence = false;
|
|
486
497
|
expectedLines.forEach((expectedLine: string, index: number) => {
|
|
487
498
|
const trimmedLine = expectedLine.trim();
|
|
488
499
|
if (trimmedLine.length === 0) {
|
|
489
500
|
return;
|
|
490
501
|
}
|
|
491
502
|
|
|
503
|
+
// As with step data, leave dots untouched inside fenced code blocks.
|
|
504
|
+
const isFence = trimmedLine.startsWith("```");
|
|
505
|
+
const content =
|
|
506
|
+
insideCodeFence || isFence ? trimmedLine : escapeStepContent(trimmedLine);
|
|
492
507
|
if (index === 0) {
|
|
493
|
-
lines.push(` ${label}: ${
|
|
508
|
+
lines.push(` ${label}: ${content}`);
|
|
494
509
|
} else {
|
|
495
|
-
lines.push(` ${
|
|
510
|
+
lines.push(` ${content}`);
|
|
511
|
+
}
|
|
512
|
+
if (isFence) {
|
|
513
|
+
insideCodeFence = !insideCodeFence;
|
|
496
514
|
}
|
|
497
515
|
});
|
|
498
516
|
}
|