Hello community,

here is the log from the commit of package yast2-registration for 
openSUSE:Factory checked in at 2020-01-30 09:40:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-registration (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-registration.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-registration"

Thu Jan 30 09:40:52 2020 rev:48 rq:768337 version:4.2.30

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-registration/yast2-registration.changes    
2020-01-24 14:11:16.430411711 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-registration.new.26092/yast2-registration.changes
 2020-01-30 09:41:41.481499435 +0100
@@ -1,0 +2,22 @@
+Wed Jan 29 14:26:12 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
+
+- Fix random building problems (bsc#1162122).
+- 4.2.30
+
+-------------------------------------------------------------------
+Tue Jan 28 16:19:45 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
+
+- Improves the online search mechanism (jsc#SLE-9109):
+  - Do not crash when a package does not belong to an addon.
+  - Display dependencies when enabling a module/extension.
+  - Handle multiple packages with the same name properly.
+  - Show an error when a package cannot be selected for
+    installation.
+  - After selecting a package, unselect the addon if it is not
+    needed anymore.
+  - Forces a minimal number of characters before performing the
+    search.
+  - Removes the 'Back' button.
+- 4.2.29
+
+-------------------------------------------------------------------

Old:
----
  yast2-registration-4.2.28.tar.bz2

New:
----
  yast2-registration-4.2.30.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-registration.spec ++++++
--- /var/tmp/diff_new_pack.rW6Vds/_old  2020-01-30 09:41:42.101499767 +0100
+++ /var/tmp/diff_new_pack.rW6Vds/_new  2020-01-30 09:41:42.105499768 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-registration
-Version:        4.2.28
+Version:        4.2.30
 Release:        0
 Summary:        YaST2 - Registration Module
 License:        GPL-2.0-only

++++++ yast2-registration-4.2.28.tar.bz2 -> yast2-registration-4.2.30.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/package/yast2-registration.changes 
new/yast2-registration-4.2.30/package/yast2-registration.changes
--- old/yast2-registration-4.2.28/package/yast2-registration.changes    
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/package/yast2-registration.changes    
2020-01-29 15:33:17.000000000 +0100
@@ -1,4 +1,26 @@
 -------------------------------------------------------------------
+Wed Jan 29 14:26:12 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
+
+- Fix random building problems (bsc#1162122).
+- 4.2.30
+
+-------------------------------------------------------------------
+Tue Jan 28 16:19:45 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
+
+- Improves the online search mechanism (jsc#SLE-9109):
+  - Do not crash when a package does not belong to an addon.
+  - Display dependencies when enabling a module/extension.
+  - Handle multiple packages with the same name properly.
+  - Show an error when a package cannot be selected for
+    installation.
+  - After selecting a package, unselect the addon if it is not
+    needed anymore.
+  - Forces a minimal number of characters before performing the
+    search.
+  - Removes the 'Back' button.
+- 4.2.29
+
+-------------------------------------------------------------------
 Thu Jan 23 11:58:16 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
 
 - Add support to perform online package searches through all the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/package/yast2-registration.spec 
new/yast2-registration-4.2.30/package/yast2-registration.spec
--- old/yast2-registration-4.2.28/package/yast2-registration.spec       
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/package/yast2-registration.spec       
2020-01-29 15:33:17.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-registration
-Version:        4.2.28
+Version:        4.2.30
 Release:        0
 Summary:        YaST2 - Registration Module
 License:        GPL-2.0-only
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/src/lib/registration/addon.rb 
new/yast2-registration-4.2.30/src/lib/registration/addon.rb
--- old/yast2-registration-4.2.28/src/lib/registration/addon.rb 2020-01-24 
10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/src/lib/registration/addon.rb 2020-01-29 
15:33:17.000000000 +0100
@@ -356,6 +356,17 @@
       !eula_url.to_s.strip.empty?
     end
 
+    # Returns all the dependencies
+    #
+    # Includes all dependencies in a recursive way.
+    #
+    # @return [Array<Addon>]
+    def dependencies
+      return [] if depends_on.nil?
+
+      [depends_on] + depends_on.dependencies
+    end
+
     def self.dump_addons
       # dump the downloaded data to a file for easier debugging,
       # avoid write failures when running as an unprivileged user (rspec tests)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/src/lib/registration/clients/online_search.rb 
new/yast2-registration-4.2.30/src/lib/registration/clients/online_search.rb
--- old/yast2-registration-4.2.28/src/lib/registration/clients/online_search.rb 
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/src/lib/registration/clients/online_search.rb 
2020-01-29 15:33:17.000000000 +0100
@@ -18,6 +18,7 @@
 # find current contact information at www.suse.com.
 
 require "yast"
+require "yast2/popup"
 require "registration/dialogs/online_search"
 require "registration/addon"
 require "registration/registration"
@@ -53,12 +54,14 @@
       # Sequence workflow aliases
       #
       # @see #find_addons
-      # @see #package_search
-      # @see #commit
+      # @see #search_packages
+      # @see #display_eula
+      # @see #register_addons
+      # @see #select_packages
       def workflow_aliases
         {
           "find_addons"     => ->() { find_addons },
-          "search"          => ->() { search_packages },
+          "search_packages" => ->() { search_packages },
           "display_eula"    => ->() { display_eula },
           "register_addons" => ->() { register_addons },
           "select_packages" => ->() { select_packages }
@@ -72,7 +75,8 @@
       #   1. Find the addons
       #   2. Search for packages (UI)
       #   3. Register the addons
-      #   4. Select the packages for installation
+      #   4. Display the EULA if needed
+      #   5. Select the packages for installation
       #
       # @return [Symbol] Sequence's result (:next or :abort)
       def run
@@ -80,9 +84,9 @@
           "ws_start"        => "find_addons",
           "find_addons"     => {
             abort: :abort,
-            next:  "search"
+            next:  "search_packages"
           },
-          "search"          => {
+          "search_packages" => {
             abort: :abort,
             next:  "display_eula"
           },
@@ -106,32 +110,50 @@
 
     private
 
+      # Find all available addons
+      #
+      # @return [:next]
       def find_addons
         ::Registration::Addon.find_all(registration)
         :next
       end
 
       # Opens the online search dialog
+      #
+      # @return [:next]
       def search_packages
         reset_selected_addons_cache!
         package_search_dialog.run
       end
 
-      # display EULAs for the selected addons
+      # Display EULAs for the selected addons
+      #
+      # @return [Symbol] User input (:next, :back, :abort)
+      #   or :next if there are not licenses to accept
+      #
       def display_eula
         return :next if selected_addons.empty?
         ::Registration::UI::AddonEulaDialog.run(selected_addons)
       end
 
+      # Registers addons
+      #
+      # @return [Symbol] User input (:next, :back, :abort)
+      #   or :next if there are not licenses to accept
       def register_addons
         return :next if selected_addons.empty?
         registration_ui.register_addons(selected_addons, {})
       end
 
+      # Selects packages for installation
+      #
+      # It displays an error when a package cannot be selected.
+      #
+      # @return [:next]
       def select_packages
         ::Registration::SwMgmt.select_addon_products
         package_search_dialog.selected_packages.each do |pkg|
-          Yast::Pkg.PkgInstall(pkg.name)
+          pkg_install_error_message(pkg.name) unless 
Yast::Pkg.PkgInstall(pkg.name)
         end
         :next
       end
@@ -159,6 +181,17 @@
       def reset_selected_addons_cache!
         @selected_addons = nil
       end
+
+      def pkg_install_error_message(name)
+        Yast2::Popup.show(
+          format(
+            # TRANSLATORS: 'name' is the package's name
+            _("Package %{name} could not be selected for installation."),
+            name: name
+          ),
+          headline: :error
+        )
+      end
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/src/lib/registration/dialogs/online_search.rb 
new/yast2-registration-4.2.30/src/lib/registration/dialogs/online_search.rb
--- old/yast2-registration-4.2.28/src/lib/registration/dialogs/online_search.rb 
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/src/lib/registration/dialogs/online_search.rb 
2020-01-29 15:33:17.000000000 +0100
@@ -61,6 +61,11 @@
         ret
       end
 
+      # @macro seeDialog
+      def back_button
+        ""
+      end
+
     private
 
       # Package search widget
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/src/lib/registration/package_search.rb 
new/yast2-registration-4.2.30/src/lib/registration/package_search.rb
--- old/yast2-registration-4.2.28/src/lib/registration/package_search.rb        
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/src/lib/registration/package_search.rb        
2020-01-29 15:33:17.000000000 +0100
@@ -59,6 +59,7 @@
 
         remote_packages = pkg["products"].map do |product|
           RemotePackage.new(
+            id:      pkg["id"],
             name:    pkg["name"],
             version: pkg["version"],
             release: pkg["release"],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/src/lib/registration/remote_package.rb 
new/yast2-registration-4.2.30/src/lib/registration/remote_package.rb
--- old/yast2-registration-4.2.28/src/lib/registration/remote_package.rb        
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/src/lib/registration/remote_package.rb        
2020-01-29 15:33:17.000000000 +0100
@@ -24,20 +24,24 @@
   #
   # @example Find the status
   class RemotePackage
-    attr_reader :name, :arch, :version, :release, :addon
+    attr_reader :id, :name, :arch, :version, :release, :addon
 
+    # @param id      [Integer] Package ID
     # @param name    [String] Package name
     # @param arch    [String] Architecture
     # @param version [String] Version number
     # @param release [String] Release number
     # @param addon   [Addon]  Addon which the package belongs to
-    def initialize(name:, arch:, version:, release:, addon:)
+    # rubocop:disable Metrics/ParameterLists
+    def initialize(id:, name:, arch:, version:, release:, addon:)
+      @id = id
       @name = name
       @arch = arch
       @version = version
       @release = release
       @addon = addon
     end
+    # rubocop:enable Metrics/ParameterLists
 
     def full_version
       "#{version}-#{release}"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/src/lib/registration/widgets/package_search.rb 
new/yast2-registration-4.2.30/src/lib/registration/widgets/package_search.rb
--- 
old/yast2-registration-4.2.28/src/lib/registration/widgets/package_search.rb    
    2020-01-24 10:26:17.000000000 +0100
+++ 
new/yast2-registration-4.2.30/src/lib/registration/widgets/package_search.rb    
    2020-01-29 15:33:17.000000000 +0100
@@ -23,8 +23,10 @@
 require "registration/widgets/remote_packages_table"
 require "registration/widgets/remote_package_details"
 require "registration/package_search"
+require "yast2/popup"
 
 Yast.import "Popup"
+Yast.import "HTML"
 
 module Registration
   module Widgets
@@ -138,12 +140,13 @@
       #
       # @param text [String] Text to search for
       def search_package(text)
+        return unless valid_search_text?(text)
         @search = ::Registration::PackageSearch.new(text: text)
         # TRANSLATORS: searching for packages
         Yast::Popup.Feedback(_("Searching..."), _("Searching for packages")) do
-          selected_package_names = @selected_packages.map(&:name)
+          selected_package_ids = selected_packages.map(&:id)
           @search.packages.each do |pkg|
-            pkg.select! if selected_package_names.include?(pkg.name)
+            pkg.select! if selected_package_ids.include?(pkg.id)
           end
         end
         packages_table.change_items(@search.packages)
@@ -155,7 +158,8 @@
       # @return [RemotePackage,nil]
       def find_current_package
         return unless search && packages_table.value
-        search.packages.find { |p| p.name == packages_table.value }
+        selected_id = packages_table.value
+        search.packages.find { |p| p.id == selected_id }
       end
 
       # Selects/unselects the current package for installation
@@ -177,20 +181,62 @@
 
       # Selects the current package for installation
       #
-      # If required, it selects the addon for registration.
+      # If required, it selects the corresponding addon
+      #
+      # @param package [RemotePackage] Package to select
       def select_package(package)
         addon = package.addon
-        return unless addon.registered? || addon.selected? || 
enable_addon?(addon)
-
-        addon.selected unless addon.registered? || addon.selected?
-        package.select!
-        @selected_packages << package
+        select_addon(addon) if addon
+        set_package_as_selected(package) if addon.nil? || addon.selected? || 
addon.registered?
       end
 
       # Unselects the current package for installation
+      #
+      # If not needed, unselects the corresponding addon
+      #
+      # @param package [RemotePackage] Package to unselect
+      #
+      # @see #unselect_addon
+      # @see #unselect_package!
       def unselect_package(package)
+        unset_package_as_selected(package)
+        unselect_addon(package.addon) if package.addon
+      end
+
+      # Selects the given addon if needed
+      #
+      # @param addon [Addon] Addon to select
+      def select_addon(addon)
+        return if addon.registered? || addon.selected? || addon.auto_selected?
+        addon.selected if enable_addon?(addon)
+      end
+
+      # Unselects the given addon if required
+      #
+      # @param addon [Addon] Addon to unselect
+      def unselect_addon(addon)
+        return if addon.registered? || needed_addon?(addon)
+        addon.unselected if disable_addon?(addon)
+      end
+
+      # Sets the package as selected
+      #
+      # Marks the package as selected and adds it to the list of selected 
packages.
+      #
+      # @param package [RemotePackage] Package to add
+      def set_package_as_selected(package)
+        package.select!
+        selected_packages << package
+      end
+
+      # Unsets the package as selected
+      #
+      # Marks the package as not selected and removes it from the list of 
selected packages.
+      #
+      # @param package [RemotePackage] Package to remove
+      def unset_package_as_selected(package)
         package.unselect!
-        @selected_packages.delete(package)
+        selected_packages.delete(package)
       end
 
       # Updates the package details widget
@@ -201,16 +247,73 @@
 
       # Asks the user to enable the addon
       #
-      # It omits the question if the addon is already registered or selected 
for registration.
-      #
       # @param addon [Addon] Addon to ask about
       def enable_addon?(addon)
+        description = Yast::HTML.Para(
+          format(
+            _("The selected package is provided by the '%{name}', " \
+              "which is not enabled on this system yet."),
+            name: addon.name
+          )
+        )
+
+        unselected_deps = addon.dependencies.reject { |d| d.selected? || 
d.registered? }
+        if !unselected_deps.empty?
+          description << Yast::HTML.Para(
+            format(
+              _("Additionally, '%{name}' depends on the following 
modules/extensions:"),
+              name: addon.name
+            )
+          )
+          description << Yast::HTML.List(unselected_deps.map(&:name))
+        end
+        # TRANSLATORS: 'it' and 'them' refers to the modules/extensions to 
enable
+        question = n_(
+          "Do you want to enable it?", "Do you want to enable them?", 
unselected_deps.size + 1
+        )
+        yes_no_popup(description + question)
+      end
+
+      # Asks the user to disable the addon
+      #
+      # @param addon [Addon] Addon to ask about
+      def disable_addon?(addon)
         message = format(
-          _("'%{name}' module/extension is not enabled for this system.\n" \
-            "Do you want to enable it?"),
+          _("The '%{name}' is not needed anymore.\n" \
+            "Do you want to unselect it?"),
           name: addon.name
         )
-        Yast::Popup.YesNo(message)
+        yes_no_popup(message)
+      end
+
+      MINIMAL_SEARCH_TEXT_SIZE = 2
+
+      # Determines whether the search text is valid or not
+      #
+      # @param text [String] Text to search for
+      def valid_search_text?(text)
+        return true if text.to_s.size >= MINIMAL_SEARCH_TEXT_SIZE
+        Yast2::Popup.show(
+          format(
+            # TRANSLATORS: the minimal size of the text to search for package 
names
+            _("Please, type at least %{minimal_size} characters to search 
for."),
+            minimal_size: MINIMAL_SEARCH_TEXT_SIZE
+          )
+        )
+        false
+      end
+
+      # Determines whether the addon is still needed
+      def needed_addon?(addon)
+        selected_packages.any? { |pkg| pkg.addon == addon }
+      end
+
+      # Asks a yes/no question
+      #
+      # @return [Boolean] true if the answer is affirmative; false otherwise
+      def yes_no_popup(message)
+        ret = Yast2::Popup.show(message, richtext: true, buttons: :yes_no)
+        ret == :yes
       end
     end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/src/lib/registration/widgets/remote_packages_table.rb
 
new/yast2-registration-4.2.30/src/lib/registration/widgets/remote_packages_table.rb
--- 
old/yast2-registration-4.2.28/src/lib/registration/widgets/remote_packages_table.rb
 2020-01-24 10:26:17.000000000 +0100
+++ 
new/yast2-registration-4.2.30/src/lib/registration/widgets/remote_packages_table.rb
 2020-01-29 15:33:17.000000000 +0100
@@ -52,19 +52,12 @@
         ]
       end
 
-      # Returns the selected item
-      #
-      # @return [RemotePackage]
-      def selected_item
-        items.find { |i| i.name == value }
-      end
-
       # Updates the information for the given package
       #
       # @param item [RemotePackage] Package to update
       def update_item(item)
         columns_for_item(item).each_with_index do |content, idx|
-          change_cell(Id(item.name), idx, content)
+          change_cell(Id(item.id), idx, content)
         end
       end
 
@@ -73,7 +66,7 @@
       # @see https://www.rubydoc.info/github/yast/yast-yast2/CWM%2FTable
       def format_items(items)
         items.map do |item|
-          columns = [Id(item.name)] + columns_for_item(item)
+          columns = [Id(item.id)] + columns_for_item(item)
           Item(*columns)
         end
       end
@@ -82,7 +75,11 @@
       #
       # @param item [RemotePackage]
       def columns_for_item(item)
-        [package_status(item), item.name, item.addon.name]
+        [
+          package_status(item),
+          item.name,
+          item.addon ? item.addon.name : ""
+        ]
       end
 
       # Package status indicator
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-registration-4.2.28/test/addon_spec.rb 
new/yast2-registration-4.2.30/test/addon_spec.rb
--- old/yast2-registration-4.2.28/test/addon_spec.rb    2020-01-24 
10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/test/addon_spec.rb    2020-01-29 
15:33:17.000000000 +0100
@@ -374,4 +374,26 @@
       expect(addon.to_h).to be_a(Hash)
     end
   end
+
+  describe "#dependencies" do
+    let(:registration) do
+      instance_double(
+        Registration::Registration,
+        activated_products: load_yaml_fixture("activated_products.yml"),
+        get_addon_list:     load_yaml_fixture("pure_addons.yml")
+      )
+    end
+
+    let(:addons) do
+      Registration::Addon.find_all(registration)
+    end
+
+    subject(:addon) do
+      addons.find { |a| a.identifier == "sle-ha-geo" }
+    end
+
+    it "returns all addon dependencies" do
+      expect(addon.dependencies.map(&:identifier)).to eq(["sle-ha"])
+    end
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/test/migration_repos_workflow_spec.rb 
new/yast2-registration-4.2.30/test/migration_repos_workflow_spec.rb
--- old/yast2-registration-4.2.28/test/migration_repos_workflow_spec.rb 
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/test/migration_repos_workflow_spec.rb 
2020-01-29 15:33:17.000000000 +0100
@@ -192,7 +192,7 @@
       end
 
       it "reports error and aborts when no installed product is found" do
-        expect(Registration::SwMgmt).to receive(:installed_products)
+        allow(Registration::SwMgmt).to receive(:installed_products)
           .and_return([])
         expect(Yast::Report).to receive(:Error)
 
@@ -201,7 +201,7 @@
 
       it "reports error and aborts when no migration is available" do
         # installed SLES12
-        expect(Registration::SwMgmt).to receive(:installed_products)
+        allow(Registration::SwMgmt).to receive(:installed_products)
           
.and_return([load_yaml_fixture("products_legacy_installation.yml")[1]])
         expect_any_instance_of(Registration::RegistrationUI).to 
receive(:migration_products)
           .and_return([])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/test/registration/clients/online_search_test.rb 
new/yast2-registration-4.2.30/test/registration/clients/online_search_test.rb
--- 
old/yast2-registration-4.2.28/test/registration/clients/online_search_test.rb   
    2020-01-24 10:26:17.000000000 +0100
+++ 
new/yast2-registration-4.2.30/test/registration/clients/online_search_test.rb   
    2020-01-29 15:33:17.000000000 +0100
@@ -41,9 +41,11 @@
       allow(Registration::Addon).to receive(:find_all)
       allow(Registration::Dialogs::OnlineSearch).to 
receive(:new).and_return(search_dialog)
       allow(Registration::RegistrationUI).to 
receive(:new).and_return(registration_ui)
+      allow(Registration::UI::AddonEulaDialog).to 
receive(:run).and_return(:next)
       allow(Registration::SwMgmt).to receive(:select_addon_products)
       allow(Registration::UrlHelpers).to receive(:registration_url)
         .and_return("https://scc.suse.com";) # speed up the test
+      allow(Yast::Pkg).to receive(:PkgInstall).and_return(true)
     end
 
     context "when an addon is selected" do
@@ -110,9 +112,20 @@
 
     context "when a package is selected" do
       it "selects the package for installation" do
-        expect(Yast::Pkg).to receive(:PkgInstall).with(package.name)
+        expect(Yast::Pkg).to 
receive(:PkgInstall).with(package.name).and_return(true)
         subject.run
       end
+
+      context "but the package is not found" do
+        before do
+          allow(Yast::Pkg).to receive(:PkgInstall).and_return(false)
+        end
+
+        it "warns the user" do
+          expect(Yast2::Popup).to receive(:show).with(/could not be selected/, 
headline: :error)
+          subject.run
+        end
+      end
     end
 
     context "when the user aborts the search" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/test/registration/remote_package_test.rb 
new/yast2-registration-4.2.30/test/registration/remote_package_test.rb
--- old/yast2-registration-4.2.28/test/registration/remote_package_test.rb      
2020-01-24 10:26:17.000000000 +0100
+++ new/yast2-registration-4.2.30/test/registration/remote_package_test.rb      
2020-01-29 15:33:17.000000000 +0100
@@ -24,7 +24,7 @@
 describe Registration::RemotePackage do
   subject(:package) do
     described_class.new(
-      name: "foobar", arch: :x86_64, version: "1.0", release: "1", addon: nil
+      id: 1, name: "foobar", arch: :x86_64, version: "1.0", release: "1", 
addon: nil
     )
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.2.28/test/registration/widgets/package_search_test.rb 
new/yast2-registration-4.2.30/test/registration/widgets/package_search_test.rb
--- 
old/yast2-registration-4.2.28/test/registration/widgets/package_search_test.rb  
    2020-01-24 10:26:17.000000000 +0100
+++ 
new/yast2-registration-4.2.30/test/registration/widgets/package_search_test.rb  
    2020-01-29 15:33:17.000000000 +0100
@@ -27,8 +27,8 @@
 
   let(:packages_table) do
     instance_double(
-      Registration::Widgets::RemotePackagesTable, value: package.name, 
change_items: nil,
-      update_item: nil, selected_item: package
+      Registration::Widgets::RemotePackagesTable, value: package.id,
+      change_items: nil, update_item: nil
     )
   end
 
@@ -38,7 +38,7 @@
 
   let(:package) do
     instance_double(
-      Registration::RemotePackage, name: "gnome-desktop", addon: addon,
+      Registration::RemotePackage, id: 1, name: "gnome-desktop", addon: addon,
       selected?: false, select!: nil, installed?: installed?
     )
   end
@@ -47,7 +47,8 @@
 
   let(:addon) do
     instance_double(
-      Registration::Addon, name: "desktop", registered?: false, selected?: 
false, selected: nil
+      Registration::Addon, name: "desktop", registered?: false, selected?: 
false,
+      auto_selected?: nil, selected: nil, unselected: nil, dependencies: []
     )
   end
 
@@ -66,9 +67,10 @@
   describe "#handle" do
     context "when the user asks for a package" do
       let(:event) { { "WidgetID" => "search_form_button" } }
+      let(:text) { "gnome" }
 
       let(:search_form) do
-        instance_double(Registration::Widgets::PackageSearchForm, text: 
"gnome")
+        instance_double(Registration::Widgets::PackageSearchForm, text: text)
       end
 
       before do
@@ -79,7 +81,7 @@
 
       it "searches for the package in SCC" do
         expect(Registration::PackageSearch).to receive(:new)
-          .with(text: "gnome").and_return(search)
+          .with(text: text).and_return(search)
         subject.handle(event)
       end
 
@@ -88,11 +90,76 @@
         expect(package_details).to receive(:update).with(package)
         subject.handle(event)
       end
+
+      context "when the search text is not enough" do
+        let(:text) { "g" }
+
+        it "asks the user to introduce some text" do
+          expect(Yast2::Popup).to receive(:show)
+            .with(/at least/)
+          subject.handle(event)
+        end
+      end
     end
 
     context "when a package is selected for installation" do
       let(:event) { { "WidgetID" => "remote_packages_table", "EventReason" => 
"Activated" } }
 
+      context "and the package is already selected" do
+        let(:package) do
+          instance_double(
+            Registration::RemotePackage, id: 1, name: "gnome-desktop", addon: 
addon,
+            selected?: true, unselect!: nil, installed?: false
+          )
+        end
+
+        it "unselects the package" do
+          allow(Yast2::Popup).to receive(:show).and_return(:yes)
+          expect(package).to receive(:unselect!)
+          subject.handle(event)
+        end
+
+        context "and the addon is still needed" do
+          let(:another_package) do
+            instance_double(Registration::RemotePackage, name: "eog", addon: 
addon)
+          end
+
+          before do
+            allow(subject).to receive(:selected_packages).and_return([package, 
another_package])
+            subject.handle(event)
+          end
+
+          it "does not unselect the addon" do
+            expect(addon).to_not receive(:unselected)
+            subject.handle(event)
+          end
+        end
+
+        context "and the addon is not needed anymore" do
+          before do
+            allow(Yast2::Popup).to receive(:show).and_return(unselect?)
+          end
+
+          context "and the user agrees to unselect it" do
+            let(:unselect?) { :yes }
+
+            it "unselects the addon" do
+              expect(addon).to receive(:unselected)
+              subject.handle(event)
+            end
+          end
+
+          context "and the user wants to keep the addon" do
+            let(:unselect?) { :no }
+
+            it "does not unselect the addon" do
+              expect(addon).to_not receive(:unselected)
+              subject.handle(event)
+            end
+          end
+        end
+      end
+
       context "and the addon is already registered" do
         before do
           allow(addon).to receive(:registered?).and_return(true)
@@ -106,11 +173,16 @@
 
       context "when the addon is not registered" do
         before do
-          allow(Yast::Popup).to receive(:YesNo).and_return(register?)
+          allow(Yast2::Popup).to receive(:show).and_return(register?)
+        end
+
+        let(:addon) do
+          pure_addon = load_yaml_fixture("pure_addons.yml").first
+          Registration::Addon.new(pure_addon)
         end
 
         context "but the user accepts to register the addon" do
-          let(:register?) { true }
+          let(:register?) { :yes }
 
           it "adds the package to the list of packages to install" do
             subject.handle(event)
@@ -124,7 +196,7 @@
         end
 
         context "and the user refuses to register the addon" do
-          let(:register?) { false }
+          let(:register?) { :no }
 
           it "does not add the package to the list of packages to install" do
             subject.handle(event)
@@ -144,7 +216,7 @@
         end
 
         it "does not ask about registering the addon" do
-          expect(Yast::Popup).to_not receive(:YesNo)
+          expect(Yast2::Popup).to_not receive(:show)
           subject.handle(event)
         end
 
@@ -155,6 +227,7 @@
       end
 
       it "updates the table and the package details" do
+        allow(Yast2::Popup).to receive(:show)
         expect(packages_table).to receive(:update_item).with(package)
         expect(package_details).to receive(:update).with(package)
         subject.handle(event)


Reply via email to