Skip to content

Commit cc3a498

Browse files
SavioBS629claude
andcommitted
refactor(testmanagement): trim rich-text comments, add generality tests
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 82a3be2 commit cc3a498

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/tools/testmanagement-utils/create-testcase.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,6 @@ export async function createTestCase(
325325
new Set([...(testCaseParams.tags ?? []), "MCP Generated"]),
326326
);
327327

328-
// Rich-text fields must be HTML-wrapped or the TM UI shows entity-encoded
329-
// text literally (PMAA-185); see rich-text.ts.
330328
testCaseParams.test_case_steps = wrapTestCaseSteps(
331329
testCaseParams.test_case_steps,
332330
);

src/tools/testmanagement-utils/rich-text.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
// TM's v2 API treats step/result, preconditions and description as rich-text
2-
// fields: its write-time sanitizer entity-encodes <, > and & in text nodes
3-
// (preserving allowed tags like <p>), and the TM UI renders the stored value
4-
// as rich text only when it is HTML-wrapped — bare text is displayed
5-
// literally, so a bare ">" surfaces to users as "&gt;" (PMAA-185).
6-
// Per the TM team, external API content must be wrapped in <p> tags to opt
7-
// into rich-text rendering. Quotes are not entity-encoded, so only values
8-
// containing <, > or & need the wrap; everything else is left untouched.
9-
1+
// TM UI renders these fields as rich text only when HTML-wrapped;
102
const LOOKS_LIKE_HTML = /^\s*<[a-z][^>]*>/i;
113
const HAS_ENCODABLE_CHARS = /[<>&]/;
124

src/tools/testmanagement-utils/update-testcase.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ export async function updateTestCase(
178178
const testCaseBody: Record<string, any> = {};
179179

180180
if (params.name !== undefined) testCaseBody.name = params.name;
181-
// Rich-text fields must be HTML-wrapped or the TM UI shows entity-encoded
182-
// text literally (PMAA-185); see rich-text.ts.
183181
if (params.description !== undefined)
184182
testCaseBody.description = wrapRichText(params.description);
185183
if (params.preconditions !== undefined)

tests/tools/richText.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ describe('wrapRichText', () => {
4141
'<p>< 5 items are shown</p>',
4242
);
4343
});
44+
45+
it('handles any characters, not just fixed strings', () => {
46+
expect(wrapRichText('émojis 🎉 and ünïcode ≥ 5 stay bare')).toBe(
47+
'émojis 🎉 and ünïcode ≥ 5 stay bare',
48+
);
49+
expect(wrapRichText('unicode plus html char: 温度 > 30°C')).toBe(
50+
'<p>unicode plus html char: 温度 > 30°C</p>',
51+
);
52+
expect(wrapRichText('line1 a > b\nline2 c < d')).toBe(
53+
'<p>line1 a > b\nline2 c < d</p>',
54+
);
55+
expect(wrapRichText('a>=b && c<=d & "e"')).toBe(
56+
'<p>a>=b && c<=d & "e"</p>',
57+
);
58+
});
4459
});
4560

4661
describe('wrapTestCaseSteps', () => {

0 commit comments

Comments
 (0)