merge: PR #32을 합친 검사 브랜치에 넣는다
This commit is contained in:
@@ -41,8 +41,8 @@
|
||||
"initialJavascript": {
|
||||
"gzipBytes": 194354,
|
||||
"files": 17,
|
||||
"firstFeatureGzipBytes": 6327,
|
||||
"perFeatureGzipBytes": 539,
|
||||
"perContextGzipBytes": 4
|
||||
"firstFeatureGzipBytes": 6355,
|
||||
"perFeatureGzipBytes": 528,
|
||||
"perContextGzipBytes": 21
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,6 +884,7 @@ export type ${pascal}CreateCommand = Readonly<{ name: string }>;
|
||||
`
|
||||
: "";
|
||||
return `import type {} from "../../../application/ports/in/application-api.ts";
|
||||
import { isAbortFailure } from "../../../contracts/errors.ts";
|
||||
${write ? `import type { MutationIntent } from "../../../contracts/mutation-intent.ts";\n` : ""}import type { Result } from "../../../contracts/result.ts";
|
||||
import {
|
||||
failOpenTelemetryPort,
|
||||
@@ -938,7 +939,8 @@ export function create${pascal}FeatureInput(
|
||||
// scale-architecture.md §24, §26: telemetry is best-effort and never changes the result.
|
||||
const events = failOpenTelemetryPort(telemetry);
|
||||
function reported<Value>(kind: string, result: Result<Value>): Result<Value> {
|
||||
if (!result.ok && result.error.kind !== "REQUEST_ABORTED") {
|
||||
// An aborted or fenced request did not fail (isAbortFailure).
|
||||
if (!result.ok && !isAbortFailure(result.error)) {
|
||||
void events.emit({
|
||||
kind,
|
||||
severity: "warning",
|
||||
@@ -1279,6 +1281,18 @@ describe("${names.id} application input", () => {
|
||||
await expect(input.listItems()).resolves.toEqual({ ok: false, error: failure });
|
||||
expect(emit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not report a load a scope fence ended", async () => {
|
||||
const failure = createFailure("SCOPE_GENERATION_CHANGED", "${operationId}", 0);
|
||||
const emit = vi.fn<TelemetryPort["emit"]>();
|
||||
const input = create${pascal}FeatureInput(
|
||||
gatewayListing(async () => ({ ok: false, error: failure })),
|
||||
{ telemetry: { emit } },
|
||||
);
|
||||
|
||||
await expect(input.listItems()).resolves.toEqual({ ok: false, error: failure });
|
||||
expect(emit).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -270,6 +270,16 @@ export const REFUSALS_OF_EVERY_ATTEMPT: Readonly<Record<string, number>> =
|
||||
IDEMPOTENCY_KEY_INVALID: 400,
|
||||
});
|
||||
|
||||
/**
|
||||
* 1112/01-03. The request did not fail: its caller aborted it
|
||||
* (`REQUEST_ABORTED`) or a scope fence ended it (`SCOPE_GENERATION_CHANGED`,
|
||||
* sign-out or account switch). Telemetry and terminal error screens do not
|
||||
* count it (testing strategy 7.1절).
|
||||
*/
|
||||
export function isAbortFailure(failure: AppFailure): boolean {
|
||||
return failure.kind === "REQUEST_ABORTED" || failure.kind === "SCOPE_GENERATION_CHANGED";
|
||||
}
|
||||
|
||||
/**
|
||||
* 1106/03-01 (D10 supplement and its second fix). A `NOT_APPLIED` refusal
|
||||
* the same request gets on every attempt: a row above, code and status
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createFailure, isAbortFailure } from "../../src/contracts/errors.ts";
|
||||
|
||||
/**
|
||||
* 1112/01-03. A request its caller aborted and one a scope fence ended
|
||||
* (sign-out, account switch) are not failures: telemetry and terminal error
|
||||
* screens must not count them (docs/design/2026-07-26-frontend-platform-testing-strategy-design.md
|
||||
* 7.1절). The generated feature asked only for `REQUEST_ABORTED`, so a fenced
|
||||
* request went out as `<base>.list.failed`.
|
||||
*/
|
||||
describe("isAbortFailure", () => {
|
||||
it("counts a caller abort and a scope fence as aborts", () => {
|
||||
expect(isAbortFailure(createFailure("REQUEST_ABORTED", "LIST", 0))).toBe(true);
|
||||
expect(isAbortFailure(createFailure("SCOPE_GENERATION_CHANGED", "LIST", 0))).toBe(true);
|
||||
});
|
||||
|
||||
it("does not count a timeout, a server failure or a refusal", () => {
|
||||
for (const kind of ["REQUEST_TIMEOUT", "SERVER_FAILURE", "FORBIDDEN", "RATE_LIMITED"] as const) {
|
||||
expect(isAbortFailure(createFailure(kind, "LIST", 0)), kind).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -459,6 +459,21 @@ describe("create:feature context declaration", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// 1112/01-03. The generated input reports a failed load, not one a scope
|
||||
// fence ended (sign-out, account switch): it asks the shared rule.
|
||||
describe("generated feature input telemetry", () => {
|
||||
it("does not report a load a scope fence ended", () => {
|
||||
const { files } = plan({ id: "invoice-feature" });
|
||||
|
||||
expect(files.get("src/features/invoice-feature/application/invoice-feature-api.ts")).toContain(
|
||||
"isAbortFailure(result.error)",
|
||||
);
|
||||
expect(files.get("tests/features/invoice-feature/invoice-feature-input.test.ts")).toContain(
|
||||
'createFailure("SCOPE_GENERATION_CHANGED"',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("create:feature refusals", () => {
|
||||
it.each(["Invoice", "invoice_feature", "-invoice", "invoice--x", "invoice-", "", "a".repeat(41)])(
|
||||
"refuses the id %j",
|
||||
|
||||
Reference in New Issue
Block a user