mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
🧪 ci: Update Test Files & fix ESLint issues
This commit is contained in:
parent
75324e1c7e
commit
74e029e78f
5 changed files with 47 additions and 75 deletions
|
@ -61,11 +61,8 @@ describe('File Routes - Delete with Agent Access', () => {
|
||||||
let Agent;
|
let Agent;
|
||||||
let AclEntry;
|
let AclEntry;
|
||||||
let User;
|
let User;
|
||||||
let AccessRole;
|
|
||||||
let methods;
|
let methods;
|
||||||
let modelsToCleanup = [];
|
let modelsToCleanup = [];
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
let agentId;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
mongoServer = await MongoMemoryServer.create();
|
mongoServer = await MongoMemoryServer.create();
|
||||||
|
@ -90,7 +87,6 @@ describe('File Routes - Delete with Agent Access', () => {
|
||||||
Agent = models.Agent;
|
Agent = models.Agent;
|
||||||
AclEntry = models.AclEntry;
|
AclEntry = models.AclEntry;
|
||||||
User = models.User;
|
User = models.User;
|
||||||
AccessRole = models.AccessRole;
|
|
||||||
|
|
||||||
// Seed default roles using our methods
|
// Seed default roles using our methods
|
||||||
await methods.seedDefaultRoles();
|
await methods.seedDefaultRoles();
|
||||||
|
@ -139,7 +135,6 @@ describe('File Routes - Delete with Agent Access', () => {
|
||||||
// Create test data
|
// Create test data
|
||||||
authorId = new mongoose.Types.ObjectId();
|
authorId = new mongoose.Types.ObjectId();
|
||||||
otherUserId = new mongoose.Types.ObjectId();
|
otherUserId = new mongoose.Types.ObjectId();
|
||||||
agentId = uuidv4();
|
|
||||||
fileId = uuidv4();
|
fileId = uuidv4();
|
||||||
|
|
||||||
// Create users in database
|
// Create users in database
|
||||||
|
|
|
@ -419,6 +419,7 @@ describe('loadDefaultInterface', () => {
|
||||||
[Permissions.VIEW_USERS]: undefined,
|
[Permissions.VIEW_USERS]: undefined,
|
||||||
},
|
},
|
||||||
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: true },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -450,6 +451,7 @@ describe('loadDefaultInterface', () => {
|
||||||
[Permissions.VIEW_USERS]: undefined,
|
[Permissions.VIEW_USERS]: undefined,
|
||||||
},
|
},
|
||||||
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -481,6 +483,7 @@ describe('loadDefaultInterface', () => {
|
||||||
[Permissions.VIEW_USERS]: undefined,
|
[Permissions.VIEW_USERS]: undefined,
|
||||||
},
|
},
|
||||||
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: false },
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: false },
|
||||||
|
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -517,7 +520,7 @@ describe('loadDefaultInterface', () => {
|
||||||
[Permissions.VIEW_USERS]: undefined,
|
[Permissions.VIEW_USERS]: undefined,
|
||||||
},
|
},
|
||||||
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true },
|
||||||
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: true },
|
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -530,13 +533,22 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MEMORIES]: {
|
||||||
|
[Permissions.USE]: undefined,
|
||||||
|
[Permissions.OPT_OUT]: undefined,
|
||||||
|
},
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: true },
|
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: true },
|
||||||
|
[PermissionTypes.MARKETPLACE]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_GROUPS]: undefined,
|
||||||
|
[Permissions.VIEW_USERS]: undefined,
|
||||||
|
},
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -549,13 +561,22 @@ describe('loadDefaultInterface', () => {
|
||||||
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
expect(updateAccessPermissions).toHaveBeenCalledWith(SystemRoles.USER, {
|
||||||
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.PROMPTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.BOOKMARKS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.MEMORIES]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MEMORIES]: {
|
||||||
|
[Permissions.USE]: undefined,
|
||||||
|
[Permissions.OPT_OUT]: undefined,
|
||||||
|
},
|
||||||
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
[PermissionTypes.MULTI_CONVO]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
[PermissionTypes.AGENTS]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
[PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
[PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
[PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: false },
|
[PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: false },
|
||||||
|
[PermissionTypes.MARKETPLACE]: { [Permissions.USE]: undefined },
|
||||||
|
[PermissionTypes.PEOPLE_PICKER]: {
|
||||||
|
[Permissions.VIEW_GROUPS]: undefined,
|
||||||
|
[Permissions.VIEW_USERS]: undefined,
|
||||||
|
},
|
||||||
|
[PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -503,8 +503,11 @@ describe('Accessibility Improvements', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const tab = screen.getByRole('tab');
|
const tab = screen.getByRole('tab');
|
||||||
expect(tab.className).toContain('focus:outline-none');
|
// Check that the tab has proper ARIA attributes for accessibility
|
||||||
expect(tab.className).toContain('focus:bg-gray-100');
|
expect(tab).toHaveAttribute('aria-selected', 'true');
|
||||||
|
expect(tab).toHaveAttribute('tabIndex', '0');
|
||||||
|
// Check that tab has proper role and can receive focus
|
||||||
|
expect(tab).toHaveAttribute('role', 'tab');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -178,12 +178,12 @@ describe('AgentDetail', () => {
|
||||||
expect(screen.getByText('com_agents_no_description')).toBeInTheDocument();
|
expect(screen.getByText('com_agents_no_description')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render 3-dot menu button', () => {
|
it('should render copy link button', () => {
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
renderWithProviders(<AgentDetail {...defaultProps} />);
|
||||||
|
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
||||||
expect(menuButton).toBeInTheDocument();
|
expect(copyLinkButton).toBeInTheDocument();
|
||||||
expect(menuButton).toHaveAttribute('aria-haspopup', 'menu');
|
expect(copyLinkButton).toHaveAttribute('aria-label', 'com_agents_copy_link');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render Start Chat button', () => {
|
it('should render Start Chat button', () => {
|
||||||
|
@ -241,46 +241,11 @@ describe('AgentDetail', () => {
|
||||||
expect(mockNavigate).not.toHaveBeenCalled();
|
expect(mockNavigate).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open dropdown when 3-dot menu is clicked', async () => {
|
|
||||||
const user = userEvent.setup();
|
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
|
||||||
|
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
|
||||||
await user.click(menuButton);
|
|
||||||
|
|
||||||
expect(screen.getByRole('button', { name: 'com_agents_copy_link' })).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should close dropdown when clicking outside', async () => {
|
|
||||||
const user = userEvent.setup();
|
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
|
||||||
|
|
||||||
// Open dropdown
|
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
|
||||||
await user.click(menuButton);
|
|
||||||
|
|
||||||
expect(screen.getByRole('button', { name: 'com_agents_copy_link' })).toBeInTheDocument();
|
|
||||||
|
|
||||||
// Click outside (on the agent name)
|
|
||||||
const agentName = screen.getByText('Test Agent');
|
|
||||||
await user.click(agentName);
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(
|
|
||||||
screen.queryByRole('button', { name: 'com_agents_copy_link' }),
|
|
||||||
).not.toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should copy link and show success toast when Copy Link is clicked', async () => {
|
it('should copy link and show success toast when Copy Link is clicked', async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
renderWithProviders(<AgentDetail {...defaultProps} />);
|
||||||
|
|
||||||
// Open dropdown
|
// Click copy link button directly (no dropdown needed)
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
|
||||||
await user.click(menuButton);
|
|
||||||
|
|
||||||
// Click copy link
|
|
||||||
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
||||||
await user.click(copyLinkButton);
|
await user.click(copyLinkButton);
|
||||||
|
|
||||||
|
@ -296,13 +261,6 @@ describe('AgentDetail', () => {
|
||||||
message: 'com_agents_link_copied',
|
message: 'com_agents_link_copied',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dropdown should close
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(
|
|
||||||
screen.queryByRole('button', { name: 'com_agents_copy_link' }),
|
|
||||||
).not.toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show error toast when clipboard write fails', async () => {
|
it('should show error toast when clipboard write fails', async () => {
|
||||||
|
@ -311,10 +269,7 @@ describe('AgentDetail', () => {
|
||||||
|
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
renderWithProviders(<AgentDetail {...defaultProps} />);
|
||||||
|
|
||||||
// Open dropdown and click copy link
|
// Click copy link button directly
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
|
||||||
await user.click(menuButton);
|
|
||||||
|
|
||||||
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
||||||
await user.click(copyLinkButton);
|
await user.click(copyLinkButton);
|
||||||
|
|
||||||
|
@ -345,33 +300,32 @@ describe('AgentDetail', () => {
|
||||||
it('should have proper ARIA attributes', () => {
|
it('should have proper ARIA attributes', () => {
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
renderWithProviders(<AgentDetail {...defaultProps} />);
|
||||||
|
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
||||||
expect(menuButton).toHaveAttribute('aria-haspopup', 'menu');
|
expect(copyLinkButton).toHaveAttribute('aria-label', 'com_agents_copy_link');
|
||||||
expect(menuButton).toHaveAttribute('aria-label', 'com_agents_more_options');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support keyboard navigation for dropdown', async () => {
|
it('should support keyboard navigation', async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
renderWithProviders(<AgentDetail {...defaultProps} />);
|
||||||
|
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
||||||
|
|
||||||
// Focus and open with Enter key
|
// Focus and activate with Enter key
|
||||||
menuButton.focus();
|
copyLinkButton.focus();
|
||||||
await user.keyboard('{Enter}');
|
await user.keyboard('{Enter}');
|
||||||
|
|
||||||
expect(screen.getByRole('button', { name: 'com_agents_copy_link' })).toBeInTheDocument();
|
await waitFor(() => {
|
||||||
|
expect(mockWriteText).toHaveBeenCalledWith(
|
||||||
|
`${window.location.origin}/c/new?agent_id=test-agent-id`,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have proper focus management', async () => {
|
it('should have proper focus management', async () => {
|
||||||
const user = userEvent.setup();
|
|
||||||
renderWithProviders(<AgentDetail {...defaultProps} />);
|
renderWithProviders(<AgentDetail {...defaultProps} />);
|
||||||
|
|
||||||
const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' });
|
|
||||||
await user.click(menuButton);
|
|
||||||
|
|
||||||
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' });
|
||||||
expect(copyLinkButton).toHaveClass('focus:bg-surface-hover', 'focus:outline-none');
|
expect(copyLinkButton).toHaveClass('focus:outline-none', 'focus:ring-2');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1208,7 +1208,6 @@
|
||||||
"com_agents_copy_link": "Copy Link",
|
"com_agents_copy_link": "Copy Link",
|
||||||
"com_agents_link_copied": "Link copied",
|
"com_agents_link_copied": "Link copied",
|
||||||
"com_agents_link_copy_failed": "Failed to copy link",
|
"com_agents_link_copy_failed": "Failed to copy link",
|
||||||
"com_agents_more_options": "More options",
|
|
||||||
"com_agents_loading": "Loading...",
|
"com_agents_loading": "Loading...",
|
||||||
"com_agents_error_loading": "Error loading agents",
|
"com_agents_error_loading": "Error loading agents",
|
||||||
"com_agents_error_searching": "Error searching agents",
|
"com_agents_error_searching": "Error searching agents",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue