-
Notifications
You must be signed in to change notification settings - Fork 66.6k
Expand file tree
/
Copy pathcodeql-cli-transformer.ts
More file actions
48 lines (39 loc) · 1.68 KB
/
codeql-cli-transformer.ts
File metadata and controls
48 lines (39 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { describe, expect, test, beforeAll } from 'vitest'
import { get } from '@/tests/helpers/e2etest'
const makeURL = (pathname: string): string =>
`/api/article/body?${new URLSearchParams({ pathname })}`
describe('codeql cli article body api', () => {
beforeAll(() => {
if (!process.env.ROOT) {
console.warn(
'WARNING: The CodeQL CLI transformer tests require the ROOT environment variable to be set to the fixture root',
)
}
})
test('database-analyze page', async () => {
const res = await get(
makeURL('/en/code-security/codeql-cli/codeql-cli-manual/database-analyze'),
)
expect(res.statusCode).toBe(200)
expect(res.headers['content-type']).toContain('text/markdown')
// Check for title injection
expect(res.body).toContain('# database analyze')
// Check for intro injection
expect(res.body).toContain(
'Analyze a database, producing meaningful results in the context of the source code.',
)
// Check for content
expect(res.body).toContain('## Synopsis')
expect(res.body).toContain('## Description')
expect(res.body).toContain('## Options')
// Verify HTML comments are stripped
expect(res.body).not.toContain('<!-- markdownlint-disable GHD053 -->')
expect(res.body).not.toContain('<!-- markdownlint-disable GHD030 -->')
expect(res.body).not.toContain('<!-- Content after this section is automatically generated -->')
})
test('canTransform returns false for non-codeql-cli pages', async () => {
const res = await get(makeURL('/en/get-started/start-your-journey/hello-world'))
// This should not be transformed by CodeQL CLI transformer
expect(res.statusCode).toBe(200)
})
})