Skip to content

test: deduplicate runtime stabilization specs - #201

Merged
LucasSantana-Dev merged 2 commits into
mainfrom
fix/runtime-access-test-dedup
Mar 13, 2026
Merged

LucasSantana-Dev merged 2 commits into
mainfrom
fix/runtime-access-test-dedup

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Mar 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Changes

  • packages/backend/tests/unit/services/GuildAccessService.test.ts: shared MANAGE_ALL_ACCESS + reusable RBAC-unavailable assertion helper
  • packages/frontend/src/pages/AutoMod.test.tsx: template-apply setup and interaction helpers, parameterized error assertions
  • packages/frontend/src/pages/ServerSettings.test.tsx: shared manager RBAC payload/setup helpers, parameterized baseline-failure assertions
  • packages/frontend/src/pages/TwitchNotifications.test.tsx: reusable add-form helpers to remove repeated interaction blocks

Verification

  • npm run test --workspace=packages/backend -- tests/unit/services/GuildAccessService.test.ts
  • npm run test --workspace=packages/frontend -- src/pages/AutoMod.test.tsx src/pages/ServerSettings.test.tsx src/pages/TwitchNotifications.test.tsx
  • npm run type:check --workspace=packages/backend
  • npm run type:check --workspace=packages/frontend

Summary by CodeRabbit

  • Tests
    • Refactored suites to reduce duplication and improve maintainability via shared constants and helpers (including a standardized admin-access constant and a helper for asserting RBAC storage errors).
    • Template tests now use dynamic context and a generic apply-click helper; success and error paths are parameterized.
    • Server settings tests adopt centralized RBAC setup and parameterized error cases.
    • Notification tests add helpers to open and fill the add-notification form.

@vercel

vercel Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Mar 13, 2026 6:22pm

Request Review

@netlify

netlify Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for regal-bunny-0c8efe ready!

Name Link
🔨 Latest commit 1eedf18
🔍 Latest deploy log https://app.netlify.com/projects/regal-bunny-0c8efe/deploys/69b455a9a68967000854fea3
😎 Deploy Preview https://deploy-preview-201--regal-bunny-0c8efe.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Consolidates and refactors test code across backend and frontend: introduces shared RBAC constants/helpers, centralizes RBAC test payload/setup, and extracts reusable UI test helpers for template application and Twitch notification flows. No production code changes.

Changes

Cohort / File(s) Summary
Backend RBAC Test Standardization
packages/backend/tests/unit/services/GuildAccessService.test.ts
Added MANAGE_ALL_ACCESS constant and expectRbacStorageUnavailable helper; replaced inline admin access objects and repeated 503 assertions with the new constants/helpers across listAuthorizedGuilds and resolveGuildContext tests.
Frontend Template Application Tests
packages/frontend/src/pages/AutoMod.test.tsx
Refactored tests to use setTemplateContext(template) and clickTemplateApply(label) helpers; converted hard-coded fixtures to a dynamic template object and consolidated error cases into a parameterized test.each.
Frontend Server Settings RBAC Helpers
packages/frontend/src/pages/ServerSettings.test.tsx
Added GuildRbacResponse/GuildRbacPayload types, managerGuild/managerRoles/managerModules, makeManagerRbacPayload, and setupManagerRbac; replaced repeated per-test RBAC mocks with centralized helpers and parameterized error scenarios.
Frontend Twitch Notifications Test Helpers
packages/frontend/src/pages/TwitchNotifications.test.tsx
Introduced TWITCH_INPUT_PLACEHOLDER, openAddForm(user), and fillNotificationForm(user, twitchInput) helpers and replaced repeated form-open/fill sequences with these helpers across tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

frontend, backend, size/s

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly describes the main change: deduplicating test code (reducing runtime stabilization specs) across multiple test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/runtime-access-test-dedup
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the size/s label Mar 13, 2026
@github-actions

github-actions Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 300 kB

ℹ️ View Unchanged
Filename Size
packages/frontend/dist/assets/ActionPanel-eiFA61CV.js 470 B
packages/frontend/dist/assets/AutoMessages-c_LvL7T5.js 1.55 kB
packages/frontend/dist/assets/AutoMod-CrY1QNha.js 3.17 kB
packages/frontend/dist/assets/badge-U1g5Wmrg.js 449 B
packages/frontend/dist/assets/Card-C0RrB2ms.js 375 B
packages/frontend/dist/assets/CommandsConfig-KrXsLiBG.js 1.43 kB
packages/frontend/dist/assets/Config-BxbWKiL_.js 1.59 kB
packages/frontend/dist/assets/CustomCommands-C9J2-TaN.js 2.1 kB
packages/frontend/dist/assets/DashboardOverview-DMyLYBpI.js 2.77 kB
packages/frontend/dist/assets/Features-DjY_mCKx.js 2.81 kB
packages/frontend/dist/assets/index-BBq3X5sV.css 13.8 kB
packages/frontend/dist/assets/index-Bio0yiwI.js 69.5 kB
packages/frontend/dist/assets/input-CKMGbOWp.js 426 B
packages/frontend/dist/assets/label-DSfeWJQE.js 442 B
packages/frontend/dist/assets/LastFm-CIgNd_-G.js 1.68 kB
packages/frontend/dist/assets/Login-D_HXDxyK.js 2.29 kB
packages/frontend/dist/assets/Lyrics-B8znk-Id.js 1.28 kB
packages/frontend/dist/assets/Moderation-BWBM6i6j.js 3.76 kB
packages/frontend/dist/assets/ModerationConfig-Bdev1FgC.js 1.93 kB
packages/frontend/dist/assets/Music-Dbl8Z676.js 6.15 kB
packages/frontend/dist/assets/MusicConfig-ClTkQAKF.js 1.6 kB
packages/frontend/dist/assets/PrivacyPolicy-DRgRuFzn.js 756 B
packages/frontend/dist/assets/select-0s7HBAB3.js 1.19 kB
packages/frontend/dist/assets/ServerLogs-CECf5CQk.js 2.82 kB
packages/frontend/dist/assets/ServerSettings-BaGh05xp.js 3.67 kB
packages/frontend/dist/assets/ServersPage-DJs_FjQ9.js 2.63 kB
packages/frontend/dist/assets/Skeleton-V0KwMAVs.js 228 B
packages/frontend/dist/assets/switch-ClW7Uu9M.js 515 B
packages/frontend/dist/assets/TermsOfService-dxNnsZqU.js 794 B
packages/frontend/dist/assets/TrackHistory-boqVZtZs.js 1.82 kB
packages/frontend/dist/assets/TwitchNotifications-DfuQ45HW.js 2.2 kB
packages/frontend/dist/assets/usePageMetadata-Dudc5JrX.js 287 B
packages/frontend/dist/assets/vendor-forms-C1Gy4syj.js 21.1 kB
packages/frontend/dist/assets/vendor-radix-BTf9AecN.js 33.5 kB
packages/frontend/dist/assets/vendor-react-Bu1Oeml_.js 17.3 kB
packages/frontend/dist/assets/vendor-state-Szs8I3iE.js 25 kB
packages/frontend/dist/assets/vendor-ui-Dpvwn85C.js 64.7 kB
packages/frontend/dist/assets/zod-CLxBCFgw.js 1.58 kB

compressed-size-action

coderabbitai[bot]
coderabbitai Bot previously requested changes Mar 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/backend/tests/unit/services/GuildAccessService.test.ts (1)

87-94: Consider deriving MANAGE_ALL_ACCESS from RBAC_MODULES for maintainability.

The constant hardcodes all 6 modules. If RBAC_MODULES in @lucky/shared is updated with new modules, this test constant will need manual synchronization, risking incomplete permission coverage in tests.

♻️ Optional: Derive from source of truth
+import { RBAC_MODULES } from '@lucky/shared/services'
+
-const MANAGE_ALL_ACCESS = {
-    overview: 'manage',
-    settings: 'manage',
-    moderation: 'manage',
-    automation: 'manage',
-    music: 'manage',
-    integrations: 'manage',
-}
+const MANAGE_ALL_ACCESS = Object.fromEntries(
+    RBAC_MODULES.map((module) => [module, 'manage'])
+) as Record<(typeof RBAC_MODULES)[number], string>

Note: This would also apply to EMPTY_ACCESS (line 78-85) which follows the same pattern. Since both predate this PR and the deduplication goal is met, this is a nice-to-have for a follow-up.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/backend/tests/unit/services/GuildAccessService.test.ts` around lines
87 - 94, Replace the hardcoded MANAGE_ALL_ACCESS and EMPTY_ACCESS objects in the
test with maps derived from the shared RBAC_MODULES constant so they stay in
sync with the source of truth; import RBAC_MODULES from '@lucky/shared' and
construct MANAGE_ALL_ACCESS by iterating RBAC_MODULES to set each module's value
to 'manage' and construct EMPTY_ACCESS by iterating RBAC_MODULES to set each
module's value to '' (empty string), replacing the existing literals in
GuildAccessService.test.ts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/frontend/src/pages/ServerSettings.test.tsx`:
- Around line 34-44: The RBAC test fixtures are incomplete and loosely typed:
update managerRoles to include the required GuildRoleOption fields (add color
and position) and tighten makeManagerRbacPayload's signature to use the real
payload/interface instead of Record<string, unknown> (import the appropriate
RBAC response/payload type used by the app and use Partial<ThatType> for
overrides); remove any uses of as any in the test and return a correctly typed
object (refer to managerRoles, makeManagerRbacPayload, defaultAccess, and
GuildRoleOption to locate where to add color/position and apply the stronger
typing).

---

Nitpick comments:
In `@packages/backend/tests/unit/services/GuildAccessService.test.ts`:
- Around line 87-94: Replace the hardcoded MANAGE_ALL_ACCESS and EMPTY_ACCESS
objects in the test with maps derived from the shared RBAC_MODULES constant so
they stay in sync with the source of truth; import RBAC_MODULES from
'@lucky/shared' and construct MANAGE_ALL_ACCESS by iterating RBAC_MODULES to set
each module's value to 'manage' and construct EMPTY_ACCESS by iterating
RBAC_MODULES to set each module's value to '' (empty string), replacing the
existing literals in GuildAccessService.test.ts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c43c3c9d-b46d-4ccb-b421-011b8cf95b5a

📥 Commits

Reviewing files that changed from the base of the PR and between ffb7bd0 and 5d25654.

📒 Files selected for processing (4)
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: SonarCloud Scan
  • GitHub Check: Quality Gates
  • GitHub Check: compressed-size
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{js,jsx,ts,tsx,vue,html}

📄 CodeRabbit inference engine (.cursor/rules/accessibility-openness.mdc)

Provide accessible UI components using semantic HTML and ARIA attributes where necessary

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/dependency-injection.mdc)

**/*.{ts,tsx,js,jsx}: Prefer constructor injection for classes that require dependencies
Avoid global mutable singletons unless necessary
Use explicit interfaces for external dependencies to make testing easier

**/*.{ts,tsx,js,jsx}: Include required references in PRs/code for non-trivial logic: TypeScript (official docs), MDN (JavaScript reference), and official docs for any runtime/framework/libraries used (e.g., Node.js, React) as applicable.
Before assuming behavior of an API, include the doc link and a ≤25-word quote when the change relies on it.

**/*.{ts,tsx,js,jsx}: Prefer named exports for clear usage and easier refactors in TypeScript/JavaScript
Keep import order consistent: external first, then internal modules
Remove dead code and unused imports

**/*.{ts,tsx,js,jsx}: Use PascalCase naming convention for React/UI components
Use camelCase naming convention for variables and functions
Use UPPER_SNAKE_CASE naming convention for constants
Maintain consistent import grouping and ordering within the project, keeping third-party imports separate from local imports
For external data sources (HTTP, database), always validate and sanitize input using type guards or schema validators

**/*.{ts,tsx,js,jsx}: Use Prettier with no semicolons, single quotes, 4-space indent, 80 character width
Files must not exceed 250 lines and this is enforced

Implement TypeScript typecheck and linter in CI quality checks

**/*.{ts,tsx,js,jsx}: Use TypeScript for enhanced type safety
Implement error handling and error logging
Avoid commenting code unless extremely necessary - code should explain itself with descriptive names
Leave NO todos, placeholders or missing pieces in the code
Variables and functions must use camelCase
Constants must use UPPER_SNAKE_CASE
Use arrow functions for methods and computed properties
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
Maintain consistent import grouping/order: external imports first, then...

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

**/*.{js,jsx,ts,tsx}: Never throw strings. Throw Error (or typed subclasses) with descriptive messages
Include causal error as cause when available for better debugging
Define clear, stable error codes (e.g., ERR_AUTH_EXPIRED, ERR_NETWORK_TIMEOUT)
Provide optional metadata (e.g., details, retryable, status, correlationId) in error objects
Use domain error classes per area (e.g., AuthenticationError, ValidationError, NetworkError)
Log errors with structure (message, code, stack, cause, correlationId, user context where appropriate)
Mark retryable vs nonRetryable errors where helpful for operations
Set timeouts and handle aborts/cancellations; avoid dangling requests in API/network code
Implement backoff for transient failures; avoid infinite retries
Map HTTP status → domain errors; 4xx vs 5xx behave differently (e.g., retry for 5xx/network)

**/*.{js,jsx,ts,tsx}: Use functional components with hooks in React/React Native. Avoid class components.
Keep components focused on a single responsibility; extract complex logic into custom hooks.
Keep state local when possible. Use Context/Zustand/Redux only when necessary for state management.
If props or state traverse more than 3 levels, consider using context or a feature-scoped store instead of prop drilling.
Use performance optimization techniques: React.memo, useMemo, useCallback, Suspense (web), and virtualization for long lists; avoid unnecessary re-renders.
Web accessibility: use semantic HTML, labels, focus management, keyboard navigation, and aria-* attributes as needed.
React Native accessibility: use accessibility props (accessible, accessibilityLabel), proper roles and labels.
Identify and extract repetitive UI components proactively to components/ with clear props and minimal coupling.
Web styles: prefer co-located styles or design system tokens; avoid global style leakage.
React Native styles: prefer StyleSheet.create, design tokens, and theme providers; avoid in...

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

**/*.{jsx,tsx}: Use toasts/snackbars for transient errors; avoid blocking modals for non-critical issues in React/React Native UI
Debounce/suppress duplicate toasts to prevent spam
Provide retry/refresh actions when meaningful (e.g., network failure) in error UI
Use error boundaries for render-time exceptions; show fallback UI in React
Respect accessibility: toasts should be announced (aria-live on web; accessibility hints on React Native)

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Test behavior, not implementation. Prefer Testing Library utilities for testing React/React Native components.
For React Native tests: mock native modules and test component interactions and accessibility labels.

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

Introduce interfaces at module boundaries to enable testing and substitutions

**/*.{ts,tsx}: Avoid using any type in TypeScript. If unavoidable, use unknown with type guards and justify with a code comment
Prefer interface for defining public object shapes in TypeScript, use type for unions and utility types
Use TypeScript utility types such as Partial, Pick, Omit, Readonly, and Record when appropriate
Use I{Name} naming convention for interfaces in TypeScript
Use T{Name} naming convention for type aliases and utility types in TypeScript

**/*.{ts,tsx}: Functions must be less than 50 lines with cyclomatic complexity less than 10
Do not use any types - ESLint enforces this at error level

**/*.{ts,tsx}: Prefer types over interfaces for most cases
Don't ever use any - type safety always
Avoid enums; use const objects instead
For complex types, create a separate file to declare them and import them
Avoid using any type; if unavoidable, use unknown with type guards and justify with code comment
Prefer interface for public API shapes; use type for unions and utility types
Use TypeScript utility types (Partial, Pick, Omit, Readonly, Record)

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Test behavior, not implementation details
Prefer unit tests for core logic; add integration tests at meaningful boundaries

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/testing-quality.mdc)

**/*.{test,spec}.{js,ts,jsx,tsx}: Use Jest + a React testing library for unit and component tests as applicable
Test behavior, not implementation details

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
packages/frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/frontend/src/**/*.{ts,tsx}: Frontend errors are created by Axios interceptor and should be of type ApiError with status and details from backend
Frontend uses path alias @/ mapped to src/ - use this alias for all imports from the src directory

Do not depend on @lucky/shared package in frontend code; make API calls to backend via configured base URL (env)

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/documentation.mdc)

**/*.{js,ts,tsx,jsx}: Minimize comments in code; explain the 'why' when non-obvious, let code express the 'what' through clear naming
Document trade-offs briefly when deviating from ideal patterns

**/*.{js,ts,tsx,jsx}: Store secrets, ports, and hosts in environment variables (.env, .env.example) and never hardcode them
Avoid redundant or decorative AI comments; code should be self-explanatory and only commented when logic is non-obvious; prefer refactoring over lengthy comments

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
packages/frontend/src/pages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-frontend.mdc)

