diff --git a/test/system/source_and_output_test.rb b/test/system/source_and_output_test.rb
index 3a6689d..d11be11 100644
--- a/test/system/source_and_output_test.rb
+++ b/test/system/source_and_output_test.rb
@@ -177,4 +177,157 @@ class SourceAndOutputTest < ApplicationSystemTestCase
end
end
end
+
+ sub_test_case "filter" do
+ setup do
+ config = <<-CONFIG.strip_heredoc
+
+ @type dummy
+ tag debug.*
+
+
+
+ @type stdout
+
+
+
+ # http://docs.fluentd.org/articles/out_stdout
+ type stdout
+
+ CONFIG
+ @daemon.agent.config_write(config)
+ visit(source_and_output_daemon_setting_path)
+ end
+
+ test "elements" do
+ assert_equal(first(".filter .card .card-header").text, "stdout (debug.*)")
+ end
+ end
+
+ sub_test_case "label" do
+ setup do
+ @config = <<-CONFIG.strip_heredoc
+
+ @type dummy
+ tag debug.*
+ @label @INPUT
+
+
+
+ CONFIG
+ @daemon.agent.config_write(@config)
+ visit(source_and_output_daemon_setting_path)
+ end
+
+ test "elements under @INPUT" do
+ assert do
+ all(".input h5").map(&:text).include?("@INPUT")
+ end
+ assert_equal(first(".input .card .card-header").text, "dummy")
+ assert do
+ all(".filter h5").map(&:text).include?("@INPUT")
+ end
+ assert_equal(first(".filter .card .card-header").text, "grep (debug.*)")
+ assert do
+ all(".output h5").map(&:text).include?("@INPUT")
+ end
+ assert_equal(first(".output .card .card-header").text, "stdout (debug.*)")
+ end
+
+ test "click delete button" do
+ assert do
+ find(".filter .card-header").click
+ end
+ page.accept_confirm do
+ find(".filter .btn", text: I18n.t("terms.destroy")).click
+ end
+ within(".filter .empty") do
+ assert do
+ has_content?(I18n.t("fluentd.settings.source_and_output.setting_empty"))
+ end
+ end
+ end
+
+ test "click edit and cancel" do
+ config = <<-CONFIG.strip_heredoc
+
+ @type grep
+
+ key message
+ pattern /debug.+/
+
+
+ CONFIG
+ new_config = <<-CONFIG.strip_heredoc
+
+ @type grep
+
+ key message
+ pattern /debug2.+/
+
+
+ CONFIG
+ assert do
+ find(".filter .card-header").click
+ end
+ find(".filter .btn", text: I18n.t("terms.edit")).click
+ original_contents = page.evaluate_script(%Q!document.querySelector(".CodeMirror").CodeMirror.getValue()!)
+ assert_equal(original_contents, config)
+ page.execute_script(<<-JS)
+ var cm = document.querySelector('.CodeMirror').CodeMirror;
+ cm.setValue(#{new_config.to_json});
+ JS
+ find(".filter .btn", text: I18n.t("terms.cancel")).click
+ contents = page.evaluate_script("document.querySelector('.filter pre').textContent")
+ assert_equal(contents, config)
+ assert_equal(@daemon.agent.config.strip, @config.strip)
+ end
+
+ test "click edit and save" do
+ config = <<-CONFIG.strip_heredoc
+
+ @type grep
+
+ key message
+ pattern /debug.+/
+
+
+ CONFIG
+ new_config = <<-CONFIG.strip_heredoc
+
+ @type grep
+
+ key message
+ pattern /debug2.+/
+
+
+ CONFIG
+ assert do
+ find(".filter .card-header").click
+ end
+ find(".filter .btn", text: I18n.t("terms.edit")).click
+ original_contents = page.evaluate_script(%Q!document.querySelector(".CodeMirror").CodeMirror.getValue()!)
+ assert_equal(original_contents, config)
+ page.execute_script(<<-JS)
+ var cm = document.querySelector('.CodeMirror').CodeMirror;
+ cm.setValue(#{new_config.to_json});
+ JS
+ find(".filter .btn", text: I18n.t("terms.save")).click
+ sleep(1)
+ contents = page.evaluate_script("document.querySelector('.filter pre').textContent")
+ assert_equal(new_config, contents)
+ end
+ end
end