test(chat): add extractAgentText coverage — 6 cases
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 16s
CI / Detect changes (pull_request) Successful in 35s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 38s
E2E API Smoke Test / detect-changes (pull_request) Successful in 49s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 18s
Harness Replays / detect-changes (pull_request) Successful in 35s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 48s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 24s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 38s
gate-check-v3 / gate-check (pull_request) Successful in 30s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Failing after 1m26s
qa-review / approved (pull_request) Failing after 17s
security-review / approved (pull_request) Failing after 15s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: 7
CI / Platform (Go) (pull_request) Successful in 8s
sop-checklist-gate / gate (pull_request) Successful in 16s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m25s
sop-tier-check / tier-check (pull_request) Successful in 17s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 6s
CI / Python Lint & Test (pull_request) Successful in 7s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m43s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 9s
Harness Replays / Harness Replays (pull_request) Successful in 8s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 8s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 6s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 2m1s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 8m3s
CI / Canvas (Next.js) (pull_request) Successful in 11m29s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 1s
audit-force-merge / audit (pull_request) Has been skipped
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 16s
CI / Detect changes (pull_request) Successful in 35s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 38s
E2E API Smoke Test / detect-changes (pull_request) Successful in 49s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 18s
Harness Replays / detect-changes (pull_request) Successful in 35s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 48s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 24s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 38s
gate-check-v3 / gate-check (pull_request) Successful in 30s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Failing after 1m26s
qa-review / approved (pull_request) Failing after 17s
security-review / approved (pull_request) Failing after 15s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: 7
CI / Platform (Go) (pull_request) Successful in 8s
sop-checklist-gate / gate (pull_request) Successful in 16s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m25s
sop-tier-check / tier-check (pull_request) Successful in 17s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 6s
CI / Python Lint & Test (pull_request) Successful in 7s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m43s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 9s
Harness Replays / Harness Replays (pull_request) Successful in 8s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 8s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 6s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 2m1s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 8m3s
CI / Canvas (Next.js) (pull_request) Successful in 11m29s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 1s
audit-force-merge / audit (pull_request) Has been skipped
Covers the 4 unique branches not exercised by extractTextsFromParts: artifacts[0].parts fallback, status.message.parts fallback, bare-string passthrough, and the try/catch sentinel on null input. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
b67269aee7
commit
b705d62fd1
@ -281,6 +281,41 @@ describe("extractTextsFromParts", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("extractAgentText", () => {
|
||||
it("extracts from task.parts via extractTextsFromParts", () => {
|
||||
const task = { parts: [{ kind: "text", text: "Agent reply" }] };
|
||||
expect(extractAgentText(task)).toBe("Agent reply");
|
||||
});
|
||||
|
||||
it("falls back to artifacts[0].parts when task.parts is absent", () => {
|
||||
const task = {
|
||||
artifacts: [{ parts: [{ kind: "text", text: "Artifact text" }] }],
|
||||
};
|
||||
expect(extractAgentText(task)).toBe("Artifact text");
|
||||
});
|
||||
|
||||
it("falls back to status.message.parts when both parts and artifacts are absent", () => {
|
||||
const task = {
|
||||
status: { message: { parts: [{ kind: "text", text: "Status text" }] } },
|
||||
};
|
||||
expect(extractAgentText(task)).toBe("Status text");
|
||||
});
|
||||
|
||||
it("returns the task as-is when it is a bare string", () => {
|
||||
expect(extractAgentText("Bare string response")).toBe("Bare string response");
|
||||
});
|
||||
|
||||
it("returns sentinel when nothing extractable is present", () => {
|
||||
expect(extractAgentText({})).toBe("(Could not extract response text)");
|
||||
});
|
||||
|
||||
it("returns sentinel for null input (caught by try/catch)", () => {
|
||||
expect(extractAgentText(null as unknown as Record<string, unknown>)).toBe(
|
||||
"(Failed to parse response)"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("extractFilesFromTask", () => {
|
||||
it("pulls A2A file parts out of a result", () => {
|
||||
const task = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user