Skip to content

Features/export templates clean#84

Open
therealbrad wants to merge 42 commits intomainfrom
features/export-templates-clean
Open

Features/export templates clean#84
therealbrad wants to merge 42 commits intomainfrom
features/export-templates-clean

Conversation

@therealbrad
Copy link
Contributor

Description

This PR introduces three major features and several supporting improvements:

  1. QuickScript — AI-Powered Test Code Generation: A new feature that lets users generate test automation code (Playwright, API tests, etc.) directly from test cases using LLM integrations. Includes a modal UI, server actions for streaming AI exports, admin-managed QuickScript templates with variable insertion, code repository integration for providing file context to the AI, and sample case data previews.
  2. Code Repository Connections: Adds the ability to connect external code repositories (GitHub, GitLab, Bitbucket, Azure DevOps) to projects. Includes adapter implementations for each provider, a file cache layer, SSRF protection utilities, admin UI for managing repositories, and project-level configuration for selecting relevant files as AI context.
  3. LLM Budget Alerts: Adds a budget alerting system for LLM integrations. When spend crosses configured thresholds (50%, 75%, 90%, 100%), notifications are sent to admins via a new BullMQ background worker. Includes schema changes (alertThresholdsFired field, LLM_BUDGET_ALERT enum), a BudgetAlertService, budget progress UI in the LLM integration edit dialog, and automatic threshold reset on config save.

Other changes

  • Documentation additions for QuickScript and LLM integrations
  • Update color classes for success indicators across components
  • Replace Switch with Badge for automated test case status display
  • Dependency version updates

Related Issue

This PR implements #83

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement

How Has This Been Tested?

Describe the tests you ran to verify your changes:

  • Unit tests
  • Integration tests
  • E2E tests
  • Manual testing

21 test files added/modified with ~2,960 lines of test code covering:

  • BudgetAlertService (719 lines of tests)
  • QuickScript export actions (450+ lines)
  • AI export actions (173 lines)
  • Code context service (159 lines)
  • Import analyzer (396 lines)
  • Git repo adapters (GitHub, GitLab, Bitbucket, Azure DevOps)
  • SSRF protection utilities (111 lines)
  • QuickScript utilities and sample case data

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have signed the CLA

Screenshots (if applicable)

Screenshot 2026-03-02 at 10 58 58 AM Screenshot 2026-03-02 at 10 57 02 AM Screenshot 2026-03-02 at 10 58 10 AM Screenshot 2026-03-02 at 10 53 28 AM

Additional Notes

  • 174 files changed across the branch (~46,885 insertions)
  • New database models: CaseExportTemplate, CaseExportTemplateProjectAssignment, CodeRepository, ProjectCodeRepositoryConfig
  • New BullMQ worker: budgetAlertWorker
  • New API routes for code repository operations (test-connection, preview-files, refresh-cache) and AI export streaming
  • New admin pages: /admin/quickscripts, /admin/code-repositories
  • New project settings page: /projects/settings/[projectId]/quickscript

therealbrad and others added 25 commits March 1, 2026 11:09
Add QuickScript feature for AI-driven export of test cases to executable
test code. Includes code repository integrations (GitHub, GitLab,
Bitbucket, Azure DevOps), customizable export templates, LLM-powered
code generation with streaming, and project-level configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive test coverage for new export template functionality:
- SSRF protection (IPv4/IPv6, private ranges, protocols)
- AI export helpers (markdown fence stripping, error chain formatting)
- Code context service (term extraction, relevance scoring, path filtering)
- Git repo adapters (GitHub, GitLab, Bitbucket, Azure DevOps)

Also fix IPv6 SSRF bypass where URL.hostname returns bracketed addresses
that did not match the regex patterns.

Export 5 private helper functions for testability: stripMarkdownFences,
formatAiError, applyPathPatterns, extractTerms, scoreFileRelevance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Upgraded 'ioredis' to version 5.10.0 in both package.json and pnpm-lock.yaml.
- Updated '@types/node' to version 25.3.3 in testplanit/package.json.
- Incremented versions for several dependencies including '@atlaskit/editor-jira-transformer' to 15.0.1, '@aws-sdk/client-s3' and '@aws-sdk/s3-request-presigner' to 3.1000.0, '@swagger-api/apidom-core' to 1.6.0, 'ai' to 6.0.105, 'axios' to 1.13.6, 'multer' to 2.1.0, 'react-day-picker' to 9.14.0, 'simple-icons' to 16.10.0, 'swagger-ui-react' to 5.32.0, and 'autoprefixer' to 10.4.27.
- Adjusted various package specifications for better compatibility.
- Updated 'minimatch' versions in package.json and pnpm-lock.yaml to 5.1.8, 10.2.3, and 10.2.4 for improved compatibility.
- Added new dependencies: 'node-forge', 'tar-fs', and 'glob' with specified versions.
- Updated 'ioredis' to version 5.10.0 in testplanit/pnpm-lock.yaml.
- Incremented '@types/node' to version 25.3.3 in testplanit/package.json.
- Adjusted various package specifications for better compatibility.
- Reformatted schema.zmodel for consistency in formatting.
… to schema.zmodel

