-
Notifications
You must be signed in to change notification settings - Fork 66.9k
Expand file tree
/
Copy pathaudit-logs-transformer.ts
More file actions
95 lines (76 loc) · 3.09 KB
/
audit-logs-transformer.ts
File metadata and controls
95 lines (76 loc) · 3.09 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { beforeAll, describe, expect, test } from 'vitest'
import { get } from '@/tests/helpers/e2etest'
const makeURL = (pathname: string): string => {
const params = new URLSearchParams({ pathname })
return `/api/article/body?${params}`
}
describe('Audit Logs transformer', () => {
beforeAll(() => {
if (!process.env.ROOT) {
console.warn(
'WARNING: The Audit Logs transformer tests require the ROOT environment variable to be set to the fixture root',
)
}
})
test('Security log events page renders with markdown structure', async () => {
const res = await get(
makeURL('/en/authentication/keeping-your-account-and-data-secure/security-log-events'),
)
expect(res.statusCode).toBe(200)
expect(res.headers['content-type']).toContain('text/markdown')
// Check for the main heading
expect(res.body).toContain('# Security log events')
// Check for intro
expect(res.body).toContain(
'Learn about security log events recorded for your personal account.',
)
// Check for manual content section heading
expect(res.body).toContain('## About security log events')
// Check for new main heading
expect(res.body).toContain('## Audit log events')
// Check for category heading
// The template renders "### Category"
expect(res.body).toMatch(/### \w+/)
})
test('Enterprise audit log events page renders with markdown structure', async () => {
const res = await get(
makeURL(
'/en/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise',
),
)
expect(res.statusCode).toBe(200)
expect(res.headers['content-type']).toContain('text/markdown')
expect(res.body).toContain('# Audit log events for your enterprise')
})
test('Organization audit log events page renders with markdown structure', async () => {
const res = await get(
makeURL(
'/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/audit-log-events-for-your-organization',
),
)
expect(res.statusCode).toBe(200)
expect(res.headers['content-type']).toContain('text/markdown')
expect(res.body).toContain('# Audit log events for your organization')
})
test('Events are formatted correctly', async () => {
const res = await get(
makeURL('/en/authentication/keeping-your-account-and-data-secure/security-log-events'),
)
expect(res.statusCode).toBe(200)
// Check for event action header
// #### `action.name`
expect(res.body).toMatch(/#### `[\w.]+`/)
// Check for fields section
expect(res.body).toContain('**Fields:**')
// Check for reference section
expect(res.body).toContain('**Reference:**')
})
test('Manual content is preserved', async () => {
const res = await get(
makeURL('/en/authentication/keeping-your-account-and-data-secure/security-log-events'),
)
expect(res.statusCode).toBe(200)
// The source file has manual content before the marker
expect(res.body).toContain('## About security log events')
})
})