<commit_before>(function () {
  'use strict';

  var utils = require('../e2e/_utils');
  var CONSTANTS = require('../protractor.constants.js');
  var modelsRecipe = require('./_modelsRecipe');

  var case_to_accept;
  var grouped_benefits_case;
  var assign_form = element(by.name('assign_provider_form'));
  var accept_button = element(by.name('accept-case'));
  var close_button = element(by.name('provider-close-case'));
  var reopen_button = element(by.name('reopen-case'));
  var debt_referral_button = element(by.name('debt-referral-case'));
  var grouped_text = 'Are you or your partner directly or indirectly in receipt of Universal Credit, Income Support, Income-based Jobseeker\'s Allowance, Income-related Employment and Support Allowance or Guarantee Credit?';
  var specific_text = 'Do you or your partner receive any of the following benefits:';
  var modalEl = element(by.css('div.modal'));
  var notes = modalEl.element(by.name('outcomeNotes'));
  var modalSubmit = modalEl.element(by.css('button[type="submit"]'));

  describe('providerCase', function () {
    describe('An operator', function () {
      beforeEach(utils.setUp);

      it('should create a specific benefits case as operator and assign (manually) to a provider', function () {
        modelsRecipe.Case.createSpecificBenefitsReadyToAssign().then(function (case_ref) {
          case_to_accept = case_ref;
          browser.get(CONSTANTS.callcentreBaseUrl + case_ref + '/assign/?as_of=2014-08-06T11:50');
          get_provider().then(function (provider) {
            if (provider !== 'Duncan Lewis') {
              utils.manuallySetProvider(1); // set to Duncan Lewis
            }
            do_assign();
            expect(browser.getCurrentUrl()).toBe(browser.baseUrl + CONSTANTS.callcentreBaseUrl);
          });
        });
      });

      it('should create a grouped benefits case as operator and assign (manually) to a provider', function () {
        modelsRecipe.Case.createGroupedBenefitsReadyToAssign().then(function (case_ref) {
          grouped_benefits_case = case_ref;
          browser.get(CONSTANTS.callcentreBaseUrl + case_ref + '/assign/?as_of=2014-08-06T11:50');
          get_provider().then(function (provider) {
            if (provider !== '<NAME>') {
              utils.manuallySetProvider(1); // set to Duncan Lewis
            }
            do_assign();
            expect(browser.getCurrentUrl()).toBe(browser.baseUrl + CONSTANTS.callcentreBaseUrl);
          });
        });
      });

      it('should logout', function () {
        this.after(function () {
          utils.logout();
        });
      });
    });

    describe('A provider', function () {
      beforeEach(utils.setUpAsProvider);

      it('should be able to accept a case', function () {
        browser.get(CONSTANTS.providerBaseUrl + case_to_accept + '/');

        expect(close_button.isPresent()).toBe(false);
        expect(accept_button.isPresent()).toBe(true);

        // click but cancel accept
        accept_button.click();

        // check can't accept anymore
        expect(accept_button.isPresent()).toBe(false);
        expect(close_button.isPresent()).toBe(true);
        expect(element(by.css('.NoticeContainer--fixed')).getInnerHtml()).toContain('Case accepted successfully');
      });

      it('should be able to close a case', function () {
        expect(close_button.isPresent()).toBe(true);

        // click but cancel accept
        close_button.click();
        browser.switchTo().alert().dismiss();

        expect(close_button.isPresent()).toBe(true);

        // click and accept case
        close_button.click();
        browser.switchTo().alert().accept();

        // check redirected
        expect(browser.getLocationAbsUrl()).not.toContain(case_to_accept);
      });
<commit_msg>Update test for case closing button<commit_after>(function () {
  'use strict';

  var utils = require('../e2e/_utils');
  var CONSTANTS = require('../protractor.constants.js');
  var modelsRecipe = require('./_modelsRecipe');

  var case_to_accept;
  var grouped_benefits_case;
  var assign_form = element(by.name('assign_provider_form'));
  var accept_button = element(by.name('accept-case'));
  var close_button = element(by.name('provider-close-case'));
  var reopen_button = element(by.name('reopen-case'));
  var debt_referral_button = element(by.name('debt-referral-case'));
  var grouped_text = 'Are you or your partner directly or indirectly in receipt of Universal Credit, Income Support, Income-based Jobseeker\'s Allowance, Income-related Employment and Support Allowance or Guarantee Credit?';
  var specific_text = 'Do you or your partner receive any of the following benefits:';
  var modalEl = element(by.css('div.modal'));
  var notes = modalEl.element(by.name('outcomeNotes'));
  var modalSubmit = modalEl.element(by.css('button[type="submit"]'));

  describe('providerCase', function () {
    describe('An operator', function () {
      beforeEach(utils.setUp);

      it('should create a specific benefits case as operator and assign (manually) to a provider', function () {
        modelsRecipe.Case.createSpecificBenefitsReadyToAssign().then(function (case_ref) {
          case_to_accept = case_ref;
          browser.get(CONSTANTS.callcentreBaseUrl + case_ref + '/assign/?as_of=2014-08-06T11:50');
          get_provider().then(function (provider) {
            if (provider !== 'Duncan Lewis') {
              utils.manuallySetProvider(1); // set to Duncan Lewis
            }
            do_assign();
            expect(browser.getCurrentUrl()).toBe(browser.baseUrl + CONSTANTS.callcentreBaseUrl);
          });
        });
      });

      it('should create a grouped benefits case as operator and assign (manually) to a provider', function () {
        modelsRecipe.Case.createGroupedBenefitsReadyToAssign().then(function (case_ref) {
          grouped_benefits_case = case_ref;
          browser.get(CONSTANTS.callcentreBaseUrl + case_ref + '/assign/?as_of=2014-08-06T11:50');
          get_provider().then(function (provider) {
            if (provider !== '<NAME>') {
              utils.manuallySetProvider(1); // set to Duncan Lewis
            }
            do_assign();
            expect(browser.getCurrentUrl()).toBe(browser.baseUrl + CONSTANTS.callcentreBaseUrl);
          });
        });
      });

      it('should logout', function () {
        this.after(function () {
          utils.logout();
        });
      });
    });

    describe('A provider', function () {
      beforeEach(utils.setUpAsProvider);

      it('should be able to accept a case', function () {
        browser.get(CONSTANTS.providerBaseUrl + case_to_accept + '/');

        expect(close_button.isPresent()).toBe(false);
        expect(accept_button.isPresent()).toBe(true);

        // click but cancel accept
        accept_button.click();

        // check can't accept anymore
        expect(accept_button.isPresent()).toBe(false);
        expect(close_button.isPresent()).toBe(true);
        expect(element(by.css('.NoticeContainer--fixed')).getInnerHtml()).toContain('Case accepted successfully');
      });

      it('should be able to close a case', function () {
        expect(close_button.isPresent()).toBe(true);

        close_button.click();

        // check redirected
        expect(browser.getLocationAbsUrl()).not.toContain(case_to_accept);
      });

{'fraction_non_alphanumeric': 0.13622835497835498, 'fraction_numerical': 0.007305194805194805, 'mean_word_length': 3.0420995079278295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7572406', 'n_tokens_mistral': 2144, 'n_tokens_neox': 2050, 'n_words': 429}