<commit_before>require File.expand_path(File.dirname(__FILE__) + '/common')

def visit_page
  get "/courses/#{@course.id}/content_migrations"
  wait_for_ajaximations
end

def select_migration_type(type=nil)
  type ||= @type
  click_option('#chooseMigrationConverter', type, :value)
end

def select_migration_file(opts={})
  filename = opts[:filename] || @filename

  new_filename, fullpath, data = get_file(filename, opts[:data])
  f('#migrationFileUpload').send_keys(fullpath)
  return new_filename
end

def fill_migration_form(opts={})
  select_migration_type(opts[:type])
  select_migration_file(opts)
end

def submit
  submit_btn = f('#submitMigration')
  submit_btn.click
  keep_trying_until { f('#migrationFileUpload').blank? }
end

def run_migration(cm=nil)
  cm ||= @course.content_migrations.last
  cm.reload
  worker_class = Canvas::Migration::Worker.const_get(Canvas::Plugin.find(cm.migration_type).settings['worker'])
  worker_class.new(cm.id).perform
end

def import(cm=nil)
  cm ||= @course.content_migrations.last
  cm.reload
  cm.set_default_settings
  cm.import_content
end

def test_selective_content(source_course=nil)
  visit_page

  f('.migrationProgressItem .progressStatus').should include_text("Waiting for select")
  f('.migrationProgressItem .selectContentBtn').click
  wait_for_ajaximations

  topic_id = "I_00009_R"
  att_ids = ["I_00003_R_IMAGERESOURCE", "6a35b0974f59819404dc86d48fe39fc3", "7acb90d1653008e73753aa2cafb16298", "f5",
             "8612e3db71e452d5d2952ff64647c0d8", "f4", "f3", "I_media_R", "I_00006_Media", "I_00001_R"]
  # these attachments are inside the folder we'll deselect
  selected_att_ids = att_ids - ["6a35b0974f59819404dc86d48fe39fc3", "7acb90d1653008e73753aa2cafb16298", "I_00003_R_IMAGERESOURCE"]<commit_msg>spec: fix failing content migration selenium spec<commit_after>require File.expand_path(File.dirname(__FILE__) + '/common')

def visit_page
  get "/courses/#{@course.id}/content_migrations"
  wait_for_ajaximations
end

def select_migration_type(type=nil)
  type ||= @type
  click_option('#chooseMigrationConverter', type, :value)
end

def select_migration_file(opts={})
  filename = opts[:filename] || @filename

  new_filename, fullpath, data = get_file(filename, opts[:data])
  f('#migrationFileUpload').send_keys(fullpath)
  return new_filename
end

def fill_migration_form(opts={})
  select_migration_type(opts[:type])
  select_migration_file(opts)
end

def submit
  submit_btn = fj('#submitMigration')
  submit_btn.click
  keep_trying_until { fj('#migrationFileUpload').blank? }
end

def run_migration(cm=nil)
  cm ||= @course.content_migrations.last
  cm.reload
  worker_class = Canvas::Migration::Worker.const_get(Canvas::Plugin.find(cm.migration_type).settings['worker'])
  worker_class.new(cm.id).perform
end

def import(cm=nil)
  cm ||= @course.content_migrations.last
  cm.reload
  cm.set_default_settings
  cm.import_content
end

def test_selective_content(source_course=nil)
  visit_page

  f('.migrationProgressItem .progressStatus').should include_text("Waiting for select")
  f('.migrationProgressItem .selectContentBtn').click
  wait_for_ajaximations

  topic_id = "I_00009_R"
  att_ids = ["I_00003_R_IMAGERESOURCE", "6a35b0974f59819404dc86d48fe39fc3", "<KEY>", "f5",
             "8612e3db71e452d5d2952ff64647c0d8", "f4", "f3", "I_media_R", "I_00006_Media", "I_00001_R"]
  # these attachments are inside the folder we'll deselect
  selected_att_ids = att_ids - ["6a35b0974f59819404dc86d48fe39fc3", "7acb90d1653008e73753aa2cafb16298", "I_00003_R_IMAGERESOURCE"]
{'fraction_non_alphanumeric': 0.11988716502115655, 'fraction_numerical': 0.07080394922425952, 'mean_word_length': 6.691973969631237, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4926120', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1306, 'n_words': 201}