feat: connect Subject Ticket assignments across public execution paths
This commit is contained in:
@@ -29,7 +29,9 @@ Deno.test("ticket child operations reset across Workspaces even when the retaine
|
||||
const keyedChildren = [...pageSource.matchAll(
|
||||
/\{#key JSON\.stringify\(\[data\.workspaceId, ticket\.id\]\)\}([\s\S]*?)\{\/key\}/g,
|
||||
)].map((match) => match[1]);
|
||||
for (const child of ["TicketTags", "TicketHandling", "TicketWorkerObservation"]) {
|
||||
for (
|
||||
const child of ["TicketTags", "TicketHandling", "TicketWorkerObservation"]
|
||||
) {
|
||||
assert(
|
||||
keyedChildren.some((block) => block.includes(`<${child}`)),
|
||||
`${child} must reset for the Workspace and Ticket, whether in main or rail`,
|
||||
@@ -63,8 +65,20 @@ Deno.test("ticket detail fences stale mutation responses", () => {
|
||||
|
||||
Deno.test("ticket responsibility display does not claim Worker liveness or work authority", () => {
|
||||
assertStringIncludes(pageSource, "Role assignments and manual Workers");
|
||||
assertStringIncludes(pageSource, "Assignments are retained independently of Worker state.");
|
||||
assertStringIncludes(pageSource, "assignment.principal.runtime_id");
|
||||
assertStringIncludes(pageSource, "assignment.principal.worker_id");
|
||||
assertStringIncludes(
|
||||
pageSource,
|
||||
"Assignments are retained independently of Worker state.",
|
||||
);
|
||||
assertStringIncludes(
|
||||
pageSource,
|
||||
"assignmentPrincipalLabel(assignment.principal)",
|
||||
);
|
||||
const modelSource = Deno.readTextFileSync(
|
||||
new URL("../src/lib/workspace/tickets/ticket-panel.ts", import.meta.url),
|
||||
);
|
||||
assertStringIncludes(modelSource, 'principal.kind === "subject"');
|
||||
assertStringIncludes(modelSource, "principal.subject_id");
|
||||
assertStringIncludes(modelSource, "principal.runtime_id");
|
||||
assertStringIncludes(modelSource, "principal.worker_id");
|
||||
assert(!pageSource.includes("No active role assignment."));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "subject-handling",
|
||||
"title": "Ticket Subject responsibility, separate from Worker execution",
|
||||
"baseUrl": "http://127.0.0.1:15371",
|
||||
"colorScheme": "dark",
|
||||
"reducedMotion": "reduce",
|
||||
"personas": [
|
||||
{
|
||||
"id": "member",
|
||||
"label": "Synthetic authenticated member, not settings owner",
|
||||
"auth": {
|
||||
"kind": "anonymous"
|
||||
}
|
||||
}
|
||||
],
|
||||
"viewports": [
|
||||
{
|
||||
"label": "desktop",
|
||||
"width": 1440,
|
||||
"height": 900
|
||||
},
|
||||
{
|
||||
"label": "narrow",
|
||||
"width": 768,
|
||||
"height": 900
|
||||
},
|
||||
{
|
||||
"label": "mobile",
|
||||
"width": 390,
|
||||
"height": 844
|
||||
}
|
||||
],
|
||||
"routes": [
|
||||
{
|
||||
"id": "principal",
|
||||
"label": "Choose responsibility",
|
||||
"path": "/w/tickets/tickets/T-2",
|
||||
"goal": "Inspect handling and choose responsible Subject",
|
||||
"dataState": "Open and waiting with current assignment, no current body Worker",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".ticket-handling"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "choice",
|
||||
"label": "Observed assignment and choice",
|
||||
"interaction": [
|
||||
{
|
||||
"action": "click",
|
||||
"selector": ".assignment-principal summary"
|
||||
}
|
||||
],
|
||||
"fullPage": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "legacy",
|
||||
"path": "/w/tickets-legacy/tickets/T-2",
|
||||
"goal": "Inspect retained legacy assignment audit",
|
||||
"dataState": "Legacy assignment; requires explicit Subject reissue",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".ticket-handling"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "audit",
|
||||
"label": "Legacy audit and no implicit startup",
|
||||
"fullPage": true
|
||||
}
|
||||
],
|
||||
"label": "Inspect retained legacy assignment audit"
|
||||
},
|
||||
{
|
||||
"id": "handling",
|
||||
"path": "/w/tickets/orchestrator",
|
||||
"goal": "Inspect handling across Subjects",
|
||||
"dataState": "Multiple Ticket cases and self-reported handling",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".orchestrator-assignments"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "list",
|
||||
"label": "Responsibility list",
|
||||
"fullPage": true
|
||||
}
|
||||
],
|
||||
"label": "Inspect handling across Subjects"
|
||||
},
|
||||
{
|
||||
"id": "cases",
|
||||
"path": "/w/tickets/tickets",
|
||||
"goal": "Find Ticket cases without singleton startup",
|
||||
"dataState": "Ticket cases including open and closed",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".ticket-panel-page"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "list",
|
||||
"label": "Ticket case list",
|
||||
"fullPage": true
|
||||
}
|
||||
],
|
||||
"label": "Find Ticket cases without singleton startup"
|
||||
}
|
||||
],
|
||||
"processes": [
|
||||
{
|
||||
"id": "ticket-fixture",
|
||||
"command": "deno",
|
||||
"cwd": "../../../../tools/web-ux",
|
||||
"args": [
|
||||
"run",
|
||||
"--allow-net",
|
||||
"--allow-read",
|
||||
"browser-tests/ticket_fixture_server.ts",
|
||||
"15372",
|
||||
"../../web/workspace/build"
|
||||
],
|
||||
"readyUrl": "http://127.0.0.1:15372/health"
|
||||
},
|
||||
{
|
||||
"id": "subject-fixture-proxy",
|
||||
"command": "deno",
|
||||
"cwd": "../..",
|
||||
"args": [
|
||||
"run",
|
||||
"--allow-net",
|
||||
"test/visual-review/subject-handling-fixture-server.ts",
|
||||
"15371",
|
||||
"http://127.0.0.1:15372"
|
||||
],
|
||||
"readyUrl": "http://127.0.0.1:15371/health"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
// 共有Ticket fixtureの古い認証・担当projectionだけをAPI境界で更新する。
|
||||
// 製品shell/CSS・認可処理には手を加えず、実Backend/Worker実行の証拠にはしない。
|
||||
const port = Number(Deno.args[0]);
|
||||
const upstream = Deno.args[1];
|
||||
const baseline = Deno.args.includes("--baseline");
|
||||
if (!Number.isInteger(port) || !upstream) {
|
||||
throw new Error("usage: server <port> <upstream> [--baseline]");
|
||||
}
|
||||
const subject = (id: string, state = "active") => ({
|
||||
id,
|
||||
role: "Research",
|
||||
state,
|
||||
behavior_md: "",
|
||||
memory_fingerprint: "fixture",
|
||||
created_at: "2026-01-01T00:00:00Z",
|
||||
updated_at: "2026-01-01T00:00:00Z",
|
||||
current_worker: null,
|
||||
});
|
||||
function project(value: unknown): unknown {
|
||||
if (Array.isArray(value)) return value.map(project);
|
||||
if (value && typeof value === "object") {
|
||||
const item = value as Record<string, unknown>;
|
||||
if (
|
||||
item.kind === "workspace_agent" &&
|
||||
item.agent_key === "workspace-orchestrator"
|
||||
) return { kind: "subject", subject_id: "subject-a" };
|
||||
return Object.fromEntries(
|
||||
Object.entries(item).map(([key, value]) => [key, project(value)]),
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
Deno.serve({ hostname: "127.0.0.1", port }, async (request) => {
|
||||
const url = new URL(request.url);
|
||||
if (
|
||||
url.pathname.endsWith("/protocol/ws") &&
|
||||
request.headers.get("upgrade") === "websocket"
|
||||
) {
|
||||
const { socket, response } = Deno.upgradeWebSocket(request);
|
||||
socket.onmessage = (event) => {
|
||||
const frame = JSON.parse(String(event.data));
|
||||
if (frame?.message?.method === "subscribe_events") {
|
||||
socket.send(JSON.stringify({
|
||||
protocol_version: 2,
|
||||
frame: "response",
|
||||
message: {
|
||||
result: "subscribed",
|
||||
payload: {
|
||||
request_id: frame.message.params.request_id,
|
||||
subscription_id: "fixture-workers",
|
||||
selector: frame.message.params.selector,
|
||||
snapshot: { topic: "workers", data: { workers: [] } },
|
||||
},
|
||||
},
|
||||
}));
|
||||
}
|
||||
};
|
||||
return response;
|
||||
}
|
||||
if (url.pathname === "/api/auth/whoami") {
|
||||
return Response.json({
|
||||
authentication_reference: "fixture-authentication",
|
||||
session: { kind: "authenticated", expires_at: "2099-01-01T00:00:00Z" },
|
||||
actor: {
|
||||
user_id: "fixture-user",
|
||||
account_id: "fixture-member",
|
||||
handle: "mika",
|
||||
display_name: "Mika",
|
||||
auth_method: "browser_session",
|
||||
},
|
||||
});
|
||||
}
|
||||
if (url.pathname === "/api/hosting/access") {
|
||||
return Response.json({ is_admin: false });
|
||||
}
|
||||
if (url.pathname.endsWith("/subjektiv/subjects")) {
|
||||
if (url.pathname.includes("tickets-denied")) {
|
||||
return Response.json({ message: "Subject listing denied" }, {
|
||||
status: 403,
|
||||
});
|
||||
}
|
||||
if (url.pathname.includes("tickets-empty")) {
|
||||
return Response.json({
|
||||
limit: 100,
|
||||
items: [],
|
||||
has_more: false,
|
||||
next_cursor: null,
|
||||
});
|
||||
}
|
||||
const more = url.searchParams.has("cursor");
|
||||
return Response.json({
|
||||
limit: 100,
|
||||
items: more
|
||||
? [
|
||||
subject("subject-a"),
|
||||
subject("subject-b"),
|
||||
subject("subject-retired", "retired"),
|
||||
]
|
||||
: [subject("subject-a")],
|
||||
has_more: !more,
|
||||
next_cursor: more ? null : "next-subject",
|
||||
});
|
||||
}
|
||||
if (url.pathname.endsWith("/tickets/browse")) {
|
||||
const input = await request.json();
|
||||
const queryUrl = new URL(
|
||||
url.pathname.replace(/\/browse$/, "/query"),
|
||||
upstream,
|
||||
);
|
||||
const response = await fetch(queryUrl, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
if (!response.ok) return response;
|
||||
const data = await response.json();
|
||||
data.items = data.items.map((item: Record<string, unknown>) =>
|
||||
Object.fromEntries(
|
||||
[
|
||||
"id",
|
||||
"resource_key",
|
||||
"title",
|
||||
"state",
|
||||
"updated_at",
|
||||
"tags",
|
||||
"current_closure",
|
||||
"assignment_tracking",
|
||||
].map((key) => [key, item[key]]),
|
||||
)
|
||||
);
|
||||
return Response.json(baseline ? data : project(data));
|
||||
}
|
||||
const response = await fetch(new URL(url.pathname + url.search, upstream), {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
body: request.method === "GET" || request.method === "HEAD"
|
||||
? undefined
|
||||
: await request.arrayBuffer(),
|
||||
redirect: "manual",
|
||||
});
|
||||
if (url.pathname.endsWith("/workspace") && response.ok) {
|
||||
const value = await response.json();
|
||||
value.permissions.delete_subjects = false;
|
||||
return Response.json(value);
|
||||
}
|
||||
if (
|
||||
!baseline && !url.pathname.includes("tickets-legacy") &&
|
||||
/(?:\/api\/w|\/workspaces)\/[^/]+\/tickets/.test(url.pathname) &&
|
||||
response.headers.get("content-type")?.includes("application/json")
|
||||
) {
|
||||
return Response.json(project(await response.json()), {
|
||||
status: response.status,
|
||||
});
|
||||
}
|
||||
return response;
|
||||
});
|
||||
@@ -0,0 +1,143 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "subject-handling",
|
||||
"title": "Ticket Subject responsibility, separate from Worker execution",
|
||||
"baseUrl": "http://127.0.0.1:15371",
|
||||
"colorScheme": "light",
|
||||
"reducedMotion": "reduce",
|
||||
"personas": [
|
||||
{
|
||||
"id": "member",
|
||||
"label": "Synthetic authenticated member, not settings owner",
|
||||
"auth": {
|
||||
"kind": "anonymous"
|
||||
}
|
||||
}
|
||||
],
|
||||
"viewports": [
|
||||
{
|
||||
"label": "desktop",
|
||||
"width": 1440,
|
||||
"height": 900
|
||||
},
|
||||
{
|
||||
"label": "narrow",
|
||||
"width": 768,
|
||||
"height": 900
|
||||
},
|
||||
{
|
||||
"label": "mobile",
|
||||
"width": 390,
|
||||
"height": 844
|
||||
}
|
||||
],
|
||||
"routes": [
|
||||
{
|
||||
"id": "principal",
|
||||
"label": "Choose responsibility",
|
||||
"path": "/w/tickets/tickets/T-2",
|
||||
"goal": "Inspect handling and choose responsible Subject",
|
||||
"dataState": "Open and waiting with current assignment, no current body Worker",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".ticket-handling"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "choice",
|
||||
"label": "Observed assignment and choice",
|
||||
"interaction": [
|
||||
{
|
||||
"action": "click",
|
||||
"selector": ".assignment-principal summary"
|
||||
}
|
||||
],
|
||||
"fullPage": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "legacy",
|
||||
"path": "/w/tickets-legacy/tickets/T-2",
|
||||
"goal": "Inspect retained legacy assignment audit",
|
||||
"dataState": "Legacy assignment; requires explicit Subject reissue",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".ticket-handling"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "audit",
|
||||
"label": "Legacy audit and no implicit startup",
|
||||
"fullPage": true
|
||||
}
|
||||
],
|
||||
"label": "Inspect retained legacy assignment audit"
|
||||
},
|
||||
{
|
||||
"id": "handling",
|
||||
"path": "/w/tickets/orchestrator",
|
||||
"goal": "Inspect handling across Subjects",
|
||||
"dataState": "Multiple Ticket cases and self-reported handling",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".orchestrator-assignments"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "list",
|
||||
"label": "Responsibility list",
|
||||
"fullPage": true
|
||||
}
|
||||
],
|
||||
"label": "Inspect handling across Subjects"
|
||||
},
|
||||
{
|
||||
"id": "cases",
|
||||
"path": "/w/tickets/tickets",
|
||||
"goal": "Find Ticket cases without singleton startup",
|
||||
"dataState": "Ticket cases including open and closed",
|
||||
"ready": {
|
||||
"kind": "selector",
|
||||
"selector": ".ticket-panel-page"
|
||||
},
|
||||
"capturePoints": [
|
||||
{
|
||||
"id": "list",
|
||||
"label": "Ticket case list",
|
||||
"fullPage": true
|
||||
}
|
||||
],
|
||||
"label": "Find Ticket cases without singleton startup"
|
||||
}
|
||||
],
|
||||
"processes": [
|
||||
{
|
||||
"id": "ticket-fixture",
|
||||
"command": "deno",
|
||||
"cwd": "../../../../tools/web-ux",
|
||||
"args": [
|
||||
"run",
|
||||
"--allow-net",
|
||||
"--allow-read",
|
||||
"browser-tests/ticket_fixture_server.ts",
|
||||
"15372",
|
||||
"../../web/workspace/build"
|
||||
],
|
||||
"readyUrl": "http://127.0.0.1:15372/health"
|
||||
},
|
||||
{
|
||||
"id": "subject-fixture-proxy",
|
||||
"command": "deno",
|
||||
"cwd": "../..",
|
||||
"args": [
|
||||
"run",
|
||||
"--allow-net",
|
||||
"test/visual-review/subject-handling-fixture-server.ts",
|
||||
"15371",
|
||||
"http://127.0.0.1:15372"
|
||||
],
|
||||
"readyUrl": "http://127.0.0.1:15371/health"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
import { assert, assertEquals } from "jsr:@std/assert@1.0.19";
|
||||
import { chromium } from "npm:playwright@1.59.1";
|
||||
import { loadScenario } from "../../../../tools/web-ux/src/scenario.ts";
|
||||
import {
|
||||
startOwnedProcesses,
|
||||
stopOwnedProcesses,
|
||||
} from "../../../../tools/web-ux/src/processes.ts";
|
||||
|
||||
// 実production buildのnative selectとloopback fixtureだけを検証する。
|
||||
// 実Backend認可、Worker起動、通知配送の成功とは区別する。
|
||||
Deno.test("Subject selection, paging, audit, permission failure and exact retry without singleton startup", async () => {
|
||||
const scenarioPath =
|
||||
new URL("./subject-handling-light.json", import.meta.url).pathname;
|
||||
const scenario = await loadScenario(scenarioPath);
|
||||
function freePort() {
|
||||
const listener = Deno.listen({ hostname: "127.0.0.1", port: 0 });
|
||||
const port = (listener.addr as Deno.NetAddr).port;
|
||||
listener.close();
|
||||
return port;
|
||||
}
|
||||
const upstream = freePort();
|
||||
let proxy = freePort();
|
||||
while (upstream === proxy) proxy = freePort();
|
||||
scenario.processes![0].args![4] = String(upstream);
|
||||
scenario.processes![0].readyUrl = `http://127.0.0.1:${upstream}/health`;
|
||||
scenario.processes![1].args![3] = String(proxy);
|
||||
scenario.processes![1].args![4] = `http://127.0.0.1:${upstream}`;
|
||||
scenario.processes![1].readyUrl = `http://127.0.0.1:${proxy}/health`;
|
||||
const base = `http://127.0.0.1:${proxy}`;
|
||||
const output = new URL(
|
||||
"../../../../target/web-ux/t778-validation/browser/",
|
||||
import.meta.url,
|
||||
).pathname;
|
||||
await Deno.mkdir(output, { recursive: true });
|
||||
const processes = await startOwnedProcesses(
|
||||
scenario.processes!,
|
||||
scenarioPath,
|
||||
output + "/process-logs",
|
||||
[],
|
||||
);
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const captures: unknown[] = [];
|
||||
try {
|
||||
for (const colorScheme of ["light", "dark"] as const) {
|
||||
for (const width of [1440, 768, 390]) {
|
||||
const context = await browser.newContext({
|
||||
viewport: { width, height: 900 },
|
||||
colorScheme,
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
try {
|
||||
const page = await context.newPage();
|
||||
let documentStatus: number | null = null;
|
||||
page.on("response", (response) => {
|
||||
if (response.request().isNavigationRequest()) {
|
||||
documentStatus = response.status();
|
||||
}
|
||||
});
|
||||
const errors: string[] = [];
|
||||
const pageErrors: string[] = [];
|
||||
const requestFailures: string[] = [];
|
||||
page.on("requestfailed", (request) => {
|
||||
requestFailures.push(
|
||||
`${request.method()} ${
|
||||
new URL(request.url()).pathname
|
||||
}: ${request.failure()?.errorText}`,
|
||||
);
|
||||
});
|
||||
async function captureState(state: string, expectedFailure = false) {
|
||||
assertEquals(pageErrors, []);
|
||||
const image = `${colorScheme}-${width}-${state}.png`;
|
||||
const bytes = await page.screenshot({
|
||||
path: output + image,
|
||||
fullPage: true,
|
||||
});
|
||||
const sha256 = Array.from(
|
||||
new Uint8Array(
|
||||
await crypto.subtle.digest("SHA-256", new Uint8Array(bytes)),
|
||||
),
|
||||
).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
||||
captures.push({
|
||||
image,
|
||||
sha256,
|
||||
route: page.url(),
|
||||
documentStatus,
|
||||
colorScheme,
|
||||
width,
|
||||
expectedFailure,
|
||||
errors: [...errors],
|
||||
pageErrors: [...pageErrors],
|
||||
requestFailures: [...requestFailures],
|
||||
horizontalOverflow: await page.evaluate(
|
||||
"document.documentElement.scrollWidth > innerWidth",
|
||||
),
|
||||
snapshot: await page.locator("main").first().ariaSnapshot(),
|
||||
});
|
||||
}
|
||||
const paths: string[] = [];
|
||||
page.on("pageerror", (error) => pageErrors.push(String(error)));
|
||||
page.on("console", (message) => {
|
||||
if (message.type() === "error") errors.push(message.text());
|
||||
});
|
||||
page.on("request", (request) => {
|
||||
paths.push(new URL(request.url()).pathname);
|
||||
});
|
||||
await page.goto(base + "/w/tickets/tickets/T-2");
|
||||
await page.getByText("Self-reported handling: waiting", {
|
||||
exact: true,
|
||||
}).waitFor();
|
||||
await page.getByText("Choose responsible Subject", { exact: true })
|
||||
.click();
|
||||
const select = page.getByRole("combobox", {
|
||||
name: "Subject",
|
||||
exact: true,
|
||||
});
|
||||
await select.selectOption("subject-a");
|
||||
await page.getByRole("button", { name: "More Subjects", exact: true })
|
||||
.click();
|
||||
await page.locator('option[value="subject-b"]').waitFor({
|
||||
state: "attached",
|
||||
});
|
||||
assertEquals(
|
||||
await select.locator('option[value="subject-a"]').count(),
|
||||
1,
|
||||
);
|
||||
assert(
|
||||
await select.locator('option[value="subject-retired"]').evaluate((
|
||||
option,
|
||||
) => (option as unknown as { disabled: boolean }).disabled),
|
||||
await select.innerHTML(),
|
||||
);
|
||||
// Native select remains keyboard operable after paging.
|
||||
await select.focus();
|
||||
await select.press("Home");
|
||||
await select.press("ArrowDown");
|
||||
assertEquals(await select.inputValue(), "subject-a");
|
||||
await select.press("ArrowDown");
|
||||
assertEquals(await select.inputValue(), "subject-b");
|
||||
assert(
|
||||
await page.evaluate("document.activeElement?.tagName === 'SELECT'"),
|
||||
);
|
||||
await select.scrollIntoViewIfNeeded();
|
||||
await captureState("selection");
|
||||
assertEquals(
|
||||
await page.evaluate(
|
||||
"document.documentElement.scrollWidth > innerWidth",
|
||||
),
|
||||
false,
|
||||
);
|
||||
assertEquals(errors, []);
|
||||
assertEquals(requestFailures, []);
|
||||
const sent: string[] = [];
|
||||
await page.route("**/assignments/orchestrator", async (route) => {
|
||||
if (route.request().method() === "PUT") {
|
||||
sent.push(route.request().postData()!);
|
||||
await route.abort("failed");
|
||||
} else await route.continue();
|
||||
});
|
||||
await page.getByText("Replace this delegation", { exact: true })
|
||||
.click();
|
||||
page.once("dialog", (dialog) => dialog.accept());
|
||||
await page.getByRole("button", {
|
||||
name: "Replace assignment",
|
||||
exact: true,
|
||||
}).click();
|
||||
await page.getByRole("alert").filter({ hasText: "Outcome unknown" })
|
||||
.waitFor();
|
||||
assertEquals(sent.length, 1);
|
||||
const input = JSON.parse(sent[0]);
|
||||
assertEquals(input.principal, {
|
||||
kind: "subject",
|
||||
subject_id: "subject-b",
|
||||
});
|
||||
assertEquals(input.expected_assignment_id, "assignment-T-2");
|
||||
assert(await select.isDisabled());
|
||||
await page.getByRole("alert").filter({ hasText: "Outcome unknown" })
|
||||
.scrollIntoViewIfNeeded();
|
||||
await captureState("unknown", true);
|
||||
assertEquals(errors, ["Failed to load resource: net::ERR_FAILED"]);
|
||||
assertEquals(requestFailures.length, 1);
|
||||
assert(requestFailures[0].startsWith("PUT /api/w/tickets/tickets/"));
|
||||
assert(
|
||||
requestFailures[0].endsWith(
|
||||
"/assignments/orchestrator: net::ERR_FAILED",
|
||||
),
|
||||
);
|
||||
const failed = page.waitForEvent(
|
||||
"requestfailed",
|
||||
(r) =>
|
||||
r.method() === "PUT" &&
|
||||
r.url().endsWith("/assignments/orchestrator"),
|
||||
);
|
||||
await page.getByRole("button", {
|
||||
name: "Retry exact operation",
|
||||
exact: true,
|
||||
}).click();
|
||||
await failed;
|
||||
assertEquals(sent.length, 2);
|
||||
assertEquals(sent[1], sent[0]);
|
||||
assertEquals(
|
||||
paths.filter((path) => /\/api\/w\/[^/]+\/orchestrator/.test(path)),
|
||||
[],
|
||||
);
|
||||
await page.unroute("**/assignments/orchestrator");
|
||||
for (const persona of ["legacy", "readonly", "empty", "denied"]) {
|
||||
errors.length = 0;
|
||||
requestFailures.length = 0;
|
||||
await page.goto(`${base}/w/tickets-${persona}/tickets/T-2`);
|
||||
await page.locator(".ticket-handling").waitFor();
|
||||
if (persona === "legacy") {
|
||||
await page.getByText(/Legacy assignment retained for audit only/)
|
||||
.scrollIntoViewIfNeeded();
|
||||
assertEquals(
|
||||
await page.getByRole("textbox", {
|
||||
name: "Answer / continue this handling",
|
||||
}).count(),
|
||||
0,
|
||||
);
|
||||
} else if (persona === "readonly") {
|
||||
assertEquals(
|
||||
await page.getByText("Choose responsible Subject", {
|
||||
exact: true,
|
||||
}).count(),
|
||||
0,
|
||||
);
|
||||
} else {
|
||||
await page.getByText("Choose responsible Subject", {
|
||||
exact: true,
|
||||
}).click();
|
||||
if (persona === "empty") {
|
||||
await page.getByText(/No Subjects available/).waitFor();
|
||||
} else {await page.getByRole("button", { name: "Retry Subjects" })
|
||||
.waitFor();}
|
||||
await page.getByText("Replace this delegation", { exact: true })
|
||||
.click();
|
||||
assert(
|
||||
await page.getByRole("button", {
|
||||
name: "Replace assignment",
|
||||
exact: true,
|
||||
}).isDisabled(),
|
||||
);
|
||||
await page.getByRole("button", {
|
||||
name: "Replace assignment",
|
||||
exact: true,
|
||||
}).scrollIntoViewIfNeeded();
|
||||
}
|
||||
if (persona === "readonly") {
|
||||
await page.locator(".ticket-handling").scrollIntoViewIfNeeded();
|
||||
}
|
||||
await captureState(persona, persona === "denied");
|
||||
assertEquals(
|
||||
await page.evaluate(
|
||||
"document.documentElement.scrollWidth > innerWidth",
|
||||
),
|
||||
false,
|
||||
);
|
||||
if (persona !== "denied") {
|
||||
assertEquals(errors, []);
|
||||
assertEquals(requestFailures, []);
|
||||
} else {
|
||||
assertEquals(errors, [
|
||||
"Failed to load resource: the server responded with a status of 403 (Forbidden)",
|
||||
]);
|
||||
assertEquals(requestFailures, [
|
||||
"GET /api/w/tickets-denied/subjektiv/subjects: net::ERR_ABORTED",
|
||||
]);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
await context.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
await Deno.writeTextFile(
|
||||
output + "/review-context.json",
|
||||
JSON.stringify(
|
||||
{
|
||||
source: "production Web build, synthetic API boundary only",
|
||||
captures,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
await browser.close();
|
||||
await stopOwnedProcesses(processes);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user