Skip to content

test(Common): add tests for Types/AI/AIChatPermissionModeHelper#2682

Merged
simlarsen merged 1 commit into
OneUptime:masterfrom
suvvvv:test/ai-chat-permission-mode
Jul 14, 2026
Merged

test(Common): add tests for Types/AI/AIChatPermissionModeHelper#2682
simlarsen merged 1 commit into
OneUptime:masterfrom
suvvvv:test/ai-chat-permission-mode

Conversation

@suvvvv

@suvvvv suvvvv commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Adds unit tests for AIChatPermissionModeHelper in Common/Types/AI/AIChatPermissionMode.ts, which previously had no test coverage.

This enum gates whether the AI chat agent may run mutating tools (create/acknowledge/resolve incidents and alerts). It's persisted per-conversation on AIConversation.permissionMode and enforced in ChatAgentRunner, so its parsing behaviour is security-relevant.

Covered:

  • getDefault — returns AskForApproval, and explicitly asserts it is not the permissive AutoRun.
  • isValid — accepts every mode; rejects undefined, empty string, wrong casing, trailing whitespace, and unknown values.
  • parse — round-trips every valid mode and falls back to the default for unrecognized input. Includes a fail-safe invariant: a malformed or missing persisted value must never resolve to AutoRun, so a bad column value can't silently let the agent mutate project data without approval.
  • getOptions — exposes exactly one option per mode (no duplicates, none missing), each with a non-empty title and description, and every offered option is itself parseable.

Why

Improves test coverage for the Common/Types utilities (part of the broader test-coverage effort). The fail-safe and option-completeness invariants guard the permission gate as new modes get added.

Testing

node node_modules/.bin/jest --runInBand ./Tests/Types/AI/AIChatPermissionMode.test.ts

All 17 tests pass. Prettier- and eslint-clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@simlarsen

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@simlarsen simlarsen merged commit 049b645 into OneUptime:master Jul 14, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants