artifacts.rb 2.86 KB
Newer Older
1
class Spinach::Features::ProjectBuildsArtifacts < Spinach::FeatureSteps
2 3 4 5 6
  include SharedAuthentication
  include SharedProject
  include SharedBuilds
  include RepoHelpers

7
  step 'I click artifacts download button' do
Phil Hughes's avatar
Phil Hughes committed
8
    click_link 'Download'
9 10 11
  end

  step 'I click artifacts browse button' do
Phil Hughes's avatar
Phil Hughes committed
12
    click_link 'Browse'
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  end

  step 'I should see content of artifacts archive' do
    page.within('.tree-table') do
      expect(page).to have_no_content '..'
      expect(page).to have_content 'other_artifacts_0.1.2'
      expect(page).to have_content 'ci_artifacts.txt'
      expect(page).to have_content 'rails_sample.jpg'
    end
  end

  step 'I click link to subdirectory within build artifacts' do
    page.within('.tree-table') { click_link 'other_artifacts_0.1.2' }
  end

  step 'I should see content of subdirectory within artifacts archive' do
    page.within('.tree-table') do
      expect(page).to have_content '..'
      expect(page).to have_content 'another-subdirectory'
      expect(page).to have_content 'doc_sample.txt'
    end
  end
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

  step 'recent build artifacts contain directory with UTF-8 characters' do
    # metadata fixture contains relevant directory
  end

  step 'I navigate to directory with UTF-8 characters in name' do
    page.within('.tree-table') { click_link 'tests_encoding' }
    page.within('.tree-table') { click_link 'utf8 test dir ✓' }
  end

  step 'I should see content of directory with UTF-8 characters in name' do
    page.within('.tree-table') do
      expect(page).to have_content '..'
      expect(page).to have_content 'regular_file_2'
    end
  end

  step 'recent build artifacts contain directory with invalid UTF-8 characters' do
    # metadata fixture contains relevant directory
  end

  step 'I navigate to parent directory of directory with invalid name' do
    page.within('.tree-table') { click_link 'tests_encoding' }
  end

  step 'I should not see directory with invalid name on the list' do
    page.within('.tree-table') do
      expect(page).to have_no_content('non-utf8-dir')
    end
  end
65

66 67
  step 'I click a link to file within build artifacts' do
    page.within('.tree-table') { find_link('ci_artifacts.txt').click }
68 69 70
  end

  step 'download of a file extracted from build artifacts should start' do
71 72 73 74 75 76 77 78 79
    send_data = response_headers[Gitlab::Workhorse::SEND_DATA_HEADER]

    expect(send_data).to start_with('artifacts-entry:')

    params = JSON.parse(Base64.urlsafe_decode64(send_data[/(?<=:)(.+)/]))

    expect(params.keys).to eq(['Archive', 'Entry'])
    expect(params['Archive']).to end_with('build_artifacts.zip')
    expect(params['Entry']).to eq(Base64.encode64('ci_artifacts.txt'))
80
  end
81 82 83 84 85 86 87 88 89 90

  step 'I click a first row within build artifacts table' do
    row = first('tr[data-link]')
    @row_path = row['data-link']
    row.click
  end

  step 'page with a coresponding path is loading' do
    expect(current_path).to eq @row_path
  end
91
end