From e58d4f3ff6290853d89bff4b2bc1232f68c28fde Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Sun, 20 Sep 2026 17:28:27 +0800 Subject: [PATCH] fix(web): route IP policy references to bound agents (SNP-829) --- .../ip-policies-page/__tests__/index.spec.tsx | 61 +++++++++++++++++++ .../ip-policies-page/referenced-apps.tsx | 6 +- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/web/app/components/header/account-setting/ip-policies-page/__tests__/index.spec.tsx b/web/app/components/header/account-setting/ip-policies-page/__tests__/index.spec.tsx index b8822d6aec5..a4935daa693 100644 --- a/web/app/components/header/account-setting/ip-policies-page/__tests__/index.spec.tsx +++ b/web/app/components/header/account-setting/ip-policies-page/__tests__/index.spec.tsx @@ -567,4 +567,65 @@ describe('IpPoliciesPage', () => { expect(screen.queryByText('Enforcing')).not.toBeInTheDocument() }, ) + + it.each(['view', 'edit', 'delete'] as const)( + 'links agent and regular app references correctly in %s', + async (mode) => { + const user = userEvent.setup() + const queryClient = createConsoleQueryClient() + seedNetworkAccessGroups(queryClient, { + groups: [ + createNetworkAccessGroupFixture({ + used_by_count: 2, + enforcing_count: 1, + apps: [ + { + id: 'backing-app', + bound_agent_id: 'agent-1', + name: 'New Agent', + mode: 'workflow', + icon: null, + icon_type: null, + icon_background: null, + }, + { + id: 'app-2', + name: 'Workflow', + mode: 'workflow', + icon: null, + icon_type: null, + icon_background: null, + }, + ], + }), + ], + }) + renderWithConsoleQuery( + + + , + { + queryClient, + currentWorkspace: { role: mode === 'view' ? 'editor' : 'owner' }, + systemFeatures: { deployment_edition: 'CLOUD' }, + }, + ) + if (mode === 'delete') { + await user.click(screen.getByRole('button', { name: 'More actions for Internal Network' })) + await user.click(screen.getByRole('menuitem', { name: 'Delete' })) + expect(screen.getByText('Still used by 2 apps')).toBeInTheDocument() + } else { + await user.click(screen.getByRole('button', { name: 'Internal Network' })) + } + expect(screen.getByRole('link', { name: 'New Agent' })).toHaveAttribute( + 'href', + '/agents/agent-1/configure', + ) + expect(screen.getByRole('link', { name: 'New Agent' })).toHaveAttribute('target', '_blank') + expect(screen.getByRole('link', { name: 'Workflow' })).toHaveAttribute( + 'href', + '/app/app-2/overview', + ) + }, + ) }) diff --git a/web/app/components/header/account-setting/ip-policies-page/referenced-apps.tsx b/web/app/components/header/account-setting/ip-policies-page/referenced-apps.tsx index de2788e000a..bbfa533eb6a 100644 --- a/web/app/components/header/account-setting/ip-policies-page/referenced-apps.tsx +++ b/web/app/components/header/account-setting/ip-policies-page/referenced-apps.tsx @@ -32,7 +32,11 @@ export function PolicyReferencedApps({ apps, usedByCount }: PolicyReferencedApps {apps.map((app) => (