fix: preserve filtered command actions (#60)
This commit is contained in:
1 parent
36f500d58b
commit
3e1ce3e72a
3 files changed
+36
-3
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
COMMANDS = Path(__file__).parents[1] / "frontend" / "commands.js"
|
||||
|
||||
|
||||
def test_filtered_command_runs_the_matching_action():
|
||||
script = f"""
|
||||
const filterCommands = require({json.dumps(str(COMMANDS))});
|
||||
let action = '';
|
||||
const commands = [
|
||||
{{ name: 'Open whiteboard', run: () => {{ action = 'whiteboard'; }} }},
|
||||
{{ name: 'Refresh now', run: () => {{ action = 'refresh'; }} }},
|
||||
];
|
||||
const matches = filterCommands(commands, 'refresh');
|
||||
if (matches.length !== 1) throw new Error(`expected one match, got ${{matches.length}}`);
|
||||
matches[0].run();
|
||||
if (action !== 'refresh') throw new Error(`expected refresh, got ${{action}}`);
|
||||
"""
|
||||
|
||||
subprocess.run(["node", "-e", script], check=True, capture_output=True, text=True)
|
||||
Reference in new issue
Block a user