57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Tests\Support\TestLaneBudget;
|
|
use Tests\Support\TestLaneManifest;
|
|
|
|
it('evaluates lane budgets into within-budget, warning, and over-budget states', function (): void {
|
|
$warnBudget = TestLaneBudget::fromArray([
|
|
'thresholdSeconds' => 30,
|
|
'baselineSource' => 'measured-current-suite',
|
|
'enforcement' => 'warn',
|
|
'lifecycleState' => 'documented',
|
|
]);
|
|
|
|
$hardFailBudget = TestLaneBudget::fromArray([
|
|
'thresholdSeconds' => 30,
|
|
'baselineSource' => 'measured-current-suite',
|
|
'enforcement' => 'hard-fail',
|
|
'lifecycleState' => 'documented',
|
|
]);
|
|
|
|
expect($warnBudget->evaluate(24.5)['budgetStatus'])->toBe('within-budget')
|
|
->and($warnBudget->evaluate(31.2)['budgetStatus'])->toBe('warning')
|
|
->and($hardFailBudget->evaluate(31.2)['budgetStatus'])->toBe('over-budget');
|
|
});
|
|
|
|
it('evaluates family targets through the generic budget target path', function (): void {
|
|
$familyTargets = array_values(array_filter(
|
|
TestLaneManifest::budgetTargets(),
|
|
static fn (array $target): bool => $target['targetType'] === 'family',
|
|
));
|
|
|
|
$evaluations = TestLaneBudget::evaluateBudgetTargets(
|
|
$familyTargets,
|
|
0.0,
|
|
[],
|
|
[
|
|
'ops-ux-governance' => 18.4,
|
|
'action-surface-contract' => 7.8,
|
|
'browser-smoke' => 14.2,
|
|
],
|
|
);
|
|
|
|
expect($evaluations)->not->toBeEmpty()
|
|
->and($evaluations[0])->toHaveKeys([
|
|
'budgetId',
|
|
'targetType',
|
|
'targetId',
|
|
'thresholdSeconds',
|
|
'baselineSource',
|
|
'enforcement',
|
|
'lifecycleState',
|
|
'measuredSeconds',
|
|
'budgetStatus',
|
|
]);
|
|
}); |