Issue #3586455: Add automated CCC tests for remaining 1.0 coverage gaps.
Description
Follow-up to [Plan] Review CCC automated test suite for mate... (#3586454 - closed) • Unassigned • 1.0.0-beta5. Adds the remaining 1.0 CCC coverage in one pass: kernel and EchoAI tests for hooks, cache contexts, storage bypasses, event wiring, and the colon instance-ID path from Implement plugin-based generic context consumer... (#3586346 - closed) • Unassigned • 1.0.0-beta5 / !283 (merged). The existing ladder, scope, EchoAI, access, tools, scheduler, and consumer-plugin suites are left alone.
Each issue task has a test that fails if that behavior is removed.
Coverage
ai_context_requirements()(AiContextRequirementsTest) — non-runtime phases return empty; bundledai_context_editorialworkflow is silent; no covering workflow returnsREQUIREMENT_WARNING; config sync suppresses the warning.AiContextEntityItemCacheContext(AiContextEntityItemCacheContextTest) —getContext()isnonewith no entity andentity_type:idwhen set; metadata includes the entity tag when loaded and stays empty / swallows an unknown type.- Syncing save over
max_global_items(AiContextItemValidatorTest) — constraint throws on a normal save; a syncing save succeeds. - Injected system-prompt prefix (
BuildSystemPromptSubscriberInjectionToggleTest,AiContextPreGenerateResponseSubscriberTest) — customcontext_prefixappears on the agent and generic chat paths; empty config usesAiContextSelection::DEFAULT_CONTEXT_PREFIX. Empty-string tests writecontext_prefix: ''so they hit the code fallback, not the installed default. - Agent tool events (
AiContextAgentToolSubscriberTest) —AgentToolFinishedExecutionEvent/AgentFinishedExecutionEventcallrecordToolUsed()/flushToolsUsed(); regex and ContentEntitySeederextractEntityInfo()cases; event-pathattachEntity()writes usage-row entity fields. AiContextOverviewSettingService::invalidateIfChanged()(AiContextOverviewSettingServiceTest) — persistssaveShowOverviewPage(); no-op when unchanged; menu cache + route rebuild on change.- Batch token-count backfill (
AiContextBatchBackfillTokenCountsTest) — operation processes queued items; empty queue finishes immediately; finished callback posts success and error messages. ai_context_post_update_0001(AiContextCanvasPagePostUpdateTest) — stripscanvas_page, keeps other types, re-indexes, is idempotent, returns early when config is missing.- GetRelevant no-permission path (
AiContextFunctionCallAccessTest) — same insufficient-permissions message as List and Load. - EchoAI translation (
AiContextEchoAiSystemPromptTest::testTranslatedItemBodyAppearsInSystemPrompt) — Spanish body appears on/es/; English body does not. - EchoAI Never include (
AiContextEchoAiSystemPromptTest::testNeverIncludeWinsOverAlwaysInclude) — body appears with Always include alone, then is absent when the same ID is also Never include. AiContextItemAccessControlHandler(AiContextItemAccessControlHandlerCacheTest) —access(..., TRUE)cache tags/contexts for published view, owner unpublished view, and non-owner unpublished view.- Colon instance ID (
AiContextConsumerColonInstanceIdTest) —type:a:bthrough config store → usage entity → route → consumer form. - Scheduler Unit-suite dependency (
tests/README.md,docs/contribute/testing.md,AiContextSchedulerContentModerationSyncTest) — no top-leveluseof Scheduler classes;class_exists()skip so a checkout without the require-dev packages does not fatal the Unit suite.
Production change
AiContextSelection::DEFAULT_CONTEXT_PREFIX is the shared fallback used by both injection subscribers. That is the only production change; it stops the agent and generic-chat prefixes from drifting. No API or hook changes.
Out of scope
Unchanged from Add automated CCC tests for remaining 1.0 cover... (#3586455 - closed) • Unassigned • 1.0.0-beta5: consumer-plugin re-test from !283 (merged), leftover consumer hardening, delegated-account acting user (Add automated CCC tests with dummy echoai provi... (#3586428 - closed) • Unassigned • 1.0.0-beta5), .module polish hooks, and entity-item view-builder access cacheability (Honor entity view access and bubble scope-label... (#3586422 - closed) • Unassigned • 1.0.0-beta5).
Testing Instructions
From the Drupal root in a Drupal 11 + ai_context environment:
cd web/modules/contrib/ai_context
git fetch ai_context-3586455
git checkout 3586455-add-automated-ccc-tests-for-remaining-10-coverage-gapsphpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextRequirementsTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextEntityItemCacheContextTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextItemValidatorTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/BuildSystemPromptSubscriberInjectionToggleTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextPreGenerateResponseSubscriberTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextAgentToolSubscriberTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextOverviewSettingServiceTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextBatchBackfillTokenCountsTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextCanvasPagePostUpdateTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextFunctionCallAccessTest.php
phpunit -c web/core --filter='testNeverIncludeWinsOverAlwaysInclude|testTranslatedItemBodyAppearsInSystemPrompt' web/modules/contrib/ai_context/tests/src/Kernel/AiContextEchoAiSystemPromptTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextItemAccessControlHandlerCacheTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Kernel/AiContextConsumerColonInstanceIdTest.php
phpunit -c web/core web/modules/contrib/ai_context/tests/src/Unit/AiContextSchedulerContentModerationSyncTest.phpExpected: all pass. Deprecation notices from ai / Drupal 11 are pre-existing.
Confirm the existing ai_context suite still passes.
No post-merge config import or cache rebuild.
Checklist
- I have updated the MR title to use format:
Issue #1234: My issue title. - I have updated the MR description to include:
Closes #1234 - I have performed a self-review of my own code
- I have added or updated tests, or explained in the description why this change is not covered by tests
- I have updated documentation for any new or changed functionality
- I have written testing instructions and verified them locally
- I have noted any required post-merge steps (config imports, cache rebuilds, manual changes)
- This MR contains no breaking API or hook changes, or they are explicitly documented in the description
AI Compliance
Note
Check the one that best describes your usage, or leave all unchecked if AI was not significantly used.
- AI Assisted Code
Mainly written by a human; AI used for autocomplete or partial generation under full human supervision. - AI Generated Code
Mainly generated by AI, reviewed and approved by a human before this MR was created. - Vibe Coded
Generated by AI and only functionally reviewed before this MR was created.
Closes #3586455 (closed)