mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
🧪 ci: Update PermissionService tests for PromptGroup resource type
- Refactor tests to use PromptGroup roles instead of Project roles. - Initialize models and seed default roles in test setup. - Update error handling for non-existent resource types. - Ensure proper cleanup of test data while retaining seeded roles.
This commit is contained in:
parent
fc8fd489d6
commit
90b037a67f
5 changed files with 66 additions and 99 deletions
|
|
@ -10,7 +10,6 @@ import type t from 'librechat-data-provider';
|
|||
import { Constants, EModelEndpoint } from 'librechat-data-provider';
|
||||
|
||||
import AgentDetail from '../AgentDetail';
|
||||
import { useToast } from '~/hooks';
|
||||
|
||||
// Mock dependencies
|
||||
jest.mock('react-router-dom', () => ({
|
||||
|
|
@ -19,11 +18,15 @@ jest.mock('react-router-dom', () => ({
|
|||
}));
|
||||
|
||||
jest.mock('~/hooks', () => ({
|
||||
useToast: jest.fn(),
|
||||
useMediaQuery: jest.fn(() => false), // Mock as desktop by default
|
||||
useLocalize: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('@librechat/client', () => ({
|
||||
...jest.requireActual('@librechat/client'),
|
||||
useToastContext: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('~/utils/agents', () => ({
|
||||
renderAgentAvatar: jest.fn((agent, options) => (
|
||||
<div data-testid="agent-avatar" data-size={options?.size} />
|
||||
|
|
@ -101,7 +104,8 @@ describe('AgentDetail', () => {
|
|||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
(useNavigate as jest.Mock).mockReturnValue(mockNavigate);
|
||||
(useToast as jest.Mock).mockReturnValue({ showToast: mockShowToast });
|
||||
const { useToastContext } = require('@librechat/client');
|
||||
(useToastContext as jest.Mock).mockReturnValue({ showToast: mockShowToast });
|
||||
const { useLocalize } = require('~/hooks');
|
||||
(useLocalize as jest.Mock).mockReturnValue(mockLocalize);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue