<commit_before>const fixtures = require('../../fixtures')
const selectors = require('../../../../selectors')

const { companies, interactions } = require('../../../../../src/lib/urls')

const today = Cypress.moment().format('D MMMM YYYY')

describe('Interaction', () => {
  beforeEach(() => {
    cy.visit(
      companies.interactions.createType(
        fixtures.company.venusLtd.id,
        'export',
        'interaction'
      )
    )
  })

  context('An interaction with no countries discussed', () => {
    it('should add the interaction', () => {
      const subject = 'Some interesting interaction'
      const formSelectors = selectors.interactionForm

      cy.get(formSelectors.service).select('Export Win')
      cy.get(formSelectors.contact).select('<NAME>')
      cy.get(formSelectors.communicationChannel).select('Email/Website')
      cy.get(formSelectors.subject).type(subject)
      cy.get(formSelectors.notes).type('Conversation with potential client')
      cy.get(formSelectors.policyFeedbackNo).click()
      cy.get(formSelectors.countriesDiscussed.no).click()

      cy.get(selectors.interactionForm.add).click()
      cy.get(selectors.message.successful).should(
        'contain',
        'Interaction created'
      )

      cy.visit(interactions.index())
      cy.get(selectors.filter.interaction.myInteractions).click()

      cy.get(selectors.collection.items)
        .should('contain', '<NAME>')
        .and('contain', 'Some interesting interaction')
        .and('contain', 'Venus Ltd')
        .and(
          'contain',
          'DIT Staff, UKTI Team East Midlands - International Trade Team'
        )
        .and('contain', 'Export Win')
        .and('contain', today)
    })
  })

  context('An interaction where countries were discussed', () => {
    function selectCountry(id, text) {
      const typeahead = `${id} .multiselect`
      const textInput = `${id} .multiselect__input`

      cy.get(typeahead)
        .click()
        .get(textInput)
        .type(text)
        .type('{enter}')
        .type('{esc}')
    }

    context('A unique country is added to each category', () => {
      it('should add the interaction', () => {
        const subject = 'Some interesting interaction about countries'
        const formSelectors = selectors.interactionForm

        cy.get(formSelectors.service).select('Export Win')
        cy.get(formSelectors.contact).select('<NAME>')
        cy.get(formSelectors.communicationChannel).select('Email/Website')
        cy.get(formSelectors.subject).type(subject)
        cy.get(formSelectors.notes).type(
          'Conversation with potential client about countries'
        )
        cy.get(formSelectors.policyFeedbackNo).click()
        cy.get(formSelectors.countriesDiscussed.yes).click()
        selectCountry(formSelectors.countries.export, 'Fran')
        selectCountry(formSelectors.countries.future, 'Germ')
        selectCountry(formSelectors.countries.noInterest, 'Spai')

        cy.get(selectors.interactionForm.add).click()
        cy.get(selectors.message.successful)
          .should('contain', 'Interaction created')
          .and('contain', 'You discussed some countries within the interaction')

        cy.get('.table--key-value')
          .should('contain', 'Countries currently exporting toFrance')
          .and('contain', 'Future countries of interestGermany')
          .and('contain', 'Countries not interested inSpain')

        cy.visit(companies.exports.index(fixtures.company.venusLtd.id))

        cy.contains('Export countries information')
          .parent()
          .should('contain', 'Currently exporting toFrance')
          .and('contain', 'Future countries of interestGermany')
          .and('contain', 'Countries of no interestSpain')
      })
    })
  })
})

