<commit_before>require 'spec_helper'

feature 'project import', feature: true, js: true do
  include Select2Helper

  let(:user) { create(:admin) }
  let!(:namespace) { create(:namespace, name: "asd", owner: user) }
  let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
  let(:export_path) { "#{Dir::tmpdir}/import_file_spec" }
  background do
    allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
    login_as(user)
  end

  after(:each) do
    FileUtils.rm_rf(export_path, secure: true)
  end

  scenario 'user imports an exported project successfully' do
    expect(Project.all.count).to be_zero

    visit new_project_path

    select2('2', from: '#project_namespace_id')
    fill_in :project_path, with:'test-project-path', visible: true
    click_link 'GitLab project'

    expect(page).to have_content('GitLab project export')
    expect(URI.parse(current_url).query).to eq('namespace_id=2&path=test-project-path')

    attach_file('file', file)

    click_on 'Continue to the next step' # import starts

    expect(Project.last).not_to be_nil
    expect(Project.last.issues).not_to be_empty
    expect(Project.last.repo_exists?).to be true
  end
end
<commit_msg>added more tests to integration spec<commit_after>require 'spec_helper'

feature 'project import', feature: true, js: true do
  include Select2Helper

  let(:user) { create(:admin) }
  let!(:namespace) { create(:namespace, name: "asd", owner: user) }
  let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
  let(:export_path) { "#{Dir::tmpdir}/import_file_spec" }
  let(:project) { Project.last }
  background do
    allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
    login_as(user)
  end

  after(:each) do
    FileUtils.rm_rf(export_path, secure: true)
  end

  scenario 'user imports an exported project successfully' do
    expect(Project.all.count).to be_zero

    visit new_project_path

    select2('2', from: '#project_namespace_id')
    fill_in :project_path, with:'test-project-path', visible: true
    click_link 'GitLab project'

    expect(page).to have_content('GitLab project export')
    expect(URI.parse(current_url).query).to eq('namespace_id=2&path=test-project-path')

    attach_file('file', file)

    click_on 'Continue to the next step' # import starts

    expect(project).not_to be_nil
    expect(project.issues).not_to be_empty
    expect(project.merge_requests).not_to be_empty
    expect(project.repo_exists?).to be true
    expect(wiki_exists?).to be true
  end

  def wiki_exists?
    wiki = ProjectWiki.new(project)
    File.exists?(wiki.repository.path_to_repo) && !wiki.repository.empty?
  end
end

{'fraction_non_alphanumeric': 0.12836879432624113, 'fraction_numerical': 0.0028368794326241137, 'mean_word_length': 4.780737704918033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1459107', 'n_tokens_mistral': 946, 'n_tokens_neox': 910, 'n_words': 197}