diff --git a/app/static/builder/command-builder.js b/app/static/builder/command-builder.js index 03468123..9b567c7f 100644 --- a/app/static/builder/command-builder.js +++ b/app/static/builder/command-builder.js @@ -1229,7 +1229,7 @@ else if(d.harborChoice!==undefined){const rec=r(),v=el.value;if(v==='path')rec.harborDev='';else if(v==='dev')rec.harborDev=rec.harborDev||'~/harbor-dev/.venv/bin/harbor';renderForm();refreshPlan();if(v==='dev')root.querySelector('[data-field="harborDev"]')?.select();} else if(el.id==='nb-import-file'){ const file=el.files[0];if(!file)return; - try{if(file.size>100000)throw Error('Recipe file is too large.');recipe=C.fromJSON(await file.text());savedId='';step=REVIEW;render(true);status('Imported “'+(recipe.title||recipe.name)+'”. Review the recipe before copying commands.');}catch(error){status('Could not import recipe: '+error.message);}el.value=''; + try{if(file.size>100000)throw Error('Recipe file is too large.');recipe=C.fromJSON(await file.text());savedId='';step=REVIEW;render(true);status('Imported “'+(recipe.title||recipe.name)+'”. Check it, then Run.');}catch(error){status('Could not import recipe: '+error.message);}el.value=''; } }); { const dl=document.getElementById('nb-models'); if(dl){const seen=new Set(); for(const o of [...dl.options]){const v=C.bareModel(o.value); if(!v||seen.has(v)){o.remove();continue;} seen.add(v); o.value=v;}} } diff --git a/app/ui_tests/test_builder_notices.py b/app/ui_tests/test_builder_notices.py new file mode 100644 index 00000000..228ff5a9 --- /dev/null +++ b/app/ui_tests/test_builder_notices.py @@ -0,0 +1,23 @@ +"""The builder's own words: Run on Review starts a recipe, nothing is copied.""" +import re +import unittest +from pathlib import Path + +APP = Path(__file__).resolve().parents[1] +BUILDER_TEXT = [*sorted((APP / "static/builder").glob("*.js")), *sorted((APP / "templates/builder").glob("*.html"))] + + +class BuilderNotices(unittest.TestCase): + def test_no_builder_text_tells_the_user_to_copy_run_commands(self): + for path in BUILDER_TEXT: + with self.subTest(path=path.name): + text = path.read_text(encoding="utf-8") + self.assertIsNone(re.search(r"cop(?:y|ying)\s+(?:the\s+)?(?:run\s+)?commands", text, re.I)) + + def test_the_import_notice_says_to_check_the_recipe_then_run_it(self): + page = (APP / "static/builder/command-builder.js").read_text(encoding="utf-8") + self.assertIn("status('Imported “'+(recipe.title||recipe.name)+'”. Check it, then Run.')", page) + + +if __name__ == "__main__": + unittest.main()