# THIS FILE IS AUTOGENERATED FROM trailblazer-activity-dsl-linear/test/docs/sequence_options_test.rb
require "test_helper"
# require "trailblazer/developer"

module A
  class Id_DocSeqOptionsTest < Minitest::Spec
    Memo = Struct.new(:text)

    #:id
    module Memo::Operation
      class Create < Trailblazer::Operation
        step :validate
        step :save, id: :save_the_world
        step :notify
        #~meths
        include T.def_steps(:validate, :save, :notify)
        #~meths end
      end
    end
    #:id end

    it ":id shows up in introspect" do
=begin
      output =
        #:id-inspect
        Trailblazer::Developer.railway(Memo::Operation::Create)
        #=> [>validate,>save_the_world,>notify]
        #:id-inspect end
=end

#~ignore end

      assert Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Create, id: :save_the_world)
      #:id-introspect
      puts Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Create, id: :save_the_world)
      #=> #<struct Trailblazer::Operation::Schema::Nodes::Attributes id=:save_the_world, ...>
      #:id-introspect end
    end
  end
end

module B
  class Delete_DocsSequenceOptionsTest < Minitest::Spec
    Memo = A::Id_DocSeqOptionsTest::Memo

    it ":delete removes step" do
      #:delete
      module Memo::Operation
        class Admin < Create
          step nil, delete: :validate
        end
      end
      #:delete end

=begin
     output =
      #:delete-inspect
      Trailblazer::Developer.railway(Memo::Operation::Admin)
      #=> [>save_the_world,>notify]
      #:delete-inspect end
=end

#~ignore end
    end
  end
end

module C
  class Before_DocsSequenceOptionsTest < Minitest::Spec
    it ":before" do
      Memo = A::Id_DocSeqOptionsTest::Memo

      #:before
      module Memo::Operation
        class Authorized < Memo::Operation::Create
          step :policy, before: :validate
          #~meths
          include T.def_steps(:policy)
          #~meths end
        end
      end
      #:before end

=begin
      #:before-inspect
      Trailblazer::Developer.railway(Memo::Operation::Authorized)
      #=> [>policy,>validate,>save_the_world,>notify]
      #:before-inspect end
=end

#~ignore end
    end

  end
end

module D
  class After_DocsSequenceOptionsTest < Minitest::Spec
    it ":after" do
      Memo = Class.new(A::Id_DocSeqOptionsTest::Memo)
      Memo::Operation = Module.new
      Memo::Operation::Create = Class.new(A::Id_DocSeqOptionsTest::Memo::Operation::Create)

      #:after
      module Memo::Operation
        class Authorized < Memo::Operation::Create
          step :policy, after: :validate
          #~meths
          include T.def_steps(:policy)
          #~meths end
        end
      end
      #:after end

=begin
      #:after-inspect
      Trailblazer::Developer.railway(Memo::Operation::Authorized)
      #=> [>validate,>policy,>save_the_world,>notify]
      #:after-inspect end
=end

#~ignore end
    end
  end
end

module E
  class Replace_DocsSequenceOptionsTest < Minitest::Spec
    Memo = Class.new
    module Memo::Operation
      class Create < Trailblazer::Operation
        step :validate
        step :save
        step :notify
        #~meths
        include T.def_steps(:validate, :save, :notify)
        #~meths end
      end
    end

    it "{:replace} automatically assigns ID" do
      #:replace
      module Memo::Operation
        class Update < Create
          step :update, replace: :save
          #~meths
          include T.def_steps(:update)
          #~meths end
        end

      end
      #:replace end

=begin
      #:replace-inspect
      Trailblazer::Developer.railway(Memo::Operation::Update)
      #=> [>validate,>update,>notify]
      #:replace-inspect end
=end
      assert Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Update, id: :update)

#~ignore end
    end
  end
end

#@ {#replace} with {:id}
module E_2
  class Replace_With_ID_DocsSequenceOptionsTest < Minitest::Spec
    Memo = Class.new
    module Memo::Operation
      class Create < Trailblazer::Operation
        step :validate
        step :save
        step :notify
        #~meths
        include T.def_steps(:validate, :save, :notify)
        #~meths end
      end
    end

    it "{:replace} allows explicit ID" do
      #:replace-id
      module Memo::Operation
        class Update < Create
          step :update, replace: :save, id: :update_memo
          #~meths
          include T.def_steps(:update)
          #~meths end
        end

      end
      #:replace-id end

      # assert_equal Trailblazer::Developer.railway(Memo::Operation::Update), %([>validate,>update_memo,>notify])

      Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Update, id: :update_memo)

#~ignore end
    end
  end
end