Organize pages in packages/frontend/src/pages/ directory (e.g., Login, Dashboard, Config, Features, ServersPage)

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
packages/frontend/src/{components,pages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-frontend.mdc)

Use React functional components and hooks; keep components small and focused

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
packages/frontend/src/{components,pages}/**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/lucky-frontend.mdc)

Follow existing styling approach (e.g., Tailwind if present); avoid inline styles for layout and theming

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
packages/frontend/**

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

The frontend package uses React with Vite and must not depend on the shared package

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/*.{spec,test}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/quality.mdc)

**/*.{spec,test}.{ts,tsx,js,jsx}: Use Jest for unit and integration tests
Test behavior, not implementation details
Run unit, integration tests, and coverage report in CI quality checks

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
**/[A-Z]*.{ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

Components must use PascalCase naming

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
packages/backend/tests/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-backend-api.mdc)

Organize tests in packages/backend/tests/ with unit tests under unit/ and integration tests under integration/, following existing patterns with fixtures and setup

Files:

  • packages/backend/tests/unit/services/GuildAccessService.test.ts
packages/backend/**

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

The backend package depends on shared and contains Express API with auth and guild routes

Files:

  • packages/backend/tests/unit/services/GuildAccessService.test.ts
**/*.{js,mjs,ts,mts}

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

Use Node.js version ≥22 with ESM (ECMAScript modules) only; no CommonJS

Files:

  • packages/backend/tests/unit/services/GuildAccessService.test.ts
{packages/*/tests/**/*.test.{js,ts},tests/**/*.test.{js,ts}}

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

Add or adjust unit and integration tests when changing behavior; follow existing patterns in packages/*/tests and root tests/ directories

Files:

  • packages/backend/tests/unit/services/GuildAccessService.test.ts
packages/backend/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-backend.mdc)

packages/backend/**/*.ts: Apply .cursor/rules/lucky-backend-api.mdc for structure and conventions when acting as backend specialist
Use .cursor/skills/backend-express/SKILL.md for Express routes, middleware, and services when acting as backend specialist
Use @lucky/shared for config and DB/Redis when needed in backend code

Files:

  • packages/backend/tests/unit/services/GuildAccessService.test.ts
packages/backend/tests/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-backend.mdc)

Follow existing patterns for unit and integration tests in packages/backend/tests/

Files:

  • packages/backend/tests/unit/services/GuildAccessService.test.ts
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/tests/**/*.{ts,tsx} : Organize tests in `packages/backend/tests/` with unit tests under `unit/` and integration tests under `integration/`, following existing patterns with fixtures and setup
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-backend.mdc:0-0
Timestamp: 2026-03-09T20:21:38.098Z
Learning: Applies to packages/backend/tests/**/*.ts : Follow existing patterns for unit and integration tests in `packages/backend/tests/`
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to {packages/*/tests/**/*.test.{js,ts},tests/**/*.test.{js,ts}} : Add or adjust unit and integration tests when changing behavior; follow existing patterns in `packages/*/tests` and root `tests/` directories
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-09T20:22:47.453Z
Learning: Add or adjust unit/integration tests in `packages/*/tests` and root `tests/` when changing behavior; follow existing patterns in the repository
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-frontend.mdc:0-0
Timestamp: 2026-03-09T20:21:58.991Z
Learning: Write unit and integration tests in `packages/frontend/tests`; use Playwright for E2E tests when changing user flows
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-frontend.mdc:0-0
Timestamp: 2026-03-09T20:20:56.356Z
Learning: Applies to packages/frontend/tests/**/*.{ts,tsx,js} : Write tests in `packages/frontend/tests/` using existing test patterns (e.g., Playwright for e2e if configured)
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to tests/**/*.test.{ts,tsx,js,jsx} : Add integration tests where appropriate
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to {packages/*/tests/**/*.test.{js,ts},tests/**/*.test.{js,ts}} : Add or adjust unit and integration tests when changing behavior; follow existing patterns in `packages/*/tests` and root `tests/` directories

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to tests/**/*.test.{ts,tsx,js,jsx} : Add integration tests where appropriate

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/ServerSettings.test.tsx
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to **/*.{spec,test}.{ts,tsx,js,jsx} : Test behavior, not implementation details

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/tests/**/*.{ts,tsx} : Organize tests in `packages/backend/tests/` with unit tests under `unit/` and integration tests under `integration/`, following existing patterns with fixtures and setup

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
📚 Learning: 2026-03-09T20:20:56.356Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-frontend.mdc:0-0
Timestamp: 2026-03-09T20:20:56.356Z
Learning: Applies to packages/frontend/tests/**/*.{ts,tsx,js} : Write tests in `packages/frontend/tests/` using existing test patterns (e.g., Playwright for e2e if configured)

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
📚 Learning: 2026-03-09T20:21:38.098Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-backend.mdc:0-0
Timestamp: 2026-03-09T20:21:38.098Z
Learning: Applies to packages/backend/tests/**/*.ts : Follow existing patterns for unit and integration tests in `packages/backend/tests/`

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/services/GuildAccessService.test.ts
  • packages/frontend/src/pages/ServerSettings.test.tsx
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to tests/**/*.test.ts : Integration tests must use naming convention `*.test.ts` and be located inside a `/tests` folder at the project's root

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to **/*.{spec,test}.{ts,tsx,js,jsx} : Use Jest for unit and integration tests

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
📚 Learning: 2026-03-09T20:21:58.991Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-frontend.mdc:0-0
Timestamp: 2026-03-09T20:21:58.991Z
Learning: Write unit and integration tests in `packages/frontend/tests`; use Playwright for E2E tests when changing user flows

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to **/*.{spec,test}.{ts,tsx,js,jsx} : Run unit, integration tests, and coverage report in CI quality checks

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/src/{services,middleware}/**/*.{ts,tsx} : Implement Discord OAuth for authentication in backend services

