The `sign_in(nil)` method was a bit hard to understand IMHO. After all, in controller and system tests we don't have to specify no user is signed in; that's the default behavior. So we're making it the default behavior for component tests as well.
44 lines
1.3 KiB
Ruby
44 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
describe MachineLearning::CommentsSummaryComponent do
|
|
let(:commentable) { double(summary_comment: double(body: "There's a general agreement")) }
|
|
let(:component) { MachineLearning::CommentsSummaryComponent.new(commentable) }
|
|
|
|
before do
|
|
Setting["feature.machine_learning"] = true
|
|
Setting["machine_learning.comments_summary"] = true
|
|
end
|
|
|
|
it "is displayed when the setting is enabled" do
|
|
render_inline component
|
|
|
|
expect(page).to have_content "Comments summary"
|
|
expect(page).to have_content "There's a general agreement"
|
|
expect(page).to have_content "Content generated by AI / Machine Learning"
|
|
end
|
|
|
|
it "is not displayed when the setting is disabled" do
|
|
Setting["machine_learning.comments_summary"] = false
|
|
|
|
render_inline component
|
|
|
|
expect(page.native.inner_html).to be_empty
|
|
end
|
|
|
|
it "is not displayed when the machine learning feature is disabled" do
|
|
Setting["feature.machine_learning"] = false
|
|
|
|
render_inline component
|
|
|
|
expect(page.native.inner_html).to be_empty
|
|
end
|
|
|
|
it "is not displayed when there's no summary" do
|
|
commentable = double(summary_comment: double(body: ""))
|
|
|
|
render_inline MachineLearning::CommentsSummaryComponent.new(commentable)
|
|
|
|
expect(page.native.inner_html).to be_empty
|
|
end
|
|
end
|