11import { describe , expect , test } from 'vitest'
22import { convertContentToDocs } from '../scripts/convert-markdown-for-docs'
3+ import config from '@/codeql-cli/lib/config.json'
4+
5+ const RELATIVE_LINK_PATH = config . targetDirectory . replace ( 'content' , '' )
36
47describe ( 'convertContentToDocs circular link handling' , ( ) => {
58 const testContent = `
@@ -26,7 +29,7 @@ For more information, see \`codeql database analyze<database-analyze>\`{.interpr
2629
2730 // Should not contain circular link
2831 expect ( result . content ) . not . toContain (
29- ' [codeql bqrs interpret](/code-security/codeql-cli/codeql-cli-manual/ bqrs-interpret)' ,
32+ ` [codeql bqrs interpret](${ RELATIVE_LINK_PATH } / bqrs-interpret)` ,
3033 )
3134
3235 // Should contain plain text instead
@@ -38,7 +41,7 @@ For more information, see \`codeql database analyze<database-analyze>\`{.interpr
3841
3942 // Should preserve valid cross-reference link
4043 expect ( result . content ) . toContain (
41- ' [codeql database analyze](/code-security/codeql-cli/codeql-cli-manual/ database-analyze)' ,
44+ ` [codeql database analyze](${ RELATIVE_LINK_PATH } / database-analyze)` ,
4245 )
4346 } )
4447
@@ -47,7 +50,7 @@ For more information, see \`codeql database analyze<database-analyze>\`{.interpr
4750
4851 // Should preserve link when no filename is provided
4952 expect ( result . content ) . toContain (
50- ' [codeql bqrs interpret](/code-security/codeql-cli/codeql-cli-manual/ bqrs-interpret)' ,
53+ ` [codeql bqrs interpret](${ RELATIVE_LINK_PATH } / bqrs-interpret)` ,
5154 )
5255 } )
5356
@@ -56,7 +59,7 @@ For more information, see \`codeql database analyze<database-analyze>\`{.interpr
5659
5760 // Should preserve link when filename is different
5861 expect ( result . content ) . toContain (
59- ' [codeql bqrs interpret](/code-security/codeql-cli/codeql-cli-manual/ bqrs-interpret)' ,
62+ ` [codeql bqrs interpret](${ RELATIVE_LINK_PATH } / bqrs-interpret)` ,
6063 )
6164 } )
6265
@@ -65,12 +68,12 @@ For more information, see \`codeql database analyze<database-analyze>\`{.interpr
6568
6669 // Circular link should be plain text
6770 expect ( result . content ) . not . toContain (
68- ' [codeql bqrs interpret](/code-security/codeql-cli/codeql-cli-manual/ bqrs-interpret)' ,
71+ ` [codeql bqrs interpret](${ RELATIVE_LINK_PATH } / bqrs-interpret)` ,
6972 )
7073
7174 // Non-circular link should be preserved
7275 expect ( result . content ) . toContain (
73- ' [codeql database analyze](/code-security/codeql-cli/codeql-cli-manual/ database-analyze)' ,
76+ ` [codeql database analyze](${ RELATIVE_LINK_PATH } / database-analyze)` ,
7477 )
7578
7679 // Both should have their text content present
0 commit comments