describe('Service delivery', () => {
  beforeEach(() => {
    cy.visit(
      companies.interactions.createType(
        fixtures.company.venusLtd.id,
        'export',
        'service-delivery'
      )
    )
  })<commit_msg>Add test to cover adding the same country to two catgories<commit_after>const fixtures = require('../../fixtures')
const selectors = require('../../../../selectors')

const { companies, interactions } = require('../../../../../src/lib/urls')

const today = Cypress.moment().format('D MMMM YYYY')

describe('Interaction', () => {
  beforeEach(() => {
    cy.visit(
      companies.interactions.createType(
        fixtures.company.venusLtd.id,
        'export',
        'interaction'
      )
    )
  })

  context('An interaction with no countries discussed', () => {
    it('should add the interaction', () => {
      const subject = 'Some interesting interaction'
      const formSelectors = selectors.interactionForm

      cy.get(formSelectors.service).select('Export Win')
      cy.get(formSelectors.contact).select('<NAME>')
      cy.get(formSelectors.communicationChannel).select('Email/Website')
      cy.get(formSelectors.subject).type(subject)
      cy.get(formSelectors.notes).type('Conversation with potential client')
      cy.get(formSelectors.policyFeedbackNo).click()
      cy.get(formSelectors.countriesDiscussed.no).click()

      cy.get(selectors.interactionForm.add).click()
      cy.get(selectors.message.successful).should(
        'contain',
        'Interaction created'
      )

      cy.visit(interactions.index())
      cy.get(selectors.filter.interaction.myInteractions).click()

      cy.get(selectors.collection.items)
        .should('contain', '<NAME>')
        .and('contain', 'Some interesting interaction')
        .and('contain', 'Venus Ltd')
        .and(
          'contain',
          'DIT Staff, UKTI Team East Midlands - International Trade Team'
        )
        .and('contain', 'Export Win')
        .and('contain', today)
    })
  })

  context('An interaction where countries were discussed', () => {
    function selectCountry(id, text) {
      const typeahead = `${id} .multiselect`
      const textInput = `${id} .multiselect__input`

      cy.get(typeahead)
        .click()
        .get(textInput)
        .type(text)
        .type('{enter}')
        .type('{esc}')
    }

    context('A unique country is added to each category', () => {
      it('should add the interaction', () => {
        const subject = 'Some interesting interaction about countries'
        const formSelectors = selectors.interactionForm

        cy.get(formSelectors.service).select('Export Win')
        cy.get(formSelectors.contact).select('<NAME>')
        cy.get(formSelectors.communicationChannel).select('Email/Website')
        cy.get(formSelectors.subject).type(subject)
        cy.get(formSelectors.notes).type(
          'Conversation with potential client about countries'
        )
        cy.get(formSelectors.policyFeedbackNo).click()
        cy.get(formSelectors.countriesDiscussed.yes).click()
        selectCountry(formSelectors.countries.export, 'Fran')
        selectCountry(formSelectors.countries.future, 'Germ')
        selectCountry(formSelectors.countries.noInterest, 'Spai')

        cy.get(selectors.interactionForm.add).click()
        cy.get(selectors.message.successful)
          .should('contain', 'Interaction created')
          .and('contain', 'You discussed some countries within the interaction')

        cy.get('.table--key-value')
          .should('contain', 'Countries currently exporting toFrance')
          .and('contain', 'Future countries of interestGermany')
          .and('contain', 'Countries not interested inSpain')

        cy.visit(companies.exports.index(fixtures.company.venusLtd.id))

        cy.contains('Export countries information')
          .parent()
          .should('contain', 'Currently exporting toFrance')
          .and('contain', 'Future countries of interestGermany')
          .and('contain', 'Countries of no interestSpain')
      })
    })

    context('The same country is added to two categories', () => {
      it('should get an error saving the interaction', () => {
        const subject = 'Some interesting interaction about countries'
        const formSelectors = selectors.interactionForm

        cy.get(formSelectors.service).select('Export Win')
        cy.get(formSelectors.contact).select('<NAME>')
        cy.get(formSelectors.communicationChannel).select('Email/Website')
        cy.get(formSelectors.subject).type(subject)
        cy.get(formSelectors.notes).type(
          'Conversation with potential client about countries'
        )
        cy.get(formSelectors.policyFeedbackNo).click()
        cy.get(formSelectors.countriesDiscussed.yes).click()
        selectCountry(formSelectors.countries.export, 'Fran')
        selectCountry(formSelectors.countries.future, 'Fran')

        cy.get(selectors.interactionForm.add).click()
        cy.contains(
          'A country that was discussed cannot be entered in multiple fields.'
        )
      })
    })
  })
})

describe('Service delivery', () => {
  beforeEach(() => {
    cy.visit(
      companies.interactions.createType(
        fixtures.company.venusLtd.id,
        'export',
        'service-delivery'
      )
    )
  })
{'fraction_non_alphanumeric': 0.1403662682311657, 'fraction_numerical': 0.0, 'mean_word_length': 2.7905236907730675, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 30, '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': '6884557', 'n_tokens_mistral': 2627, 'n_tokens_neox': 2561, 'n_words': 477}