<commit_before>describe('Opportunities', () => {
  before(() => {
    cy.setupRegion('scratch')
  })

  beforeEach(() => {
    cy.fixture('regions/scratch.json').as('region')
    cy.navTo(/Opportunity datasets/i)
    cy.get('div.leaflet-container').as('map')
  })

  it('can be uploaded as CSV', function () {
    let opportunity = this.region.opportunities.csv
    let oppName = opportunity.name + ' ' + Date.now()
    let expectedFieldCount = 1 + opportunity.numericFields.length
    cy.findByText(/Upload a new dataset/i).click()
    cy.location('pathname').should('match', /\/opportunities\/upload$/)
    cy.findByPlaceholderText(/^Opportunity dataset/i).type(oppName)
    cy.findByLabelText(/^Select opportunity dataset/i).attachFile(
      opportunity.file
    )
    cy.findByLabelText(/Latitude/).type(opportunity.latitudeField)
    cy.findByLabelText(/Longitude/).type(opportunity.longitudeField)
    cy.get('a.btn')
      .contains(/Upload/)
      .should('not.be.disabled')
      .click()
    cy.location('pathname').should('match', /opportunities$/)
    // find the message showing this upload is complete
    cy.contains(new RegExp(oppName + ' \\(DONE\\)'), {timeout: 10000})
      .parent()
      .parent()
      .as('notice')
    // check number of fields uploaded
    cy.get('@notice').contains(
      `Finished uploading ${expectedFieldCount} features`
    )
    // close the message
    cy.get('@notice').findByRole('button', /x/).click()
    // select in the dropdown
    cy.findByText(/Select\.\.\./)
      .click()
      .type(`${oppName}: ${opportunity.numericFields[0]} {enter}`)
    // look at the map
    //cy.waitForMapToLoad()
    //cy.get('@map').matchImageSnapshot('csv-' + opportunity.name)
    //
    cy.contains(/Delete entire dataset/i).click()
  })

  it('can be uploaded as shapefile', function () {
    let opportunity = this.region.opportunities.shapefile
    let oppName = opportunity.name + ' ' + Date.now()
    let expectedFieldCount = opportunity.numericFields.length
    cy.findByText(/Upload a new dataset/i).click()
    cy.location('pathname').should('match', /\/opportunities\/upload$/)
    cy.findByPlaceholderText(/^Opportunity dataset/i).type(oppName)
    cy.findByLabelText(/Select opportunity dataset/)
      .attachFile({filePath: opportunity.files[0], encoding: 'base64'})
      .attachFile({filePath: opportunity.files[1], encoding: 'base64'})
      .attachFile({filePath: opportunity.files[2], encoding: 'base64'})
      .attachFile({filePath: opportunity.files[3], encoding: 'base64'})
    cy.get('a.btn')
      .contains(/Upload/)
      .should('not.be.disabled')
      .click()
    cy.location('pathname').should('match', /opportunities$/)
    // find the message showing this upload is complete
    cy.contains(new RegExp(oppName + ' \\(DONE\\)'), {timeout: 30000})
      .parent()
      .parent()
      .as('notice')
    // check number of fields uploaded
    cy.get('@notice').contains(
      `Finished uploading ${expectedFieldCount} features`
    )
    // close the message
    cy.get('@notice').findByRole('button', /x/).click()
    // select in the dropdown
    cy.findByText(/Select\.\.\./)
      .click()
      .type(`${oppName}: ${opportunity.numericFields[0]} {enter}`)
    cy.contains(/Delete entire dataset/i).click()
  })

  it('can be uploaded as grid', function () {
    let opportunity = this.region.opportunities.grid
    let oppName =
      Cypress.env('dataPrefix') + opportunity.name + ' ' + Date.now()
    cy.findByText(/Upload a new dataset/i).click()
    cy.location('pathname').should('match', /\/opportunities\/upload$/)
    cy.findByPlaceholderText(/^Opportunity dataset/i).type(oppName)
    cy.findByLabelText(/Select opportunity dataset/).attachFile({
      filePath: opportunity.file,
      encoding: 'base64'
    })
    cy.get('a.btn')
      .contains(/Upload/)
      .should('not.be.disabled')
      .click()
    cy.location('pathname').should('match', /opportunities$/)
    // find the message showing this upload is complete
    cy.contains(new RegExp(oppName + ' \\(DONE\\)'), {timeout: 10000})
      .parent()
      .parent()
      .as('notice')
    // check number of fields uploaded
    cy.get('@notice').contains(/Finished uploading 1 feature/i)
    // close the message
    cy.get('@notice').findByRole('button', /x/).click()
    // select in the dropdown
    cy.findByText(/Select\.\.\./)
      .click()
      .type(`${oppName} {enter}`)
    cy.contains(/Delete entire dataset/i).click()
  })

  it('can be downloaded as grid', function () {
    // TODO
  })

  it('can be downloaded as tiff', function () {
    // TODO
  })

  after(() => {
    cy.log('after!')
    // TODO probably will want to clean up here and delete anything imported
  })
})<commit_msg>use name prefixes<commit_after>describe('Opportunities', () => {
  before(() => {
    cy.setupRegion('scratch')
  })

  beforeEach(() => {
    cy.fixture('regions/scratch.json').as('region')
    cy.navTo(/Opportunity datasets/i)
    cy.get('div.leaflet-container').as('map')
  })

  after(() => {
    // TODO check that everything imported by these tests has been deleted
    // can look for the '_temp' suffix
  })

  it('can be uploaded as CSV', function () {
    let opportunity = this.region.opportunities.csv
    let oppName = Cypress.env('dataPrefix') + opportunity.name + '_temp'
    let expectedFieldCount = 1 + opportunity.numericFields.length
    cy.findByText(/Upload a new dataset/i).click()
    cy.location('pathname').should('match', /\/opportunities\/upload$/)
    cy.findByPlaceholderText(/^Opportunity dataset/i).type(oppName)
    cy.findByLabelText(/^Select opportunity dataset/i).attachFile(
      opportunity.file
    )
    cy.findByLabelText(/Latitude/).type(opportunity.latitudeField)
    cy.findByLabelText(/Longitude/).type(opportunity.longitudeField)
    cy.get('a.btn')
      .contains(/Upload/)
      .should('not.be.disabled')
      .click()
    cy.location('pathname').should('match', /opportunities$/)
    // find the message showing this upload is complete
    cy.contains(new RegExp(oppName + ' \\(DONE\\)'), {timeout: 10000})
      .parent()
      .parent()
      .as('notice')
    // check number of fields uploaded
    cy.get('@notice').contains(
      `Finished uploading ${expectedFieldCount} features`
    )
    // close the message
    cy.get('@notice').findByRole('button', /x/).click()
    // select in the dropdown
    cy.findByText(/Select\.\.\./)
      .click()
      .type(`${oppName}: ${opportunity.numericFields[0]} {enter}`)
    // look at the map
    //cy.waitForMapToLoad()
    //cy.get('@map').matchImageSnapshot('csv-' + opportunity.name)
    //
    cy.contains(/Delete entire dataset/i).click()
  })

  it('can be uploaded as shapefile', function () {
    let opportunity = this.region.opportunities.shapefile
    let oppName = Cypress.env('dataPrefix') + opportunity.name + '_temp'
    let expectedFieldCount = opportunity.numericFields.length
    cy.findByText(/Upload a new dataset/i).click()
    cy.location('pathname').should('match', /\/opportunities\/upload$/)
    cy.findByPlaceholderText(/^Opportunity dataset/i).type(oppName)
    cy.findByLabelText(/Select opportunity dataset/)
      .attachFile({filePath: opportunity.files[0], encoding: 'base64'})
      .attachFile({filePath: opportunity.files[1], encoding: 'base64'})
      .attachFile({filePath: opportunity.files[2], encoding: 'base64'})
      .attachFile({filePath: opportunity.files[3], encoding: 'base64'})
    cy.get('a.btn')
      .contains(/Upload/)
      .should('not.be.disabled')
      .click()
    cy.location('pathname').should('match', /opportunities$/)
    // find the message showing this upload is complete
    cy.contains(new RegExp(oppName + ' \\(DONE\\)'), {timeout: 30000})
      .parent()
      .parent()
      .as('notice')
    // check number of fields uploaded
    cy.get('@notice').contains(
      `Finished uploading ${expectedFieldCount} features`
    )
    // close the message
    cy.get('@notice').findByRole('button', /x/).click()
    // select in the dropdown
    cy.findByText(/Select\.\.\./)
      .click()
      .type(`${oppName}: ${opportunity.numericFields[0]} {enter}`)
    cy.contains(/Delete entire dataset/i).click()
  })

  it('can be uploaded as grid', function () {
    let opportunity = this.region.opportunities.grid
    let oppName = Cypress.env('dataPrefix') + opportunity.name + '_temp'
    cy.findByText(/Upload a new dataset/i).click()
    cy.location('pathname').should('match', /\/opportunities\/upload$/)
    cy.findByPlaceholderText(/^Opportunity dataset/i).type(oppName)
    cy.findByLabelText(/Select opportunity dataset/).attachFile({
      filePath: opportunity.file,
      encoding: 'base64'
    })
    cy.get('a.btn')
      .contains(/Upload/)
      .should('not.be.disabled')
      .click()
    cy.location('pathname').should('match', /opportunities$/)
    // find the message showing this upload is complete
    cy.contains(new RegExp(oppName + ' \\(DONE\\)'), {timeout: 10000})
      .parent()
      .parent()
      .as('notice')
    // check number of fields uploaded
    cy.get('@notice').contains(/Finished uploading 1 feature/i)
    // close the message
    cy.get('@notice').findByRole('button', /x/).click()
    // select in the dropdown
    cy.findByText(/Select\.\.\./)
      .click()
      .type(`${oppName} {enter}`)
    cy.contains(/Delete entire dataset/i).click()
  })

  it('can be downloaded as grid', function () {
    // TODO
  })

  it('can be downloaded as tiff', function () {
    // TODO
  })
})
{'fraction_non_alphanumeric': 0.17310308738880167, 'fraction_numerical': 0.006907378335949764, 'mean_word_length': 3.044011849344054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3301581', 'n_tokens_mistral': 3045, 'n_tokens_neox': 2931, 'n_words': 590}