<commit_before>const expect = require('chai').expect
const authenticationHelp = require('../helpers/routes/authentication-helper')

let adminUserURL
const username = '<EMAIL>'

describe('Application Support', () => {
  before(async function () {
    await authenticationHelp.login(authenticationHelp.users.ApplicationSupport)
    adminUserURL = '/admin/user'
    await browser.url(adminUserURL)
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot see Super User role', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(username)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      let radioButton = await $('#superAdminRadio')
      const SuperUserVisible = await radioButton.isExisting()
      expect(SuperUserVisible).to.be.equal(false)

      radioButton = await $('#ApplicationSupportRadio')
      await radioButton.click()
      let isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#managerRadio')
      await radioButton.click()
      isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#staffRadio')
      await radioButton.click()
      isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)
    })
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot demote a Super User to Application Support', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(`${authentication<EMAIL>`)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      const radioButton = await $('#managerRadio')
      await radioButton.click()
      const isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      const submitRole = await $('.govuk-button')
      await submitRole.click()

      const header = await $('.govuk-heading-xl')
      const headerText = await header.getText('.govuk-heading-xl')
      expect(headerText).to.equal('Access is denied')
    })
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot demote a Super User to manager', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(`${authentication<EMAIL>`)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      const radioButton = await $('#ApplicationSupportRadio')
      await radioButton.click()
      const isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      const submitRole = await $('.govuk-button')
      await submitRole.click()

      const header = await $('.govuk-heading-xl')
      const headerText = await header.getText('.govuk-heading-xl')
      expect(headerText).to.equal('Access is denied')
    })
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot demote a Super User to staff', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(`${authentication<EMAIL>`)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      const radioButton = await $('#staffRadio')
      await radioButton.click()
      const isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      const submitRole = await $('.govuk-button')
      await submitRole.click()

      const header = await $('.govuk-heading-xl')
      const headerText = await header.getText('.govuk-heading-xl')
      expect(headerText).to.equal('Access is denied')
    })
  })

  after(function () {
    authenticationHelp.logout()
  })
})

describe('Super User', () => {
  before(async function () {
    await authenticationHelp.login(authenticationHelp.users.SuperUser)
    adminUserURL = '/admin/user'
    await browser.url(adminUserURL)
  })

  describe('should navigate to the user rights page', () => {
    it('and can see all roles', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(username)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      let radioButton = await $('#superAdminRadio')
      await radioButton.click()
      let isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#ApplicationSupportRadio')
      await radioButton.click()
      isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#managerRadio')
      await radioButton.click()<commit_msg>WFP-738 fixed e2e clicking on element<commit_after>const expect = require('chai').expect
const authenticationHelp = require('../helpers/routes/authentication-helper')

let adminUserURL
const username = '<EMAIL>'

describe('Application Support', () => {
  before(async function () {
    await authenticationHelp.login(authenticationHelp.users.ApplicationSupport)
    adminUserURL = '/admin/user'
    await browser.url(adminUserURL)
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot see Super User role', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(username)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      let radioButton = await $('#superAdminRadio')
      const SuperUserVisible = await radioButton.isExisting()
      expect(SuperUserVisible).to.be.equal(false)

      radioButton = await $('#applicationSupportRadio')
      await radioButton.click()
      let isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#managerRadio')
      await radioButton.click()
      isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#staffRadio')
      await radioButton.click()
      isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)
    })
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot demote a Super User to Application Support', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(`${<EMAIL>`)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      const radioButton = await $('#managerRadio')
      await radioButton.click()
      const isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      const submitRole = await $('.govuk-button')
      await submitRole.click()

      const header = await $('.govuk-heading-xl')
      const headerText = await header.getText('.govuk-heading-xl')
      expect(headerText).to.equal('Access is denied')
    })
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot demote a Super User to manager', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(`${authentication<EMAIL>.Super<EMAIL>`)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      const radioButton = await $('#applicationSupportRadio')
      await radioButton.click()
      const isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      const submitRole = await $('.govuk-button')
      await submitRole.click()

      const header = await $('.govuk-heading-xl')
      const headerText = await header.getText('.govuk-heading-xl')
      expect(headerText).to.equal('Access is denied')
    })
  })

  describe('should navigate to the user rights page', () => {
    it('and cannot demote a Super User to staff', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(`${authentication<EMAIL>`)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      const radioButton = await $('#staffRadio')
      await radioButton.click()
      const isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      const submitRole = await $('.govuk-button')
      await submitRole.click()

      const header = await $('.govuk-heading-xl')
      const headerText = await header.getText('.govuk-heading-xl')
      expect(headerText).to.equal('Access is denied')
    })
  })

  after(function () {
    authenticationHelp.logout()
  })
})

describe('Super User', () => {
  before(async function () {
    await authenticationHelp.login(authenticationHelp.users.SuperUser)
    adminUserURL = '/admin/user'
    await browser.url(adminUserURL)
  })

  describe('should navigate to the user rights page', () => {
    it('and can see all roles', async () => {
      await browser.url(adminUserURL)

      const breadcrumbs = await $('.govuk-breadcrumbs')
      const exists = await breadcrumbs.isExisting()
      expect(exists).to.be.equal(true)

      const usernameField = await $('#username')
      await usernameField.setValue(username)

      const submit = await $('.govuk-button')
      await submit.click()

      const pageTitle = await $('.govuk-heading-xl')
      const text = await pageTitle.getText('.govuk-heading-xl')
      expect(text).to.equal('User rights')

      let radioButton = await $('#superAdminRadio')
      await radioButton.click()
      let isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#applicationSupportRadio')
      await radioButton.click()
      isSelected = await radioButton.isSelected()
      expect(isSelected).to.be.equal(true)

      radioButton = await $('#managerRadio')
      await radioButton.click()
{'fraction_non_alphanumeric': 0.13493602171384259, 'fraction_numerical': 0.00031019775106630476, 'mean_word_length': 3.2365308804204993, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 36, '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': '2462208', 'n_tokens_mistral': 3600, 'n_tokens_neox': 3576, 'n_words': 852}