diff --git a/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/after-decide-complete/estimation-infra.json b/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/after-decide-complete/estimation-infra.json index a1e13789d..436c14d71 100644 --- a/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/after-decide-complete/estimation-infra.json +++ b/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/after-decide-complete/estimation-infra.json @@ -48,6 +48,9 @@ ], "stay_if": [ "need Heroku DX indefinitely" + ], + "would_flip_if": [ + "A confirmed always-on traffic pattern would raise the AWS compute estimate materially." ] }, "workshop": { diff --git a/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/retained-execution-pack/estimation-infra.json b/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/retained-execution-pack/estimation-infra.json index a1e13789d..436c14d71 100644 --- a/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/retained-execution-pack/estimation-infra.json +++ b/plugins/aws-startup-advisor/fixtures/heroku-decision-gate/retained-execution-pack/estimation-infra.json @@ -48,6 +48,9 @@ ], "stay_if": [ "need Heroku DX indefinitely" + ], + "would_flip_if": [ + "A confirmed always-on traffic pattern would raise the AWS compute estimate materially." ] }, "workshop": { diff --git a/plugins/aws-startup-advisor/fixtures/migration-report-reference.html b/plugins/aws-startup-advisor/fixtures/migration-report-reference.html index 6f6b0a3b3..aa1027f49 100644 --- a/plugins/aws-startup-advisor/fixtures/migration-report-reference.html +++ b/plugins/aws-startup-advisor/fixtures/migration-report-reference.html @@ -170,6 +170,12 @@

Stay entirely if

  • Cost is the only metric and a dual-run period must be avoided
  • +

    What would flip this

    + +

    Key decisions ahead

    1. Target region and deployment model (Fargate vs EKS)
    2. diff --git a/plugins/aws-startup-advisor/scripts/test_validate_migration_report_decision_core.py b/plugins/aws-startup-advisor/scripts/test_validate_migration_report_decision_core.py new file mode 100644 index 000000000..b0b74b5b9 --- /dev/null +++ b/plugins/aws-startup-advisor/scripts/test_validate_migration_report_decision_core.py @@ -0,0 +1,449 @@ +"""Decision-core content checks for the shared migration-report validator. + +A report used to pass when the section IDs existed, even if it never rendered +the verdict headline, flip conditions, specialist callout, or architecture +section. These tests lock the artifact-gated checks that reject that report. +""" + +from __future__ import annotations + +import importlib.util +import json +from pathlib import Path + +PLUGIN = Path(__file__).resolve().parent.parent +SCRIPT = PLUGIN / "scripts" / "validate-migration-report.py" +FIXTURES = PLUGIN / "fixtures" + + +def _load(): + spec = importlib.util.spec_from_file_location("validate_migration_report", SCRIPT) + module = importlib.util.module_from_spec(spec) + assert spec.loader is not None + spec.loader.exec_module(module) + return module + + +def _reference_html() -> str: + return (FIXTURES / "migration-report-reference.html").read_text(encoding="utf-8") + + +def _reference_estimate() -> dict: + return json.loads( + (FIXTURES / "estimation-infra-reference.json").read_text(encoding="utf-8") + ) + + +def test_reference_fixture_still_passes() -> None: + validator = _load() + ai = json.loads((FIXTURES / "estimation-ai-reference.json").read_text(encoding="utf-8")) + errors = validator.validate_report( + _reference_html(), + _reference_estimate(), + ai, + ) + assert errors == [], errors + + +def test_missing_would_flip_list_fails() -> None: + validator = _load() + html = _reference_html().replace("

      What would flip this

      ", "

      Notes

      ") + errors = validator.validate_report(html, _reference_estimate(), None) + assert any("would_flip" in err for err in errors), errors + + +def test_would_flip_list_only_in_template_fails() -> None: + # A browser never renders