From af9fc5ec0c797f86a1347951bf48564e133b42f8 Mon Sep 17 00:00:00 2001 From: joykare Date: Tue, 25 Apr 2017 15:33:13 +0300 Subject: [PATCH 01/44] component snapshot --- .../__tests__/components/orderSummary.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js diff --git a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js new file mode 100644 index 00000000000..1f35f3d7660 --- /dev/null +++ b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js @@ -0,0 +1,18 @@ +// test("Bla", () => { +// expect(true).toBe(true); +// }); +import React from "react"; +import OrderSummary from "../../components/orderSummary"; +import { shallow } from "enzyme"; +import shallowToJSON from "enzyme-to-json"; + +test("OrderSummary snapshot test", () => { + const component = shallow({}} + tracking={()=>{}} + order={{ shipping: [{ shipmentMethod: {} }], billing: [{ paymentMethod: {}, invoice: {} }] }} + shipmentStatus={()=>({})} + profile={{}} + printableLabels={()=>({})} />); + const tree = shallowToJSON(component); + expect(tree).toMatchSnapshot(); +}); From 6fa0cc6b1760094e1960aa0bb9df1f1731bcd64a Mon Sep 17 00:00:00 2001 From: joykare Date: Tue, 25 Apr 2017 22:15:00 +0300 Subject: [PATCH 02/44] babel additions --- .babelrc | 2 +- .../__snapshots__/orderSummary.spec.js.snap | 187 ++++++++++++++++++ .../__tests__/components/orderSummary.spec.js | 3 - package.json | 7 + 4 files changed, 195 insertions(+), 4 deletions(-) create mode 100644 imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap diff --git a/.babelrc b/.babelrc index 0d172c5c9e0..00f112f96cc 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,4 @@ { "plugins": ["lodash"], - "presets": ["stage-2"] + "presets": ["latest", "react", "stage-2"] } diff --git a/imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap b/imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap new file mode 100644 index 00000000000..8fcf163bac6 --- /dev/null +++ b/imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap @@ -0,0 +1,187 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`OrderSummary snapshot test 1`] = ` +
+
+ + , +
+ + ID + +
+
+
+
+
+ +
+
+ + Created + +
+
+
+ + Processor + +
+
+
+ + Payment + +
+ ( + ) +
+
+
+ + Transaction + +
+
+
+ + Carrier + +
+ - +
+
+
+ + Tracking + +
+
+
+ + Labels + + + + Print Customs + + +
+
+
+
+
+ + Ship to + +
+ + Phone: + +
+
+
+ +
+ +
+ + , + , + + +
+
+`; diff --git a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js index 1f35f3d7660..c567134f192 100644 --- a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js +++ b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js @@ -1,6 +1,3 @@ -// test("Bla", () => { -// expect(true).toBe(true); -// }); import React from "react"; import OrderSummary from "../../components/orderSummary"; import { shallow } from "enzyme"; diff --git a/package.json b/package.json index e56acd5e01d..a83e76d9dfe 100644 --- a/package.json +++ b/package.json @@ -99,14 +99,21 @@ }, "devDependencies": { "babel-eslint": "^7.2.1", + "babel-jest": "^19.0.0", "babel-plugin-lodash": "^3.2.11", + "babel-preset-latest": "^6.24.1", + "babel-preset-react": "https://registry.npmjs.org/babel-preset-react/-/babel-preset-react-6.24.1.tgz", "babel-preset-stage-2": "^6.22.0", "browserstack-local": "^1.3.0", "chai": "^3.5.0", + "enzyme": "^2.8.2", + "enzyme-to-json": "^1.5.1", "eslint": "^3.18.0", "eslint-plugin-react": "^6.10.3", + "jest": "^19.0.2", "js-yaml": "^3.8.2", "react-addons-test-utils": "15.4.2", + "react-test-renderer": "^15.5.4", "wdio-allure-reporter": "^0.1.2", "wdio-mocha-framework": "^0.5.9", "webdriverio": "^4.6.2" From 49c3335c8eb4392659e83676294754d01e4a9879 Mon Sep 17 00:00:00 2001 From: joykare Date: Wed, 26 Apr 2017 21:34:46 +0300 Subject: [PATCH 03/44] remove dependancies not used --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index a83e76d9dfe..5bee556e519 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,6 @@ "jest": "^19.0.2", "js-yaml": "^3.8.2", "react-addons-test-utils": "15.4.2", - "react-test-renderer": "^15.5.4", "wdio-allure-reporter": "^0.1.2", "wdio-mocha-framework": "^0.5.9", "webdriverio": "^4.6.2" From e1472f70792cce0bd5e0851f48b1daee4e89b73c Mon Sep 17 00:00:00 2001 From: joykare Date: Wed, 26 Apr 2017 22:10:21 +0300 Subject: [PATCH 04/44] Use mocks to mock input props for component --- .../__tests__/components/orderSummary.spec.js | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js index c567134f192..689f1cec97d 100644 --- a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js +++ b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js @@ -3,13 +3,41 @@ import OrderSummary from "../../components/orderSummary"; import { shallow } from "enzyme"; import shallowToJSON from "enzyme-to-json"; +/** + * Order Summary is a display only component + * It receives props and displays them accordingly + */ + +afterEach(() => { + jest.clearAllMocks(); +}); + test("OrderSummary snapshot test", () => { - const component = shallow({}} - tracking={()=>{}} - order={{ shipping: [{ shipmentMethod: {} }], billing: [{ paymentMethod: {}, invoice: {} }] }} - shipmentStatus={()=>({})} - profile={{}} - printableLabels={()=>({})} />); + // Initializing all the props passed into order summary component + const dateFormat = jest.fn(); + const tracking = jest.fn(); + const profile = jest.fn(); + const shipmentStatus = jest.fn(()=>({})); + const printableLabels = jest.fn(()=>({})); + const order = { + shipping: [{ shipmentMethod: {} }], + billing: [ + { paymentMethod: {}, + invoice: {} + } + ] + }; + + const component = shallow( + + ); const tree = shallowToJSON(component); expect(tree).toMatchSnapshot(); }); From 6c5b725f6d60fb709d4a81112f55a53f7486e0fe Mon Sep 17 00:00:00 2001 From: joykare Date: Wed, 26 Apr 2017 22:29:50 +0300 Subject: [PATCH 05/44] Change stored snapshot to match new look after merge with development --- .../components/__snapshots__/orderSummary.spec.js.snap | 2 +- .../orders/client/__tests__/components/orderSummary.spec.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap b/imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap index 8fcf163bac6..bf4765cb8a1 100644 --- a/imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap +++ b/imports/plugins/core/orders/client/__tests__/components/__snapshots__/orderSummary.spec.js.snap @@ -48,7 +48,7 @@ exports[`OrderSummary snapshot test 1`] = ` } >
{ jest.clearAllMocks(); }); +/** + * Snapshots make sure your UI does not change unexpectedly + */ + test("OrderSummary snapshot test", () => { // Initializing all the props passed into order summary component const dateFormat = jest.fn(); From 65fb97b57e3d0a8479b47c0640ca10b9be3da263 Mon Sep 17 00:00:00 2001 From: joykare Date: Tue, 2 May 2017 12:42:04 +0300 Subject: [PATCH 06/44] replace babel-latest with babel-es2015 --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5bee556e519..b4396ac724b 100644 --- a/package.json +++ b/package.json @@ -101,9 +101,8 @@ "babel-eslint": "^7.2.1", "babel-jest": "^19.0.0", "babel-plugin-lodash": "^3.2.11", - "babel-preset-latest": "^6.24.1", - "babel-preset-react": "https://registry.npmjs.org/babel-preset-react/-/babel-preset-react-6.24.1.tgz", - "babel-preset-stage-2": "^6.22.0", + "babel-preset-es2015": "^6.22.0", + "babel-preset-react": "^6.24.1", "browserstack-local": "^1.3.0", "chai": "^3.5.0", "enzyme": "^2.8.2", From c96c7a240e644bc32f13774b5ac2243b5b45b42b Mon Sep 17 00:00:00 2001 From: joykare Date: Tue, 2 May 2017 12:43:24 +0300 Subject: [PATCH 07/44] Take care of warning --- .../orders/client/__tests__/components/orderSummary.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js index 5e638afd9f1..9cc1129bcff 100644 --- a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js +++ b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js @@ -20,9 +20,9 @@ test("OrderSummary snapshot test", () => { // Initializing all the props passed into order summary component const dateFormat = jest.fn(); const tracking = jest.fn(); - const profile = jest.fn(); const shipmentStatus = jest.fn(()=>({})); const printableLabels = jest.fn(()=>({})); + const profile = {}; const order = { shipping: [{ shipmentMethod: {} }], billing: [ From 5255cb0b1647b0f6db948636eb7910d7b8f7173c Mon Sep 17 00:00:00 2001 From: joykare Date: Tue, 2 May 2017 12:53:02 +0300 Subject: [PATCH 08/44] babelrc to es2015 --- .babelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index 00f112f96cc..d3d0d09fd36 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,4 @@ { "plugins": ["lodash"], - "presets": ["latest", "react", "stage-2"] + "presets": ["es2015", "react", "stage-2"] } From 4caa8273eb83bfb17a2339ad488e84d62c23d73d Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 4 May 2017 13:55:15 +0800 Subject: [PATCH 09/44] Add back in missing babel package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b4396ac724b..e407aaa9490 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,7 @@ "babel-eslint": "^7.2.1", "babel-jest": "^19.0.0", "babel-plugin-lodash": "^3.2.11", + "babel-preset-stage-2": "^6.22.0", "babel-preset-es2015": "^6.22.0", "babel-preset-react": "^6.24.1", "browserstack-local": "^1.3.0", From 433b1e7c6593876f55effe132750fadb927c6b45 Mon Sep 17 00:00:00 2001 From: Jeremy Shimko Date: Wed, 10 May 2017 19:31:35 -0400 Subject: [PATCH 10/44] no more globals! --- client/api/index.js | 5 --- .../accounts/templates/forgot/forgot.js | 1 + .../accounts/templates/signIn/signIn.js | 1 + .../accounts/templates/signUp/signUp.js | 1 + .../updatePassword/updatePassword.js | 1 + .../server/methods/authnet.js | 32 +++++++++---------- .../server/methods/braintreeApi.js | 2 +- .../server/methods/exampleapi.js | 4 +-- .../payments-paypal/server/methods/express.js | 4 +-- lib/api/account-validation.js | 3 +- lib/api/catalog.js | 2 +- lib/api/index.js | 1 + server/api/index.js | 15 --------- server/publications/collections/sessions.js | 1 - 14 files changed, 28 insertions(+), 45 deletions(-) diff --git a/client/api/index.js b/client/api/index.js index 64322a572fc..4facd0bf914 100644 --- a/client/api/index.js +++ b/client/api/index.js @@ -1,11 +1,6 @@ import { Reaction } from "/client/modules/core"; import { Router } from "/client/modules/router"; -// Legacy globals -// TODO: add deprecation warnings -ReactionCore = Reaction; -ReactionRouter = Router; - export { Reaction, Router diff --git a/client/modules/accounts/templates/forgot/forgot.js b/client/modules/accounts/templates/forgot/forgot.js index b08e3b5f27f..9815524561d 100644 --- a/client/modules/accounts/templates/forgot/forgot.js +++ b/client/modules/accounts/templates/forgot/forgot.js @@ -2,6 +2,7 @@ import { Meteor } from "meteor/meteor"; import { Template } from "meteor/templating"; import { i18next } from "/client/api"; import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers"; +import { LoginFormValidation } from "/lib/api"; Template.loginFormResetPasswordView.events({ diff --git a/client/modules/accounts/templates/signIn/signIn.js b/client/modules/accounts/templates/signIn/signIn.js index 629bf3ba0ab..1fa8d480080 100644 --- a/client/modules/accounts/templates/signIn/signIn.js +++ b/client/modules/accounts/templates/signIn/signIn.js @@ -1,6 +1,7 @@ import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers"; import { Meteor } from "meteor/meteor"; import { Template } from "meteor/templating"; +import { LoginFormValidation } from "/lib/api"; /** * onCreated: Login form sign in view diff --git a/client/modules/accounts/templates/signUp/signUp.js b/client/modules/accounts/templates/signUp/signUp.js index 4b94a19aa59..2cbfdffc6ec 100644 --- a/client/modules/accounts/templates/signUp/signUp.js +++ b/client/modules/accounts/templates/signUp/signUp.js @@ -1,5 +1,6 @@ import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers"; import { Template } from "meteor/templating"; +import { LoginFormValidation } from "/lib/api"; /** * onCreated: Login form sign up view diff --git a/client/modules/accounts/templates/updatePassword/updatePassword.js b/client/modules/accounts/templates/updatePassword/updatePassword.js index fdc5b03785a..1338ac6afce 100644 --- a/client/modules/accounts/templates/updatePassword/updatePassword.js +++ b/client/modules/accounts/templates/updatePassword/updatePassword.js @@ -2,6 +2,7 @@ import { Accounts } from "meteor/accounts-base"; import { Template } from "meteor/templating"; import { i18next } from "/client/api"; import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers"; +import { LoginFormValidation } from "/lib/api"; /** * Accounts Event: onResetPasswordLink When a user uses a password reset link diff --git a/imports/plugins/included/payments-authnet/server/methods/authnet.js b/imports/plugins/included/payments-authnet/server/methods/authnet.js index 5e23609701a..f155c010e38 100644 --- a/imports/plugins/included/payments-authnet/server/methods/authnet.js +++ b/imports/plugins/included/payments-authnet/server/methods/authnet.js @@ -38,6 +38,22 @@ function getSettings(settings, ref, valueName) { return undefined; } +const ValidCardNumber = Match.Where(function (x) { + return /^[0-9]{14,16}$/.test(x); +}); + +const ValidExpireMonth = Match.Where(function (x) { + return /^[0-9]{1,2}$/.test(x); +}); + +const ValidExpireYear = Match.Where(function (x) { + return /^[0-9]{4}$/.test(x); +}); + +const ValidCVV = Match.Where(function (x) { + return /^[0-9]{3,4}$/.test(x); +}); + Meteor.methods({ authnetSubmit: function (transactionType = "authorizeTransaction", cardInfo, paymentInfo) { check(transactionType, String); @@ -198,19 +214,3 @@ function voidTransaction(transId, service) { }); return Promise.await(transactionRequest); } - -ValidCardNumber = Match.Where(function (x) { - return /^[0-9]{14,16}$/.test(x); -}); - -ValidExpireMonth = Match.Where(function (x) { - return /^[0-9]{1,2}$/.test(x); -}); - -ValidExpireYear = Match.Where(function (x) { - return /^[0-9]{4}$/.test(x); -}); - -ValidCVV = Match.Where(function (x) { - return /^[0-9]{3,4}$/.test(x); -}); diff --git a/imports/plugins/included/payments-braintree/server/methods/braintreeApi.js b/imports/plugins/included/payments-braintree/server/methods/braintreeApi.js index 909590d0160..2acc7005347 100644 --- a/imports/plugins/included/payments-braintree/server/methods/braintreeApi.js +++ b/imports/plugins/included/payments-braintree/server/methods/braintreeApi.js @@ -76,7 +76,7 @@ function getGateway() { return gateway; } -getRefundDetails = function (refundId) { +function getRefundDetails(refundId) { check(refundId, String); const gateway = getGateway(); const braintreeFind = Meteor.wrapAsync(gateway.transaction.find, gateway.transaction); diff --git a/imports/plugins/included/payments-example/server/methods/exampleapi.js b/imports/plugins/included/payments-example/server/methods/exampleapi.js index 79e4cd383c1..40bf01ca00f 100644 --- a/imports/plugins/included/payments-example/server/methods/exampleapi.js +++ b/imports/plugins/included/payments-example/server/methods/exampleapi.js @@ -3,7 +3,7 @@ // And is called so that it can be stubbed out for testing. This would be a library // like Stripe or Authorize.net usually just included with a NPM.require -ThirdPartyAPI = { +const ThirdPartyAPI = { authorize: function (transactionType, cardData, paymentData) { if (transactionType === "authorize") { const results = { @@ -64,7 +64,7 @@ export const cardSchema = new SimpleSchema({ type: { type: String } }); -paymentDataSchema = new SimpleSchema({ +export const paymentDataSchema = new SimpleSchema({ total: { type: String }, currency: { type: String } }); diff --git a/imports/plugins/included/payments-paypal/server/methods/express.js b/imports/plugins/included/payments-paypal/server/methods/express.js index 41c40c91d03..df636108f09 100644 --- a/imports/plugins/included/payments-paypal/server/methods/express.js +++ b/imports/plugins/included/payments-paypal/server/methods/express.js @@ -375,14 +375,14 @@ function parseRefundReponse(response) { return paypalArray; } -getSetting = function (shopId, parameter) { +function getSetting(shopId, parameter) { const settings = Packages.findOne({ name: "reaction-paypal", shopId: shopId, enabled: true }).settings; return settings[parameter]; -}; +} // export methods to Meteor Meteor.methods(methods); diff --git a/lib/api/account-validation.js b/lib/api/account-validation.js index 337c8214c4b..0793f2e92cf 100644 --- a/lib/api/account-validation.js +++ b/lib/api/account-validation.js @@ -102,7 +102,7 @@ const validationMethods = { }; // Export object globally -LoginFormValidation = validationMethods; +export const LoginFormValidation = validationMethods; // Register validation methods as meteor methods Meteor.methods({ @@ -110,4 +110,3 @@ Meteor.methods({ "accounts/validation/email": validationMethods.email, "accounts/validation/password": validationMethods.password }); - diff --git a/lib/api/catalog.js b/lib/api/catalog.js index a753f194d30..9d8e2cbbbc2 100644 --- a/lib/api/catalog.js +++ b/lib/api/catalog.js @@ -1,7 +1,7 @@ import { Products } from "/lib/collections"; import { applyProductRevision } from "/lib/api/products"; -export default Catalog = { +export default { /** * setProduct * @summary method to set default/parameterized product variant diff --git a/lib/api/index.js b/lib/api/index.js index 4126eab0228..15090b1ef93 100644 --- a/lib/api/index.js +++ b/lib/api/index.js @@ -1,3 +1,4 @@ +export * from "./account-validation"; export { default as Catalog } from "./catalog"; export { default as ReactionProduct } from "./products"; export { PropTypes } from "./prop-types"; diff --git a/server/api/index.js b/server/api/index.js index 3048814ad61..4fb415a4225 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -6,21 +6,6 @@ import Hooks from "./hooks"; import Logger from "./logger"; import { MethodHooks } from "./method-hooks"; -// Legacy globals -// TODO: add deprecation warnings -ReactionCore = Reaction; -ReactionRouter = Router; -ReactionRegistry = { - assignOwnerRoles: Reaction.assignOwnerRoles, - createDefaultAdminUser: Reaction.createDefaultAdminUser, - getRegistryDomain: Reaction.getRegistryDomain, - loadPackages: Reaction.loadPackages, - loadSettings: Reaction.loadSettings, - Packages: Reaction.Packages, - setDomain: Reaction.setDomain, - setShopName: Reaction.setShopName -}; - export { Reaction, Accounts, diff --git a/server/publications/collections/sessions.js b/server/publications/collections/sessions.js index 608d0abed44..3122f9ea2e0 100644 --- a/server/publications/collections/sessions.js +++ b/server/publications/collections/sessions.js @@ -9,7 +9,6 @@ import { Reaction } from "/server/api"; */ export const ServerSessions = new Mongo.Collection("Sessions"); -this.ServerSessions = ServerSessions; Meteor.publish("Sessions", function (sessionId) { check(sessionId, Match.OneOf(String, null)); From b8bbb23908ccf2d166d4038d240b38983fd27ded Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 11 May 2017 08:36:00 +0800 Subject: [PATCH 11/44] Declare variable before assigning --- server/api/core/core.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/api/core/core.js b/server/api/core/core.js index 2324c561d46..3d98f731ac3 100644 --- a/server/api/core/core.js +++ b/server/api/core/core.js @@ -72,6 +72,7 @@ export default { let permissions; // default group to the shop or global if shop isn't defined for some reason. + let group; if (checkGroup !== undefined && typeof checkGroup === "string") { group = checkGroup; } else { From 0092774ae38dee315c5d05c8e5d032f11b8f725b Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 11 May 2017 09:14:42 +0800 Subject: [PATCH 12/44] Declare variable before assigning --- .../publications/collections/members-publications.app-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/publications/collections/members-publications.app-test.js b/server/publications/collections/members-publications.app-test.js index ee8075dac05..b543c1e7fec 100644 --- a/server/publications/collections/members-publications.app-test.js +++ b/server/publications/collections/members-publications.app-test.js @@ -36,7 +36,7 @@ describe("Account Publications", function () { }; const cursor = publication.apply(thisContext); // verify - data = cursor.fetch()[0]; + const data = cursor.fetch()[0]; expect(data._id).to.equal(user._id); }); @@ -64,7 +64,7 @@ describe("Account Publications", function () { const publication = Meteor.server.publish_handlers["ShopMembers"]; const cursor = publication.apply(thisContext); // verify - data = cursor.fetch(); + const data = cursor.fetch(); // we expect services will be clean object expect(data.some(_user => { // we expect two users. First will be without services, second with From 76942d37a31cf062101a8d0ab4a2429a7a33d8d6 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 11 May 2017 09:15:13 +0800 Subject: [PATCH 13/44] Declare variable before assigning. Remove unused variables --- .../publications/collections/orders-publications.app-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/publications/collections/orders-publications.app-test.js b/server/publications/collections/orders-publications.app-test.js index 43f604f0e92..70bb33b512c 100644 --- a/server/publications/collections/orders-publications.app-test.js +++ b/server/publications/collections/orders-publications.app-test.js @@ -62,7 +62,7 @@ describe("Order Publication", function () { }); sandbox.stub(Reaction, "getShopId", () => shop._id); sandbox.stub(Roles, "userIsInRole", () => true); - order = Factory.create("order", { status: "created" }); + const order = Factory.create("order", { status: "created" }); const publication = Meteor.server.publish_handlers["Orders"]; const cursor = publication.apply(thisContext); const data = cursor.fetch()[0]; @@ -81,7 +81,7 @@ describe("Order Publication", function () { }); sandbox.stub(Reaction, "getShopId", () => shop._id); sandbox.stub(Roles, "userIsInRole", () => false); - order = Factory.create("order", { status: "created" }); + Factory.create("order", { status: "created" }); const publication = Meteor.server.publish_handlers["Orders"]; const cursor = publication.apply(thisContext); expect(cursor.fetch().length).to.equal(0); From 5ce8d55a81ab5e21fcf396f2867b5b5a41e223d6 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 11 May 2017 09:15:30 +0800 Subject: [PATCH 14/44] Remove unused variable, check --- server/publications/collections/products.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/server/publications/collections/products.js b/server/publications/collections/products.js index 60a385b2565..3f4b3c3c79c 100644 --- a/server/publications/collections/products.js +++ b/server/publications/collections/products.js @@ -111,13 +111,6 @@ Meteor.publish("Products", function (productScrollLimit = 24, productFilters, so $in: productFilters.shops } }); - - // check if this user is a shopAdmin - for (const thisShopId of productFilters.shops) { - if (Roles.userIsInRole(this.userId, ["admin", "createProduct"], thisShopId)) { - shopAdmin = true; - } - } } // filter by tags From 789dfc9593efb0745714fa81ab23217c3ef75529 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 12 May 2017 10:35:14 +0800 Subject: [PATCH 15/44] Declare variable before using it --- server/startup/accounts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/startup/accounts.js b/server/startup/accounts.js index 4983d5c09d4..59e358122a4 100644 --- a/server/startup/accounts.js +++ b/server/startup/accounts.js @@ -168,7 +168,7 @@ export default function () { Accounts.onLogin((opts) => { // run onLogin hooks // (the options object must be returned by all callbacks) - options = Hooks.Events.run("onLogin", opts); + const options = Hooks.Events.run("onLogin", opts); // remove anonymous role // all users are guest, but anonymous user don't have profile access From 06e0bb1b3ae4d66068a695cbef3fd084578f20f4 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 12 May 2017 12:54:50 +0800 Subject: [PATCH 16/44] Declare variable before using it --- .../core/layout/client/templates/layout/alerts/inlineAlerts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js b/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js index f24ab78a4d2..8eb18aeccb7 100644 --- a/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js +++ b/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js @@ -4,7 +4,7 @@ import { Mongo } from "meteor/mongo"; /* * Forked and modifed from https://github.com/asktomsk/bootstrap-alerts/ */ -Alerts = { +const Alerts = { /* Default options. Can be overridden for application From 622122190389f266fc54d68a980b68adeaf00d1b Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 12 May 2017 14:00:10 +0800 Subject: [PATCH 17/44] Can't use `this` in an arrow function --- server/api/geocoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/api/geocoder.js b/server/api/geocoder.js index dcf97609f45..38466f72cd3 100644 --- a/server/api/geocoder.js +++ b/server/api/geocoder.js @@ -19,7 +19,7 @@ if (typeof Meteor.wrapAsync === "undefined") { /* eslint func-style: 1 */ // // init geocoder -export const GeoCoder = (options) => { +export const GeoCoder = function (options) { let extra; const self = this; // fetch shop settings for api auth credentials From 882fd7ddab23af8143830dcfe91c0384d5173ecf Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 12 May 2017 14:00:30 +0800 Subject: [PATCH 18/44] Correct function declarations --- .../client/checkout/braintree.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/imports/plugins/included/payments-braintree/client/checkout/braintree.js b/imports/plugins/included/payments-braintree/client/checkout/braintree.js index 321d8f5eaec..c8cb7d32b6d 100644 --- a/imports/plugins/included/payments-braintree/client/checkout/braintree.js +++ b/imports/plugins/included/payments-braintree/client/checkout/braintree.js @@ -16,32 +16,32 @@ Template.braintreePaymentForm.helpers({ }); -uiEnd = function (template, buttonText) { +function uiEnd(template, buttonText) { template.$(":input").removeAttr("disabled"); template.$("#btn-complete-order").text(buttonText); return template.$("#btn-processing").addClass("hidden"); -}; +} -paymentAlert = function (errorMessage) { +function paymentAlert(errorMessage) { return $(".alert").removeClass("hidden").text(errorMessage); -}; +} -hidePaymentAlert = function () { +function hidePaymentAlert() { return $(".alert").addClass("hidden").text(""); -}; +} -handleBraintreeSubmitError = function (error) { +function handleBraintreeSubmitError(error) { const serverError = error !== null ? error.message : void 0; if (serverError) { return paymentAlert("Server Error " + serverError); } else if (error) { return paymentAlert("Oops! Credit card is invalid. Please check your information and try again."); } -}; +} let submitting = false; -submitToBrainTree = function (doc, template) { +function submitToBrainTree(doc, template) { submitting = true; hidePaymentAlert(); const cardData = { @@ -97,7 +97,7 @@ submitToBrainTree = function (doc, template) { } } }); -}; +} AutoForm.addHooks("braintree-payment-form", { onSubmit: function (doc) { @@ -133,13 +133,13 @@ const normalizedStates = { default: "failed" }; -normalizeState = function (stateString) { +function normalizeState(stateString) { let normalizedState = normalizedStates[stateString]; if (typeof normalizedState === "undefined") { normalizedState = normalizedStates.default; } return normalizedState; -}; +} const normalizedModes = { settled: "capture", @@ -151,10 +151,10 @@ const normalizedModes = { default: "capture" }; -normalizeMode = function (modeString) { +function normalizeMode(modeString) { let normalizedMode = normalizedModes[modeString]; if (typeof normalizedMode === "undefined") { normalizedMode = normalizedModes.default; } return normalizedMode; -}; +} From 1d38e3f23e1f041eb35144fbd3f34bc1abe398f3 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 12 May 2017 14:02:22 +0800 Subject: [PATCH 19/44] Eliminate implied global `Alerts` + no undeclared --- client/modules/i18n/startup.js | 5 +++-- .../layout/client/templates/layout/alerts/reactionAlerts.js | 1 + imports/plugins/included/analytics/client/startup.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/modules/i18n/startup.js b/client/modules/i18n/startup.js index a7e7c5acc14..8d07570ffb7 100644 --- a/client/modules/i18n/startup.js +++ b/client/modules/i18n/startup.js @@ -4,6 +4,7 @@ import i18nextLocalStorageCache from "i18next-localstorage-cache"; import i18nextSprintfPostProcessor from "i18next-sprintf-postprocessor"; import i18nextJquery from "jquery-i18next"; import { Meteor } from "meteor/meteor"; +import { $ } from "meteor/jquery"; import { Tracker } from "meteor/tracker"; import { Reaction } from "/client/api"; import { Shops, Translations } from "/lib/collections"; @@ -97,7 +98,7 @@ Meteor.startup(() => { // global first time init event finds and replaces // data-i18n attributes in html/template source. - $elements = $("[data-i18n]").localize(); + $("[data-i18n]").localize(); // apply language direction to html if (i18next.dir(language) === "rtl") { @@ -144,7 +145,7 @@ Meteor.startup(() => { this.autorun((function () { return function () { i18nextDep.depend(); - $elements = $("[data-i18n]").localize(); + $("[data-i18n]").localize(); }; })(this)); }); diff --git a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js index 4dc16711ebb..0a78a62346c 100644 --- a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js +++ b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js @@ -2,6 +2,7 @@ import _ from "lodash"; import { Meteor } from "meteor/meteor"; import swal from "sweetalert2"; import "sweetalert2/dist/sweetalert2.css"; +import Alerts from "./inlineAlerts"; // Extends Bootstaps alerts and add more alert types Meteor.startup(function () { diff --git a/imports/plugins/included/analytics/client/startup.js b/imports/plugins/included/analytics/client/startup.js index 1ded80b1439..72627bc7d0c 100644 --- a/imports/plugins/included/analytics/client/startup.js +++ b/imports/plugins/included/analytics/client/startup.js @@ -3,6 +3,7 @@ import { Meteor } from "meteor/meteor"; import { Tracker } from "meteor/tracker"; import { AnalyticsEvents, Packages } from "/lib/collections"; import { Reaction, i18next, Logger } from "/client/api"; +import Alerts from "/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts"; // Create a queue, but don't obliterate an existing one! analytics = window.analytics = window.analytics || []; From 5b947a50763f050c500a56ad8b0fc8aee4d42d5a Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 12 May 2017 14:15:37 +0800 Subject: [PATCH 20/44] Remove commented out code --- .../server/methods/inventory.app-test.js | 94 ------------------- 1 file changed, 94 deletions(-) diff --git a/imports/plugins/included/inventory/server/methods/inventory.app-test.js b/imports/plugins/included/inventory/server/methods/inventory.app-test.js index df3ca6e9492..e9dfec1f3bb 100644 --- a/imports/plugins/included/inventory/server/methods/inventory.app-test.js +++ b/imports/plugins/included/inventory/server/methods/inventory.app-test.js @@ -94,98 +94,4 @@ describe("inventory method", function () { expect(newQty).to.equal(0); }); }); - - // - // inventory/register is invoked from hooks.js before cart update - // - describe("inventory/register invoked from hooks", function () { - // it("should create backordered inventory when no inventory available", function (done) { - // let product = Factory.create("product"); - // let cartId = Factory.create("cart")._id; - // let productId = product._id; - // let quantity = product.variants[0].inventoryQuantity; - // let variantData = product.variants[0]; - // - // spyOn(ReactionCore, "hasPermission").and.returnValue(true); - // spyOn(ReactionCore.Collections.Cart.after, "update"); - // expect(_.size(product.variants)).toEqual(1); - // - // // add to cart - // Meteor.call("cart/addToCart", cartId, productId, variantData, quantity, function () { - // // fetch reserved inventory - // let inventory = ReactionCore.Collections.Inventory.find({ - // "workflow.status": "backorder" - // }); - // - // let inventoryCount = _.size(inventory); - // expect(inventoryCount).toEqual(quantity); - // done(); - // }); - // }); - - // it("should reserve product variants added to cart", function () { - // let product = Factory.create("product"); - // let cartId = Factory.create("cart")._id; - // let productId = product._id; - // let quantity = product.variants[0].inventoryQuantity; - // let variantData = product.variants[0]; - // expect(_.size(product.variants)).toEqual(1); - // // create some inventory to reserve - // spyOn(ReactionCore, "hasPermission").and.returnValue(true); - // - // //Setup a spy to watch for calls to Inventory.insert - // spyOn(ReactionCore.Collections.Inventory, "insert"); - // spyOn(ReactionCore.Collections.Cart, "update"); - // Meteor.call("inventory/register", product); - // expect(ReactionCore.Collections.Inventory.insert).toHaveBeenCalled(); - // - // // add to cart (expect to reserve) - // Meteor.call("cart/addToCart", cartId, productId, variantData, quantity); - // expect(ReactionCore.Collections.Cart.update).toHaveBeenCalled(); - // - // // fetch reserved inventory - // console.log("productId", productId); - // console.log("variantId", product.variants[0]._id); - // console.log("orderId", cartId); - // - // let reservedInventory = ReactionCore.Collections.Inventory.find({ - // "workflow.status": "reserved" - // }).count(); - // console.log('reservedInventory', reservedInventory); - // expect(reservedInventory).toEqual(quantity);; - // }); - - // - // it("should remove inventory reservation when removed cart", function ( - // done) { - // done(); - // }); - // - - // - // it("should converted backordered inventory to reserved when inventory available", function ( - // done) { - // done(); - // }); - // - // it("should update sold inventory on product and inventory when order fulfilled", function ( - // done) { - // done(); - // }); - // - // it("should make reserved inventory available when cart deleted", function ( - // done) { - // done(); - // }); - // - // it("should update cart reservations when product sold out", function ( - // done) { - // done(); - // }); - // - // it("should send inventory notification when low stock on product", function ( - // done) { - // done(); - // }); - }); }); From e305df15b8d2172260ef6db86ea24b8904315577 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 12 May 2017 14:16:03 +0800 Subject: [PATCH 21/44] Declare explicit globals --- client/api/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/api/index.js b/client/api/index.js index 4facd0bf914..e8425bb57a3 100644 --- a/client/api/index.js +++ b/client/api/index.js @@ -1,6 +1,9 @@ import { Reaction } from "/client/modules/core"; import { Router } from "/client/modules/router"; +global.ReactionCore = Reaction; +global.ReactionRouter = Router; + export { Reaction, Router From da994a7678d5d89efce7c492d4d400813fd5d945 Mon Sep 17 00:00:00 2001 From: Erik Kieckhafer Date: Fri, 12 May 2017 18:29:22 -0700 Subject: [PATCH 22/44] move default userCurrency deeper in the object (#2259) This should fix the tests brought upon by strict mode --- lib/collections/schemas/payments.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/collections/schemas/payments.js b/lib/collections/schemas/payments.js index 639bebac5e4..2a89e97f505 100644 --- a/lib/collections/schemas/payments.js +++ b/lib/collections/schemas/payments.js @@ -123,7 +123,8 @@ export const Invoice = new SimpleSchema({ export const Currency = new SimpleSchema({ userCurrency: { type: String, - optional: true + optional: true, + defaultValue: "USD" }, exchangeRate: { type: Number, @@ -156,8 +157,7 @@ export const Payment = new SimpleSchema({ }, currency: { type: Currency, - optional: true, - defaultValue: "USD" + optional: true } }); From 24b36b795a356a62468b7a51df2668efa7f8137c Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 11:27:08 +0800 Subject: [PATCH 23/44] Use Collection explicit functions --- server/api/core/import.js | 4 +--- server/startup/load-data.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/server/api/core/import.js b/server/api/core/import.js index b05ff4331fb..55a93089a30 100644 --- a/server/api/core/import.js +++ b/server/api/core/import.js @@ -223,9 +223,7 @@ Import.buffer = function (collection) { * * Push the variant if it doesn't exist. * * Update the variant. */ -Import.product = function (key, product, parent) { - check(parent, Object); - +Import.product = function (key, product) { return this.object(Collections.Products, key, product); }; diff --git a/server/startup/load-data.js b/server/startup/load-data.js index f831c6880a4..7721e8714b3 100644 --- a/server/startup/load-data.js +++ b/server/startup/load-data.js @@ -9,29 +9,33 @@ export default function () { Logger.info("Load default data from /private/data/"); try { + Logger.debug("Loading Shop Data"); Reaction.Import.process(Assets.getText("data/Shops.json"), ["name"], Reaction.Import.shop); // ensure Shops are loaded first. Reaction.Import.flush(Shops); } catch (error) { - Logger.info("Bypassing loading Shop default data"); + Logger.error(error, "Bypassing loading Shop default data"); } try { + Logger.debug("Loading Shipping Data"); Fixture.process(Assets.getText("data/Shipping.json"), ["name"], Reaction.Import.shipping); } catch (error) { - Logger.info("Bypassing loading Shipping default data."); + Logger.error("Bypassing loading Shipping default data."); } try { - Fixture.process(Assets.getText("data/Products.json"), ["title"], Reaction.Import.load); + Logger.debug("Loading Product Data"); + Fixture.process(Assets.getText("data/Products.json"), ["title"], Reaction.Import.product); } catch (error) { - Logger.info("Bypassing loading Products default data."); + Logger.error(error, "Bypassing loading Products default data."); } try { - Fixture.process(Assets.getText("data/Tags.json"), ["name"], Reaction.Import.load); + Logger.debug("Loading Tag Data"); + Fixture.process(Assets.getText("data/Tags.json"), ["name"], Reaction.Import.tag); } catch (error) { - Logger.info("Bypassing loading Tags default data."); + Logger.error(error, "Bypassing loading Tags default data."); } // // these will flush and import with the rest of the imports from core init. From 2779dfd446a9e895321a1ca95bb153ab8b4fc87d Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 11:27:38 +0800 Subject: [PATCH 24/44] Don't log doing nothing --- imports/plugins/included/jobcontrol/server/jobs/cart.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/plugins/included/jobcontrol/server/jobs/cart.js b/imports/plugins/included/jobcontrol/server/jobs/cart.js index a8eadc23e16..53e34fe75d1 100644 --- a/imports/plugins/included/jobcontrol/server/jobs/cart.js +++ b/imports/plugins/included/jobcontrol/server/jobs/cart.js @@ -23,7 +23,7 @@ Hooks.Events.add("afterCoreInit", () => { cancelRepeats: true }); } else { - Logger.warn("No cart cleanup schedule"); + Logger.debug("No cart cleanup schedule"); } }); @@ -72,7 +72,7 @@ export default () => { } }); } else { - Logger.warn("No cart cleanup schedule"); + Logger.debug("No cart cleanup schedule"); } callback(); }); From a5dbd5df08e37fe3ca32e1d688c0861ef8e600a7 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 11:28:33 +0800 Subject: [PATCH 25/44] Make Alert a global because it's a mess --- imports/plugins/core/ui/client/components/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imports/plugins/core/ui/client/components/index.js b/imports/plugins/core/ui/client/components/index.js index fdd2746f38f..042e7cfe120 100644 --- a/imports/plugins/core/ui/client/components/index.js +++ b/imports/plugins/core/ui/client/components/index.js @@ -32,3 +32,5 @@ export { default as MultiSelect } from "./multiselect/multiselect"; export { Overlay } from "./modal"; export * from "./tabs"; export { default as Select } from "./select/select.react"; + +window.Alerts = Alerts; From 3c7daf7d06a1c9da4b6ea806a7e96280e970ac8c Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 11:52:20 +0800 Subject: [PATCH 26/44] Ok actually, don't do that --- imports/plugins/core/ui/client/components/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/imports/plugins/core/ui/client/components/index.js b/imports/plugins/core/ui/client/components/index.js index 042e7cfe120..fdd2746f38f 100644 --- a/imports/plugins/core/ui/client/components/index.js +++ b/imports/plugins/core/ui/client/components/index.js @@ -32,5 +32,3 @@ export { default as MultiSelect } from "./multiselect/multiselect"; export { Overlay } from "./modal"; export * from "./tabs"; export { default as Select } from "./select/select.react"; - -window.Alerts = Alerts; From 63cb3b39beb05f07b88f4bdb3d9e7e556a7cbbc1 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 14:07:30 +0800 Subject: [PATCH 27/44] Don't allow implicit globals --- .eslintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc b/.eslintrc index 40c516a2e27..088b394af73 100644 --- a/.eslintrc +++ b/.eslintrc @@ -54,6 +54,7 @@ "args": "after-used" }], "no-use-before-define": [2, "nofunc"], // http://eslint.org/docs/rules/no-use-before-define + "no-implicit-globals": 2, // http://eslint.org/docs/rules/no-implicit-globals /** * Possible errors From a557e37e63e0c03f2a702276fdb0cf407544ad51 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 14:07:44 +0800 Subject: [PATCH 28/44] Bug fixes --- client/api/index.js | 4 ++-- .../accounts/templates/addressBook/form/form.js | 2 +- .../client/templates/layout/alerts/alerts.js | 3 +++ .../templates/layout/alerts/inlineAlerts.js | 1 + .../client/templates/checkout/shipping.js | 6 +++--- .../core/taxes/client/settings/custom.js | 3 ++- .../client/templates/settings/rates.js | 6 +++--- server/api/geocoder.js | 17 +++++++---------- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/client/api/index.js b/client/api/index.js index e8425bb57a3..b588f6f5efb 100644 --- a/client/api/index.js +++ b/client/api/index.js @@ -1,8 +1,8 @@ import { Reaction } from "/client/modules/core"; import { Router } from "/client/modules/router"; -global.ReactionCore = Reaction; -global.ReactionRouter = Router; +window.ReactionCore = Reaction; +window.ReactionRouter = Router; export { Reaction, diff --git a/client/modules/accounts/templates/addressBook/form/form.js b/client/modules/accounts/templates/addressBook/form/form.js index a9e5f95b800..1513f5fd258 100644 --- a/client/modules/accounts/templates/addressBook/form/form.js +++ b/client/modules/accounts/templates/addressBook/form/form.js @@ -22,7 +22,7 @@ Template.addressBookForm.helpers({ if ((shop !== null ? shop.locales.countries[selectedCountry].states : void 0) === null) { return false; } - options = []; + const options = []; const ref = shop !== null ? shop.locales.countries[selectedCountry].states : void 0; for (const state in ref) { if ({}.hasOwnProperty.call(ref, state)) { diff --git a/imports/plugins/core/layout/client/templates/layout/alerts/alerts.js b/imports/plugins/core/layout/client/templates/layout/alerts/alerts.js index 6ee6766af14..c4bc8636b31 100644 --- a/imports/plugins/core/layout/client/templates/layout/alerts/alerts.js +++ b/imports/plugins/core/layout/client/templates/layout/alerts/alerts.js @@ -1,3 +1,6 @@ +import { Meteor } from "meteor/meteor"; +import Alerts from "./inlineAlerts"; + /** * inlineAlert helpers */ diff --git a/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js b/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js index 8eb18aeccb7..eddf2f17556 100644 --- a/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js +++ b/imports/plugins/core/layout/client/templates/layout/alerts/inlineAlerts.js @@ -144,4 +144,5 @@ const Alerts = { collection_: new Mongo.Collection(null) }; +window.Alerts = Alerts; export default Alerts; diff --git a/imports/plugins/core/shipping/client/templates/checkout/shipping.js b/imports/plugins/core/shipping/client/templates/checkout/shipping.js index ae4be11edea..9912afe2c9e 100644 --- a/imports/plugins/core/shipping/client/templates/checkout/shipping.js +++ b/imports/plugins/core/shipping/client/templates/checkout/shipping.js @@ -14,7 +14,7 @@ function cartShippingQuotes(currentCart) { if (cart.shipping) { for (const shipping of cart.shipping) { if (shipping.shipmentQuotes) { - for (quote of shipping.shipmentQuotes) { + for (const quote of shipping.shipmentQuotes) { shipmentQuotes.push(quote); } } @@ -48,7 +48,7 @@ function enabledShipping() { provides: "shippingSettings", enabled: true }); - for (app of apps) { + for (const app of apps) { if (app.enabled === true) enabledShippingArr.push(app); } return enabledShippingArr; @@ -89,7 +89,7 @@ Template.coreCheckoutShipping.helpers({ const self = this; const shipmentMethods = cartShipmentMethods(); - for (method of shipmentMethods) { + for (const method of shipmentMethods) { // if there is already a selected method, set active if (_.isEqual(self.method, method)) { return "active"; diff --git a/imports/plugins/core/taxes/client/settings/custom.js b/imports/plugins/core/taxes/client/settings/custom.js index 8907ba96f5e..9d22131c8e3 100644 --- a/imports/plugins/core/taxes/client/settings/custom.js +++ b/imports/plugins/core/taxes/client/settings/custom.js @@ -1,3 +1,4 @@ +import { Meteor } from "meteor/meteor"; import { Template } from "meteor/templating"; import { ReactiveDict } from "meteor/reactive-dict"; import { AutoForm } from "meteor/aldeed:autoform"; @@ -205,7 +206,7 @@ Template.customTaxRates.events({ }); }, "click .cancel, .tax-grid-row .active": function () { - instance = Template.instance(); + const instance = Template.instance(); // remove active rows from grid instance.state.set({ isEditing: false, diff --git a/imports/plugins/included/shipping-rates/client/templates/settings/rates.js b/imports/plugins/included/shipping-rates/client/templates/settings/rates.js index 0dae2eabbc4..675c2e29335 100644 --- a/imports/plugins/included/shipping-rates/client/templates/settings/rates.js +++ b/imports/plugins/included/shipping-rates/client/templates/settings/rates.js @@ -89,7 +89,7 @@ Template.shippingRatesSettings.helpers({ // from flat rate shipping provider function transform(results) { const result = []; - for (method of results) { + for (const method of results) { if (method.provider && method.provider.name === "flatRates") { result.push(method.methods); } @@ -128,7 +128,7 @@ Template.shippingRatesSettings.helpers({ let rate = {}; if (providerRates && providerRates.methods) { if (id) { - for (method of providerRates.methods) { + for (const method of providerRates.methods) { if (method._id === id) { rate = method; } @@ -161,7 +161,7 @@ Template.shippingRatesSettings.events({ }); }, "click .cancel, .shipping-grid-row .active": function () { - instance = Template.instance(); + const instance = Template.instance(); // remove active rows from grid instance.state.set({ isEditing: false, diff --git a/server/api/geocoder.js b/server/api/geocoder.js index 38466f72cd3..bab001cdd80 100644 --- a/server/api/geocoder.js +++ b/server/api/geocoder.js @@ -1,7 +1,7 @@ -import { Packages } from "/lib/collections"; -import { Logger, Reaction } from "/server/api"; import { HTTP } from "meteor/http"; import { Meteor } from "meteor/meteor"; +import { Packages } from "/lib/collections"; +import { Logger, Reaction } from "/server/api"; /** * meteor-geocoder @@ -12,14 +12,9 @@ import { Meteor } from "meteor/meteor"; * Copyright (c) 2014 Eric Dobbertin */ -// backwards compatibility -if (typeof Meteor.wrapAsync === "undefined") { - Meteor.wrapAsync = Meteor._wrapAsync; -} -/* eslint func-style: 1 */ // // init geocoder -export const GeoCoder = function (options) { +function GeoCoder(options) { let extra; const self = this; // fetch shop settings for api auth credentials @@ -46,7 +41,7 @@ export const GeoCoder = function (options) { httpAdapter: "https", extra: extra }, options || {}); -}; +} function gc(address, options, callback) { const g = require("node-geocoder")(options.geocoderProvider, options.httpAdapter, @@ -86,7 +81,7 @@ GeoCoder.prototype.reverse = function geoCoderReverse(lat, lng, callback) { rv(lat, lng, this.options, geoCallback); } else { try { - address = Meteor.wrapAsync(rv)(lat, lng, this.options); + const address = Meteor.wrapAsync(rv)(lat, lng, this.options); return address[0]; } catch (_error) { return { @@ -135,3 +130,5 @@ GeoCoder.prototype.geoip = function geoCoderGeocode(address, callback) { } } }; + +export default GeoCoder; From adaaf3ff8f110976b86258f589f4122ce382ac6a Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 14:55:14 +0800 Subject: [PATCH 29/44] Fixing lack of declaration --- .../core/orders/client/templates/workflow/shippingInvoice.js | 4 ++-- .../plugins/core/payments/client/checkout/payment/methods.js | 2 +- .../included/payments-stripe/client/checkout/stripe.js | 2 +- server/api/index.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/imports/plugins/core/orders/client/templates/workflow/shippingInvoice.js b/imports/plugins/core/orders/client/templates/workflow/shippingInvoice.js index aec08e4ac94..b774893e8c7 100644 --- a/imports/plugins/core/orders/client/templates/workflow/shippingInvoice.js +++ b/imports/plugins/core/orders/client/templates/workflow/shippingInvoice.js @@ -552,12 +552,12 @@ Template.coreOrderShippingInvoice.helpers({ provides: "paymentMethod", enabled: true }); - for (app of apps) { + for (const app of apps) { if (app.enabled === true) enabledPaymentsArr.push(app); } let discount = false; - for (enabled of enabledPaymentsArr) { + for (const enabled of enabledPaymentsArr) { if (enabled.packageName === "discount-codes") { discount = true; break; diff --git a/imports/plugins/core/payments/client/checkout/payment/methods.js b/imports/plugins/core/payments/client/checkout/payment/methods.js index d655bd057f5..6301f36108e 100644 --- a/imports/plugins/core/payments/client/checkout/payment/methods.js +++ b/imports/plugins/core/payments/client/checkout/payment/methods.js @@ -31,7 +31,7 @@ function enabledPayments() { provides: "paymentMethod", enabled: true }); - for (app of apps) { + for (const app of apps) { if (app.enabled === true) enabledPaymentsArr.push(app); } return enabledPaymentsArr; diff --git a/imports/plugins/included/payments-stripe/client/checkout/stripe.js b/imports/plugins/included/payments-stripe/client/checkout/stripe.js index dae9193d76d..550bae74f44 100644 --- a/imports/plugins/included/payments-stripe/client/checkout/stripe.js +++ b/imports/plugins/included/payments-stripe/client/checkout/stripe.js @@ -104,7 +104,7 @@ AutoForm.addHooks("stripe-payment-form", { }); submitting = false; - paymentMethod = { + const paymentMethod = { processor: "Stripe", storedCard: storedCard, method: "credit", diff --git a/server/api/index.js b/server/api/index.js index 4fb415a4225..20c7ad3273a 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -1,7 +1,7 @@ import Reaction from "./core"; import * as Accounts from "./core/accounts"; import Router from "./router"; -import { GeoCoder } from "./geocoder"; +import GeoCoder from "./geocoder"; import Hooks from "./hooks"; import Logger from "./logger"; import { MethodHooks } from "./method-hooks"; From 3e0a5c1347cd09b3816b917b3ce92ccf64f43de5 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Fri, 19 May 2017 15:17:24 +0800 Subject: [PATCH 30/44] Pass error to logger --- server/startup/load-data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/startup/load-data.js b/server/startup/load-data.js index 7721e8714b3..90f75ebfc04 100644 --- a/server/startup/load-data.js +++ b/server/startup/load-data.js @@ -21,7 +21,7 @@ export default function () { Logger.debug("Loading Shipping Data"); Fixture.process(Assets.getText("data/Shipping.json"), ["name"], Reaction.Import.shipping); } catch (error) { - Logger.error("Bypassing loading Shipping default data."); + Logger.error(error, "Bypassing loading Shipping default data."); } try { From 952be34dcf1e874e0be5aa3ce1344732a3af710a Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Tue, 23 May 2017 09:23:57 +0800 Subject: [PATCH 31/44] Fix import order --- .../layout/client/templates/layout/alerts/reactionAlerts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js index 0a78a62346c..069b8b9ee90 100644 --- a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js +++ b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js @@ -1,6 +1,6 @@ import _ from "lodash"; -import { Meteor } from "meteor/meteor"; import swal from "sweetalert2"; +import { Meteor } from "meteor/meteor"; import "sweetalert2/dist/sweetalert2.css"; import Alerts from "./inlineAlerts"; From b841ead4dbfbeb84ea9a050e5021c6e6a9bc07e4 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Tue, 23 May 2017 10:14:51 +0800 Subject: [PATCH 32/44] Fix changed reference --- .../orders/client/__tests__/components/orderSummary.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js index 9cc1129bcff..3c7cb8644d8 100644 --- a/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js +++ b/imports/plugins/core/orders/client/__tests__/components/orderSummary.spec.js @@ -22,7 +22,7 @@ test("OrderSummary snapshot test", () => { const tracking = jest.fn(); const shipmentStatus = jest.fn(()=>({})); const printableLabels = jest.fn(()=>({})); - const profile = {}; + const profileShippingAddress = {}; const order = { shipping: [{ shipmentMethod: {} }], billing: [ @@ -36,7 +36,7 @@ test("OrderSummary snapshot test", () => { Date: Tue, 23 May 2017 10:19:10 +0800 Subject: [PATCH 33/44] Add jest testing to Circle CI --- circle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/circle.yml b/circle.yml index cd1650b52e8..d3210b84744 100644 --- a/circle.yml +++ b/circle.yml @@ -16,6 +16,8 @@ dependencies: test: override: - reaction test + - npm install -g jest + - jest - .reaction/ci/build.sh deployment: From 8a9e7658475eceada22db8268ded57be94168ad5 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Tue, 23 May 2017 10:34:15 +0800 Subject: [PATCH 34/44] Update NPM packages --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index d3210b84744..2986fac0f95 100644 --- a/circle.yml +++ b/circle.yml @@ -17,6 +17,7 @@ test: override: - reaction test - npm install -g jest + - npm update - jest - .reaction/ci/build.sh From 826e5968424a6cfd4e71639f58e3f215688f4e61 Mon Sep 17 00:00:00 2001 From: Mike Murray Date: Tue, 23 May 2017 11:05:47 -0700 Subject: [PATCH 35/44] Added npm test command --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e888888dabc..cb272ca6589 100644 --- a/package.json +++ b/package.json @@ -133,6 +133,7 @@ } }, "scripts": { + "test": "jest", "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", From 0fa663926181c6584964c3b5c15c0d510d2a371b Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Wed, 24 May 2017 04:36:24 +0800 Subject: [PATCH 36/44] Use an NPM script rather than global Jest --- circle.yml | 4 +--- package.json | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index 2986fac0f95..301b6845fde 100644 --- a/circle.yml +++ b/circle.yml @@ -15,10 +15,8 @@ dependencies: test: override: + - npm run test-react - reaction test - - npm install -g jest - - npm update - - jest - .reaction/ci/build.sh deployment: diff --git a/package.json b/package.json index cb272ca6589..2b4ff97daee 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ } }, "scripts": { - "test": "jest", + "test-react": "jest", "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", From f54f155f0aa822460aa096058a41866e79cb2b31 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Wed, 24 May 2017 08:10:50 +0800 Subject: [PATCH 37/44] Make changes to new CI config --- .circleci/config.yml | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 825569172ec..8562dabc989 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,10 @@ jobs: name: Restoring Meteor dev_bundle cache key: dev_bundle - - run: reaction test + - steps: + - run: npm test + - run: reaction test + - save_cache: name: Saving Meteor dev_bundle to cache diff --git a/package.json b/package.json index 2b4ff97daee..cb272ca6589 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ } }, "scripts": { - "test-react": "jest", + "test": "jest", "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", From c7b18736beb54189f1b2cd2e0964c458efb5894c Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Wed, 24 May 2017 08:25:08 +0800 Subject: [PATCH 38/44] Change to proper step configuration --- .circleci/config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8562dabc989..36746683a41 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,9 +45,8 @@ jobs: name: Restoring Meteor dev_bundle cache key: dev_bundle - - steps: - - run: npm test - - run: reaction test + - run: npm test + - run: reaction test - save_cache: From fc38b243eedb8f7a861495cae71651e6c2e4853e Mon Sep 17 00:00:00 2001 From: aaronjudd Date: Tue, 23 May 2017 17:40:58 -0700 Subject: [PATCH 39/44] For clarity, `test-react` `npm run test-react` to run jest tests. --- .circleci/config.yml | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 36746683a41..7ee3698e958 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,9 +45,9 @@ jobs: name: Restoring Meteor dev_bundle cache key: dev_bundle - - run: npm test - - run: reaction test + - run: npm run test-react + - run: reaction test - save_cache: name: Saving Meteor dev_bundle to cache diff --git a/package.json b/package.json index cb272ca6589..2b4ff97daee 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ } }, "scripts": { - "test": "jest", + "test-react": "jest", "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", From f8eaa7f554981347d84558cda54cebd648d08f08 Mon Sep 17 00:00:00 2001 From: aaronjudd Date: Tue, 23 May 2017 17:43:28 -0700 Subject: [PATCH 40/44] Revert "For clarity, `test-react`" This reverts commit fc38b243eedb8f7a861495cae71651e6c2e4853e. --- .circleci/config.yml | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ee3698e958..36746683a41 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,10 +45,10 @@ jobs: name: Restoring Meteor dev_bundle cache key: dev_bundle - - run: npm run test-react - + - run: npm test - run: reaction test + - save_cache: name: Saving Meteor dev_bundle to cache key: dev_bundle diff --git a/package.json b/package.json index 2b4ff97daee..cb272ca6589 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ } }, "scripts": { - "test-react": "jest", + "test": "jest", "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", From 8eaaa19c913e3aaf1fe0ca033675430b8b2ff07a Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 25 May 2017 10:31:32 +0800 Subject: [PATCH 41/44] Update Jest to current version --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index cb272ca6589..743c1d20252 100644 --- a/package.json +++ b/package.json @@ -105,18 +105,18 @@ }, "devDependencies": { "babel-eslint": "^7.2.1", - "babel-jest": "^19.0.0", + "babel-jest": "^20.0.3", "babel-plugin-lodash": "^3.2.11", - "babel-preset-stage-2": "^6.22.0", "babel-preset-es2015": "^6.22.0", "babel-preset-react": "^6.24.1", + "babel-preset-stage-2": "^6.22.0", "browserstack-local": "^1.3.0", "chai": "^3.5.0", "enzyme": "^2.8.2", "enzyme-to-json": "^1.5.1", "eslint": "^3.18.0", "eslint-plugin-react": "^6.10.3", - "jest": "^19.0.2", + "jest": "^20.0.4", "js-yaml": "^3.8.2", "react-addons-test-utils": "15.4.2", "wdio-allure-reporter": "^0.1.2", From 07f82eb629d9ade35868a1d5781da3f1516120ab Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 25 May 2017 10:43:03 +0800 Subject: [PATCH 42/44] Just testing to see if this fixes it --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 36746683a41..b8888194135 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,6 +45,7 @@ jobs: name: Restoring Meteor dev_bundle cache key: dev_bundle + - run: npm install - run: npm test - run: reaction test From 19b7528838c43d5043e9d890a6f9016181f7dd4b Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 25 May 2017 11:08:07 +0800 Subject: [PATCH 43/44] Remove npm install of desperation --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b8888194135..36746683a41 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,6 @@ jobs: name: Restoring Meteor dev_bundle cache key: dev_bundle - - run: npm install - run: npm test - run: reaction test From 43d0f614f22846d7bd7752a809520cc63e2da6b9 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 25 May 2017 12:00:40 +0800 Subject: [PATCH 44/44] Remove node cache --- .circleci/config.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 36746683a41..7fd05c01f1d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,18 +28,9 @@ jobs: - ~/.meteor # install app dependencies - - restore_cache: - name: Restoring node_modules cache - key: node_modules - run: meteor npm install - - save_cache: - name: Saving node_modules to cache - key: node_modules - paths: - - /home/reaction/node_modules - # run tests - restore_cache: name: Restoring Meteor dev_bundle cache