- Add LLM_BUDGET_ALERT value to NotificationType enum for budget alert notifications
- Add alertThresholdsFired Json? field to LlmProviderConfig model for tracking fired thresholds per billing month

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Run zenstack generate to regenerate Prisma schema, model meta, and OpenAPI spec
- Add alertThresholdsFired: null to all LlmProviderConfig mock objects in test files and route
- TypeScript type-check passes with zero errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 28 tests covering threshold detection, deduplication, month boundary,
  notification delivery, notification content, early exits, decimal
  handling, alertThresholdsFired update, and spend aggregation
- Tests fail because budgetAlertService.ts does not exist yet (TDD RED)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- BudgetAlertService.checkAndAlert detects newly crossed thresholds at 80%, 90%, 100%
- Deduplication via alertThresholdsFired JSON field (per month key)
- Notification fan-out to all ADMIN users per threshold via NotificationService
- Early exit for deleted providers, null/zero budget, no config
- Number() wrapping for all Prisma Decimal values (monthlyBudget, totalCost)
- Atomic alertThresholdsFired update before notification delivery
- Notification content includes provider name, dollar amounts, disclaimer
- All 41 unit tests pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Import afterEach from vitest to fix TypeScript error TS2304
- Auto-fixed: Rule 1 bug (missing import caused type-check failure)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add BUDGET_ALERT_QUEUE_NAME constant to queueNames.ts
- Add getBudgetAlertQueue() lazy-init function to queues.ts
- Include budgetAlertQueue in getAllQueues() for admin dashboard access
- Standard job options: 3 attempts, exponential backoff, 7-day retention

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create budgetAlertWorker.ts following auditLogWorker pattern
- Worker processes check-budget jobs via BudgetAlertService.checkAndAlert
- Add worker:budget-alert script and include in workers concurrently command
- Add budget-alert-worker PM2 entry in ecosystem.config.js
- Add budgetAlert i18n keys under admin.llm for Phase 3 UI use

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create 02-02-SUMMARY.md with execution results
- Update STATE.md position to plan 2 of 3, 60% progress
- Update ROADMAP.md plan progress for phase 02
- Mark CHCK-03 requirement as complete

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nd trackStreamUsage

- Add budget-check job enqueue after updateRateLimit in both trackUsage() and trackStreamUsage()
- Use dynamic import() to avoid circular dependencies (LlmManager -> queues -> valkey)
- Enqueue is fire-and-forget: not awaited, errors caught and logged, never propagated
- Skip providers without monthlyBudget (null or zero, including Ollama)
- Use Number() conversion for Prisma Decimal comparison

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add alertThresholdsFired: {} to updateLlmProviderConfig data payload
- Clears previously fired thresholds when admin saves provider config
- Allows thresholds to fire again against updated budget values

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
.planning/ is in .gitignore but these files were tracked before
the ignore rule was added. Removes them from version control
while keeping local copies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…udgetPercentage i18n key

- Pass currentSpend from usageByIntegrationId map through columns.tsx action cell
- Add budgetPercentage i18n key to en-US.json budgetAlert section
- Update EditLlmIntegrationProps interface to accept optional currentSpend prop

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…o EditLlmIntegration dialog

- Add Info icon import from lucide-react and Alert component import
- Add tBudgetAlert translation namespace for budget alert i18n keys
- Watch monthlyBudget field for reactive conditional rendering
- Add disclaimer callout (Alert with Info icon) below monthlyBudget field
- Display current month spend as "$X.XX of $Y.00" with i18n interpolation
- Add color-coded progress bar: green (<80%), yellow (80-100%), red (>100%)
- Show percentage text or "Over budget" label below progress bar
- Section only visible when monthlyBudget > 0, responds to live edits

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Updated source maps for various workers including auditLogWorker, elasticsearchReindexWorker, emailWorker, notificationWorker, syncWorker, and testmoImportWorker.
- Enhanced budget alert descriptions in en-US.json for clarity on spending targets and notifications.
- Updated budget alert descriptions for clarity in notifications.
- Added budget disclaimer to the notification content for LLM budget alerts.
- Improved color-coded progress bar in EditLlmIntegration dialog to reflect budget status.
- Refactored styles to include success color variables for better UI feedback.
- Adjusted translations in multiple languages to include budget disclaimer messages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replaced instances of 'text-green-600' and related classes with 'text-success' for consistency in success indicators.
- Updated background colors and badge styles to use 'bg-success' and 'bg-success/10' for improved UI feedback.
- Ensured all relevant components reflect the new success color scheme for better visual coherence.
- Added access to QuickScript from both the repository and individual test cases.
- Introduced a new column for default LLM provider configuration with toggle functionality.
- Updated DeleteLlmIntegration component to prevent deletion of default integrations.
- Enhanced EditLlmIntegration to disable options for default LLM providers.
- Improved QuickScript modal to reflect the number of selected cases in the output mode label.
- Updated translations for improved clarity and consistency across multiple languages.
…stCaseFormControl and TestCaseVersions

- Updated TestCaseFormControl to use Badge component for displaying automated/manual status instead of Switch.
- Refactored TestCaseVersions to reflect the same change, enhancing UI clarity and consistency.
- Improved accessibility by ensuring proper aria-labels are maintained for the Badge component.
…ge support

- Updated AddQuickScriptTemplate and EditQuickScriptTemplate components to include code highlighting using PrismJS.
- Introduced language mapping for syntax highlighting in the QuickScript preview.
- Improved UI for displaying highlighted code snippets in both add and edit modals.
- Adjusted package.json to increase memory allocation for Zenstack generation.
…dapters

- Updated error logging in generateAiExportBatch and generateAiExport functions for clearer output.
- Added SSRF safety checks in AzureDevOpsRepoAdapter, BitbucketRepoAdapter, and GitLabRepoAdapter to prevent requests to unsafe URLs.
- Introduced assertSsrfSafe method in GitRepoAdapter to validate URLs before making fetch requests.
…adapters

- Introduced SSRF safety checks in AzureDevOpsRepoAdapter and GitLabRepoAdapter to validate URLs.
- Updated error handling in formatError function for better clarity.
- Enhanced MockResizeObserver in vitest setup for improved testing capabilities.
- Updated AzureDevOpsRepoAdapter, BitbucketRepoAdapter, and GitLabRepoAdapter to use sanitizeUrl for SSRF safety checks.
- Enhanced GitRepoAdapter to include sanitizeUrl method, ensuring URLs are validated before fetch requests.
- Improved code clarity and maintainability by centralizing URL sanitization logic.
- Updated the sanitizeUrl method to preserve trailing slashes for base URLs, preventing double-slashes during path concatenation.
- Improved documentation for clarity on the method's functionality and its role in SSRF safety checks.
@therealbrad
Copy link
Contributor Author

Do not merge this until the QuickScript demo is finished. Then add an upgrade notification including a link tot he demo.

- Added details on mixed content errors related to file uploads when using MinIO with HTTPS.
- Explained the necessity of setting `IS_HOSTED=true` in the environment to enable proxy mode for secure uploads.
- Clarified the upload flow and provided an alternative configuration for public endpoint URLs to avoid mixed content issues.
- Enhanced documentation for better understanding of proxy mode and its implications for file storage.
…nent

- Added 'demo/' directory to .gitignore to prevent tracking of demo files.
- Removed unused reference to 'workflows.id' in the EditWorkflow component for cleaner code.
- Changed the default value for the test details panel width from 100 to 40 for improved layout consistency during server-side rendering.
- Updated the fallback logic in getInitialPanelRightWidth to reflect this change.
- Added `resolveSharedSteps` utility to enhance the fetching of steps in `exportActions` and `quickScriptActions`.
- Updated the selection clause for steps to include additional fields such as `sharedStepGroupId`.
- Modified the `fetchAllCasesForExport` and `fetchCasesForQuickScript` functions to resolve shared step references, ensuring accurate data retrieval.
- Adjusted tests to reflect changes in data fetching behavior when resolving shared steps.
…ility and state management

- Introduced unique IDs for ResizablePanel components across various pages to enhance accessibility and improve state management.
- Updated panel configurations in Welcome, MilestoneDetailsPage, ProjectOverview, AddCaseModal, ProjectRepository, TestCaseDetails, TestCaseVersions, JunitTableSection, and Session pages.
- Removed unused cookie handling logic related to panel widths for cleaner code.
- Updated the test for `resolveSharedSteps` to explicitly define the type of `cases`, ensuring better type safety and clarity in the test implementation.
- Removed the unused Badge import for cleaner code.
- Adjusted formatting for better readability in the useIssueColumns function, including consistent line breaks and indentation for JSX elements.
… performance

- Updated max_memory_restart from '512M' to '4G' to allow for greater memory usage.
- Adjusted node_args from '--max-old-space-size=384' to '--max-old-space-size=3584' to optimize Node.js memory allocation.
- Replaced the previous validation method with a new function to identify invalid characters, including control characters and commas.
- Updated error messages to specify the exact invalid character detected, enhancing user feedback during input validation.
- Ensured consistent validation logic across AddCaseField, AddResultField, EditCaseField, and EditResultField components.
…omponents

- Modified the header styling in DraggableFieldOptions to include a border and change the background color for improved visibility.
- Updated the icon selection background color in FieldIconPicker to enhance user experience and visual consistency.
…ication

- Introduced an `automated` property in various components including NameCell, TestCaseDetails, TestCaseNameDisplay, and CaseDisplay to better identify automated test cases.
- Updated logic to display appropriate icons based on the `automated` status, improving visual representation of test case types.
- Ensured consistent handling of the `automated` property across relevant components for better data management.
…nhanced test case identification

- Added the `automated` property to multiple components including RepositoryCasesSection, TestCaseVersions, and CaseListDisplay to improve identification of automated test cases.
- Updated data selection in queries and component props to ensure consistent handling of the `automated` flag across the application.
- Enhanced visual representation of test cases by integrating the `automated` status in relevant displays.
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.

1 participant