Update relevant CCC skipped tests
Audit of `web/modules/contrib/ai_context/tests` — static review of all `markTestSkipped()` usage and conditional skip paths.
**Note:** `dynamic_entity_reference` is present in this project (`web/modules/contrib/dynamic_entity_reference`), so Category B skips should **not** fire here. PHPUnit also lacks `SIMPLETEST_DB` in `web/core/phpunit.xml`, which causes kernel/functional tests to error rather than skip — that is a test-runner config issue, not an intentional skip in module code.
---
## Summary
| Category | Skip sites in code | Test methods affected (max) | Always skipped? |
|----------|-------------------|-----------------------------|---------------------------|
| A — Explicit `markTestSkipped()` | 3 locations | 7 methods | **Yes — 6 always** (+ 1 redundant) |
| B — Conditional via `DynamicEntityReferenceTestTrait` | 1 trait, 10 test classes | 37 methods (if DER absent) | **No** (DER is installed) |
**Total intentional skip points in source:** 4 `markTestSkipped()` calls + 1 conditional trait.
---
## Category A — Always skipped (ticket-worthy)
### 1. `AiContextSchedulerRaceConditionTest` — entire class blocked in `setUp()`
**File:** `tests/src/Functional/AiContextSchedulerRaceConditionTest.php`
**Reason:** `Skipped pending implementation of scheduler_hide_publish/unpublish_date hooks.`
**Scope:** All 5 methods in the class are skipped because `setUp()` calls `markTestSkipped()` before any test runs.
| Test method |
|-------------|
| `testFirstFormRequestInstallsScmiFields` |
| `testSubsequentFormRequestsWorkCorrectly` |
| `testFormSubmissionWorksAfterLazyInstallation` |
| `testSchedulerFieldStorageExistsAfterInstall` |
| `testModulesInstalledHookIsSafeToCall` |
**Follow-up for ticket:** Implement `scheduler_hide_publish/unpublish_date` hooks (or remove the class-level skip once hooks exist). The inline skip in `testModulesInstalledHookIsSafeToCall` is redundant dead code while `setUp()` skips the class; it has a separate reason (`sync() cannot install SCMI fields from test process on Drupal 10`) and a `@todo` to rework via HTTP.
---
### 2. `AiContextItemTranslationUITest::testTranslationUI` — inherited test overridden
**File:** `tests/src/Functional/AiContextItemTranslationUITest.php`
**Method:** `testTranslationUI`
**Reason:** Parent `ContentTranslationUITestBase` helpers assume non-moderated entities; incompatible with content-moderated AI Context Items.
**Replacement coverage:** Custom methods in the same class:
- `testNonTranslatableFieldsShared`
- `testPublishedStatusPerTranslation` (likely — verify in file)
- `testGlobalFlagPerTranslation` (per PHPDoc)
**Follow-up for ticket:** Either adapt parent helpers for moderated entities, or remove the inherited method and document why custom tests replace it (consider deleting the override if the parent method can be excluded another way).
---
## Category B — Conditionally skipped (DER not available)
**File:** `tests/src/Traits/DynamicEntityReferenceTestTrait.php`
**Trigger:** `installDynamicEntityReference()` when `dynamic_entity_reference` module is not discovered.
**Message:** `dynamic_entity_reference module is not available in this environment.`
**Status in D11 v2:** Should **run** — module is in `web/modules/contrib/`.
### Per-class breakdown
| Test class | Type | Methods that call `installDynamicEntityReference()` | Count |
|------------|------|-----------------------------------------------------|-------|
| `AiContextScopeManagerTest` | Kernel | `testGetScopePluginsReturnsAllCorePlugins`, `testScopePluginDisplayWeightsMirrorPluginOrder`, `testContribScopePluginsSortAfterCoreScopes`, `testPluginsAreSortedByWeight` | 4 |
| `AiContextSelectorAlgorithmTest` | Kernel | `testSelectorAutoIncludesMatchingTargetedItems` | 1 |
| `AiContextScopeTargetEntityTest` | Kernel | **All methods** — called in `setUp()` | 21 |
| `AiContextScopePluginTest` | Kernel | `testTargetEntityPluginAttributes`, `testTargetEntityPluginExtractFormValues`, `testTargetEntityPluginSupportsSubscriptions` | 3 |
| `AiContextScopeEntityTest` | Kernel | `testPreSaveClearsNonGlobalScopeWhenGlobal`, `testTargetEntityDataAndRenderArray` | 2 |
| `AiContextScopeCleanupServiceTest` | Kernel | **All methods** — called in `setUp()` | 3 |
| `AiContextItemTranslationTest` | Kernel | `testTranslatableFields` | 1 |
| `AiContextItemFieldTranslationTest` | Kernel | `testTargetEntitiesFieldNotTranslatable` | 1 |
| `AiContextScopeContextItemFormTest` | Functional | `testSavingAsGlobalClearsOtherScopeValues` | 1 |
**Classes using trait but not skipping:** `AiContextScopeSiteSectionTest`, `AiContextScopeLanguageTest` — trait is imported but `installDynamicEntityReference()` is never called.
**Follow-up for ticket:** Decide whether DER should be a hard test dependency (add to `composer.json` / test ` $modules` and remove conditional skip) vs. keep optional contrib behavior.
---
## Suggested ticket text
**Title:** Unskip or resolve intentionally skipped `ai_context` tests
**Problem:** The test suite contains 6 permanently skipped test methods (5 in one functional class + 1 translation UI override) and 37 methods that skip when `dynamic_entity_reference` is absent. Permanently skipped tests reduce CI signal and can hide regressions.
**Acceptance criteria:**
1. **`AiContextSchedulerRaceConditionTest`** — Remove class-level `setUp()` skip after implementing `scheduler_hide_publish/unpublish_date` hooks; re-enable all 5 tests. Rework `testModulesInstalledHookIsSafeToCall` to trigger SCMI sync via HTTP if direct hook calls remain unreliable on D11.
2. **`AiContextItemTranslationUITest::testTranslationUI`** — Either fix moderation compatibility with parent helpers or formally drop the inherited test and document replacement coverage in class PHPDoc.
3. **`DynamicEntityReferenceTestTrait`** — Make DER a declared test dependency in CI/dev template, or mock/stub target-entity behavior so 37 tests never skip in standard environments.
4. Remove redundant/dead `markTestSkipped()` in `testModulesInstalledHookIsSafeToCall` once class-level skip is lifted.
5. Configure `SIMPLETEST_DB` / `SIMPLETEST_BASE_URL` in `web/core/phpunit.xml` so kernel and functional tests execute (not error) in DDEV.
**Files to touch:**
- `tests/src/Functional/AiContextSchedulerRaceConditionTest.php`
- `tests/src/Functional/AiContextItemTranslationUITest.php`
- `tests/src/Traits/DynamicEntityReferenceTestTrait.php`
- Plus the 10 test classes listed in Category B (as needed)
## AI usage
- [x] AI assisted issue
- [ ] AI generated code
issue