feat: online verification, node removals, and knowledge browser
CI / quality (push) Canceled after 0s
CI / quality (push) Canceled after 0s
Adds claim-bound online evidence records and citation verification scripts, node removal transport/adapter, retrieval benchmark and owner-review tooling, GraphCanvas/SourceDetail knowledge browser UI, and the ingest handoff helper. Bumps the agents/gewu pack to the online-verification branch.
This commit is contained in:
1 parent
a3156f4e08
commit
78033bb830
83 files changed
+13476
-1051
No files matched your search
@@ -1,60 +1,65 @@
|
||||
import { cleanup, render, screen, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { afterEach, expect, it, vi } from 'vitest';
|
||||
import Admin from './Admin';
|
||||
import { cleanup, render, screen, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import Admin from "./Admin";
|
||||
|
||||
afterEach(() => { cleanup(); vi.unstubAllGlobals(); });
|
||||
|
||||
it('creates a project from the admin form and makes it available for account and agent grants', async () => {
|
||||
it("creates a project from the admin form and makes it available for account and agent grants", async () => {
|
||||
let created = false;
|
||||
let conflict = true;
|
||||
const project = {
|
||||
schema_version: 1, project_id: 'my-research', title: 'My research', status: 'active',
|
||||
north_star: 'Investigate useful techniques.', key_questions: ['What works?', 'Under what conditions?'],
|
||||
owners: ['user:admin'], autonomy_policy_id: 'my-research-policy',
|
||||
schema_version: 1, project_id: "my-research", title: "My research", status: "active",
|
||||
north_star: "Investigate useful techniques.", key_questions: ["What works?", "Under what conditions?"],
|
||||
owners: ["user:admin"], autonomy_policy_id: "my-research-policy",
|
||||
};
|
||||
const fetchMock = vi.fn(async (path: string, init?: RequestInit) => {
|
||||
if (path === '/v1/session' && init?.method === 'GET') return { ok: false, status: 401, json: async () => ({}) };
|
||||
if (path === "/v1/session" && init?.method === "GET") return { ok: false, status: 401, json: async () => ({}) };
|
||||
let result: unknown = [];
|
||||
if (path === '/v1/users/session') result = { csrf_token: 'csrf-fixture' };
|
||||
if (path === '/v1/me') result = { principal_id: 'user:admin' };
|
||||
if (path === '/v1/admin/projects') {
|
||||
if (init?.method === 'POST') {
|
||||
if (conflict) return { ok: false, status: 409, json: async () => ({ detail: 'Project ID is already registered' }) };
|
||||
if (path === "/v1/users/session") result = { csrf_token: "csrf-fixture" };
|
||||
if (path === "/v1/me") result = { principal_id: "user:admin" };
|
||||
if (path === "/v1/admin/projects") {
|
||||
if (init?.method === "POST") {
|
||||
if (conflict) return { ok: false, status: 409, json: async () => ({ detail: "Project ID is already registered" }) };
|
||||
created = true; result = project;
|
||||
} else result = created ? [project] : [];
|
||||
}
|
||||
return { ok: true, json: async () => result };
|
||||
});
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
const user = userEvent.setup();
|
||||
render(<Admin />);
|
||||
await user.type(await screen.findByLabelText('Username'), 'admin');
|
||||
await user.type(screen.getByLabelText('Password'), 'password-fixture');
|
||||
await user.click(screen.getByRole('button', { name: 'Sign in' }));
|
||||
const projects = await screen.findByRole('region', { name: 'Projects' });
|
||||
expect(within(projects).getByText('No projects yet. Create your first project below.')).toBeVisible();
|
||||
expect(within(projects).getByLabelText(/Owner ID/)).toHaveValue('user:admin');
|
||||
await user.type(within(projects).getByLabelText('Project name'), 'My research');
|
||||
expect(within(projects).getByLabelText(/Project ID/)).toHaveValue('my-research');
|
||||
await user.type(within(projects).getByLabelText('Project purpose'), 'Investigate useful techniques.');
|
||||
await user.type(within(projects).getByLabelText('Key research questions'), 'What works?\nUnder what conditions?');
|
||||
await user.click(within(projects).getByRole('button', { name: 'Create project' }));
|
||||
expect(await screen.findByRole('alert')).toHaveTextContent('Project ID is already registered');
|
||||
expect(within(projects).getByLabelText('Project name')).toHaveValue('My research');
|
||||
await user.type(await screen.findByLabelText("Username"), "admin");
|
||||
await user.type(screen.getByLabelText("Password"), "password-fixture");
|
||||
await user.click(screen.getByRole("button", { name: "Sign in" }));
|
||||
const projects = await screen.findByRole("region", { name: "Projects" });
|
||||
expect(within(projects).getByText("No projects yet. Create your first project below.")).toBeVisible();
|
||||
await user.click(within(projects).getByRole("button", { name: "Create project" }));
|
||||
const dialog = await screen.findByRole("dialog", { name: "Create a project" });
|
||||
expect(within(dialog).getByLabelText(/Owner ID/)).toHaveValue("user:admin");
|
||||
await user.type(within(dialog).getByLabelText("Project name"), "My research");
|
||||
expect(within(dialog).getByLabelText(/Project ID/)).toHaveValue("my-research");
|
||||
await user.type(within(dialog).getByLabelText("Project purpose"), "Investigate useful techniques.");
|
||||
await user.type(within(dialog).getByLabelText("Key research questions"), "What works?\nUnder what conditions?");
|
||||
await user.click(within(dialog).getByRole("button", { name: "Create project" }));
|
||||
expect(await screen.findByRole("alert")).toHaveTextContent("Project ID is already registered");
|
||||
expect(within(dialog).getByLabelText("Project name")).toHaveValue("My research");
|
||||
conflict = false;
|
||||
await user.click(within(projects).getByRole('button', { name: 'Create project' }));
|
||||
await screen.findByText('Created My research. It is now available for user access and agent keys.');
|
||||
expect(fetchMock).toHaveBeenCalledWith('/v1/admin/projects', expect.objectContaining({
|
||||
method: 'POST', headers: expect.objectContaining({ 'X-GEWU-CSRF': 'csrf-fixture' }),
|
||||
await user.click(within(dialog).getByRole("button", { name: "Create project" }));
|
||||
await screen.findByText("Created My research. It is now available for user access and agent keys.");
|
||||
expect(fetchMock).toHaveBeenCalledWith("/v1/admin/projects", expect.objectContaining({
|
||||
method: "POST", headers: expect.objectContaining({ "X-GEWU-CSRF": "csrf-fixture" }),
|
||||
body: JSON.stringify({
|
||||
project: { project_id: 'my-research', title: 'My research', status: 'active', owners: ['user:admin'], north_star: 'Investigate useful techniques.', key_questions: ['What works?', 'Under what conditions?'], autonomy_policy_id: 'my-research-policy', default_includes: [] },
|
||||
policy: { policy_id: 'my-research-policy', policy_version: 1, project_id: 'my-research', automatic_source_registration: true, automatic_node_types: ['finding', 'problem', 'technique', 'case', 'entity', 'event', 'concept', 'datapoint', 'synthesis'], require_supported_assessment: true },
|
||||
project: { project_id: "my-research", title: "My research", status: "active", owners: ["user:admin"], north_star: "Investigate useful techniques.", key_questions: ["What works?", "Under what conditions?"], autonomy_policy_id: "my-research-policy", default_includes: [] },
|
||||
policy: { policy_id: "my-research-policy", policy_version: 1, project_id: "my-research", automatic_source_registration: true, automatic_node_types: ["finding", "problem", "technique", "case", "entity", "event", "concept", "datapoint", "synthesis"], require_supported_assessment: true },
|
||||
}),
|
||||
}));
|
||||
expect(within(projects).getByLabelText('Project name')).toHaveValue('');
|
||||
await user.click(screen.getByRole('tab', { name: 'Users' }));
|
||||
expect(within(screen.getByRole('region', { name: 'User accounts' })).getByLabelText('My research')).toBeVisible();
|
||||
await user.click(screen.getByRole('tab', { name: 'Credentials' }));
|
||||
expect(within(screen.getByRole('region', { name: 'Create a credential' })).getByLabelText('My research')).toBeVisible();
|
||||
await user.click(screen.getByRole("tab", { name: "Users" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Add user" }));
|
||||
const usersDialog = await screen.findByRole("dialog", { name: "Add user" });
|
||||
expect(within(usersDialog).getByLabelText("My research")).toBeVisible();
|
||||
await user.click(screen.getByRole("tab", { name: "Credentials" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Add credential" }));
|
||||
const credsDialog = await screen.findByRole("dialog", { name: "Add credential" });
|
||||
expect(within(credsDialog).getByLabelText("My research")).toBeVisible();
|
||||
});
|
||||
Reference in new issue
Block a user