Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Update and add specs

Mir Bhatiac1573fca2c80
diff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rb
index d92a4edc3f2..98614fd3f77 100644
--- a/app/components/enterprise_edition/banner_component.rb
+++ b/app/components/enterprise_edition/banner_component.rb
@@ -44,7 +44,7 @@ module EnterpriseEdition
VARIANT_OPTIONS = %i[inline medium large].freeze
# @param feature_key [Symbol, NilClass] The key of the feature to show the banner for.
- # @param variant [Symbol, NilClass] The variant of the banner comopnent.
+ # @param variant [Symbol, NilClass] The variant of the banner component.
# @param image [String, NilClass] Path to the image to show on the banner, or nil.
# Only applicable and required when variant is :medium.
# @param video [String, NilClass] Path to the video to show on the banner, or nil.
@@ -123,7 +123,8 @@ module EnterpriseEdition
@system_arguments[:classes],
"op-enterprise-banner",
@variant == :medium ? "op-enterprise-banner_medium" : nil,
- @variant == :large ? "op-enterprise-banner_large" : nil
+ @variant == :large ? "op-enterprise-banner_large" : nil,
+ trial_feature? ? "op-enterprise-banner_trial" : nil
)
end
diff --git a/spec/components/enterprise_edition/banner_component_spec.rb b/spec/components/enterprise_edition/banner_component_spec.rb
index 0731ac03bb2..59b0eb34c75 100644
--- a/spec/components/enterprise_edition/banner_component_spec.rb
+++ b/spec/components/enterprise_edition/banner_component_spec.rb
@@ -144,7 +144,7 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component do
context "when banner is dismissed" do
let(:preference) { build_stubbed(:user_preference) }
let(:user) { build_stubbed(:user, preference:) }
- let(:dismiss_key) { :some_enterprise_feature }
+ let(:dismiss_key) { "some_enterprise_feature" }
let(:component_args) { { dismissable: true } }
before do
@@ -164,7 +164,7 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component do
end
context "when using a custom dismiss_key" do
- let(:dismiss_key) { :foo }
+ let(:dismiss_key) { "foo" }
let(:component_args) { { dismiss_key:, dismissable: true } }
it_behaves_like "does not render the component"
@@ -295,4 +295,27 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component do
end
end
end
+
+ context "with a trial token" do
+ before do
+ allow(EnterpriseToken).to receive(:trialling?).and_return(true)
+ end
+
+ it_behaves_like "renders the component"
+
+ it "renders with trial overrides" do
+ render_component_in_mo
+
+ component = find_test_selector(component_test_selector)
+
+ expect(component[:class]).to include("op-enterprise-banner_trial")
+ expect(component[:class]).not_to include("op-enterprise-banner_medium")
+ expect(component[:class]).not_to include("op-enterprise-banner_large")
+
+ within(component) do
+ expect(page).to have_css(".op-enterprise-banner--close_icon")
+ expect(page).to have_content("Buy now")
+ end
+ end
+ end
end
diff --git a/spec/features/custom_fields/hierarchy_custom_field_spec.rb b/spec/features/custom_fields/hierarchy_custom_field_spec.rb
index c8bcd094e20..1306c8ee206 100644
--- a/spec/features/custom_fields/hierarchy_custom_field_spec.rb
+++ b/spec/features/custom_fields/hierarchy_custom_field_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe "custom fields of type hierarchy", :js do
let(:hierarchy_page) { Pages::CustomFields::HierarchyPage.new }
before do
- allow(EnterpriseToken).to receive(:allows_to?).and_return(true)
+ allow(EnterpriseToken).to receive_messages(allows_to?: true, trialling?: false)
login_as admin
end
diff --git a/spec/support/shared/with_ee.rb b/spec/support/shared/with_ee.rb
index 4c4f900e454..6787551dfa4 100644
--- a/spec/support/shared/with_ee.rb
+++ b/spec/support/shared/with_ee.rb
@@ -65,6 +65,7 @@ RSpec.configure do |config|
.to receive_messages(token_object: token_object_double,
available_features: allowed.to_a,
expired?: false,
+ trial?: false,
restrictions: {})
end
end