<commit_before>def create_artefact
  Factory.create :artefact, :name => 'Child Benefit rates'
end

def create_two_artefacts
  [
    'Probation',
    'Leaving prison'
  ].map { |name| Factory.create :artefact, :name => name }
end

def create_six_artefacts
  [
    'Driving disqualifications',
    'Book the practical driving test',
    'Driving before your licence is returned',
    'National Driver Offender Retraining Scheme',
    'Apply for a new driving licence',
    'Get a divorce'
  ].map { |name| Factory.create :artefact, :name => name }
end

def add_related_artefact(artefact, related_artefact)
  artefact.related_items.create! :artefact => related_artefact, :sort_key => (artefact.related_items.maximum(:sort_key) || -1) + 1
end

def add_related_artefacts(artefact, related_artefacts)
  related_artefacts.each do |related_artefact|
    add_related_artefact artefact, related_artefact
  end
end

def select_related_artefact(artefact)
  select_within 'Related items', artefact.name
end

def unselect_related_artefact(artefact)
  unselect_within 'Related items', artefact.name
end

def select_related_artefacts(artefacts)
  artefacts.each(&method(:select_related_artefact))
end

def submit_artefact_form<commit_msg>:need_ids are now required (but not unique) in future need_ids should be unique, but for now, this fixes the test and replicates actual behaviour<commit_after>def create_artefact
  Factory.create :artefact, :name => 'Child Benefit rates', :need_id => 1
end

def create_two_artefacts
  [
    'Probation',
    'Leaving prison'
  ].map { |name| Factory.create :artefact, :name => name, :need_id => 1 }
end

def create_six_artefacts
  [
    'Driving disqualifications',
    'Book the practical driving test',
    'Driving before your licence is returned',
    'National Driver Offender Retraining Scheme',
    'Apply for a new driving licence',
    'Get a divorce'
  ].map { |name| Factory.create :artefact, :name => name, :need_id => 1 }
end

def add_related_artefact(artefact, related_artefact)
  artefact.related_items.create! :artefact => related_artefact, :sort_key => (artefact.related_items.maximum(:sort_key) || -1) + 1
end

def add_related_artefacts(artefact, related_artefacts)
  related_artefacts.each do |related_artefact|
    add_related_artefact artefact, related_artefact
  end
end

def select_related_artefact(artefact)
  select_within 'Related items', artefact.name
end

def unselect_related_artefact(artefact)
  unselect_within 'Related items', artefact.name
end

def select_related_artefacts(artefacts)
  artefacts.each(&method(:select_related_artefact))
end

def submit_artefact_form
{'fraction_non_alphanumeric': 0.09118657001144602, 'fraction_numerical': 0.002670736360167875, 'mean_word_length': 5.3180722891566266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '5603320', 'n_tokens_mistral': 870, 'n_tokens_neox': 881, 'n_words': 226}