|
| 1 | +import { beforeAll, describe, expect, test } from 'vitest' |
| 2 | + |
| 3 | +import { get } from '@/tests/helpers/e2etest' |
| 4 | + |
| 5 | +const makeURL = (pathname: string): string => { |
| 6 | + const params = new URLSearchParams({ pathname }) |
| 7 | + return `/api/article/body?${params}` |
| 8 | +} |
| 9 | + |
| 10 | +describe('Audit Logs transformer', () => { |
| 11 | + beforeAll(() => { |
| 12 | + if (!process.env.ROOT) { |
| 13 | + console.warn( |
| 14 | + 'WARNING: The Audit Logs transformer tests require the ROOT environment variable to be set to the fixture root', |
| 15 | + ) |
| 16 | + } |
| 17 | + }) |
| 18 | + |
| 19 | + test('Security log events page renders with markdown structure', async () => { |
| 20 | + const res = await get( |
| 21 | + makeURL('/en/authentication/keeping-your-account-and-data-secure/security-log-events'), |
| 22 | + ) |
| 23 | + expect(res.statusCode).toBe(200) |
| 24 | + expect(res.headers['content-type']).toContain('text/markdown') |
| 25 | + |
| 26 | + // Check for the main heading |
| 27 | + expect(res.body).toContain('# Security log events') |
| 28 | + |
| 29 | + // Check for intro |
| 30 | + expect(res.body).toContain( |
| 31 | + 'Learn about security log events recorded for your personal account.', |
| 32 | + ) |
| 33 | + |
| 34 | + // Check for manual content section heading |
| 35 | + expect(res.body).toContain('## About security log events') |
| 36 | + |
| 37 | + // Check for new main heading |
| 38 | + expect(res.body).toContain('## Audit log events') |
| 39 | + |
| 40 | + // Check for category heading |
| 41 | + // The template renders "### Category" |
| 42 | + expect(res.body).toMatch(/### \w+/) |
| 43 | + }) |
| 44 | + |
| 45 | + test('Enterprise audit log events page renders with markdown structure', async () => { |
| 46 | + const res = await get( |
| 47 | + makeURL( |
| 48 | + '/en/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise', |
| 49 | + ), |
| 50 | + ) |
| 51 | + expect(res.statusCode).toBe(200) |
| 52 | + expect(res.headers['content-type']).toContain('text/markdown') |
| 53 | + |
| 54 | + expect(res.body).toContain('# Audit log events for your enterprise') |
| 55 | + }) |
| 56 | + |
| 57 | + test('Organization audit log events page renders with markdown structure', async () => { |
| 58 | + const res = await get( |
| 59 | + makeURL( |
| 60 | + '/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/audit-log-events-for-your-organization', |
| 61 | + ), |
| 62 | + ) |
| 63 | + expect(res.statusCode).toBe(200) |
| 64 | + expect(res.headers['content-type']).toContain('text/markdown') |
| 65 | + |
| 66 | + expect(res.body).toContain('# Audit log events for your organization') |
| 67 | + }) |
| 68 | + |
| 69 | + test('Events are formatted correctly', async () => { |
| 70 | + const res = await get( |
| 71 | + makeURL('/en/authentication/keeping-your-account-and-data-secure/security-log-events'), |
| 72 | + ) |
| 73 | + expect(res.statusCode).toBe(200) |
| 74 | + |
| 75 | + // Check for event action header |
| 76 | + // #### `action.name` |
| 77 | + expect(res.body).toMatch(/#### `[\w.]+`/) |
| 78 | + |
| 79 | + // Check for fields section |
| 80 | + expect(res.body).toContain('**Fields:**') |
| 81 | + |
| 82 | + // Check for reference section |
| 83 | + expect(res.body).toContain('**Reference:**') |
| 84 | + }) |
| 85 | + |
| 86 | + test('Manual content is preserved', async () => { |
| 87 | + const res = await get( |
| 88 | + makeURL('/en/authentication/keeping-your-account-and-data-secure/security-log-events'), |
| 89 | + ) |
| 90 | + expect(res.statusCode).toBe(200) |
| 91 | + |
| 92 | + // The source file has manual content before the marker |
| 93 | + expect(res.body).toContain('## About security log events') |
| 94 | + }) |
| 95 | +}) |
0 commit comments