refactor(cms-testing): DI-native function plugins; remove ContextPlugin from consumers#5424
Merged
Merged
Conversation
…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
Member
Author
|
/vitest |
|
Vitest tests have been initiated (for more information, click here). ✨
❌ Failed packagesPGlite
|
…com/webiny/webiny-js into adrian/cms-test-handler-ctx-to-next
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
#40 (grep
ContextPlugin→ zero): converts the createCmsTestHandler-consumer group off ContextPlugin. Based directly onnext(independent of the other stacked #40 PRs;api-headless-cms-testingis in next).container => {}function plugins inparams.plugins— called after the consuming package'sfeaturesso they can override defaults (last-wins), mirroring the legacy bridge timing. Guards theFunction.prototype.applytrap (a plain function also has.apply).processLegacyPlugins/extraPlugins, which expect objects):folder.flp.inheritance+ lifecycle mock +useGraphQlHandlerdispatchuseGraphQlHandlerdispatchcreateBulkAction+ handler dispatch (functions →plugins, statics →extraCmsPlugins)useHandler+useGraphQlHandler(InvalidateCloudfront plugin)api-headless-cms-ddb-es/graphql/security.ts(dead, zero consumers)@webiny/apidep 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.tsimports theContextPluginclass from~/plugins/ContextPluginand tests the plugins-container machinery itself — it belongs to the final ContextPlugin-class-deletion step, not this consumer sweep.Squash Merge Commit