This commit is contained in:
uu59 2014-11-26 16:13:20 +09:00
parent eb465221b8
commit 244f28caae
2 changed files with 68 additions and 0 deletions

View File

@ -89,4 +89,60 @@ describe "source_and_output", js: true do
end
end
end
describe "edit, update, delete" do
let(:config_contents) { <<-CONF.strip_heredoc }
<source>
type forward
port 24224
</source>
CONF
let(:new_config) { <<-CONF.strip_heredoc }
<source>
type http
port 8899
</source>
CONF
before do
all(".input .panel .panel-heading").first.click
end
it "click edit button transform textarea, then click cancel button to be reset" do
page.should_not have_css('.input textarea')
find(".btn", text: I18n.t('terms.edit')).click
page.should have_css('.input textarea')
find('.input textarea').value.should == config_contents
find('.input textarea').set "foo"
find(".btn", text: I18n.t('terms.cancel')).click
content = wait_until do
page.evaluate_script("document.querySelector('.input pre').textContent")
end
content.should == config_contents
daemon.agent.config.strip.should == config_contents.strip
end
it "click edit button transform textarea, then click update button to be stored" do
page.should_not have_css('.input textarea')
find(".btn", text: I18n.t('terms.edit')).click
page.should have_css('.input textarea')
find('.input textarea').value.should == config_contents
find('.input textarea').set new_config
find(".btn", text: I18n.t('terms.update')).click
content = wait_until do
page.evaluate_script("document.querySelector('.input pre').textContent")
end
content.should == new_config
daemon.agent.config.strip.should == new_config.strip
end
it "click delete button transform textarea" do
page.should have_css('.input .panel-body')
page.execute_script "__backup = window.confirm; window.confirm = function(){return true;}"
find(".btn", text: I18n.t('terms.destroy')).click
page.should_not have_css('.input .panel-body')
page.execute_script "window.confirm = __backup;"
daemon.agent.config.strip.should == ""
end
end
end

View File

@ -34,6 +34,18 @@ RSpec.configure do |config|
# Syntax sugar to use the FactoryGirl methods directly instead FactoryGirl.create ete.
config.include FactoryGirl::Syntax::Methods
config.include LoginMacro
def wait_until(seconds = 5, &block)
timeout(seconds) do
loop do
begin
ret = block.call
break ret if ret
rescue Capybara::Poltergeist::JavascriptError
end
sleep 0.01
end
end
end
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of