diff --git a/service/lib/agama/software/manager.rb b/service/lib/agama/software/manager.rb index 68296ab1ef..9c2aeb8cf9 100644 --- a/service/lib/agama/software/manager.rb +++ b/service/lib/agama/software/manager.rb @@ -215,8 +215,8 @@ def patterns(filtered) patterns = patterns.select(&:user_visible) if filtered # only display the configured patterns - if product.user_patterns - patterns.select! {|p| product.user_patterns.include?(p.name)} + if product.user_patterns && filtered + patterns.select! { |p| product.user_patterns.include?(p.name) } end patterns diff --git a/service/lib/agama/software/product_builder.rb b/service/lib/agama/software/product_builder.rb index 7ee3d270ca..c048be304e 100644 --- a/service/lib/agama/software/product_builder.rb +++ b/service/lib/agama/software/product_builder.rb @@ -81,7 +81,7 @@ def product_data_from_config(id) optional_patterns: config.arch_elements_from( id, "software", "optional_patterns", property: :pattern ), - user_patterns: config.arch_elements_from( + user_patterns: config.arch_elements_from( id, "software", "user_patterns", property: :pattern, default: nil ) } diff --git a/service/test/agama/software/manager_test.rb b/service/test/agama/software/manager_test.rb index f899ab64b3..e55988a655 100644 --- a/service/test/agama/software/manager_test.rb +++ b/service/test/agama/software/manager_test.rb @@ -239,6 +239,60 @@ end end + describe "#patterns" do + it "returns only the specified patterns" do + expect(Y2Packager::Resolvable).to receive(:find).and_return( + double( + arch: "x86_64", + category: "Base Technologies", + description: "YaST tools for installing your system.", + icon: "./yast", + kind: :pattern, + name: "yast2_install_wf", + order: "1240", + source: 0, + summary: "YaST Installation Packages", + user_visible: false, + version: "20220411-1.4" + ), + double( + arch: "x86_64", + category: "Base Technologies", + description: "YaST tools for basic system administration.", + icon: "./yast", + kind: :pattern, + name: "yast2_basis", + order: "1220", + source: 0, + summary: "YaST Base Utilities", + user_visible: true, + version: "20220411-1.4" + ), + double( + arch: "noarch", + category: "Graphical Environments", + description: + "Packages providing the Plasma desktop environment and applications from KDE.", + icon: "./pattern-kde", + kind: :pattern, + name: "kde", + order: "1110", + source: 0, + summary: "KDE Applications and Plasma 5 Desktop", + user_visible: true, + version: "20230801-1.1" + ) + ) + + expect(config).to receive(:user_patterns).and_return(["kde"]) + patterns = subject.patterns(true) + + expect(patterns).to contain_exactly( + an_object_having_attributes(name: "kde") + ) + end + end + describe "#propose" do before do subject.select_product("Tumbleweed")