-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix the mapping again, its strange * Set up docker services for protractor tests * Editor configuration * Steps to run e2e tests in Readme * Run tests through 'npm test' and set up env file for tests * Store Manager login tests (+ve and -ve) * Circle CI to run protractor tests * move test runner into the e2e directory * Circle CI won't be running tests anymore Probably will set up a pre commit git hook that'll run before every commit.
- Loading branch information
1 parent
f0a8a91
commit 5311aab
Showing
13 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MANAGER_LOGIN_USERNAME= | ||
MANAGER_LOGIN_PASSWORD= | ||
|
||
# the HOST in this URL should be the same as the value configured for VM_EXTERNAL_IP | ||
BASE_URL=http://<HOST>/#/ | ||
|
||
# each protractor run resembles one end-user | ||
# by increasing scale, you can simulate multiple end-users | ||
TEST_SCALE=1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM node:6.10.3 | ||
COPY . /project | ||
WORKDIR /project | ||
RUN npm install -g protractor | ||
RUN npm install | ||
ENTRYPOINT [ "protractor" ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Warehouse - e2e Testing Document | ||
|
||
## Prerequisites | ||
|
||
#### Docker Compose | ||
Compose is a tool for defining and running multi-container Docker applications | ||
|
||
#### Setup `.env` file | ||
1. Copy `.env.example` to `.env` file | ||
2. Configure `.env` file with valid values for testing | ||
|
||
## How To Run Test Cases | ||
- In the app root directory, run `docker-compose up e2e-selenium-and-chrome-debug`. This will create a container with image `selenium/standalone-chrome-debug`, details of which can be found here: https://github.com/SeleniumHQ/docker-selenium. | ||
- In your mac spotlight, type `vnc://<HOST>:5900`. | ||
- the HOST in this URL should be the same as the value configured for VM_EXTERNAL_IP | ||
- This will open a remote desktop access software which will allow you to view the tests running inside the docker container. | ||
- After the container is up, use `npm run test`. This will run the tests specified in `protractor.conf.js`. | ||
- the underlying command that runs is: `docker-compose up e2e-protractor-test-runner-debug` | ||
- if you want to treat it as a test harness, use [scaling](https://docs.docker.com/compose/reference/up/) and run this command directly: | ||
- `SCALE=5 npm run stressTest` | ||
- each protractor run resembles one end-user | ||
- by increasing scale, you can simulate multiple end-users |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "2" | ||
services: | ||
e2e-selenium-and-chrome-debug: | ||
ports: | ||
- "4444" | ||
- "5900:5900" | ||
image: selenium/standalone-chrome-debug | ||
volumes: | ||
- /dev/shm:/dev/shm | ||
e2e-protractor-test-runner-debug: | ||
build: . | ||
env_file: .env | ||
command: protractor.conf.js --seleniumAddress=http://e2e-selenium-and-chrome-debug:4444/wd/hub | ||
volumes: | ||
- ./modules:/project/modules | ||
- ./package.json:/project/package.json | ||
- ./protractor.conf.js:/project/protractor.conf.js |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = function () { | ||
|
||
var self = this; | ||
|
||
/** | ||
* @description Login using email and password | ||
* @param email | ||
* @param password | ||
*/ | ||
self.login = function (email, password) { | ||
console.log('Entering Login page'); | ||
var baseUrl = browser.baseUrl; | ||
var testUrl = browser.baseUrl + 'login'; | ||
browser.get(testUrl); | ||
console.log('Entering username and password', email, password); | ||
element(by.model('userName')).sendKeys(email); | ||
element(by.model('password')).sendKeys(password); | ||
console.log('Clicking login button'); | ||
return element(by.css('button[ng-click="login(userName,password)"]')).click(); | ||
}; | ||
|
||
/** | ||
* @description Click on the logout button | ||
*/ | ||
self.logout = function () { | ||
var logoutButton = element(by.css('a[href="#/logout"]')); | ||
console.log('Clicking logout button'); | ||
return logoutButton.click(); | ||
}; | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
manager: { | ||
email: process.env.MANAGER_LOGIN_USERNAME, | ||
password: process.env.MANAGER_LOGIN_PASSWORD | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var AuthFunctions = require('./../pages/auth.po.js'); | ||
describe('Login', function () { | ||
|
||
var authFunctions = new AuthFunctions(); | ||
var authParams = require('./../testData/auth.td.js'); | ||
var manager = authParams.manager; | ||
|
||
/** | ||
* Login to the warehouse as a store manager with correct credentials, | ||
* and redirect to store-landing page. | ||
*/ | ||
it('Store manager login', function () { | ||
|
||
authFunctions.login(manager.email, manager.password) | ||
.then(function () { | ||
expect(browser.getCurrentUrl()).toContain('/store-landing'); | ||
console.log('Entered store landing page'); | ||
}); | ||
|
||
}); | ||
|
||
/** | ||
* Logout of the warehouse successfully, and redirect back to login page | ||
*/ | ||
it('Store manager logout', function () { | ||
authFunctions.logout() | ||
.then(function () { | ||
expect(browser.getCurrentUrl()).toContain('/login'); | ||
console.log('Logged out successfully'); | ||
}); | ||
}); | ||
|
||
|
||
/** | ||
* Login to the warehouse using invalid username and password, and expect | ||
* to get an error without any redirection | ||
*/ | ||
it('Store manager login wrong username and password', function () { | ||
authFunctions.login(manager.email + 'blah', manager.password + 'blah') | ||
.then(function () { | ||
var userNameError = element(by.binding('errors.username')).getText(); | ||
expect(browser.getCurrentUrl()).toContain('/login'); | ||
expect(userNameError).toBe('login failed'); | ||
console.log('Login failure checked successfully'); | ||
}); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "warehouse-e2e", | ||
"version": "1.0.0", | ||
"description": "Warehouse e2e protractor tests", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ShoppinPal/warehouse.git" | ||
}, | ||
"keywords": [ | ||
"warehouse", | ||
"protractor", | ||
"e2e" | ||
], | ||
"scripts": { | ||
"protractor": "protractor", | ||
"webdriver-manager": "webdriver-manager", | ||
"test": "docker-compose up e2e-protractor-test-runner-debug", | ||
"stressTest": "docker-compose up --scale e2e-protractor-test-runner-debug=${SCALE} e2e-protractor-test-runner-debug" | ||
}, | ||
"devDependencies": { | ||
"protractor-jasmine2-screenshot-reporter": "0.4.0", | ||
"protractor": "5.1.2" | ||
}, | ||
"author": "Kamal Khatwani", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/ShoppinPal/warehouse/issues" | ||
}, | ||
"homepage": "https://github.com/ShoppinPal/warehouse#readme" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
exports.config = { | ||
framework: 'jasmine', | ||
specs: ['./modules/auth/tests/*.js'], | ||
jasmineNodeOpts: { | ||
defaultTimeoutInterval: 1000 * 60 * 10 | ||
}, | ||
baseUrl: process.env.BASE_URL | ||
}; |
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
Submodule warehouse-workers
updated
from 7c06cc to 5ee656