| | import { convertContentToDocs } from '../scripts/convert-markdown-for-docs' |
| |
|
| | |
| | const testContent = ` |
| | # bqrs interpret |
| | |
| | [Plumbing] Interpret data in a single BQRS. |
| | |
| | ## Description |
| | |
| | A command that interprets a single BQRS file according to the provided |
| | metadata and generates output in the specified format. |
| | |
| | ## Options |
| | |
| | ### Primary Options |
| | |
| | This option has no effect when passed to \`codeql bqrs interpret<bqrs-interpret>\`{.interpreted-text role="doc"}. |
| | |
| | For more information, see \`codeql database analyze<database-analyze>\`{.interpreted-text role="doc"}. |
| | ` |
| |
|
| | async function testCircularLinkFix(): Promise<boolean> { |
| | console.log('Testing circular link fix...') |
| |
|
| | try { |
| | |
| | const result1 = await convertContentToDocs(testContent, {}, 'bqrs-interpret.md') |
| | console.log('β
Conversion completed successfully') |
| |
|
| | |
| | const hasCircularLink = result1.content.includes( |
| | '[codeql bqrs interpret](/code-security/codeql-cli/codeql-cli-manual/bqrs-interpret)', |
| | ) |
| | const hasPlainText = result1.content.includes('codeql bqrs interpret') |
| |
|
| | if (hasCircularLink) { |
| | console.log('β FAIL: Circular link still present in output') |
| | console.log('Content:', result1.content) |
| | return false |
| | } else if (hasPlainText) { |
| | console.log('β
PASS: Circular link converted to plain text') |
| | } else { |
| | console.log('β οΈ WARNING: Could not find expected text in output') |
| | } |
| |
|
| | |
| | const hasValidLink = result1.content.includes( |
| | '[codeql database analyze](/code-security/codeql-cli/codeql-cli-manual/database-analyze)', |
| | ) |
| |
|
| | if (hasValidLink) { |
| | console.log('β
PASS: Non-circular link preserved correctly') |
| | } else { |
| | console.log('β FAIL: Valid cross-reference link was incorrectly removed') |
| | } |
| |
|
| | console.log('\n--- Generated content preview ---') |
| | console.log(`${result1.content.substring(0, 800)}...`) |
| |
|
| | return !hasCircularLink && hasValidLink |
| | } catch (error) { |
| | console.error('β Test failed with error:', error) |
| | return false |
| | } |
| | } |
| |
|
| | async function testEdgeCases(): Promise<boolean> { |
| | console.log('\nTesting edge cases...') |
| |
|
| | |
| | const result1 = await convertContentToDocs(testContent, {}, '') |
| | const hasLink1 = result1.content.includes( |
| | '[codeql bqrs interpret](/code-security/codeql-cli/codeql-cli-manual/bqrs-interpret)', |
| | ) |
| | if (hasLink1) { |
| | console.log('β
PASS: No filename provided - link preserved as expected') |
| | } else { |
| | console.log('β FAIL: Link incorrectly removed when no filename provided') |
| | return false |
| | } |
| |
|
| | |
| | const result2 = await convertContentToDocs(testContent, {}, 'different-file.md') |
| | const hasLink2 = result2.content.includes( |
| | '[codeql bqrs interpret](/code-security/codeql-cli/codeql-cli-manual/bqrs-interpret)', |
| | ) |
| | if (hasLink2) { |
| | console.log('β
PASS: Different filename - link preserved correctly') |
| | } else { |
| | console.log('β FAIL: Link incorrectly removed for different filename') |
| | return false |
| | } |
| |
|
| | return true |
| | } |
| |
|
| | |
| | async function runAllTests(): Promise<void> { |
| | const test1 = await testCircularLinkFix() |
| | const test2 = await testEdgeCases() |
| |
|
| | if (test1 && test2) { |
| | console.log('\nπ All tests passed!') |
| | process.exit(0) |
| | } else { |
| | console.log('\nπ₯ Tests failed!') |
| | process.exit(1) |
| | } |
| | } |
| |
|
| | runAllTests() |
| |
|