Skip to content

Instantly share code, notes, and snippets.

@edwinestrada
Created January 12, 2018 15:15
Show Gist options
  • Save edwinestrada/75a0ef9af333028943f5f6aa4b3e5794 to your computer and use it in GitHub Desktop.
Save edwinestrada/75a0ef9af333028943f5f6aa4b3e5794 to your computer and use it in GitHub Desktop.
Example Protractor Tests
do ->
'use strict'
### globals describe,it,browser,expect ###
describe 'On arriving to a conflicted snap that was previously assessed', ->
describe 'should have correct elements, title, and URL', ->
unassessedSnapPage = null
assessedSnapPage = null
conflictedSnapPage = null
beforeAll ->
loginPage = require '../login/page/login-page.js'
loginPage.load()
chainLaunchpadPage = loginPage.login browser.params.userEmail, browser.params.userPassword
dashboardPage = chainLaunchpadPage.clickOnFirstLocationCard()
dashboardPage.setChainIdFromLocalStorage()
dashboardPage.setLocationIdFromLocalStorage()
dashboardPage.setUserIdFromLocalStorage()
unassessedTabPage = dashboardPage.clickOnUnassessedTab()
unassessedSnapPage = unassessedTabPage.clickOnFirstCard()
it 'pick a service recommendation', ->
expect(unassessedSnapPage.servicesDropdown.isPresent()).toEqual true
unassessedSnapPage.servicesDropdown.sendKeys browser.params.recommended.service
# unassessedSnapPage.servicesDropdown.all(By.tagName('option')).then (options) -> options[0].click()
it 'add the selected service', ->
unassessedSnapPage.addServiceButton.click()
it 'pick a stylist recommendation', ->
expect(unassessedSnapPage.stylistsDropdown.isPresent()).toEqual true
unassessedSnapPage.stylistsDropdown.sendKeys browser.params.recommended.stylist
# unassessedSnapPage.stylistsDropdown.all(By.tagName('option')).then (options) -> options[0].click()
it 'add the selected stylist', ->
unassessedSnapPage.addStylistButton.click()
unassessedSnapPage.setSnapIdFromUrl().then () ->
assessedSnapPage = unassessedSnapPage.clickOnReadyToBookButton()
expect(browser.getLocationAbsUrl()).toEqual "/snap/assessed/#{browser.params.snapId}"
it 'should go to the assessed snap and send it to conflicted', ->
conflictedSnapPage = assessedSnapPage.clickOnSendToConflictedButton()
expect(browser.getLocationAbsUrl()).toEqual "/snap/conflicted/#{browser.params.snapId}"
it 'should display the correct title', ->
expect(browser.getTitle()).toBe 'Snap Manager'
it 'should load the correct URL', ->
expect(browser.getLocationAbsUrl()).toEqual "/snap/conflicted/#{browser.params.snapId}"
it 'should have a status label of "CONFLICTED"', ->
expect(conflictedSnapPage.statusLabel.getText()).toEqual 'CONFLICTED'
describe 'after being sent from assessed to conflicted, edited, saved, and then send back to assessed', ->
unassessedSnapPage = null
assessedSnapPage = null
conflictedSnapPage = null
returnedToPage = null
beforeAll ->
loginPage = require '../login/page/login-page.js'
loginPage.load()
chainLaunchpadPage = loginPage.login browser.params.userEmail, browser.params.userPassword
dashboardPage = chainLaunchpadPage.clickOnFirstLocationCard()
dashboardPage.setChainIdFromLocalStorage()
dashboardPage.setLocationIdFromLocalStorage()
dashboardPage.setUserIdFromLocalStorage()
unassessedTabPage = dashboardPage.clickOnUnassessedTab()
unassessedSnapPage = unassessedTabPage.clickOnFirstCard()
it 'pick a service recommendation', ->
expect(unassessedSnapPage.servicesDropdown.isPresent()).toEqual true
unassessedSnapPage.servicesDropdown.sendKeys browser.params.recommended.service
# unassessedSnapPage.servicesDropdown.all(By.tagName('option')).then (options) -> options[0].click()
it 'add the selected service', ->
unassessedSnapPage.addServiceButton.click()
it 'pick a stylist recommendation', ->
expect(unassessedSnapPage.stylistsDropdown.isPresent()).toEqual true
unassessedSnapPage.stylistsDropdown.sendKeys browser.params.recommended.stylist
# unassessedSnapPage.stylistsDropdown.all(By.tagName('option')).then (options) -> options[0].click()
it 'add the selected stylist', ->
unassessedSnapPage.addStylistButton.click()
unassessedSnapPage.setSnapIdFromUrl().then () ->
assessedSnapPage = unassessedSnapPage.clickOnReadyToBookButton()
expect(browser.getLocationAbsUrl()).toEqual "/snap/assessed/#{browser.params.snapId}"
it 'should go to the assessed snap and send it to conflicted', ->
conflictedSnapPage = assessedSnapPage.clickOnSendToConflictedButton()
expect(browser.getLocationAbsUrl()).toEqual "/snap/conflicted/#{browser.params.snapId}"
it 'should click edit button', ->
conflictedSnapPage.editButton.click()
it 'should enter new assessorsNote', ->
conflictedSnapPage.assessorsNote.sendKeys 'I am editing this note in conflicted mode!'
it 'should click save button', ->
conflictedSnapPage.saveButton.click()
browser.sleep 3000
expect(conflictedSnapPage.sendToButton.getText()).toEqual 'SEND BACK TO ASSESSED'
it 'should take snap back to assessed', ->
conflictedSnapPage.clickOnSendToButton()
browser.sleep 3000
returnedToPage = unassessedSnapPage
expect(browser.getLocationAbsUrl()).toEqual "/snap/assessed/#{browser.params.snapId}"
it 'should have a status label present', ->
expect(returnedToPage.statusLabel.isPresent()).toEqual true
it 'should have a status label of "ASSESSED"', ->
expect(returnedToPage.statusLabel.getText()).toEqual 'ASSESSED'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment