mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 19:06:12 +02:00
Add test
This commit is contained in:
parent
eb465221b8
commit
244f28caae
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user