Skip to content

Commit

Permalink
in Task::Discover, allow to pass options for multiple triggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Apr 18, 2024
1 parent 84e88e8 commit 49dbafb
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/trailblazer/workflow/task/discover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Discover
module_function

# DISCUSS: what about running this before we have a schema?
def call(namespace:, target_dir:, run_multiple_times: {}, test_filename:, **discovery_options)
def call(namespace:, target_dir:, test_filename:, **discovery_options)

filepath = Filepath.new(target_dir)

Expand Down
15 changes: 11 additions & 4 deletions test/discover_task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

class DiscoverTaskTest < Minitest::Spec
after { `rm -r test/tmp/app/concepts/posting/collaboration/generated` }
after { `rm test/tmp/test/bla_test.rb` }
# after { `rm test/tmp/test/bla_test.rb` }

TEST_ROOT = "test/tmp"

it "Discovery task: discover, serialize, create test plan, create state table/state guards" do
Dir.chdir(TEST_ROOT) do
Trailblazer::Workflow::Task::Discover.(
json_filename: "../fixtures/v1/posting-v10.json",
start_lane: "<ui> author workflow", # FIXME: old name {start_activity_json_id}
start_lane: "<ui> author workflow",

# DISCUSS: compute this automatically/from diagram?
# TODO: how to get this from CLI?
Expand All @@ -22,14 +22,21 @@ class DiscoverTaskTest < Minitest::Spec
"reviewer" => {label: "editor", icon: "☑"},
},

dsl_options_for_run_multiple_times: {
["<ui> author workflow", "Create"] => {ctx_merge: {:"article moderation:Create" => Trailblazer::Activity::Left}, config_payload: {outcome: :failure}},
# Click [UI Update] again, with invalid data.
["<ui> author workflow", "Update"] => {ctx_merge: {:"article moderation:Update" => Trailblazer::Activity::Left}, config_payload: {outcome: :failure}},
["<ui> author workflow", "Revise"] => {ctx_merge: {:"article moderation:Revise" => Trailblazer::Activity::Left}, config_payload: {outcome: :failure}},
},

namespace: "Posting::Collaboration",
target_dir: "app/concepts/posting/collaboration",
test_filename: "test/bla_test.rb",
)
end

#@ We serialized the discovered iterations, so we don't need to run discovery on every startup.
assert_equal (serialized_iteration_set = File.read("#{TEST_ROOT}/app/concepts/posting/collaboration/generated/iteration_set.json")).size, 32415
assert_equal (serialized_iteration_set = File.read("#{TEST_ROOT}/app/concepts/posting/collaboration/generated/iteration_set.json")).size, 37417

# raise
# iteration_set = Trailblazer::Workflow::Introspect::Iteration::Set.from_discovered_states(states, lanes_cfg: lanes_cfg)
Expand All @@ -39,7 +46,7 @@ class DiscoverTaskTest < Minitest::Spec
iteration_set_from_json = Trailblazer::Workflow::Introspect::Iteration::Set::Deserialize.(JSON.parse(serialized_iteration_set), lanes_cfg: schema.to_h[:lanes])

# TODO: test {Set#to_a}
assert_equal iteration_set_from_json.to_a.size, 19
assert_equal iteration_set_from_json.to_a.size, 22

#@ Assert test plan

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,95 @@
},
"outcome": "success"
},
{
"id": "catch-before-Activity_1psp91r",
"event_label": "☝ ⏵︎Create ⛞",
"start_task_position": {
"tuple": [
"UI",
"catch-before-Activity_1psp91r"
],
"comment": [
"before",
"☝ ⏵︎Create"
]
},
"start_positions": [
{
"tuple": [
"lifecycle",
"suspend-gw-to-catch-before-Activity_0wwfenp"
],
"comment": [
"before",
"⛾ ⏵︎Create"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_14h0q7a"
],
"comment": [
"before",
"☝ ⏵︎Create"
]
},
{
"tuple": [
"editor",
"suspend-gw-to-catch-before-Activity_05zip3u"
],
"comment": [
"before",
"☑ ⏵︎Notify"
]
}
],
"suspend_positions": [
{
"tuple": [
"lifecycle",
"suspend-gw-to-catch-before-Activity_0wwfenp"
],
"comment": [
"before",
"⛾ ⏵︎Create"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_14h0q7a"
],
"comment": [
"before",
"☝ ⏵︎Create"
]
},
{
"tuple": [
"editor",
"suspend-gw-to-catch-before-Activity_05zip3u"
],
"comment": [
"before",
"☑ ⏵︎Notify"
]
}
],
"suspend_task_position": {
"tuple": [
"UI",
"catch-before-Activity_1psp91r"
],
"comment": [
"before",
"☝ ⏵︎Create"
]
},
"outcome": "failure"
},
{
"id": "catch-before-Activity_1165bw9",
"event_label": "☝ ⏵︎Update form",
Expand Down Expand Up @@ -622,6 +711,95 @@
},
"outcome": "success"
},
{
"id": "catch-before-Activity_0j78uzd",
"event_label": "☝ ⏵︎Update ⛞",
"start_task_position": {
"tuple": [
"UI",
"catch-before-Activity_0j78uzd"
],
"comment": [
"before",
"☝ ⏵︎Update"
]
},
"start_positions": [
{
"tuple": [
"lifecycle",
"suspend-Gateway_0fnbg3r"
],
"comment": [
"before",
"⛾ ⏵︎Update ⏵︎Notify approver"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_0nxerxv"
],
"comment": [
"before",
"☝ ⏵︎Update"
]
},
{
"tuple": [
"editor",
"suspend-gw-to-catch-before-Activity_05zip3u"
],
"comment": [
"before",
"☑ ⏵︎Notify"
]
}
],
"suspend_positions": [
{
"tuple": [
"lifecycle",
"suspend-Gateway_0fnbg3r"
],
"comment": [
"before",
"⛾ ⏵︎Update ⏵︎Notify approver"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_0nxerxv"
],
"comment": [
"before",
"☝ ⏵︎Update"
]
},
{
"tuple": [
"editor",
"suspend-gw-to-catch-before-Activity_05zip3u"
],
"comment": [
"before",
"☑ ⏵︎Notify"
]
}
],
"suspend_task_position": {
"tuple": [
"UI",
"catch-before-Activity_0j78uzd"
],
"comment": [
"before",
"☝ ⏵︎Update"
]
},
"outcome": "failure"
},
{
"id": "catch-before-Activity_1165bw9",
"event_label": "☝ ⏵︎Update form",
Expand Down Expand Up @@ -1512,6 +1690,95 @@
},
"outcome": "success"
},
{
"id": "catch-before-Activity_1wiumzv",
"event_label": "☝ ⏵︎Revise ⛞",
"start_task_position": {
"tuple": [
"UI",
"catch-before-Activity_1wiumzv"
],
"comment": [
"before",
"☝ ⏵︎Revise"
]
},
"start_positions": [
{
"tuple": [
"lifecycle",
"suspend-Gateway_01p7uj7"
],
"comment": [
"before",
"⛾ ⏵︎Revise"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_1xs96ik"
],
"comment": [
"before",
"☝ ⏵︎Revise"
]
},
{
"tuple": [
"editor",
"suspend-gw-to-catch-before-Activity_05zip3u"
],
"comment": [
"before",
"☑ ⏵︎Notify"
]
}
],
"suspend_positions": [
{
"tuple": [
"lifecycle",
"suspend-Gateway_01p7uj7"
],
"comment": [
"before",
"⛾ ⏵︎Revise"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_1xs96ik"
],
"comment": [
"before",
"☝ ⏵︎Revise"
]
},
{
"tuple": [
"editor",
"suspend-gw-to-catch-before-Activity_05zip3u"
],
"comment": [
"before",
"☑ ⏵︎Notify"
]
}
],
"suspend_task_position": {
"tuple": [
"UI",
"catch-before-Activity_1wiumzv"
],
"comment": [
"before",
"☝ ⏵︎Revise"
]
},
"outcome": "failure"
},
{
"id": "catch-before-Activity_0zsock2",
"event_label": "☝ ⏵︎Revise form",
Expand Down

0 comments on commit 49dbafb

Please sign in to comment.