From fc8e8d2a3b26a4f858fc5b274f73474605e95120 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 25 Jul 2025 20:43:57 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20ci:=20Update=20Test=20Files=20&?= =?UTF-8?q?=20fix=20ESLint=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/server/routes/files/files.test.js | 5 -- api/server/services/start/interface.spec.js | 27 +++++- .../Agents/__tests__/Accessibility.spec.tsx | 7 +- .../Agents/__tests__/AgentDetail.spec.tsx | 82 ++++--------------- client/src/locales/en/translation.json | 1 - 5 files changed, 47 insertions(+), 75 deletions(-) diff --git a/api/server/routes/files/files.test.js b/api/server/routes/files/files.test.js index 02aaf3c688..d02caf79fd 100644 --- a/api/server/routes/files/files.test.js +++ b/api/server/routes/files/files.test.js @@ -61,11 +61,8 @@ describe('File Routes - Delete with Agent Access', () => { let Agent; let AclEntry; let User; - let AccessRole; let methods; let modelsToCleanup = []; - // eslint-disable-next-line no-unused-vars - let agentId; beforeAll(async () => { mongoServer = await MongoMemoryServer.create(); @@ -90,7 +87,6 @@ describe('File Routes - Delete with Agent Access', () => { Agent = models.Agent; AclEntry = models.AclEntry; User = models.User; - AccessRole = models.AccessRole; // Seed default roles using our methods await methods.seedDefaultRoles(); @@ -139,7 +135,6 @@ describe('File Routes - Delete with Agent Access', () => { // Create test data authorId = new mongoose.Types.ObjectId(); otherUserId = new mongoose.Types.ObjectId(); - agentId = uuidv4(); fileId = uuidv4(); // Create users in database diff --git a/api/server/services/start/interface.spec.js b/api/server/services/start/interface.spec.js index 4ee3f78724..d9f3d4e067 100644 --- a/api/server/services/start/interface.spec.js +++ b/api/server/services/start/interface.spec.js @@ -419,6 +419,7 @@ describe('loadDefaultInterface', () => { [Permissions.VIEW_USERS]: undefined, }, [PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: undefined }, + [PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: true }, }); }); @@ -450,6 +451,7 @@ describe('loadDefaultInterface', () => { [Permissions.VIEW_USERS]: undefined, }, [PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: true }, + [PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: undefined }, }); }); @@ -481,6 +483,7 @@ describe('loadDefaultInterface', () => { [Permissions.VIEW_USERS]: undefined, }, [PermissionTypes.FILE_SEARCH]: { [Permissions.USE]: false }, + [PermissionTypes.FILE_CITATIONS]: { [Permissions.USE]: undefined }, }); }); @@ -517,7 +520,7 @@ describe('loadDefaultInterface', () => { [Permissions.VIEW_USERS]: undefined, }, [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, { [PermissionTypes.PROMPTS]: { [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.AGENTS]: { [Permissions.USE]: undefined }, [PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined }, [PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined }, [PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined }, [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, { [PermissionTypes.PROMPTS]: { [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.AGENTS]: { [Permissions.USE]: undefined }, [PermissionTypes.TEMPORARY_CHAT]: { [Permissions.USE]: undefined }, [PermissionTypes.RUN_CODE]: { [Permissions.USE]: undefined }, [PermissionTypes.WEB_SEARCH]: { [Permissions.USE]: undefined }, [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 }, }); }); }); diff --git a/client/src/components/SidePanel/Agents/__tests__/Accessibility.spec.tsx b/client/src/components/SidePanel/Agents/__tests__/Accessibility.spec.tsx index 2121226f22..768d27471d 100644 --- a/client/src/components/SidePanel/Agents/__tests__/Accessibility.spec.tsx +++ b/client/src/components/SidePanel/Agents/__tests__/Accessibility.spec.tsx @@ -503,8 +503,11 @@ describe('Accessibility Improvements', () => { ); const tab = screen.getByRole('tab'); - expect(tab.className).toContain('focus:outline-none'); - expect(tab.className).toContain('focus:bg-gray-100'); + // Check that the tab has proper ARIA attributes for accessibility + 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'); }); }); diff --git a/client/src/components/SidePanel/Agents/__tests__/AgentDetail.spec.tsx b/client/src/components/SidePanel/Agents/__tests__/AgentDetail.spec.tsx index 9bf44b1f96..b9c1fd7302 100644 --- a/client/src/components/SidePanel/Agents/__tests__/AgentDetail.spec.tsx +++ b/client/src/components/SidePanel/Agents/__tests__/AgentDetail.spec.tsx @@ -178,12 +178,12 @@ describe('AgentDetail', () => { expect(screen.getByText('com_agents_no_description')).toBeInTheDocument(); }); - it('should render 3-dot menu button', () => { + it('should render copy link button', () => { renderWithProviders(); - const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' }); - expect(menuButton).toBeInTheDocument(); - expect(menuButton).toHaveAttribute('aria-haspopup', 'menu'); + const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' }); + expect(copyLinkButton).toBeInTheDocument(); + expect(copyLinkButton).toHaveAttribute('aria-label', 'com_agents_copy_link'); }); it('should render Start Chat button', () => { @@ -241,46 +241,11 @@ describe('AgentDetail', () => { expect(mockNavigate).not.toHaveBeenCalled(); }); - it('should open dropdown when 3-dot menu is clicked', async () => { - const user = userEvent.setup(); - renderWithProviders(); - - 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(); - - // 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 () => { const user = userEvent.setup(); renderWithProviders(); - // Open dropdown - const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' }); - await user.click(menuButton); - - // Click copy link + // Click copy link button directly (no dropdown needed) const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' }); await user.click(copyLinkButton); @@ -296,13 +261,6 @@ describe('AgentDetail', () => { 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 () => { @@ -311,10 +269,7 @@ describe('AgentDetail', () => { renderWithProviders(); - // Open dropdown and click copy link - const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' }); - await user.click(menuButton); - + // Click copy link button directly const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' }); await user.click(copyLinkButton); @@ -345,33 +300,32 @@ describe('AgentDetail', () => { it('should have proper ARIA attributes', () => { renderWithProviders(); - const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' }); - expect(menuButton).toHaveAttribute('aria-haspopup', 'menu'); - expect(menuButton).toHaveAttribute('aria-label', 'com_agents_more_options'); + const copyLinkButton = screen.getByRole('button', { name: 'com_agents_copy_link' }); + expect(copyLinkButton).toHaveAttribute('aria-label', 'com_agents_copy_link'); }); - it('should support keyboard navigation for dropdown', async () => { + it('should support keyboard navigation', async () => { const user = userEvent.setup(); renderWithProviders(); - 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 - menuButton.focus(); + // Focus and activate with Enter key + copyLinkButton.focus(); 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 () => { - const user = userEvent.setup(); renderWithProviders(); - const menuButton = screen.getByRole('button', { name: 'com_agents_more_options' }); - await user.click(menuButton); - 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'); }); }); diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json index c099f23965..5a23bd9eed 100644 --- a/client/src/locales/en/translation.json +++ b/client/src/locales/en/translation.json @@ -1208,7 +1208,6 @@ "com_agents_copy_link": "Copy Link", "com_agents_link_copied": "Link copied", "com_agents_link_copy_failed": "Failed to copy link", - "com_agents_more_options": "More options", "com_agents_loading": "Loading...", "com_agents_error_loading": "Error loading agents", "com_agents_error_searching": "Error searching agents",