You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.6 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'stream_entries/show.html.haml', without_verify_partial_doubles: true do
  4. before do
  5. double(:api_oembed_url => '')
  6. double(:account_stream_entry_url => '')
  7. allow(view).to receive(:show_landing_strip?).and_return(true)
  8. allow(view).to receive(:site_title).and_return('example site')
  9. allow(view).to receive(:site_hostname).and_return('example.com')
  10. allow(view).to receive(:full_asset_url).and_return('//asset.host/image.svg')
  11. allow(view).to receive(:local_time)
  12. allow(view).to receive(:local_time_ago)
  13. allow(view).to receive(:current_account).and_return(nil)
  14. assign(:instance_presenter, InstancePresenter.new)
  15. end
  16. it 'has valid author h-card and basic data for a detailed_status' do
  17. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  18. bob = Fabricate(:account, username: 'bob', display_name: 'Bob')
  19. status = Fabricate(:status, account: alice, text: 'Hello World')
  20. reply = Fabricate(:status, account: bob, thread: status, text: 'Hello Alice')
  21. assign(:status, status)
  22. assign(:stream_entry, status.stream_entry)
  23. assign(:account, alice)
  24. assign(:type, status.stream_entry.activity_type.downcase)
  25. assign(:descendant_threads, [])
  26. render
  27. mf2 = Microformats.parse(rendered)
  28. expect(mf2.entry.url.to_s).not_to be_empty
  29. expect(mf2.entry.author.name.to_s).to eq alice.display_name
  30. expect(mf2.entry.author.url.to_s).not_to be_empty
  31. end
  32. it 'has valid h-cites for p-in-reply-to and p-comment' do
  33. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  34. bob = Fabricate(:account, username: 'bob', display_name: 'Bob')
  35. carl = Fabricate(:account, username: 'carl', display_name: 'Carl')
  36. status = Fabricate(:status, account: alice, text: 'Hello World')
  37. reply = Fabricate(:status, account: bob, thread: status, text: 'Hello Alice')
  38. comment = Fabricate(:status, account: carl, thread: reply, text: 'Hello Bob')
  39. assign(:status, reply)
  40. assign(:stream_entry, reply.stream_entry)
  41. assign(:account, alice)
  42. assign(:type, reply.stream_entry.activity_type.downcase)
  43. assign(:ancestors, reply.stream_entry.activity.ancestors(1, bob))
  44. assign(:descendant_threads, [{ statuses: reply.stream_entry.activity.descendants(1) }])
  45. render
  46. mf2 = Microformats.parse(rendered)
  47. expect(mf2.entry.url.to_s).not_to be_empty
  48. expect(mf2.entry.comment.url.to_s).not_to be_empty
  49. expect(mf2.entry.comment.author.name.to_s).to eq carl.display_name
  50. expect(mf2.entry.comment.author.url.to_s).not_to be_empty
  51. expect(mf2.entry.in_reply_to.url.to_s).not_to be_empty
  52. expect(mf2.entry.in_reply_to.author.name.to_s).to eq alice.display_name
  53. expect(mf2.entry.in_reply_to.author.url.to_s).not_to be_empty
  54. end
  55. it 'has valid opengraph tags' do
  56. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  57. status = Fabricate(:status, account: alice, text: 'Hello World')
  58. assign(:status, status)
  59. assign(:stream_entry, status.stream_entry)
  60. assign(:account, alice)
  61. assign(:type, status.stream_entry.activity_type.downcase)
  62. assign(:descendant_threads, [])
  63. render
  64. header_tags = view.content_for(:header_tags)
  65. expect(header_tags).to match(%r{<meta content=".+" property="og:title" />})
  66. expect(header_tags).to match(%r{<meta content="article" property="og:type" />})
  67. expect(header_tags).to match(%r{<meta content=".+" property="og:image" />})
  68. expect(header_tags).to match(%r{<meta content="http://.+" property="og:url" />})
  69. end
  70. end