Skip to content

Commit

Permalink
browserstack example (#1409)
Browse files Browse the repository at this point in the history
* beginning of getting browserstack working

* More configs for browserstack

* runner has been moved

* creating test suite helper

* fixes and moving some stuff around

* More fixes. Allow the user to pick and choose what test suites to run.

This will make it easier for the user if they are switching test
runners frequently. I didn’t like adding all the tests in one array per
configuration. This fixes that.

Also allows the user to pick and choose what test suites apply to them.

* lint fix

* Adding reporter for tests, changed admin email, adding npm scripts for running tests

* Allow Allure reporting to be optional

* Primer for switching login/checkout tests to register/checkout

* Login tests, are now register tests

This also removes the dependency to having to create a user prior to
running

* Adding reporting to browserstack conf

Also, added npm script for opening report. Another thing I noticed,
browserstack tunnel sometimes hangs. So added process killer.

* Updating test descriptions

* lint fix

* updating npm package

* Addresses login test with hardcoded user assertion

* This allows the user to use dynamic ids in tests

* updated login test to pass local

* updated test packages

* updated from development

- use REACTION_USER/AUTH if available.

* updated versions

* updated user data
  • Loading branch information
Capt-Slow authored and Aaron Judd committed Oct 17, 2016
1 parent 0f43c18 commit 62713b6
Show file tree
Hide file tree
Showing 35 changed files with 331 additions and 294 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ node_modules
npm-debug.log
pids
results
allure-results

client/plugins.js
server/plugins.js
Expand Down
22 changes: 11 additions & 11 deletions .meteor/versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accounts-base@1.2.11
accounts-base@1.2.12_1
accounts-facebook@1.0.10
accounts-google@1.0.10
accounts-oauth@1.1.13
Expand Down Expand Up @@ -53,20 +53,20 @@ cfs:upload-http@0.0.20
cfs:worker@0.1.4
check@1.2.3
chuangbo:cookie@1.1.0
coffeescript@1.2.4_1
coffeescript@1.2.4_2
dburles:factory@1.1.0
ddp@1.2.5
ddp-client@1.3.1
ddp-client@1.3.1_1
ddp-common@1.2.6
ddp-rate-limiter@1.0.5
ddp-server@1.3.10
ddp-server@1.3.10_1
deps@1.0.12
diff-sequence@1.0.6
dispatch:mocha@0.0.9
ecmascript@0.5.8_1
ecmascript-runtime@0.3.14_1
ejson@1.0.12
email@1.1.17
email@1.1.17_1
es5-shim@4.6.14_1
facebook@1.2.9
fastclick@1.0.12
Expand Down Expand Up @@ -105,25 +105,25 @@ meteorhacks:meteorx@1.4.1
meteorhacks:picker@1.0.3
meteorhacks:ssr@2.2.0
meteorhacks:subs-manager@1.6.4
minifier-css@1.2.14
minifier-css@1.2.14_1
minifier-js@1.2.14_1
minimongo@1.0.17
mobile-experience@1.0.4
mobile-status-bar@1.0.12
modules@0.7.6_1
modules-runtime@0.7.6_1
momentjs:moment@2.15.1
mongo@1.1.12_1
mongo@1.1.12_5
mongo-id@1.0.5
mongo-livedata@1.0.12
mrt:later@1.6.1
npm-bcrypt@0.9.1
npm-mongo@1.5.50
npm-bcrypt@0.9.1_1
npm-mongo@2.2.10_1
oauth@1.1.11
oauth-encryption@1.2.0
oauth1@1.1.10
oauth2@1.1.10
observe-sequence@1.0.12
observe-sequence@1.0.13
ongoworks:security@2.0.1
ordered-dict@1.0.8
practicalmeteor:chai@2.1.0_1
Expand Down Expand Up @@ -154,7 +154,7 @@ templating-compiler@1.2.15
templating-runtime@1.2.15
templating-tools@1.0.5
tmeasday:check-npm-versions@0.3.1
tmeasday:publish-counts@0.7.3
tmeasday:publish-counts@0.8.0
tracker@1.1.0
twitter@1.1.12
ui@1.0.12
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@
"autoprefixer": "^6.5.0",
"babel-eslint": "^7.0.0",
"babel-preset-stage-2": "^6.17.0",
"browserstack-local": "^1.0.0",
"chai": "^3.5.0",
"eslint": "^3.7.1",
"eslint-plugin-react": "^6.3.0",
"js-yaml": "^3.6.1",
"react-addons-test-utils": "^15.3.2",
"wdio-mocha-framework": "^0.4.3",
"wdio-allure-reporter": "^0.1.1",
"webdriverio": "^4.2.16"
},
"postcss": {
Expand All @@ -99,5 +101,12 @@
]
}
}
},
"scripts": {
"create-report": "allure generate allure-results/ -o ~/allure-report",
"open-report": "cd && allure report open",
"del-report": "rm -rf ~/allure-report && rm -rf allure-results",
"test-local": "wdio tests/runner/local.conf.js",
"test-browserstack": "wdio tests/runner/browserstack.conf.js; kill $(ps aux | grep '[b]rowserstack' | awk '{print $2}')"
}
}
8 changes: 8 additions & 0 deletions tests/acceptance-tests/config/settings.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#This setting describes the url to test against
#Sould also be a command line setting for this
base_url: http://localhost:3000

browser: chrome

# browserstack additional capabilities
browser_version: "52.0"
os: Windows
os_version: "10"
resolution: "1920x1080"
17 changes: 17 additions & 0 deletions tests/acceptance-tests/config/test-suite-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Enable and disable different suites of tests

# Payment Processor specific tests
braintree: false
stripe: false
authnet: false
paypal: false
example: false

# Admin functionality
permissions: false

# Regression suites
smoke_test: true

# Test reporter
allure: true
11 changes: 6 additions & 5 deletions tests/acceptance-tests/config/user-data.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
admin_email: "rbgd5ngh@localhost"
admin_pw: "GCFTnUxz"
admin_user: Administrator
admin_email: testing@reactioncommerce.com
admin_pw: password123

guest_email: josh@reactioncommerce.com
guest_email: "guest@reactioncommerce.com"
guest_pw: password123

# shop address
country: US
name: Josh Ewing
name: Lewis Hamilton
address1: 2110 Main Street.
postal: 90405
city: Santa Monica
region: CA
phone: 555-555-5555

# payment info
card_holder: Josh Ewing
card_holder: Nico Roseberg
visa: 4242424242424242
paypal_visa: 4111111111111111
stripe_visa: 4000000000000077
Expand Down
3 changes: 3 additions & 0 deletions tests/acceptance-tests/elements/element-ids.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
login_dropdown: Sign In
login_email_fld_id: email
login_pw_fld_id: password
6 changes: 6 additions & 0 deletions tests/acceptance-tests/elements/element-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ login_email_fld: "[class='form-control login-input-email']"
login_pw_fld: "[class='form-control login-input-password']"
login_btn: "[data-event-action='submitSignInForm']"

#account profile
pl_email_address_fld: "//div[2]/div/div/div/form/div/input"
pl_password_fld: "//div[2]/div/div/div/form/div[2]/input"
pl_register_lnk: "//div[2]/div/div/div/form/div[4]/a[2]"
pl_register_btn: "//button[@type='Submit']"

# dashoard locators
dashboard_btn: "span.icon > i.icon-reaction-logo"
dashboard_hdr_txt: "h3.nav-dashboard-title > span"
Expand Down
25 changes: 22 additions & 3 deletions tests/acceptance-tests/lib/basic-user-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ const yaml = require("js-yaml");
const fs = require("fs");

const eleMap = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/elements/element-map.yml", "utf8"));
const usrData = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/config/user-data.yml", "utf8"));
const browserConfig = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/config/settings.yml", "utf8"));

// default to process env if we've got that
const adminEmail = process.env.REACTION_EMAIL || usrData.admin_email;
const adminPassword = process.env.REACTION_AUTH || usrData.admin_pw;

module.exports = {
UserActions: {
userLogin: function (user) {
const usrData = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/config/user-data.yml", "utf8"));
browser.pause("5000");
browser.click(eleMap.login_dropdown_btn);
if (user === "admin") {
browser.setValue(eleMap.login_email_fld, usrData.admin_email);
browser.setValue(eleMap.login_pw_fld, usrData.admin_pw);
browser.setValue(eleMap.login_email_fld, adminEmail);
browser.setValue(eleMap.login_pw_fld, adminPassword);
}
if (user === "guest") {
browser.setValue(eleMap.login_email_fld, usrData.guest_email);
Expand All @@ -35,6 +40,20 @@ module.exports = {
browser.click(eleMap.shop_btn);
browser.pause("3000");
}
},
registerUser: function () {
const baseUrl = browserConfig.base_url.toString();
const regUrl = baseUrl + "/reaction/account/profile";
browser.url(regUrl);
browser.pause(5000);
const ep = (new Date).getTime();
const email = ep + "email@reactioncommerce.com";
browser.setValue(eleMap.pl_email_address_fld, email);
browser.setValue(eleMap.pl_password_fld, usrData.guest_pw);
browser.click(eleMap.pl_register_lnk);
browser.pause(2000);
browser.click(eleMap.pl_register_btn);
browser.pause(2000);
}
}
};
18 changes: 18 additions & 0 deletions tests/acceptance-tests/lib/get-elements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";

module.exports = {
getElementByXpath: function (path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
},
getElementById: function (ele) {
const grabElement = browser.execute(function (ele) {
const elementStr = ele;
const elementId = '[id^="' + elementStr + '-"]';
return "#" + document.querySelector(elementId).id;
}, ele);
return grabElement;
},
retId: function (element) {
return this.getElementById(element).value;
}
};
7 changes: 0 additions & 7 deletions tests/acceptance-tests/lib/get-xpath.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const adminUser = require("../../lib/admin-order-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");
const adminUser = require("../../../../lib/admin-order-actions.js");


beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const adminUser = require("../../lib/admin-order-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");
const adminUser = require("../../../../lib/admin-order-actions.js");


beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");

beforeEach(function () {
const browserConfig = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/config/settings.yml", "utf8"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");


beforeEach(function () {
Expand All @@ -13,10 +13,10 @@ beforeEach(function () {
});


describe("authorize net logged in checkout test", function () {
describe("authorize net register user and checkout test", function () {
const eleMap = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/elements/element-map.yml", "utf8"));
it("verify logged in user can checkout with authorize net", function () {
userDo.UserActions.userLogin("guest");
it("verify user can register checkout with authorize net", function () {
userDo.UserActions.registerUser();
browser.pause("5000");
userDo.UserActions.refreshShop();
browser.click(eleMap.product);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const adminUser = require("../../lib/admin-order-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");
const adminUser = require("../../../../lib/admin-order-actions.js");


beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const adminUser = require("../../lib/admin-order-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");
const adminUser = require("../../../../lib/admin-order-actions.js");


beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");

beforeEach(function () {
const browserConfig = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/config/settings.yml", "utf8"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const yaml = require("js-yaml");
const fs = require("fs");
const expect = require("chai").expect;
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");


beforeEach(function () {
Expand All @@ -13,10 +13,10 @@ beforeEach(function () {
});


describe("braintree logged in checkout test", function () {
describe("braintree register user and checkout test", function () {
const eleMap = yaml.safeLoad(fs.readFileSync("./tests/acceptance-tests/elements/element-map.yml", "utf8"));
it("verify logged in user can checkout with braintree", function () {
userDo.UserActions.userLogin("guest");
it("verify user can register and checkout with braintree", function () {
userDo.UserActions.registerUser();
browser.pause("5000");
userDo.UserActions.refreshShop();
browser.click(eleMap.product);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";
const yaml = require("js-yaml");
const fs = require("fs");
const shopUser = require("../../lib/user-shop-actions.js");
const userDo = require("../../lib/basic-user-actions.js");
const adminUser = require("../../lib/admin-order-actions.js");
const shopUser = require("../../../../lib/user-shop-actions.js");
const userDo = require("../../../../lib/basic-user-actions.js");
const adminUser = require("../../../../lib/admin-order-actions.js");


beforeEach(function () {
Expand Down
Loading

0 comments on commit 62713b6

Please sign in to comment.