Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

add specs for rendering favicon link on the Storefront template

Łukasz Adamczyk4f95591a1b37
diff --git a/frontend/spec/features/template_rendering_spec.rb b/frontend/spec/features/template_rendering_spec.rb
index cc29744100..df0066d901 100644
--- a/frontend/spec/features/template_rendering_spec.rb
+++ b/frontend/spec/features/template_rendering_spec.rb
@@ -13,4 +13,35 @@ describe 'Template rendering', type: :feature do
visit spree.root_path
expect(find('link[rel=canonical]', visible: false)[:href]).to eql('http://spreestore.example.com/')
end
+
+ describe 'favicon link' do
+ let(:store) { Spree::Store.default }
+ let(:favicon_link) { find('link[rel="shortcut icon"]', visible: false) }
+
+ context 'when a store has its own favicon' do
+ let(:favicon_attachment) { Rack::Test::UploadedFile.new(file_fixture('store_favicon.ico')) }
+
+ before do
+ store.favicon_image.attach(favicon_attachment)
+ end
+
+ it 'builds a store favicon link' do
+ visit spree.root_path
+
+ expect(favicon_link[:type]).to eq('image/x-icon')
+ expect(favicon_link[:href]).to end_with('store_favicon.ico')
+
+ expect(URI.parse(favicon_link[:href]).host).to be_present
+ end
+ end
+
+ context 'when a store has no favicon' do
+ it 'builds a default favicon link' do
+ visit spree.root_path
+
+ expect(favicon_link[:type]).to eq('image/x-icon')
+ expect(favicon_link[:href]).to match(/assets\/favicon-.+\.ico/)
+ end
+ end
+ end
end
diff --git a/frontend/spec/fixtures/files/store_favicon.ico b/frontend/spec/fixtures/files/store_favicon.ico
new file mode 100644
index 0000000000..b5b89e3563
Binary files /dev/null and b/frontend/spec/fixtures/files/store_favicon.ico differ