Skip to content

refactor(cms-testing): DI-native function plugins; remove ContextPlugin from consumers#5424

Merged
adrians5j merged 6 commits into
nextfrom
adrian/cms-test-handler-ctx-to-next
Jul 17, 2026
Merged

refactor(cms-testing): DI-native function plugins; remove ContextPlugin from consumers#5424
adrians5j merged 6 commits into
nextfrom
adrian/cms-test-handler-ctx-to-next

Conversation

@adrians5j

@adrians5j adrians5j commented Jul 16, 2026

Copy link
Copy Markdown
Member

What changed

#40 (grep ContextPlugin → zero): converts the createCmsTestHandler-consumer group off ContextPlugin. Based directly on next (independent of the other stacked #40 PRs; api-headless-cms-testing is in next).

  • createCmsTestHandler now accepts plain container => {} function plugins in params.plugins — called after the consuming package's features so they can override defaults (last-wins), mirroring the legacy bridge timing. Guards the Function.prototype.apply trap (a plain function also has .apply).
  • Converted consumers (each wrapper that dispatches plugins itself now calls function plugins directly instead of routing them through processLegacyPlugins/extraPlugins, which expect objects):
    • api-acofolder.flp.inheritance + lifecycle mock + useGraphQlHandler dispatch
    • api-headless-cms-aco — lifecycle mock + useGraphQlHandler dispatch
    • api-headless-cms-bulk-actionscreateBulkAction + handler dispatch (functions → plugins, statics → extraCmsPlugins)
    • api-website-builderuseHandler + useGraphQlHandler (InvalidateCloudfront plugin)
    • deleted api-headless-cms-ddb-es/graphql/security.ts (dead, zero consumers)
  • Dropped the now-unused @webiny/api dep from api-headless-cms-aco + api-website-builder.

Verification

aco 74, hcms-aco 4, bulk-actions 3, wb 195 green; no regression in hcms-tasks/workflows/scheduler. adio clean, lint clean, references.json in sync. (ddb-es OpenSearch suites verified in CI.)

Deferred: api/__tests__/benchmark.test.ts imports the ContextPlugin class from ~/plugins/ContextPlugin and tests the plugins-container machinery itself — it belongs to the final ContextPlugin-class-deletion step, not this consumer sweep.

Squash Merge Commit

refactor(cms-testing): DI-native function plugins; remove ContextPlugin from consumers (#5424)

…gin from consumers (#40)

createCmsTestHandler now accepts plain `container => {}` function plugins in
`params.plugins` — called AFTER the consuming package's features so they can
override defaults (last-wins), mirroring the legacy bridge timing. (Guards
against the Function.prototype.apply trap.)

Converted the createCmsTestHandler-consumer group off ContextPlugin:
- api-aco (folder.flp + lifecycle mock) + its useGraphQlHandler dispatch;
- api-headless-cms-aco (lifecycle mock) + its useGraphQlHandler dispatch;
- api-headless-cms-bulk-actions (createBulkAction) + its handler dispatch
  (function plugins now go via the `plugins` param, statics via extraCmsPlugins);
- api-website-builder (useHandler + useGraphQlHandler InvalidateCloudfront plugin);
- deleted api-headless-cms-ddb-es/graphql/security.ts (dead, zero consumers).
Dropped the now-unused @webiny/api dep from api-headless-cms-aco + api-website-builder.

Each wrapper helper that dispatches plugins itself now calls function plugins
directly (fn-first) instead of routing them through processLegacyPlugins /
extraPlugins (which expect objects).

Verified green: aco 74, hcms-aco 4, bulk-actions 3, wb 195; no regression in
hcms-tasks/workflows/scheduler. (api/__tests__/benchmark.test.ts is deferred —
it tests the ContextPlugin class itself, part of the final class-deletion step.
ddb-es OpenSearch suites verified in CI.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg3MRCToopzWSTPWqU9Lga
@adrians5j adrians5j added the context-plugin-removal #40: remove legacy ContextPlugin usage (→ DI) label Jul 16, 2026
@adrians5j

Copy link
Copy Markdown
Member Author

/vitest

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

Vitest tests have been initiated (for more information, click here). ✨

Group Status
No storage ✅ 54/54 passed
DDB ✅ 17/17 passed
DDB+OS ✅ 20/20 passed
SQL ✅ 10/10 passed
PGlite ❌ 9/10 passed
❌ Failed packages

PGlite

  • api-websockets

adrians5j and others added 2 commits July 17, 2026 12:31
WB file/page flows trigger FlushCacheOn{Update,Delete}Handler ->
taskService.trigger({ definition: 'cloudfrontInvalidateCache' }), which validates
the definition exists (else TaskDefinitionNotFoundError). The def was registered
by importing the REAL prod def from @webiny/api-file-manager-s3 — but its run()
(a real CloudFront invalidation) never executes in tests (the mock TaskService
blocks dispatch to the runner), so only its id matters.

Replace the prod import with a local no-op TaskDefinition stub with the same id.
Decouples the WB test from fm-s3 internals + makes intent explicit. No AWS calls
either way. wb 195 tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg3MRCToopzWSTPWqU9Lga
@adrians5j
adrians5j merged commit 649817f into next Jul 17, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

context-plugin-removal #40: remove legacy ContextPlugin usage (→ DI)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant