feat(permissions): expose network permission state (#103)

This commit is contained in:
2026-07-25 23:05:55 +02:00
parent e8731834f4
commit 3047dc9195
31 changed files with 2080 additions and 94 deletions

View File

@ -21,6 +21,7 @@ import {
import {
MockAgentGateway,
MockPermissionGateway,
MockProfileGateway,
MockSystemGateway,
MockTemplateGateway,
@ -44,13 +45,15 @@ function renderPanel(
profile: MockProfileGateway = new MockProfileGateway(),
projectRoot = "/home/me/proj",
template?: MockTemplateGateway,
permission: MockPermissionGateway = new MockPermissionGateway(),
) {
const tmpl = template ?? new MockTemplateGateway(agent);
const gateways = { agent, profile, template: tmpl } as unknown as Gateways;
const gateways = { agent, profile, template: tmpl, permission } as unknown as Gateways;
return {
agent,
profile,
template: tmpl,
permission,
...render(
<DIProvider gateways={gateways}>
<AgentsPanel projectId={PROJECT_ID} projectRoot={projectRoot} />
@ -108,6 +111,27 @@ describe("AgentsPanel (with MockAgentGateway)", () => {
expect(agent).toBeTruthy();
});
it("shows the resolved network permission badge for an agent", async () => {
const agent = new MockAgentGateway();
const permission = new MockPermissionGateway();
const created = await agent.createAgent(PROJECT_ID, {
name: "Builder",
profileId: "p1",
});
permission.setResolvedAgentSystemPermissions(created.id, {
wanted: "allow",
effective: "deny",
runtimeLock: { state: "locked", reason: "Runtime locked." },
control: { mode: "readOnly", reason: "Runtime locked." },
});
renderPanel(agent, new MockProfileGateway(), "/home/me/proj", undefined, permission);
await waitFor(() => {
expect(screen.getByText("Réseau: Verrouillé")).toBeTruthy();
});
});
it("the Create button is disabled when the name is empty", async () => {
renderPanel();
await waitForIdle();