diff --git a/library/general/src/lib/yast2/popup.rb b/library/general/src/lib/yast2/popup.rb
index 67d2f20ca..82bdad407 100644
--- a/library/general/src/lib/yast2/popup.rb
+++ b/library/general/src/lib/yast2/popup.rb
@@ -17,7 +17,7 @@ class Popup
class << self
include Yast::I18n
- # Number of lines for richtext: :auto to switch to richtext widget
+ # Number of lines to switch to richtext widget for richtext: false
LINES_THRESHOLD = 20
RICHTEXT_WIDTH = 60
diff --git a/library/general/test/yast2/popup_test.rb b/library/general/test/yast2/popup_test.rb
index 9e82cff56..68a058285 100755
--- a/library/general/test/yast2/popup_test.rb
+++ b/library/general/test/yast2/popup_test.rb
@@ -165,5 +165,114 @@
subject.show("test\n" * 50)
end
end
+
+ context "richtext parameter is true" do
+ it "always shows message in RichText widget" do
+ expect(ui).to receive(:OpenDialog) do |_opts, content|
+ widget = content.nested_find do |w|
+ w.is_a?(Yast::Term) &&
+ w.value == :RichText &&
+ w.params.include?("test")
+ end
+ expect(widget).to_not eq nil
+
+ true
+ end
+
+ subject.show("test", richtext: true)
+ end
+
+ it "interprets richtext tags" do
+ expect(ui).to receive(:OpenDialog) do |_opts, content|
+ widget = content.nested_find do |w|
+ w.is_a?(Yast::Term) &&
+ w.value == :RichText &&
+ w.params.include?("test")
+ end
+ expect(widget).to_not eq nil
+
+ true
+ end
+
+ subject.show("test", richtext: true)
+ end
+ end
+
+ context "headline parameter is non-empty" do
+ it "shows Heading with given text" do
+ expect(ui).to receive(:OpenDialog) do |_opts, content|
+ widget = content.nested_find do |w|
+ w.is_a?(Yast::Term) &&
+ w.value == :Heading &&
+ w.params.include?("Head")
+ end
+ expect(widget).to_not eq nil
+
+ true
+ end
+
+ subject.show("test", headline: "Head")
+ end
+ end
+
+ context "timeout parameter is non-zero" do
+ before do
+ allow(ui).to receive(:TimeoutUserInput).and_return(:cancel)
+ end
+
+ it "shows Stop button" do
+ expect(ui).to receive(:OpenDialog) do |_opts, content|
+ widget = content.nested_find do |w|
+ w.is_a?(Yast::Term) &&
+ w.value == :PushButton &&
+ w.params.include?("&Stop")
+ end
+ expect(widget).to_not eq nil
+
+ true
+ end
+
+ subject.show("test", timeout: 5)
+ end
+
+ it "shows remaining time" do
+ expect(ui).to receive(:OpenDialog) do |_opts, content|
+ widget = content.nested_find do |w|
+ w.is_a?(Yast::Term) &&
+ w.value == :Label &&
+ w.params.include?("5")
+ end
+ expect(widget).to_not eq nil
+
+ true
+ end
+
+ subject.show("test", timeout: 5)
+ end
+
+ it "update remaining time every second" do
+ expect(ui).to receive(:TimeoutUserInput).and_return(:timeout, :cancel).twice
+
+ expect(ui).to receive(:ChangeWidget)
+
+ subject.show("test", timeout: 5)
+ end
+ end
+
+ context "style parameter is set" do
+ it "pass style to Dialog options" do
+ expect(ui).to receive(:OpenDialog) do |opts, _content|
+ expect(opts).to eq Yast::Term.new(:opt, :warncolor)
+
+ true
+ end
+
+ subject.show("test", style: :warning)
+ end
+
+ it "raises ArgumentError if unknown value is passed" do
+ expect { subject.show("test", style: :unknown) }.to raise_error(ArgumentError)
+ end
+ end
end
end