about summary refs log tree commit diff
path: root/spec/features/profile_spec.rb
blob: b6de3e9d155b610502b3cf4b697d1b02ab4e79cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# frozen_string_literal: true

require 'rails_helper'

feature 'Profile' do
  include ProfileStories

  given(:local_domain) { ENV['LOCAL_DOMAIN'] }

  background do
    as_a_logged_in_user
    with_alice_as_local_user
  end

  subject { page }

  scenario 'I can view Annes public account' do
    visit account_path('alice')

    is_expected.to have_title("alice (@alice@#{local_domain})")

    within('.public-account-header h1') do
      is_expected.to have_content("alice @alice@#{local_domain}")
    end

    bio_elem = first('.public-account-bio')
    expect(bio_elem).to have_content(alice_bio)
    # The bio has hashtags made clickable
    expect(bio_elem).to have_link('cryptology')
    expect(bio_elem).to have_link('science')
    # Nicknames are make clickable
    expect(bio_elem).to have_link('@alice')
    expect(bio_elem).to have_link('@bob')
    # Nicknames not on server are not clickable
    expect(bio_elem).not_to have_link('@pepe')
  end

  scenario 'I can change my account' do
    visit settings_profile_path
    fill_in 'Display name', with: 'Bob'
    fill_in 'Bio', with: 'Bob is silent'
    first('.btn[type=submit]').click
    is_expected.to have_content 'Changes successfully saved!'

    # View my own public profile and see the changes
    click_link "Bob @bob@#{local_domain}"

    within('.public-account-header h1') do
      is_expected.to have_content("Bob @bob@#{local_domain}")
    end
    expect(first('.public-account-bio')).to have_content('Bob is silent')
  end
end