<commit_before>describe 'Managing memberships', ->

  membershipsHelper = require './helpers/memberships_helper.coffee'
  groupsHelper = require './helpers/groups_helper.coffee'
  flashHelper = require './helpers/flash_helper.coffee'

  beforeEach ->
    groupsHelper.load()
    membershipsHelper.visitMembershipsPage()

  describe 'removing a group member', ->

    it 'successfully removes a group member', ->
      membershipsHelper.fillInSearchInput('Jennifer')
      membershipsHelper.clickRemoveLink()
      membershipsHelper.confirmRemoveAction()
      expect(membershipsHelper.currentMembershipRow().isPresent()).toBe(false)
      membershipsHelper.clearSearchInput()
      expect(flashHelper.flashMessage()).toContain('Removed <NAME>')
      expect(membershipsHelper.membershipsTable()).not.toContain('<NAME>')

  describe 'promoting a member to coordinator', ->

    it 'successfully assigns coordinator privileges', ->
      membershipsHelper.fillInSearchInput('Jennifer')
      membershipsHelper.checkCoordinatorCheckbox()
      membershipsHelper.clearSearchInput()
      expect(flashHelper.flashMessage()).toContain('<NAME> is now a coordinator')
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(2)

  describe 'removing coordinator privileges', ->

    it 'can remove coordinator privileges when there is more than one coordinator', ->
      membershipsHelper.makeJenniferCoordinator()
      membershipsHelper.clearSearchInput()
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(2)
      membershipsHelper.fillInSearchInput('Patrick')
      membershipsHelper.checkCoordinatorCheckbox()
      expect(flashHelper.flashMessage()).toContain('<NAME> is no longer a coordinator')
      membershipsHelper.clearSearchInput()
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(1)

    it 'cannot remove privileges for last coordinator', ->
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(1)
      membershipsHelper.fillInSearchInput('Patrick')
      expect(membershipsHelper.coordinatorCheckbox().isEnabled()).toBe(false)<commit_msg>Try to fix protractor test<commit_after>describe 'Managing memberships', ->

  membershipsHelper = require './helpers/memberships_helper.coffee'
  groupsHelper = require './helpers/groups_helper.coffee'
  flashHelper = require './helpers/flash_helper.coffee'

  beforeEach ->
    groupsHelper.load()
    membershipsHelper.visitMembershipsPage()

  describe 'removing a group member', ->

    it 'successfully removes a group member', ->
      membershipsHelper.fillInSearchInput('Jennifer')
      membershipsHelper.clickRemoveLink()
      membershipsHelper.confirmRemoveAction()
      expect(membershipsHelper.currentMembershipRow().isPresent()).toBe(false)
      membershipsHelper.clearSearchInput()
      expect(flashHelper.flashMessage()).toContain('Removed <NAME>')
      expect(membershipsHelper.membershipsTable()).not.toContain('<NAME>')

  describe 'promoting a member to coordinator', ->

    it 'successfully assigns coordinator privileges', ->
      membershipsHelper.fillInSearchInput('Jennifer')
      membershipsHelper.checkCoordinatorCheckbox()
      membershipsHelper.clearSearchInput()
      expect(flashHelper.flashMessage()).toContain('<NAME> is now a coordinator')
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(2)

  describe 'removing coordinator privileges', ->

    it 'can remove coordinator privileges when there is more than one coordinator', ->
      membershipsHelper.makeJenniferCoordinator()
      membershipsHelper.clearSearchInput()
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(2)
      membershipsHelper.fillInSearchInput('Patrick')
      membershipsHelper.checkCoordinatorCheckbox()
      browser.switchTo().alert().accept()
      expect(flashHelper.flashMessage()).toContain('<NAME> is no longer a coordinator')
      membershipsHelper.clearSearchInput()
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(1)

    it 'cannot remove privileges for last coordinator', ->
      expect(membershipsHelper.currentCoordinatorsCount()).toEqual(1)
      membershipsHelper.fillInSearchInput('Patrick')
      expect(membershipsHelper.coordinatorCheckbox().isEnabled()).toBe(false)
{'fraction_non_alphanumeric': 0.10606415359400609, 'fraction_numerical': 0.0018730976352142356, 'mean_word_length': 5.008438818565401, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, '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': '7241531', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1075, 'n_words': 192}