fix(test): replace meaningless assertions and silent skips with proper test semantics

- Replace 4x expect(true).toBe(true) in audit-logger.test.ts with
  applyAuditConfig() + app.getVersion call count assertions
- Replace if(!hasCredentials){return} pattern with it.skipIf() in
  3 integration test files (cleaner, erp-auth, extractor) so Vitest
  correctly reports 12 tests as "skipped" instead of "passed"
- Remove placeholder assertion from skipped update-service test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-04-04 21:11:12 +08:00
parent 5d8563a4c9
commit d7ebb10f38
5 changed files with 93 additions and 145 deletions

View File

@@ -118,9 +118,11 @@ describe('Audit Logger - Real File Integration', () => {
})
it('should handle all status values (success, failure, partial)', async () => {
const { logAudit, closeAuditLogger } =
const { logAudit, closeAuditLogger, applyAuditConfig } =
await import('../../src/main/services/logger/audit-logger')
applyAuditConfig(30)
// Test success status
logAudit('EXTRACT', 'user1', {
username: 'extractor',
@@ -149,14 +151,16 @@ describe('Audit Logger - Real File Integration', () => {
closeAuditLogger()
// Verify all entries were processed
expect(true).toBe(true) // Logger accepted all status types without error
// Verify logAudit executed for each entry (each call invokes app.getVersion)
expect(app.getVersion).toHaveBeenCalledTimes(3)
})
it('should handle metadata correctly (with and without)', async () => {
const { logAudit, closeAuditLogger } =
const { logAudit, closeAuditLogger, applyAuditConfig } =
await import('../../src/main/services/logger/audit-logger')
applyAuditConfig(30)
// Without metadata
logAudit('LOGIN', 'user-no-meta', {
username: 'no.meta',
@@ -176,8 +180,8 @@ describe('Audit Logger - Real File Integration', () => {
closeAuditLogger()
// Both entries should be processed successfully
expect(true).toBe(true)
// Both entries processed (each call invokes app.getVersion)
expect(app.getVersion).toHaveBeenCalledTimes(2)
})
it('should generate ISO 8601 timestamp', async () => {
@@ -209,9 +213,11 @@ describe('Audit Logger - Real File Integration', () => {
})
it('should handle special characters in fields', async () => {
const { logAudit, closeAuditLogger } =
const { logAudit, closeAuditLogger, applyAuditConfig } =
await import('../../src/main/services/logger/audit-logger')
applyAuditConfig(30)
logAudit('LOGIN_ATTEMPT', 'user-special', {
username: 'user.name+test@example.com',
computerName: 'DESKTOP-特殊字符-001',
@@ -222,14 +228,16 @@ describe('Audit Logger - Real File Integration', () => {
closeAuditLogger()
// Should handle without errors
expect(true).toBe(true)
// Verify special characters were processed without error
expect(app.getVersion).toHaveBeenCalledTimes(1)
})
it('should handle empty metadata gracefully', async () => {
const { logAudit, closeAuditLogger } =
const { logAudit, closeAuditLogger, applyAuditConfig } =
await import('../../src/main/services/logger/audit-logger')
applyAuditConfig(30)
logAudit('PING', 'ping-user', {
username: 'pinger',
computerName: 'PC-PING',
@@ -240,7 +248,7 @@ describe('Audit Logger - Real File Integration', () => {
closeAuditLogger()
// Should handle empty metadata
expect(true).toBe(true)
// Verify empty metadata was processed without error
expect(app.getVersion).toHaveBeenCalledTimes(1)
})
})