<commit_before>import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'hospitalrun/tests/helpers/start-app';

module('Acceptance | outpatient', {
  beforeEach() {
    this.application = startApp();
  },

  afterEach() {
    Ember.run(this.application, 'destroy');
  }
});

test('Check In/Check Out Existing outpatient', function(assert) {
  runWithPouchDump('patient', function() {
    authenticateUser();
    visit('/patients/outpatient');
    andThen(function() {
      assert.equal(currentURL(), '/patients/outpatient', 'Outpatient url is correct');
      assert.equal(find('.view-current-title').text(), 'Todays\' Outpatients', 'Title is correct');
      click('button:contains(Patient Check In)');
    });
    andThen(function() {
      assert.equal(currentURL(), '/visits/edit/checkin', 'Check In url is correct');
      typeAheadFillIn('.patient-name', '<NAME> - P00001');
      waitToAppear('.patient-name .ps-info-data');
    });
    andThen(function() {
      assert.equal(find('.patient-name .ps-info-data').text(), '<NAME>', 'Jo<NAME>onuts patient record displays');
      assert.equal(find('.new-patient-checkbox input:checked').length, 0, 'New Patient checkbox is not checked');
      select('.visit-type', 'Clinic');
      click('button:contains(Check In)');
      waitToAppear('.modal-dialog');
    });
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Checked In', 'Patient has been checked in');
      click('.modal-footer button:contains(Ok)');
    });
    andThen(function() {
      findWithAssert('button:contains(Check Out)');
      click('button:contains(Return)');
    });
    andThen(function() {
      assert.equal(currentURL(), '/patients/outpatient', 'Returned to Outpatient');
      assert.equal(find('.outpatient-list td:contains(Joe Bagadonuts)').length, 1, 'Checked in patient appears in list');
      click('button:contains(Check Out)');
      waitToAppear('.modal-dialog');
    });
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Check Out', 'Patient checkout confirmation displays');
      click('button:contains(Ok)');
    });
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Checked Out', 'Patient has been checked out confirmation');
      click('button:contains(Ok)');
    });
    andThen(function() {
      assert.equal(find('.outpatient-list td:contains(Joe Bagadonuts)').length, 0, 'Checked out patient no longer appears');
    });
  });
});

test('Check In/Check Out new outpatient', function(assert) {
  runWithPouchDump('patient', function() {
    let visitDate = moment('2015-10-01');
    let visitLocation = 'Outpatient Followup';
    authenticateUser();
    visit('/patients/outpatient');
    andThen(function() {
      assert.equal(currentURL(), '/patients/outpatient', 'Outpatient url is correct');
      assert.equal(find('.view-current-title').text(), 'Todays\' Outpatients', 'Title is correct');
      click('button:contains(Patient Check In)');
    });
    andThen(function() {
      assert.equal(currentURL(), '/visits/edit/checkin', 'Check In url is correct');
      typeAheadFillIn('.patient-name', '<NAME>');
    });
    andThen(function() {
      assert.equal(find('.new-patient-checkbox input:checked').length, 1, 'New Patient checkbox is checked');
      selectDate('.checkin-date input', visitDate.toDate());
      select('.visit-type', 'Followup');
      typeAheadFillIn('.visit-location', visitLocation);
    });
    andThen(function() {
      click('button:contains(Check In)');
      waitToAppear('.modal-title:contains(New Patient)');<commit_msg>Fixed failing tests<commit_after>import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'hospitalrun/tests/helpers/start-app';

module('Acceptance | outpatient', {
  beforeEach() {
    this.application = startApp();
  },

  afterEach() {
    Ember.run(this.application, 'destroy');
  }
});

test('Check In/Check Out Existing outpatient', function(assert) {
  runWithPouchDump('patient', function() {
    authenticateUser();
    visit('/patients/outpatient');
    andThen(function() {
      assert.equal(currentURL(), '/patients/outpatient', 'Outpatient url is correct');
      assert.equal(find('.view-current-title').text(), 'Today\'s Outpatients', 'Title is correct');
      click('button:contains(Patient Check In)');
    });
    andThen(function() {
      assert.equal(currentURL(), '/visits/edit/checkin', 'Check In url is correct');
      typeAheadFillIn('.patient-name', '<NAME> - P00001');
      waitToAppear('.patient-name .ps-info-data');
    });
    andThen(function() {
      assert.equal(find('.patient-name .ps-info-data').text(), '<NAME>', 'Jo<NAME>onuts patient record displays');
      assert.equal(find('.new-patient-checkbox input:checked').length, 0, 'New Patient checkbox is not checked');
      select('.visit-type', 'Clinic');
      click('button:contains(Check In)');
      waitToAppear('.modal-dialog');
    });
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Checked In', 'Patient has been checked in');
      click('.modal-footer button:contains(Ok)');
    });
    andThen(function() {
      findWithAssert('button:contains(Check Out)');
      click('button:contains(Return)');
    });
    andThen(function() {
      assert.equal(currentURL(), '/patients/outpatient', 'Returned to Outpatient');
      assert.equal(find('.outpatient-list td:contains(Joe Bagadonuts)').length, 1, 'Checked in patient appears in list');
      click('button:contains(Check Out)');
      waitToAppear('.modal-dialog');
    });
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Check Out', 'Patient checkout confirmation displays');
      click('button:contains(Ok)');
    });
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Checked Out', 'Patient has been checked out confirmation');
      click('button:contains(Ok)');
    });
    andThen(function() {
      assert.equal(find('.outpatient-list td:contains(Joe Bagadonuts)').length, 0, 'Checked out patient no longer appears');
    });
  });
});

test('Check In/Check Out new outpatient', function(assert) {
  runWithPouchDump('patient', function() {
    let visitDate = moment('2015-10-01');
    let visitLocation = 'Outpatient Followup';
    authenticateUser();
    visit('/patients/outpatient');
    andThen(function() {
      assert.equal(currentURL(), '/patients/outpatient', 'Outpatient url is correct');
      assert.equal(find('.view-current-title').text(), 'Today\'s Outpatients', 'Title is correct');
      click('button:contains(Patient Check In)');
    });
    andThen(function() {
      assert.equal(currentURL(), '/visits/edit/checkin', 'Check In url is correct');
      typeAheadFillIn('.patient-name', '<NAME>');
    });
    andThen(function() {
      assert.equal(find('.new-patient-checkbox input:checked').length, 1, 'New Patient checkbox is checked');
      selectDate('.checkin-date input', visitDate.toDate());
      select('.visit-type', 'Followup');
      typeAheadFillIn('.visit-location', visitLocation);
    });
    andThen(function() {
      click('button:contains(Check In)');
      waitToAppear('.modal-title:contains(New Patient)');
{'fraction_non_alphanumeric': 0.17964893033461327, 'fraction_numerical': 0.004662643993417444, 'mean_word_length': 4.019270474879559, 'pattern_counts': {'":': 0, '<': 11, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '348279', 'n_tokens_mistral': 2183, 'n_tokens_neox': 2096, 'n_words': 429}