|
|
|
|
@ -845,6 +845,200 @@ try {
|
|
|
|
|
]) === $restoredReadiness,
|
|
|
|
|
'Readiness recovery or reader-service DTO parity drifted.');
|
|
|
|
|
|
|
|
|
|
$database->table('ui_copy_drafts')
|
|
|
|
|
->where('id', (int) $validCount['id'])
|
|
|
|
|
->update([
|
|
|
|
|
'validation_state' => 'invalid',
|
|
|
|
|
'validation_errors_json' => '{',
|
|
|
|
|
]);
|
|
|
|
|
$corruptErrorsWorkspace = $service->workspace([
|
|
|
|
|
'page' => 'test.page',
|
|
|
|
|
'locale' => 'en',
|
|
|
|
|
'channel' => 'shared',
|
|
|
|
|
]);
|
|
|
|
|
$assert($corruptErrorsWorkspace['publication_readiness']
|
|
|
|
|
['invalid_draft_count'] === 1
|
|
|
|
|
&& $corruptErrorsWorkspace['publication_readiness']
|
|
|
|
|
['first_errors'] === [[
|
|
|
|
|
'key' => 'test.count',
|
|
|
|
|
'validation_state' => 'invalid',
|
|
|
|
|
'errors' => ['validation_result_corrupt'],
|
|
|
|
|
]],
|
|
|
|
|
'Corrupt draft validation errors did not map to a safe diagnostic.');
|
|
|
|
|
$database->table('ui_copy_drafts')
|
|
|
|
|
->where('id', (int) $validCount['id'])
|
|
|
|
|
->update([
|
|
|
|
|
'validation_state' => 'valid',
|
|
|
|
|
'validation_errors_json' => '[]',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$database->table('ui_copy_drafts')
|
|
|
|
|
->where('id', (int) $warning['id'])
|
|
|
|
|
->update([
|
|
|
|
|
'validation_state' => 'unexpected',
|
|
|
|
|
'validation_errors_json' => '["ignored_fixture"]',
|
|
|
|
|
]);
|
|
|
|
|
$unknownStateWorkspace = $service->workspace([
|
|
|
|
|
'page' => 'test.page',
|
|
|
|
|
'locale' => 'en',
|
|
|
|
|
'channel' => 'page',
|
|
|
|
|
]);
|
|
|
|
|
$assert($unknownStateWorkspace['publication_readiness']
|
|
|
|
|
['invalid_draft_count'] === 1
|
|
|
|
|
&& $unknownStateWorkspace['publication_readiness']
|
|
|
|
|
['blocking_draft_count'] === 1
|
|
|
|
|
&& $unknownStateWorkspace['publication_readiness']
|
|
|
|
|
['first_errors'] === [[
|
|
|
|
|
'key' => 'test.warning',
|
|
|
|
|
'validation_state' => 'invalid',
|
|
|
|
|
'errors' => ['validation_state_unknown'],
|
|
|
|
|
]],
|
|
|
|
|
'Unknown draft validation state did not fail closed as invalid.');
|
|
|
|
|
$database->table('ui_copy_drafts')
|
|
|
|
|
->where('id', (int) $warning['id'])
|
|
|
|
|
->update([
|
|
|
|
|
'validation_state' => 'valid',
|
|
|
|
|
'validation_errors_json' => '[]',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$targetLocaleId = (int) $database->table('ui_copy_locales')
|
|
|
|
|
->where('locale', 'en')
|
|
|
|
|
->value('id');
|
|
|
|
|
$database->table('ui_copy_locales')
|
|
|
|
|
->where('id', $targetLocaleId)
|
|
|
|
|
->update(['enabled' => 0]);
|
|
|
|
|
$disabledLocaleWorkspace = $service->workspace([
|
|
|
|
|
'page' => 'test.page',
|
|
|
|
|
'locale' => 'en',
|
|
|
|
|
'channel' => 'all',
|
|
|
|
|
]);
|
|
|
|
|
$assert($disabledLocaleWorkspace['publication_readiness']['ready']
|
|
|
|
|
=== false
|
|
|
|
|
&& $disabledLocaleWorkspace['publication_readiness']['locale_enabled']
|
|
|
|
|
=== false
|
|
|
|
|
&& $disabledLocaleWorkspace['publication_readiness']
|
|
|
|
|
['projection_ready'] === true
|
|
|
|
|
&& $disabledLocaleWorkspace['publication_readiness']
|
|
|
|
|
['blocking_draft_count'] === 0
|
|
|
|
|
&& $disabledLocaleWorkspace['write_ready'] === false,
|
|
|
|
|
'Disabled locale remained publication-ready.');
|
|
|
|
|
$database->table('ui_copy_locales')
|
|
|
|
|
->where('id', $targetLocaleId)
|
|
|
|
|
->update(['enabled' => 1]);
|
|
|
|
|
|
|
|
|
|
$sharedEntry = $database->table('ui_copy_entries')
|
|
|
|
|
->where('copy_key', 'test.shared')
|
|
|
|
|
->first();
|
|
|
|
|
$assert($sharedEntry !== null, 'Shared readiness fixture is missing.');
|
|
|
|
|
$database->table('ui_copy_entries')
|
|
|
|
|
->where('id', (int) $sharedEntry->id)
|
|
|
|
|
->update(['source_hash_zh' => str_repeat('0', 64)]);
|
|
|
|
|
$projectionBlockedWorkspace = $service->workspace([
|
|
|
|
|
'page' => 'test.page',
|
|
|
|
|
'locale' => 'en',
|
|
|
|
|
'channel' => 'shared',
|
|
|
|
|
]);
|
|
|
|
|
$assert($projectionBlockedWorkspace['publication_readiness']['ready']
|
|
|
|
|
=== false
|
|
|
|
|
&& $projectionBlockedWorkspace['publication_readiness']
|
|
|
|
|
['projection_ready'] === false
|
|
|
|
|
&& $projectionBlockedWorkspace['publication_readiness']
|
|
|
|
|
['locale_enabled'] === true
|
|
|
|
|
&& $projectionBlockedWorkspace['publication_readiness']
|
|
|
|
|
['blocking_draft_count'] === 0
|
|
|
|
|
&& $projectionBlockedWorkspace['write_ready'] === false,
|
|
|
|
|
'Unsynchronized Manifest projection remained publication-ready.');
|
|
|
|
|
$database->table('ui_copy_entries')
|
|
|
|
|
->where('id', (int) $sharedEntry->id)
|
|
|
|
|
->update(['source_hash_zh' => (string) $sharedEntry->source_hash_zh]);
|
|
|
|
|
|
|
|
|
|
$templateEntry = $database->table('ui_copy_entries')
|
|
|
|
|
->where('copy_key', 'test.title')
|
|
|
|
|
->first();
|
|
|
|
|
$templateDraft = $database->table('ui_copy_drafts')
|
|
|
|
|
->where('id', (int) $titleOne['id'])
|
|
|
|
|
->first();
|
|
|
|
|
$assert($templateEntry !== null && $templateDraft !== null,
|
|
|
|
|
'Readiness truncation fixtures are missing.');
|
|
|
|
|
$temporaryEntryIds = [];
|
|
|
|
|
for ($index = 6; $index >= 1; $index--) {
|
|
|
|
|
$copyKey = sprintf('readiness.temp.%02d', $index);
|
|
|
|
|
$entryValues = (array) $templateEntry;
|
|
|
|
|
unset($entryValues['id']);
|
|
|
|
|
$entryValues['copy_key'] = $copyKey;
|
|
|
|
|
$entryValues['location'] = 'test:' . $copyKey;
|
|
|
|
|
$entryValues['source_text_zh'] = '临时就绪度词条 ' . $index;
|
|
|
|
|
$entryValues['source_hash_zh'] = hash(
|
|
|
|
|
'sha256',
|
|
|
|
|
$entryValues['source_text_zh']
|
|
|
|
|
);
|
|
|
|
|
$temporaryEntryId = (int) $database->table('ui_copy_entries')
|
|
|
|
|
->insertGetId($entryValues);
|
|
|
|
|
$temporaryEntryIds[] = $temporaryEntryId;
|
|
|
|
|
|
|
|
|
|
$draftValues = (array) $templateDraft;
|
|
|
|
|
unset($draftValues['id']);
|
|
|
|
|
$draftValues['entry_id'] = $temporaryEntryId;
|
|
|
|
|
$draftValues['draft_text'] = 'temporary ' . $index;
|
|
|
|
|
$draftValues['draft_hash'] = hash(
|
|
|
|
|
'sha256',
|
|
|
|
|
$draftValues['draft_text']
|
|
|
|
|
);
|
|
|
|
|
$draftValues['translated_source_hash_zh']
|
|
|
|
|
= $entryValues['source_hash_zh'];
|
|
|
|
|
$draftValues['translated_placeholder_hash']
|
|
|
|
|
= $entryValues['placeholder_hash'];
|
|
|
|
|
$draftValues['validation_state'] = 'invalid';
|
|
|
|
|
$draftValues['validation_errors_json'] = json_encode(
|
|
|
|
|
['temporary_' . sprintf('%02d', $index)],
|
|
|
|
|
JSON_THROW_ON_ERROR
|
|
|
|
|
);
|
|
|
|
|
$database->table('ui_copy_drafts')->insert($draftValues);
|
|
|
|
|
}
|
|
|
|
|
$truncatedErrorsWorkspace = $service->workspace([
|
|
|
|
|
'page' => 'test.page',
|
|
|
|
|
'locale' => 'en',
|
|
|
|
|
'channel' => 'all',
|
|
|
|
|
]);
|
|
|
|
|
$assert($truncatedErrorsWorkspace['publication_readiness']
|
|
|
|
|
['blocking_draft_count'] === 6
|
|
|
|
|
&& $truncatedErrorsWorkspace['publication_readiness']
|
|
|
|
|
['invalid_draft_count'] === 6
|
|
|
|
|
&& count($truncatedErrorsWorkspace['publication_readiness']
|
|
|
|
|
['first_errors']) === 5
|
|
|
|
|
&& array_column(
|
|
|
|
|
$truncatedErrorsWorkspace['publication_readiness']['first_errors'],
|
|
|
|
|
'key'
|
|
|
|
|
) === [
|
|
|
|
|
'readiness.temp.01',
|
|
|
|
|
'readiness.temp.02',
|
|
|
|
|
'readiness.temp.03',
|
|
|
|
|
'readiness.temp.04',
|
|
|
|
|
'readiness.temp.05',
|
|
|
|
|
],
|
|
|
|
|
'Readiness diagnostics were not sorted and capped at five entries.');
|
|
|
|
|
$database->table('ui_copy_drafts')
|
|
|
|
|
->whereIn('entry_id', $temporaryEntryIds)
|
|
|
|
|
->delete();
|
|
|
|
|
$database->table('ui_copy_entries')
|
|
|
|
|
->whereIn('id', $temporaryEntryIds)
|
|
|
|
|
->delete();
|
|
|
|
|
|
|
|
|
|
$readinessAfterBoundaryChecks = $service->workspace([
|
|
|
|
|
'page' => 'test.page',
|
|
|
|
|
'locale' => 'en',
|
|
|
|
|
'channel' => 'all',
|
|
|
|
|
]);
|
|
|
|
|
$assert($readinessAfterBoundaryChecks['publication_readiness']['ready']
|
|
|
|
|
=== true
|
|
|
|
|
&& $readinessAfterBoundaryChecks['publication_readiness']
|
|
|
|
|
['projection_ready'] === true
|
|
|
|
|
&& $readinessAfterBoundaryChecks['publication_readiness']
|
|
|
|
|
['locale_enabled'] === true
|
|
|
|
|
&& $readinessAfterBoundaryChecks['publication_readiness']
|
|
|
|
|
['blocking_draft_count'] === 0,
|
|
|
|
|
'Readiness fixtures were not restored after boundary checks.');
|
|
|
|
|
|
|
|
|
|
$titleTwo = $service->saveDraft(
|
|
|
|
|
$super,
|
|
|
|
|
'test.title',
|
|
|
|
|
|