commit compras 2711
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-27 13:49:31 +02:00
parent dc73540558
commit e709d900d1
81 changed files with 5352 additions and 107 deletions
+62 -1
View File
@@ -2,6 +2,33 @@
require_once __DIR__.'/../Support/LandedQaReceipts.php';
test('estimate contention receipts require all native uniqueness races and explicit estimate effects', function () {
$command = ['php', 'worker.php', 'compras_receipts_test_000000000001', 'race-estimate'];
$rows = [['old_runtime_rejected_before_balance' => true, 'old_estimate_runtime_rejected' => true,
'runtime_landed_version' => 'COMMON-BUDGET-LANDED-COST-QA-v2', 'status' => 503]];
foreach (['same_operation', 'conflicting_plan_version', 'same_source_different_plan'] as $scenario) {
$rows[] = ['scenario' => $scenario, 'estimate' => true, 'statuses' => $scenario === 'same_operation' ? [200, 200] : [200, 409],
'blocked_writers_observed' => 2, 'commands' => 1, 'audits' => 1, 'reserved_minor' => 2000];
}
$encode = fn ($records) => implode("\n", array_map(fn ($row) => json_encode($row, JSON_THROW_ON_ERROR), $records));
expect(landedQaReceiptsVerified($command, $encode($rows)))->toBeTrue();
$reconciliation = $rows;
foreach ($reconciliation as &$row) {
if (isset($row['scenario'])) {
$row['reconciliation'] = true;
$row['commands'] = 3;
$row['reserved_minor'] = 3000;
}
}
unset($row);
$reconcileCommand = [...array_slice($command, 0, 3), 'race-estimate-reconcile'];
expect(landedQaReceiptsVerified($reconcileCommand, $encode($reconciliation)))->toBeTrue();
$reconciliation[1]['reserved_minor'] = 2000;
expect(landedQaReceiptsVerified($reconcileCommand, $encode($reconciliation)))->toBeFalse();
unset($rows[2]['estimate']);
expect(landedQaReceiptsVerified($command, $encode($rows)))->toBeFalse();
});
test('separate Pest kernels cannot reuse one disposable database with persistent migration functions', function () {
$pest = ['php', 'vendor/bin/pest', 'tests/Feature/ImportTariffCodesTest.php'];
expect(landedQaCommandIsolationVerified([$pest]))->toBeTrue();
@@ -38,8 +65,42 @@ test('restore completion requires the restored replay original snapshot and data
expect(landedQaReceiptsVerified($command, $proof))->toBeFalse();
$databaseOnly = $proof."\n".json_encode(['isolated_restore_removed' => true], JSON_THROW_ON_ERROR);
expect(landedQaReceiptsVerified($command, $databaseOnly))->toBeFalse();
$privateFiles = ['private_original_versions_restored' => 2, 'source_loss_detected' => true,
$privateFiles = ['private_original_versions_restored' => 6, 'typed_dossier_versions_restored' => 4, 'selected_party_versions_restored' => 2, 'source_loss_detected' => true,
'separate_private_root_restored' => true, 'native_authorized_evidence_resolved' => true];
expect(landedQaReceiptsVerified($command, $databaseOnly."\n".json_encode($privateFiles, JSON_THROW_ON_ERROR)))->toBeTrue();
$estimateCommand = [...array_slice($command, 0, 3), 'import-estimates'];
$existingRecovery = $databaseOnly."\n".json_encode($privateFiles, JSON_THROW_ON_ERROR);
expect(landedQaReceiptsVerified($estimateCommand, $existingRecovery))->toBeFalse();
expect(landedQaReceiptsVerified($estimateCommand, $existingRecovery."\n".json_encode([
'estimate_source_remainder_restored' => 1000, 'estimate_original_replay_without_effects' => true,
], JSON_THROW_ON_ERROR)))->toBeTrue();
$missingTyped = $privateFiles;
unset($missingTyped['typed_dossier_versions_restored']);
expect(landedQaReceiptsVerified($command, $databaseOnly."\n".json_encode($missingTyped, JSON_THROW_ON_ERROR)))->toBeFalse();
$missingParty = $privateFiles;
unset($missingParty['selected_party_versions_restored']);
expect(landedQaReceiptsVerified($command, $databaseOnly."\n".json_encode($missingParty, JSON_THROW_ON_ERROR)))->toBeFalse();
expect(landedQaReceiptsVerified(['php', 'vendor/bin/pest', '--compact'], '{"tool":"pest","result":"passed","tests":1,"passed":0,"skipped":1}'))->toBeFalse();
});
test('dossier contention requires both races one original and verified bytes', function () {
$command = ['php', 'worker.php', 'compras_receipts_test_000000000001', 'race-dossier'];
$rows = [];
foreach (['same_operation', 'same_version'] as $scenario) {
$rows[] = ['scenario' => $scenario, 'statuses' => $scenario === 'same_operation' ? [200, 200] : [200, 409],
'blocked_writers_observed' => 2, 'documents_created' => 1, 'audits' => 1, 'files_created' => 1, 'all_originals_verified' => true];
}
$encode = fn ($records) => implode("\n", array_map(fn ($row) => json_encode($row, JSON_THROW_ON_ERROR), $records));
expect(landedQaReceiptsVerified($command, $encode($rows)))->toBeTrue();
expect(landedQaReceiptsVerified($command, $encode([$rows[0]])))->toBeFalse();
$rows[1]['files_created'] = 2;
expect(landedQaReceiptsVerified($command, $encode($rows)))->toBeFalse();
$partyCommand = ['php', 'worker.php', 'compras_receipts_test_000000000001', 'race-party'];
foreach ($rows as &$row) {
$row['files_created'] = 0;
}
unset($row);
expect(landedQaReceiptsVerified($partyCommand, $encode($rows)))->toBeTrue();
$rows[1]['files_created'] = 1;
expect(landedQaReceiptsVerified($partyCommand, $encode($rows)))->toBeFalse();
});