",
+ "\n",
)
end
diff --git a/spec/fixtures/onebox/title_no_description.response b/spec/fixtures/onebox/title_no_description.response
new file mode 100644
index 00000000000..5b40faf3acb
--- /dev/null
+++ b/spec/fixtures/onebox/title_no_description.response
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+ Discontinuation of Earning My Nintendo Gold Points | Nintendo Support
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb
index 1c4679583fc..95bd5d039e7 100644
--- a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb
+++ b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb
@@ -191,6 +191,30 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
describe "missing description" do
+ let(:url) { "https://en-americas-support.nintendo.com/app/answers/detail/a_id/67660" }
+ before do
+ stub_request(:get, url).to_return(status: 200, body: onebox_response("title_no_description"))
+ stub_request(
+ :get,
+ "https://en-americas-support.nintendo.com/app/answers/detail/a_id/67660/~/discontinuation-of-earning-my-nintendo-gold-points",
+ ).to_return(status: 200, body: onebox_response("title_no_description"))
+ stub_request(
+ :head,
+ "https://en-americas-support.nintendo.com/app/answers/detail/a_id/67660/~/discontinuation-of-earning-my-nintendo-gold-points",
+ ).to_return(status: 200, body: "")
+ end
+
+ it "shows a title-only onebox" do
+ onebox = described_class.new(url)
+ expect(onebox.to_html).not_to be_nil
+ end
+
+ it "does not consider this an error" do
+ onebox = described_class.new(url)
+ onebox.data
+ expect(onebox.errors.key?(:description)).to be(false)
+ end
+
context "when working without description if image is present" do
before do
stub_request(
diff --git a/spec/lib/oneboxer_spec.rb b/spec/lib/oneboxer_spec.rb
index d8b705f1b69..4b5b496a385 100644
--- a/spec/lib/oneboxer_spec.rb
+++ b/spec/lib/oneboxer_spec.rb
@@ -781,20 +781,13 @@ RSpec.describe Oneboxer do
let(:url) { "https://example.com/fake-url/" }
- it "handles a missing description" do
+ it "handles a missing description, title-only oneboxes are fine" do
stub_request(:get, url).to_return(body: response("missing_description"))
- expect(Oneboxer.preview(url, invalidate_oneboxes: true)).to include(
+ expect(Oneboxer.preview(url, invalidate_oneboxes: true)).not_to include(
"could not be found: description",
)
end
- it "handles a missing description and image" do
- stub_request(:get, url).to_return(body: response("missing_description_and_image"))
- expect(Oneboxer.preview(url, invalidate_oneboxes: true)).to include(
- "could not be found: description, image",
- )
- end
-
it "handles a missing image" do
# Note: If the only error is a missing image, we shouldn't return an error
stub_request(:get, url).to_return(body: response("missing_image"))