From 35640040533ed56dad8ecdcfb207d862d11e9acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= Date: Wed, 14 Oct 2015 15:12:23 +0200 Subject: [PATCH] [ci][webui] Add test for saving project meta (issue#444) --- .../webui/project_controller_test.rb | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/api/test/functional/webui/project_controller_test.rb b/src/api/test/functional/webui/project_controller_test.rb index d37ebd21c58..8eb0b61271b 100644 --- a/src/api/test/functional/webui/project_controller_test.rb +++ b/src/api/test/functional/webui/project_controller_test.rb @@ -245,6 +245,56 @@ def test_add_and_modify_repo :tag => "arch", :content => "x86_64" end + def test_save_meta + use_js + + login_adrian + visit(project_show_path(project: "home:adrian")) + + # Test reading meta data + click_link("Advanced") + click_link("Meta") + # Note that textarea#editor_0 is a hidden element. + # This isn't ideal for a test, but best we can do to test this part of the ui + assert find(:css, "textarea#editor_0", visible: false). + text(:all).include?("adrian's Home Project") + + # Test writing valid meta data + xml = <<-XML.gsub(/(?:\s*\n|^\s*)/, '') # evaluate_script fails otherwise + + My Home Project + + + +XML + # Workaround. There doesn't seem to be a way to change stored meta content via the textarea. + page.evaluate_script("editors[0].setValue(\"#{xml}\");") + click_button("Save") + find(:id, 'flash-messages').must_have_text("Config successfully saved!") + click_link("Meta") + assert_equal " My Home Project " + + " ", + find(:css, "textarea#editor_0", visible: false).text(:all) + + # test writing invalid meta data + xml = " My Home Project" + page.evaluate_script("editors[0].setValue(\"#{xml}\");") + click_button("Save") + find(:id, 'flash-messages').must_have_text("project validation error: expected '>'") + + xml = "My Home Project" + page.evaluate_script("editors[0].setValue(\"#{xml}\");") + click_button("Save") + find(:id, 'flash-messages'). + must_have_text("project validation error: Expecting an element description, got nothing") + + # Trigger data reload and verify that nothing was saved + click_link("Meta") + assert_equal " My Home Project " + + " ", + find(:css, "textarea#editor_0", visible: false).text(:all) + end + def test_project_repositories_uniq_archs use_js login_tom