Files
app-autotest/tests/test_static_regressions.py
T

65 lines
2.7 KiB
Python

from pathlib import Path
def test_partial_unique_index_for_one_running_exists():
init_db_path = Path(__file__).resolve().parents[1] / "site" / "db" / "init_db.py"
content = init_db_path.read_text(encoding="utf-8")
assert "CREATE UNIQUE INDEX IF NOT EXISTS idx_one_running" in content
assert "ON scenario_runs (client_id, stand) WHERE status = 'RUNNING'" in content
def test_scenario_name_escape_chain_includes_amp_backslash_quote_doublequote():
js_path = Path(__file__).resolve().parents[1] / "site" / "static" / "js" / "scenario-list.js"
content = js_path.read_text(encoding="utf-8")
expected = (
"const escName = def.name"
".replace(/&/g,'&')"
".replace(/\\\\/g,'\\\\\\\\')"
".replace(/'/g,\"\\\\'\")"
".replace(/\"/g,'"');"
)
assert expected in content
def test_scenario_editor_loads_operations_from_selected_service():
js_path = Path(__file__).resolve().parents[1] / "site" / "static" / "js" / "scenario-form.js"
content = js_path.read_text(encoding="utf-8")
assert "async function loadServiceOperations(svcId)" in content
assert "fetch('/api/operations/' + svcId)" in content
assert "serviceOps.filter(item => item.operation !== 'reconcile')" in content
assert "const allOps = ['create', 'delete', 'modify', 'suspend', 'resume', 'redeploy']" not in content
def test_manual_create_uses_current_service_operation_id():
js_path = Path(__file__).resolve().parents[1] / "site" / "static" / "js" / "operations.js"
content = js_path.read_text(encoding="utf-8")
assert "find(o => o.operation === 'create')" in content
assert "showParams(createOp.svcOperationId, 'create')" in content
assert "showParams(18, 'create')" not in content
def test_scenario_editor_preserves_legacy_and_cloud_instance_references():
js_path = Path(__file__).resolve().parents[1] / "site" / "static" / "js" / "scenario-form.js"
content = js_path.read_text(encoding="utf-8")
assert "_legacyInstanceFallback: s.operation !== 'create'" in content
assert "_showCloud: Boolean(s.instance_uid)" in content
assert "ref === step.instance_uid" in content
assert "s.instance_uid = ref" in content
assert "&& !scenarioEditorState.steps[i]._legacyInstanceFallback" in content
def test_live_scripts_are_not_collected_as_network_tests():
tests_dir = Path(__file__).resolve().parent
user_simulation = (tests_dir / "test_user_simulation.py").read_text(encoding="utf-8")
smoke = (tests_dir / "test_smoke_all_services.py").read_text(encoding="utf-8")
assert "pytest.skip(" in user_simulation
assert "pytestmark = pytest.mark.skip" in smoke
assert "operation_id(sid, \"create\"" in user_simulation
assert "create_op[\"svcOperationId\"]" in smoke