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

module('Acceptance | patient notes', {
  beforeEach: function() {
    this.application = startApp();
  },

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

function tabTest(tabName, tabId) {
  click(`[data-test-selector=${tabName}]`);
  andThen(function() {
    findWithAssert(`#${tabId}`);
  });
}

test('patient notes crud testing', function(assert) {
  runWithPouchDump('default', function() {
    authenticateUser();
    visit('/patients');
    visit('/patients/edit/new');
    andThen(function() {
      assert.equal(currentURL(), '/patients/edit/new');
    });
    fillIn('.test-first-name input', 'John');
    fillIn('.test-last-name input', 'Doe');
    click('.panel-footer button:contains(Add)');
    waitToAppear('.modal-dialog');
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Saved', 'Patient record has been saved');
    });
    click('button:contains(Close)');
    waitToAppear('.patient-summary');
    andThen(function() {
      findWithAssert('.patient-summary');
    });
    andThen(function() {
      tabTest('visits-tab', 'visits');
    });
    click('button:contains(New Visit)');
    andThen(function() {
      assert.equal(currentURL(), '/visits/edit/new', 'Now in add visiting information route');
    });
    click('.panel-footer button:contains(Add)');
    waitToAppear('.modal-dialog');
    andThen(() => {
      assert.equal(find('.modal-title').text(), 'Visit Saved', 'New visit has been saved');
    });
    click('button:contains(Ok)');
    andThen(() => {
      findWithAssert('button:contains(New Note)');
      findWithAssert('button:contains(New Procedure)');
      findWithAssert('button:contains(New Medication)');
      findWithAssert('button:contains(New Lab)');
      findWithAssert('button:contains(New Imaging)');
      findWithAssert('button:contains(New Vitals)');
      findWithAssert('button:contains(Add Item)');
    });
    andThen(function() {
      assert.equal(find('button:contains(New Note)').length, 1, 'New Note button in visible');
      click('button:contains(New Note)');
    });
    andThen(function() {
      assert.equal(find('label:contains(Note)').length, 1, 'Notes modal appeared.');
    });
    andThen(function() {
      fillIn('.test-note-content textarea', 'This is a note.');
      fillIn('.test-note-attribution input', 'Dr. Nick');
      click('.modal-footer button:contains(Add)');
    });
    waitToAppear('#visit-notes table tr td:contains(This is a note.)');
    andThen(function() {
      assert.equal(find('#visit-notes table tr td:contains(This is a note.)').length, 1, 'Successfully added note.');
    });
    // update note
    waitToAppear('#visit-notes table tr td button:contains(Edit)');
    andThen(function() {
      click('#visit-notes table tr td button:contains(Edit)');
    });
    waitToAppear('.modal-dialog');
    andThen(function() {
      fillIn('.test-note-content textarea', 'This is an updated note.');
      click('.modal-footer button:contains(Update)');
    });
    waitToAppear('#visit-notes table tr td:contains(This is an updated note.)');
    andThen(function() {
      assert.equal(find('#visit-notes table tr td:contains(This is an updated note.)').length, 1, 'Successfully updated note.');
    });
    // delete note
    andThen(function() {
      click('#visit-notes table tr td button:contains(Delete)');
    });
    waitToAppear('.modal-dialog');
    andThen(function() {
      click('.modal-footer button:contains(Ok)');
    });
    andThen(function() {
      assert.equal(find('#visit-notes table tr td:contains(This is an updated note.)').length, 0, 'Successfully deleted note.');
    });
  });
});<commit_msg>Cleaned up patient notes test to try to fix Travis failures<commit_after>import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'hospitalrun/tests/helpers/start-app';

module('Acceptance | patient notes', {
  beforeEach: function() {
    this.application = startApp();
  },

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

test('patient notes crud testing', function(assert) {
  runWithPouchDump('default', function() {
    authenticateUser();
    visit('/patients/edit/new');
    andThen(function() {
      assert.equal(currentURL(), '/patients/edit/new');
      fillIn('.test-first-name input', 'John');
      fillIn('.test-last-name input', 'Doe');
      click('.panel-footer button:contains(Add)');
      waitToAppear('.modal-dialog');
    });
    andThen(function() {
      assert.equal(find('.modal-title').text(), 'Patient Saved', 'Patient record has been saved');
      click('button:contains(Close)');
      waitToAppear('.patient-summary');
    });
    andThen(function() {
      findWithAssert('.patient-summary');
      click('[data-test-selector=visits-tab]');
    });
    andThen(function() {
      findWithAssert('#visits');
      click('button:contains(New Visit)');
    });
    andThen(function() {
      assert.equal(currentURL(), '/visits/edit/new', 'Now in add visiting information route');
      click('.panel-footer button:contains(Add)');
      waitToAppear('.modal-dialog');
    });
    andThen(() => {
      assert.equal(find('.modal-title').text(), 'Visit Saved', 'New visit has been saved');
      click('button:contains(Ok)');
    });
    andThen(() => {
      findWithAssert('button:contains(New Note)');
      findWithAssert('button:contains(New Procedure)');
      findWithAssert('button:contains(New Medication)');
      findWithAssert('button:contains(New Lab)');
      findWithAssert('button:contains(New Imaging)');
      findWithAssert('button:contains(New Vitals)');
      findWithAssert('button:contains(Add Item)');
      assert.equal(find('button:contains(New Note)').length, 1, 'New Note button in visible');
      click('button:contains(New Note)');
    });
    andThen(function() {
      assert.equal(find('label:contains(Note)').length, 1, 'Notes modal appeared.');
      fillIn('.test-note-content textarea', 'This is a note.');
      fillIn('.test-note-attribution input', 'Dr. Nick');
      click('.modal-footer button:contains(Add)');
    });
    andThen(function() {
      waitToAppear('#visit-notes table tr td:contains(This is a note.)');
    });
    andThen(function() {
      assert.equal(find('#visit-notes table tr td:contains(This is a note.)').length, 1, 'Successfully added note.');
      click('#visit-notes table tr td button:contains(Edit)');
      waitToAppear('.modal-dialog');
    });
    andThen(function() {
      fillIn('.test-note-content textarea', 'This is an updated note.');
      click('.modal-footer button:contains(Update)');
      waitToAppear('#visit-notes table tr td:contains(This is an updated note.)');
    });
    andThen(function() {
      assert.equal(find('#visit-notes table tr td:contains(This is an updated note.)').length, 1, 'Successfully updated note.');
      click('#visit-notes table tr td button:contains(Delete)');
      waitToAppear('.modal-dialog');
    });
    andThen(function() {
      click('.modal-footer button:contains(Ok)');
    });
    andThen(function() {
      assert.equal(find('#visit-notes table tr td:contains(This is an updated note.)').length, 0, 'Successfully deleted note.');
    });
  });
});
{'fraction_non_alphanumeric': 0.18200243210376976, 'fraction_numerical': 0.0013511687609782462, 'mean_word_length': 3.790938511326861, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '960986', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2183, 'n_words': 443}