-
-
Save giosakti/ca24a13705d15f4374b0 to your computer and use it in GitHub Desktop.
protractor configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Require child process library | |
// to execute shell commands | |
var exec = require('child_process').exec; | |
// Require moment.js library to construct | |
// correct date format, because JS does | |
// not have strftime method/function | |
var moment = require('moment'); | |
// Require chai assertion library | |
// for expect/should style assertion | |
// and require chai as promised library | |
// for promise waiting assertion | |
var chai = require('chai'); | |
var chaiAsPromised = require('chai-as-promised'); | |
chai.use(chaiAsPromised); | |
module.exports = { | |
expect: chai.expect, | |
moment: moment | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseConfig = require('./test/e2e/config/base-e2e-config'); | |
var expect = baseConfig.expect; | |
exports.config = { | |
// ----- How to setup Selenium ----- | |
// | |
// There are three ways to specify how to use Selenium. Specify one of the | |
// following: | |
// | |
// 1. seleniumServerJar - to start Selenium Standalone locally. | |
// 2. seleniumAddress - to connect to a Selenium server which is already | |
// running. | |
// 3. sauceUser/sauceKey - to use remote Selenium servers via SauceLabs. | |
// | |
// If the chromeOnly option is specified, no Selenium server will be started, | |
// and chromeDriver will be used directly (from the location specified in | |
// chromeDriver) | |
// The location of the selenium standalone server .jar file, relative | |
// to the location of this config. If no other method of starting selenium | |
// is found, this will default to | |
// node_modules/protractor/selenium/selenium-server... | |
seleniumServerJar: 'node_modules/protractor/selenium/chromedriver', | |
// The port to start the selenium server on, or null if the server should | |
// find its own unused port. | |
seleniumPort: 4444, | |
// The address of a running selenium server. If specified, Protractor will | |
// connect to an already running instance of selenium. This usually looks like | |
// seleniumAddress: 'http://localhost:4444/wd/hub' | |
seleniumAddress: 'http://localhost:4444/wd/hub', | |
// Chromedriver location is used to help the selenium standalone server | |
// find chromedriver. This will be passed to the selenium jar as | |
// the system property webdriver.chrome.driver. If null, selenium will | |
// attempt to find chromedriver using PATH. | |
chromeDriver: './node_modules/protractor/selenium/chromedriver', | |
// If true, only chromedriver will be started, not a standalone selenium. | |
// Tests for browsers other than chrome will not run. | |
chromeOnly: false, | |
// Additional command line options to pass to selenium. For example, | |
// if you need to change the browser timeout, use | |
// seleniumArgs: ['-browserTimeout=60'], | |
seleniumArgs: [], | |
// If sauceUser and sauceKey are specified, seleniumServerJar will be ignored. | |
// The tests will be run remotely using SauceLabs. | |
sauceUser: null, | |
sauceKey: null, | |
// The timeout for each script run on the browser. This should be longer | |
// than the maximum time your application needs to stabilize between tasks. | |
allScriptsTimeout: 11000, | |
// ----- What tests to run ----- | |
// | |
// Spec patterns are relative to the location of this config. | |
specs: [ | |
'./test/e2e/*-spec.js' | |
], | |
// ----- Capabilities to be passed to the webdriver instance ---- | |
// | |
// For a full list of available capabilities, see | |
// https://code.google.com/p/selenium/wiki/DesiredCapabilities | |
// and | |
// https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js | |
capabilities: { | |
'browserName': 'chrome' | |
}, | |
// ----- More information for your tests ---- | |
// | |
// A base URL for your application under test. Calls to protractor.get() | |
// with relative paths will be prepended with this. | |
baseUrl: 'http://127.0.0.1:9000', | |
// Selector for the element housing the angular app - this defaults to | |
// body, but is necessary if ng-app is on a descendant of <body> | |
rootElement: 'html', | |
// A callback function called once protractor is ready and available, and | |
// before the specs are executed | |
// You can specify a file containing code to run by setting onPrepare to | |
// the filename string. | |
onPrepare: function() { | |
// At this point, global 'protractor' object will be set up, and jasmine | |
// will be available. For example, you can add a Jasmine reporter with: | |
// jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter( | |
// 'outputdir/', true, true)); | |
browser.driver.get('http://127.0.0.1:3000/reseed') | |
// Login before test are run | |
browser.get('/') | |
$('#login-button').click() | |
var username = element(by.model('session.login')) | |
var password = element(by.model('session.password')) | |
username.sendKeys(browser.params.login.username) | |
password.sendKeys(browser.params.login.password) | |
$('.btn').click() | |
}, | |
// The params object will be passed directly to the protractor instance, | |
// and can be accessed from your test. It is an arbitrary object and can | |
// contain anything you may need in your test. | |
// This can be changed via the command line as: | |
// --params.login.user 'Joe' | |
params: { | |
login: { | |
username: 'starqle', | |
password: 'starqle' | |
} | |
}, | |
// ----- The test framework ----- | |
// | |
// Mocha has limited beta support. You will need to include your own | |
// assertion framework if working with mocha. | |
framework: 'mocha', | |
// ----- Options to be passed to mocha ----- | |
// | |
// See the full list at https://github.com/juliemr/minijasminenode | |
jasmineNodeOpts: { | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scenario configuration | |
var specConfig = require('./config/base-e2e-config'); | |
var expect = specConfig.expect; | |
var moment = specConfig.moment; | |
// Page Objects | |
var procurementIndexPage = require('./pages/application/procurement/procurement-index-page'); | |
var procurementDetailShowPage = require('./pages/application/procurement/procurement-detail-show-page'); | |
var procurementDetailItemsPage = require('./pages/application/procurement/procurement-detail-items-page'); | |
var procurementDetailStatusesPage = require('./pages/application/procurement/procurement-detail-statuses-page'); | |
var procurementDetailAdjustmentsPage = require('./pages/application/procurement/procurement-detail-adjustments-page'); | |
var procurementDetailTermsPage = require('./pages/application/procurement/procurement-detail-terms-page'); | |
var inventoryIndexPage = require('./pages/application/inventory/inventory-index-page'); | |
var inventoryShowPage = require('./pages/application/inventory/inventory-show-page'); | |
describe("SHIS-229: Procurement Management", function() { | |
browser.driver.getAllWindowHandles().then(function(handles) { | |
console.log(handles[0]); | |
browser.driver.switchTo().window(handles[0]); | |
}); | |
browser.driver.manage().window().setPosition(0, 0); | |
browser.driver.manage().window().setSize(1366, 1200); | |
var today = moment().format('DD-MM-YYYY'); | |
// Callback for 'before' the whole test is executed | |
// aka only executed once | |
before(function() { | |
}); | |
// Callback for 'before each' test is executed | |
beforeEach(function() { | |
}); | |
// Callback for 'after' the whole test is executed | |
after(function() { | |
// Revert the changes made after e2e-test | |
//specConfig.seed_init(); | |
}); | |
afterEach(function() { | |
}); | |
describe("procurement index page", function() { | |
it("should be able to go to procurements management page", function() { | |
element(by.repeater('level0 in mainNavigation').row(0)).click(); | |
element(by.repeater('level1 in level0.children').row(4)).click(); | |
expect(browser.getTitle()).to.eventually. | |
equal('http://127.0.0.1:9000/procurements'); | |
}); | |
it("should be able to open and close new procurement modal", function() { | |
procurementIndexPage.newProcurementButton.click(); | |
expect(procurementIndexPage.newProcurementModal.getAttribute('aria-hidden')). | |
to.eventually.equal('false'); | |
procurementIndexPage.closeProcurementButton.click(); | |
expect(procurementIndexPage.newProcurementModal.getAttribute('aria-hidden')). | |
to.eventually.equal('true'); | |
}); | |
it("should be able to make new procurement", function() { | |
var oldProcurementCount; | |
procurementIndexPage.gridRows.then(function(arr) { | |
oldProcurementCount = arr.length; | |
}); | |
procurementIndexPage.newProcurementButton.click(); | |
expect(procurementIndexPage.newProcurementModal.getAttribute('aria-hidden')).to.eventually.equal('false'); | |
procurementIndexPage.senderField.sendKeys('Bill').then(function() { | |
// Protractor doesn't wait for typeahead to finish | |
// so the test will wait manually by 600ms to allow | |
// typeahead finish fetching the datasets | |
browser.sleep(600); | |
procurementIndexPage.senderField.sendKeys(protractor.Key.ARROW_RIGHT); | |
}); | |
procurementIndexPage.receiverField.sendKeys('Pfiz').then(function() { | |
browser.sleep(600); | |
procurementIndexPage.receiverField.sendKeys(protractor.Key.ARROW_RIGHT); | |
}); | |
procurementIndexPage.entryDateField.click().then(function() { | |
datepickerToday = $('.datepicker').findElement(by.css('.today')); | |
datepickerToday.click(); | |
expect(procurementIndexPage.entryDateField.getAttribute('value')).to.eventually.equal(today) | |
}); | |
procurementIndexPage.createProcurementButton.click(); | |
procurementIndexPage.gridRows.then(function(arr) { | |
var lastRow = procurementIndexPage.gridRows.last(); | |
var lastRowSender = lastRow.findElement(by.binding('row.entity.sender_name')); | |
var lastRowReceiver = lastRow.findElement(by.binding('row.entity.receiver_name')); | |
var lastRowEntryDate = lastRow.findElement(by.binding('row.entity.entry_date')); | |
expect(arr.length).to.equal(oldProcurementCount + 1); | |
expect(lastRowSender.getText()).to.eventually.equal('Bill Franklin'); | |
expect(lastRowReceiver.getText()).to.eventually.equal('Pfizer'); | |
expect(lastRowEntryDate.getText()).to.eventually. | |
equal(today); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment