|
| 1 | +import { describe, expect, test } from 'vitest' |
| 2 | + |
| 3 | +import { getCategorizedAuditLogEvents } from '../../lib' |
| 4 | +import config from '../../lib/config.json' |
| 5 | + |
| 6 | +describe('audit log category notes', () => { |
| 7 | + test('config contains expected category notes', () => { |
| 8 | + expect(config.categoryNotes).toBeDefined() |
| 9 | + expect(typeof config.categoryNotes).toBe('object') |
| 10 | + |
| 11 | + // Check that we have the specific category notes mentioned in the issue |
| 12 | + expect(config.categoryNotes).toHaveProperty('members_can_create_pages') |
| 13 | + expect(config.categoryNotes).toHaveProperty('git') |
| 14 | + expect(config.categoryNotes).toHaveProperty('sso_redirect') |
| 15 | + }) |
| 16 | + |
| 17 | + test('category notes are strings', () => { |
| 18 | + if (config.categoryNotes) { |
| 19 | + Object.values(config.categoryNotes).forEach((note) => { |
| 20 | + expect(typeof note).toBe('string') |
| 21 | + expect(note.length).toBeGreaterThan(0) |
| 22 | + }) |
| 23 | + } |
| 24 | + }) |
| 25 | + |
| 26 | + test('members_can_create_pages note contains reference to GitHub Pages', () => { |
| 27 | + const note = config.categoryNotes?.['members_can_create_pages'] |
| 28 | + expect(note).toContain('GitHub Pages') |
| 29 | + expect(note).toContain('organization') |
| 30 | + }) |
| 31 | + |
| 32 | + test('git category note contains REST API information', () => { |
| 33 | + const note = config.categoryNotes?.['git'] |
| 34 | + expect(note).toContain('REST API') |
| 35 | + expect(note).toContain('7-day retention') |
| 36 | + }) |
| 37 | + |
| 38 | + test('sso_redirect note mentions beta status', () => { |
| 39 | + const note = config.categoryNotes?.['sso_redirect'] |
| 40 | + expect(note).toContain('beta') |
| 41 | + expect(note).toContain('Enterprise Managed Users') |
| 42 | + }) |
| 43 | + |
| 44 | + test('category notes do not interfere with event categorization', () => { |
| 45 | + // Test that adding category notes doesn't break existing functionality |
| 46 | + const organizationEvents = getCategorizedAuditLogEvents('organization', 'free-pro-team@latest') |
| 47 | + const enterpriseEvents = getCategorizedAuditLogEvents('enterprise', 'enterprise-cloud@latest') |
| 48 | + |
| 49 | + // Should still have categorized events |
| 50 | + expect(Object.keys(organizationEvents).length).toBeGreaterThan(0) |
| 51 | + expect(Object.keys(enterpriseEvents).length).toBeGreaterThan(0) |
| 52 | + |
| 53 | + // Each category should still contain arrays of events |
| 54 | + Object.values(organizationEvents).forEach((events) => { |
| 55 | + expect(Array.isArray(events)).toBe(true) |
| 56 | + if (events.length > 0) { |
| 57 | + expect(events[0]).toHaveProperty('action') |
| 58 | + expect(events[0]).toHaveProperty('description') |
| 59 | + } |
| 60 | + }) |
| 61 | + }) |
| 62 | + |
| 63 | + test('category notes are properly typed', () => { |
| 64 | + // This test will pass once we update the types |
| 65 | + const notes = config.categoryNotes |
| 66 | + if (notes) { |
| 67 | + expect(notes).toEqual( |
| 68 | + expect.objectContaining({ |
| 69 | + members_can_create_pages: expect.any(String), |
| 70 | + git: expect.any(String), |
| 71 | + sso_redirect: expect.any(String), |
| 72 | + }), |
| 73 | + ) |
| 74 | + } |
| 75 | + }) |
| 76 | +}) |
0 commit comments