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

  1. ai_context_requirements() (AiContextRequirementsTest) — non-runtime phases return empty; bundled ai_context_editorial workflow is silent; no covering workflow returns REQUIREMENT_WARNING; config sync suppresses the warning.
  2. AiContextEntityItemCacheContext (AiContextEntityItemCacheContextTest) — getContext() is none with no entity and entity_type:id when set; metadata includes the entity tag when loaded and stays empty / swallows an unknown type.
  3. Syncing save over max_global_items (AiContextItemValidatorTest) — constraint throws on a normal save; a syncing save succeeds.
  4. Injected system-prompt prefix (BuildSystemPromptSubscriberInjectionToggleTest, AiContextPreGenerateResponseSubscriberTest) — custom context_prefix appears on the agent and generic chat paths; empty config uses AiContextSelection::DEFAULT_CONTEXT_PREFIX. Empty-string tests write context_prefix: '' so they hit the code fallback, not the installed default.
  5. Agent tool events (AiContextAgentToolSubscriberTest) — AgentToolFinishedExecutionEvent / AgentFinishedExecutionEvent call recordToolUsed() / flushToolsUsed(); regex and ContentEntitySeeder extractEntityInfo() cases; event-path attachEntity() writes usage-row entity fields.
  6. AiContextOverviewSettingService::invalidateIfChanged() (AiContextOverviewSettingServiceTest) — persists saveShowOverviewPage(); no-op when unchanged; menu cache + route rebuild on change.
  7. Batch token-count backfill (AiContextBatchBackfillTokenCountsTest) — operation processes queued items; empty queue finishes immediately; finished callback posts success and error messages.
  8. ai_context_post_update_0001 (AiContextCanvasPagePostUpdateTest) — strips canvas_page, keeps other types, re-indexes, is idempotent, returns early when config is missing.
  9. GetRelevant no-permission path (AiContextFunctionCallAccessTest) — same insufficient-permissions message as List and Load.
  10. EchoAI translation (AiContextEchoAiSystemPromptTest::testTranslatedItemBodyAppearsInSystemPrompt) — Spanish body appears on /es/; English body does not.
  11. EchoAI Never include (AiContextEchoAiSystemPromptTest::testNeverIncludeWinsOverAlwaysInclude) — body appears with Always include alone, then is absent when the same ID is also Never include.
  12. AiContextItemAccessControlHandler (AiContextItemAccessControlHandlerCacheTest) — access(..., TRUE) cache tags/contexts for published view, owner unpublished view, and non-owner unpublished view.
  13. Colon instance ID (AiContextConsumerColonInstanceIdTest) — type:a:b through config store → usage entity → route → consumer form.
  14. Scheduler Unit-suite dependency (tests/README.md, docs/contribute/testing.md, AiContextSchedulerContentModerationSyncTest) — no top-level use of 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-gaps
phpunit -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.php

Expected: 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)

Edited by Kristen Pol

Merge request reports

Loading