tree_show_spec.rb 3.11 KB
Newer Older
1 2
# frozen_string_literal: true

Phil Hughes's avatar
Phil Hughes committed
3 4
require 'spec_helper'

5
describe 'Projects tree', :js do
Phil Hughes's avatar
Phil Hughes committed
6 7 8
  let(:user) { create(:user) }
  let(:project) { create(:project, :repository) }

9 10 11
  # This commit has a known state on the master branch of gitlab-test
  let(:test_sha) { '7975be0116940bf2ad4321f79d02a55c5f7779aa' }

Phil Hughes's avatar
Phil Hughes committed
12
  before do
13
    project.add_maintainer(user)
Phil Hughes's avatar
Phil Hughes committed
14
    sign_in(user)
15
  end
Phil Hughes's avatar
Phil Hughes committed
16

17
  it 'renders tree table without errors' do
18 19 20 21 22 23 24 25 26 27 28
    visit project_tree_path(project, test_sha)
    wait_for_requests

    expect(page).to have_selector('.tree-item')
    expect(page).to have_content('add tests for .gitattributes custom highlighting')
    expect(page).not_to have_selector('.flash-alert')
    expect(page).not_to have_selector('.label-lfs', text: 'LFS')
  end

  it 'renders tree table for a subtree without errors' do
    visit project_tree_path(project, File.join(test_sha, 'files'))
29
    wait_for_requests
Phil Hughes's avatar
Phil Hughes committed
30 31

    expect(page).to have_selector('.tree-item')
32
    expect(page).to have_content('add spaces in whitespace file')
Phil Hughes's avatar
Phil Hughes committed
33
    expect(page).not_to have_selector('.label-lfs', text: 'LFS')
34
    expect(page).not_to have_selector('.flash-alert')
Phil Hughes's avatar
Phil Hughes committed
35 36
  end

37 38 39 40 41 42 43
  context 'for signed commit' do
    it 'displays a GPG badge' do
      visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
      wait_for_requests

      expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
      expect(page).to have_selector '.gpg-status-box.invalid'
Phil Hughes's avatar
Phil Hughes committed
44 45
    end

46 47 48 49 50 51 52 53 54 55 56 57 58
    context 'on a directory that has not changed recently' do
      it 'displays a GPG badge' do
        tree_path = File.join('eee736adc74341c5d3e26cd0438bc697f26a7575', 'subdir')
        visit project_tree_path(project, tree_path)
        wait_for_requests

        expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
        expect(page).to have_selector '.gpg-status-box.invalid'
      end
    end
  end

  context 'LFS' do
Phil Hughes's avatar
Phil Hughes committed
59
    it 'renders LFS badge on blob item' do
60 61
      visit project_tree_path(project, File.join('master', 'files/lfs'))

Phil Hughes's avatar
Phil Hughes committed
62 63 64
      expect(page).to have_selector('.label-lfs', text: 'LFS')
    end
  end
65

66 67
  context 'web IDE' do
    it 'opens folder in IDE' do
68 69 70 71
      visit project_tree_path(project, File.join('master', 'bar'))

      click_link 'Web IDE'

72
      wait_for_requests
73
      find('.ide-file-list')
74 75
      wait_for_requests
      expect(page).to have_selector('.is-open', text: 'bar')
76
    end
77
  end
78

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
  context 'for subgroups' do
    let(:group) { create(:group) }
    let(:subgroup) { create(:group, parent: group) }
    let(:project) { create(:project, :repository, group: subgroup) }

    it 'renders tree table without errors' do
      visit project_tree_path(project, 'master')
      wait_for_requests

      expect(page).to have_selector('.tree-item')
      expect(page).not_to have_selector('.flash-alert')
    end

    context 'for signed commit' do
      it 'displays a GPG badge' do
        visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
        wait_for_requests

        expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
        expect(page).to have_selector '.gpg-status-box.invalid'
      end
100 101
    end
  end
Phil Hughes's avatar
Phil Hughes committed
102
end