Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 14x 6x 6x 8x | /**
* `$meta.expect` — the browser's half of the expected-errors feature.
*
* A test that probes a refusal on purpose declares the type it expects, and the
* framework demotes the log entry at every boundary it crosses: the adapters and
* the gateway read `$meta.expect` server-side (see
* `docs/blong/docs/concepts/expected-errors.md`). The browser is the last
* boundary and was the one left out: `wrapHandlerProxy` logged every failed call
* at `error` level and raised the global dialog whatever the caller had
* declared, so a deliberate 403 in a UI flow reached the CI report as
* `[browser] error: [blong] … failed` beside the refusals nobody asked for
* (@@D-695).
*
* The matching rules are the server's `isExpectedError` (`blong-gogo/src/lib.ts`)
* restated: exact type, any element of an array, and a trailing `.*` prefix
* wildcard. They are duplicated rather than imported because `blong-gogo` is the
* runtime and never a dependency of browser code.
*/
/** The declaration a caller puts on `$meta`: one type, or several. */
export type ExpectedError = string | string[] | undefined;
/**
* Returns true when `errorType` matches the `expect` declaration.
*
* - `'foo.bar'` — only `foo.bar`
* - `['foo.bar', 'foo.baz']` — either
* - `'foo.*'` — any type starting with `foo.`
*/
export function isExpectedError(errorType: string | undefined, expect: ExpectedError): boolean {
if (!errorType || !expect) return false;
const patterns = ([] as string[]).concat(expect);
return patterns.some(pattern =>
pattern.endsWith('.*') ? errorType.startsWith(pattern.slice(0, -1)) : errorType === pattern,
);
}
|