Several test helpers are copy-pasted across many test files. Centralize them into a shared test-utils module (e.g. test/bookshop/lib/queue-test-utils.js or test/_utils.js) and import from there.
Duplicated helpers (current spread)
eventually / expectEventually — the same force-flush-then-poll-assertion pattern under two names: eventually (span/tracing) in tracing-outboxed-batch, tracing-scheduled, tracing.test, tracing-messaging.js; expectEventually (metrics) in metrics-outbox, metrics-outbox-multitenant, metrics.test. Should be one helper (parameterize the flush fn).
flushSpans — tracing-outboxed-batch, tracing-scheduled, tracing.test, tracing-messaging.js (unwraps the ProxyTracerProvider → delegate, guards the no-op).
clearOutbox — metrics-outbox, tracing-messaging.js (timeout-bounded DELETE FROM cds.outbox.Messages).
meaningful / isOutboxScanTrace — tracing-messaging* (×3 via the shared helper), tracing.test, tracing-scheduled, tracing-messaging.js (filters bookkeeping outbox-scan traces).
Why
These landed independently while stabilizing the HANA suite (#481), so the same logic now exists in 2-6 copies — a maintenance and drift hazard (a fix to the poll/flush logic must be applied N times). Centralizing also shrinks the per-file boilerplate.
Notes
- Keep the shared module dependency-light and consistent with
MyInMemorySpanExporter / MyInMemoryMetricReader conventions (must not require('@sap/cds') at module top).
- Reconcile the metric-flush (
forceFlush on the meter provider) vs span-flush (flushSpans on the tracer provider) variants — likely one generic eventually(assertion, {flush}) plus thin flushSpans/flushMetrics wrappers.
Part of the test-quality cluster (#477 / #478 / #475 / #486 / #487).
Several test helpers are copy-pasted across many test files. Centralize them into a shared test-utils module (e.g.
test/bookshop/lib/queue-test-utils.jsortest/_utils.js) and import from there.Duplicated helpers (current spread)
eventually/expectEventually— the same force-flush-then-poll-assertion pattern under two names:eventually(span/tracing) intracing-outboxed-batch,tracing-scheduled,tracing.test,tracing-messaging.js;expectEventually(metrics) inmetrics-outbox,metrics-outbox-multitenant,metrics.test. Should be one helper (parameterize the flush fn).flushSpans—tracing-outboxed-batch,tracing-scheduled,tracing.test,tracing-messaging.js(unwraps the ProxyTracerProvider → delegate, guards the no-op).clearOutbox—metrics-outbox,tracing-messaging.js(timeout-boundedDELETE FROM cds.outbox.Messages).meaningful/isOutboxScanTrace—tracing-messaging*(×3 via the shared helper),tracing.test,tracing-scheduled,tracing-messaging.js(filters bookkeeping outbox-scan traces).Why
These landed independently while stabilizing the HANA suite (#481), so the same logic now exists in 2-6 copies — a maintenance and drift hazard (a fix to the poll/flush logic must be applied N times). Centralizing also shrinks the per-file boilerplate.
Notes
MyInMemorySpanExporter/MyInMemoryMetricReaderconventions (must notrequire('@sap/cds')at module top).forceFlushon the meter provider) vs span-flush (flushSpanson the tracer provider) variants — likely one genericeventually(assertion, {flush})plus thinflushSpans/flushMetricswrappers.Part of the test-quality cluster (#477 / #478 / #475 / #486 / #487).