Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions calcit.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@
-> Unit
&doseq
command $ .to-list $ .distinct-values
decode-map-as
.unwrap-or (get workflow :commands) ({})
Map String $ Map Tag Dynamic
match (get workflow :commands)
(:some value)
decode-map-as value $ Map String $ Map Tag Dynamic
(:none) ({})
d! $ app.schema/Op :effect/run $ {}
:command $ decode-map-as
.unwrap $ get command :code
Expand All @@ -199,7 +200,7 @@
.unwrap $ get workflow :name
, 'String
:examples $ []
:schema $ quote $ Fn (Map Tag Dynamic) (-> respo.schema/Component)
:schema $ quote $ Fn (Map Tag V) (-> respo.schema/Component) (:generics V)
'comp-command-editor $ %{} 'CodeEntry (:doc |)
:code $ quote $ defcomp comp-command-editor (states base-command on-submit)
let
Expand Down Expand Up @@ -1031,7 +1032,7 @@
{} $ :style $ {} (:font-family ui/font-code)
<> $ str router
:examples $ []
:schema $ quote $ Fn (Map Tag Dynamic) (-> respo.schema/Component)
:schema $ quote $ Fn (Map Tag V) (-> respo.schema/Component) (:generics V)
:ns $ %{} 'NsEntry (:doc |)
:code $ quote $ ns app.comp.missing
:require
Expand Down Expand Up @@ -1678,7 +1679,7 @@
, &unit
<> "|Log out"
:examples $ []
:schema $ quote $ Fn (Map Tag Dynamic) (Map String String) (-> respo.schema/Component) (:features :io)
:schema $ quote $ Fn (Map Tag V) (Map String String) (-> respo.schema/Component) (:generics V) (:features :io)
'refresh-page! $ %{} 'CodeEntry (:doc |)
:code $ quote $ defn refresh-page! ()
let
Expand Down Expand Up @@ -2586,7 +2587,7 @@
:code $ quote $ def user
{} (:name nil) (:id nil) (:nickname nil) (:avatar nil) (:password nil)
:examples $ []
:schema $ quote $ Map Tag Dynamic
:schema $ quote $ Map Tag Nil
'workflow $ %{} 'CodeEntry (:doc |)
:code $ quote $ def workflow
{} (:id nil) (:name nil) (:base-dir |~/)
Expand Down
13 changes: 13 additions & 0 deletions tests/components.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ function elements(component) {
const values = nodes => nodes.map(node => c.listToArray(read(node, 'attrs')).map(c.listToArray).find(([key]) => key.value === 'value')[1]);
const attr = (node, name) => c.listToArray(read(node, 'attrs')).map(c.listToArray).find(([key]) => key.value === name)?.[1];

test('workflow button treats absent commands as empty and rejects invalid commands', () => {
for (const [workflow, valid] of [
[parse('{} (:name |Demo) (:base-dir |/synthetic)'), true],
[parse('{} (:name |Demo) (:base-dir |/synthetic) (:commands nil)'), false],
]) {
const button = elements(comp_command_button(workflow))[0];
const calls = [];
const click = () => read(read(button, 'event'), 'click')(parse('{}'), op => calls.push(op));
if (valid) assert.doesNotThrow(click); else assert.throws(click);
assert.equal(calls.length, 0);
}
});

test('workflow button preserves command paths and dispatches one Enum without running commands', () => {
const workflow = parse(`{}
:name |合成工作流
Expand Down