Applied to files:

  • packages/backend/tests/unit/services/GuildAccessService.test.ts
🔇 Additional comments (6)
packages/backend/tests/unit/services/GuildAccessService.test.ts (3)

96-104: Well-designed helper for RBAC storage unavailability assertions.

The helper correctly encapsulates the 503 error check with proper async handling and partial matching via toMatchObject. The message matches the production AppError thrown in GuildAccessService.ts (line 283-285).


358-360: Good use of the shared helper.

Both usages of expectRbacStorageUnavailable replace previously duplicated inline assertions, improving maintainability while preserving test behavior.

Also applies to: 524-526


224-224: Consistent application of MANAGE_ALL_ACCESS across tests.

The refactoring replaces scattered inline admin access objects with a single constant, reducing duplication and ensuring consistent permission sets across all admin-related test scenarios.

Also applies to: 298-298, 328-328, 396-396, 436-436, 531-531, 558-558, 581-581, 598-598

packages/frontend/src/pages/TwitchNotifications.test.tsx (1)

30-31: Good helper extraction for repeated add-notification flow.

This keeps tests behavior-focused while removing repeated interaction blocks, which should reduce maintenance churn.

Also applies to: 69-71, 73-80, 227-228, 294-295, 319-320, 339-339

packages/frontend/src/pages/ServerSettings.test.tsx (1)

451-452: Nice consolidation of manager RBAC and baseline-failure scenarios.

setupManagerRbac + test.each removes duplication while preserving behavior-level assertions for success, ApiError, and generic-error flows.

Also applies to: 473-500, 507-507, 509-512

packages/frontend/src/pages/AutoMod.test.tsx (1)

455-467: Solid DRY refactor of template-apply specs.

The new helpers and test.each cases keep assertions behavior-oriented and reduce duplicated setup without changing test intent.

Also applies to: 469-477, 479-501, 503-525

Comment thread packages/frontend/src/pages/ServerSettings.test.tsx Outdated
@LucasSantana-Dev
LucasSantana-Dev force-pushed the fix/runtime-access-test-dedup branch from 5d25654 to 1eedf18 Compare March 13, 2026 18:21
@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev dismissed coderabbitai[bot]’s stale review March 13, 2026 18:22

Actionable thread was addressed on head 1eedf18 and resolved. Remaining suggestions are non-blocking nits; dismissing stale CHANGES_REQUESTED gate for policy merge.

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 64df057 into main Mar 13, 2026
15 of 16 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/runtime-access-test-dedup branch March 13, 2026 18:26
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
* test: deduplicate runtime stabilization specs

* test(frontend): tighten ServerSettings RBAC fixture typing

This branch was successfully deployed

1 active deployment
Preview — 1eedf184 Deployed Mar 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant