Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
03b8685
changes from previously known `ancestors_model` moved to this branch;
newsiberian Dec 5, 2015
f06b22c
Merge branch 'development' into products_flattened_data_structure
newsiberian Dec 7, 2015
babe03e
sync with `development`;
newsiberian Dec 7, 2015
b242be8
Merge branch 'development' into products_flattened_data_structure
newsiberian Dec 16, 2015
ed434ce
sync with `development`;
newsiberian Dec 16, 2015
4c28dba
added workaround for reactionImport;
newsiberian Jan 3, 2016
89c5406
Merge branch 'development' into products_flattened_data_structure
newsiberian Jan 16, 2016
eea1b4a
added handle for multi-schema to `ReactionImport.context`;
newsiberian Jan 17, 2016
cd1e7a5
- product fixture up to date with `development`;
newsiberian Jan 17, 2016
3313110
- updated images logic. needed cleanup after tests;
newsiberian Jan 17, 2016
2dee7be
- `products/deleteVariant` method reworked;
newsiberian Jan 18, 2016
fe15838
- added `shopId` to `productVariant` schema;
newsiberian Jan 19, 2016
7718393
Merge branch 'development' into products_flattened_data_structure
newsiberian Jan 19, 2016
b981d38
- updated hook on variant remove. Now it is
newsiberian Jan 19, 2016
abd28d8
- hook `Products.after.update` now works only
newsiberian Jan 19, 2016
05d9517
Merge branch 'development' into products_flattened_data_structure
newsiberian Jan 19, 2016
dba4bef
- `products/deleteProduct` now removes `media` of
newsiberian Jan 20, 2016
5fd0865
Merge branch 'development' into products_flattened_data_structure
newsiberian Jan 20, 2016
fca3420
- attempt to move to meteor 1.3 failed, because of some
newsiberian Jan 21, 2016
ae0e819
Merge branch 'development' into products_flattened_data_structure
newsiberian Jan 21, 2016
b3a3389
- `cart/addToCart` now works;
newsiberian Jan 27, 2016
316de48
Add collection2 submodule.
tdecaluwe Jan 27, 2016
4412b6a
Merge pull request #1 from tdecaluwe/add-collection2-submodule
newsiberian Jan 27, 2016
c87e025
- added git submodules to forks of `collection2-core` and `reaction-f…
newsiberian Jan 27, 2016
e2681f9
another attempt to add submodules;
newsiberian Jan 28, 2016
c4ab0a5
Fix the workaround in ReactionImport automatic loading.
tdecaluwe Jan 28, 2016
8d93172
Merge pull request #2 from tdecaluwe/import-identification
newsiberian Jan 28, 2016
0b0bb15
Update collection2 commit.
tdecaluwe Jan 28, 2016
bb7f3bc
Merge pull request #3 from tdecaluwe/submodule-collection2
newsiberian Jan 28, 2016
8a35bc7
- `inventory/backorder` now uses bulkOp internally;
newsiberian Jan 28, 2016
0d4787d
Merge branch 'products_flattened_data_structure' of github.com:newsib…
newsiberian Jan 28, 2016
4cb976d
Adapt import to multischema Product collection.
tdecaluwe Jan 28, 2016
5811778
- core/server/products.js moved to reaction-catalog package;
newsiberian Jan 29, 2016
d6cfaf3
- cleanup;
newsiberian Jan 30, 2016
b5d5d10
Merge pull request #4 from tdecaluwe/flattened-import-review
newsiberian Jan 30, 2016
5ccc3df
- fixed few eslint issues;
newsiberian Jan 30, 2016
4ecb1e2
- fixed bug in shop tests;
newsiberian Jan 30, 2016
52d48e8
Merge branch 'development' into products_flattened_data_structure
newsiberian Feb 19, 2016
9c2f0c4
- product helper globals.js renamed to global.js,
newsiberian Feb 20, 2016
bea42e1
- temporary added collection2 forks
newsiberian Feb 20, 2016
aa382a8
Merge branch 'development' into products_flattened_data_structure
newsiberian Feb 23, 2016
ba4b89b
- removed collection2 forks;
newsiberian Feb 23, 2016
ce1660c
- update `reaction-catalog` deps;
newsiberian Feb 25, 2016
e02a244
- reaction-catalog - added missing files
newsiberian Feb 25, 2016
499c1b1
- added one more missed file;
newsiberian Feb 25, 2016
c90508b
- added TEST PLAN.md;
newsiberian Feb 25, 2016
f7ab92f
Merge branch 'development' into products_flattened_data_structure
newsiberian Feb 25, 2016
1251357
Merge branch 'development' into products_flattened_data_structure
newsiberian Mar 1, 2016
4b7ddc8
fixed typo in browserify setting;
newsiberian Mar 1, 2016
a310047
uncomment `Counts.publish()` in products
newsiberian Mar 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .gitmodules
Empty file.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ accounts-oauth

reactioncommerce:core
reactioncommerce:core-theme
reactioncommerce:reaction-catalog
reactioncommerce:reaction-layout
reactioncommerce:launchdock-connect
reactioncommerce:reaction-accounts
Expand Down
2 changes: 1 addition & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
mikowals:[email protected]
[email protected]
[email protected]
[email protected]
Expand Down Expand Up @@ -150,6 +149,7 @@ reactioncommerce:[email protected]
reactioncommerce:[email protected]
reactioncommerce:[email protected]
reactioncommerce:[email protected]
reactioncommerce:[email protected]
reactioncommerce:[email protected]
reactioncommerce:[email protected]
reactioncommerce:[email protected]
Expand Down
98 changes: 98 additions & 0 deletions TESTPLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Product test plan

## Products grid

### Non-admin user
#### Interaction with product cards
* When you click on product **image** you should be redirected to PDP (Product Details Page).
* When you click on product **price** you should be redirected to PDP.

### Admin user
#### Interaction with product cards
* When you click on product **image** you should be redirected to PDP.
* When you click on product **price** you should be redirected to PDP.
* When you click on “More Options” button, you should see pop-up menu on the right side of a page (`ActionBar`).
* By pressing “shift” or “ctrl” + left mouse button (LMB) click on a card you should see appearing `ActionBar`. Also, you should see a border around card. Within `ActionBar` “Product” section you should see Product image and title with price.
* By pressing “shift” or “ctrl” + left mouse button click on several cards you should see how additional products you selected are added to “Product” section of `ActionBar`.
* By clicking LMB + “ctrl” on selected Product card you should see how this card become unselected. `ActionBar` will not close automatically. You should see a message within it “No selected products....”
* When “Publish” button has strikethrough eye and you click on it, you should see an alert with text “_ Product name _ is now visible”
* When “Publish” button has just an eye and you click on it, you should see an alert with text “_ Product name _ is now hidden”
* When you have several products on a grid, you could drag a product card by holding left-mouse-button (LMB) in pressed state and move it relatively another product cards. When you drop it in new location, product card should be in it. Try to reload the page by pressing “F5”. Product should be in a new position.

#### Interaction with right side action bar
* When selected one or several products after click on `ActionBar` “Publish” button you should see alert against each of selected products with “is now visible/hidden” notification, also product card “Publish” buttons should change their icons (eye/strikethrough eye).
* When you click on “Duplicate Product” button you should see appearance of a new product on a grid. It should have the same images, price as original and it should have a title “original product title + -copy” or “original product title + -copy-N” if original was a copy of some other product, there N is a number of copy.
* When several products are selected clicking on “Duplicate Product” button should create a copy of each of those products.
* When you click on “Delete Product” button, you should see a dialog with confirmation “Delete this product?”. By choosing “OK” you should see how product card will disappear and alert will pop-up with message: “Deleted _ Product_name _ ”.
* The same is true when several products selected.
* When you click on product title inside “Product” section, you should be redirected to product page.
* If you browser opened wide enough and you click to one of three elements in “Size” section, you should see how product card change it's sizes. Left element – default size; middle – two size from default; right element – product card will fill all grid width. In a third case product title and price should be moved into blue block in a left bottom corner of a card.

## Product Details Page (PDP)
### Non-admin user

#### Images
* If you see several images on the page – one big and else small under the big one, you could move your mouse cursor over one of the small image. At the moment you hover a small image, it should replace the big one.

#### Tags
* If product has tags you should see them under the **Tags** header. If you click on one of these tags you should be redirected to this tag's page. There you could see all products with the same tag.

#### Options
* Product could have variants. Variants could have options. You could see variant as a long (maybe colored) block under the **Options** header. If product has several variants you could switch between them by clicking on colored blocks. If variants have different images, you should see how images change.
* If variant has options you should see it as small blocks with title under phrase “There are more options available for this selection.”. When you click on option you should see how images change (if option has individual images) and how price changes under the product title. Option block should become pressed.

#### Add to cart
* If you visit to a product page and product has variants and options, you'll need to select option (if variant has it) or select variant (if it has no options) before clicking to “Add to cart” button, otherwise you should see an alert message warning. Selected variant should have a border around it.
* You could change the number of items, which you want to add to cart by the help of input element inside “Add to cart” button. The maximum number of items that you can add should be limited by system. When you type something like 999999, it should be transformed to something like 15, where 15 – the number of items this variant or option has.
* It should not be allowed to enter number with minus sign to this field.
* When you click to “Add to cart” button with selected variant or option, you should see how this variant or options were added to you cart. You should see a green notification block in a top left corner of a page with the number you choose and the title of selected variant/option.
* When you order all items from variants/options in this product, you should see a notification that item is “Sold out!”
* When you add to cart all product's variants and options and switching to product grid page, you should see a label within product image “Sold out!”

### Admin user
#### Product management
* If you see a link “Make invisible” near “Product management:” on top of the page and you click on it, you should see an alert with text “This product is not visible to customers....”.
* If you see a colored alert on top of a page with link “You can make it visible” and you click on it, the alert should go away and you should see “Product management Make invisible”.
* Near the “Product management” you could see a “Delete” link. If you click on it, you should see a confirmation request window. If you press “OK”, you should be redirected to the products grid page. And this product should be removed. You should see an alert with text “Deleted _ Product name _”
#### Title
* When you click inside top product title you could change it. After you finished your changes click somewhere out of this field and you should see how URL change against you changes.
* When you click on a page title (second big title) you could edit it. After you finished and click outside it you should see a green blink inside this field. Your changes should be saved.

#### Images
* You could add images to each of product variants or options. To do that you need to select variant/option and then click on a image or on a “Drop file to upload” block. Also you could drop files from outside of browser. All images you have upload should be displayed in this section.
* You can't add images to product itself. Try to remove all variants by click on variant “Edit” button, and then on “Remove” button. When you'll remove all variants you should see “+ Create Variant” phrase. Try to add an image. You should see an alert “Please, create new Variant first.”
* You could change images order by drag'n'drop them. Every change should be saved automatically.

#### Tags
* You could add tags to product by putting cursor in a clean field on **Tags** section and typing tag name. If tag exist, you should see it. You could select existed tag or add new by clicking outside of this field.
* You could change tags order by dragging them.
* When you click on remove icon on tag, it should be removed.
* When you click on bookmark icon on tag, it's URL should change on a new one – tag name.
* When you click on active bookmark icon on tag, product URL should change to product title.

#### Details
* When you add text to both clean fields inside **Details** section and click outside of this fields, you should see how new details will appears within this section table.
* When you click on remove icon near one of a detail row, it should be removed.

#### Description
* When you click on “Product Vendor” field, you can edit it. Changes should be saved after you click outside of this field.
* When you click on a product description field you can edit it. Changes should be saved after you click outside of this field.

#### Options
* You can see an edit menu of each variant by clicking on “Edit” button, which is from the right side of variant block. By click on this “Edit” button you should see a block with two sections: variant settings and options list with their settings.
* By editing variant Label field you should change variant label. You should see changes immediately within variant block.
* Variant block has a badge with number, which represents the quantity for this variant (if it has no options) or sum of all options quantities for this variant.
* TAXABLE – NOT READY
* By enabling “Inventory Tracking” you allow system to notify when variant will be sold out, or when it's options' quantity will be lower then threshold, which you set in “Warn @” field.
* By enabling “Deny when out of stock” you prevent variant to be ordered if it or it variants is out of stock.
* If variant has options you could edit only “Weight”, “MSRP” and “Warn @” fields.
* If variant has no options you can edit all it's fields.
* When you click on “Add Option” button, you should see an appearance of a new option.
* When you click on “Duplicate” button, you should see an appearance of a clone of this variant. It should be with the same images, but without titles.
* When you click on “Remove” button, first you should see confirmation request and then, when you press “OK” you should see how this variant will be removed.
* If option is newly created and when you edit option field “Option”, you should see how option block appears with this text. (This is old logic)
* When you edit “Label” field you should see how this text appears within option block (new logic).
* When you add numbers to the “Quantity” field you should see how variant block changes it's badge quantity number on a left side of variant block. This number is a sum of all options' quantities. (if options exist for this variant)
* When you fill price field, you should see how product price field reflects to you changes reactively.
* When you click on remove icon from the right side of an option row, you should see confirmation request and after you press “OK”, you should see how option will be removed without any alerts.
* You could change variants order by dragging them.
2 changes: 2 additions & 0 deletions packages/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
!reaction-collections
!reaction-core
!reaction-core-theme
!reaction-catalog
!reaction-default-theme
!reaction-inventory
!reaction-layout
Expand All @@ -36,6 +37,7 @@
!reaction-collections/*
!reaction-core/*
!reaction-core-theme/*
!reaction-catalog/*
!reaction-default-theme/*
!reaction-inventory/*
!reaction-layout/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,34 +602,42 @@ describe("Account Meteor method ", function () {
});

describe("accounts/inviteShopMember", function () {
it("should not let non-Owners invite a user to the shop", function (
it(
"should not let non-Owners invite a user to the shop", function (
done) {
spyOn(ReactionCore, "hasOwnerAccess").and.returnValue(false);
spyOn(Accounts, "createUser");
// create user
expect(function () {
return Meteor.call("accounts/inviteShopMember", shopId,
fakeUser.emails[0].address, fakeUser.profile.addressBook[0].fullName);
}).toThrow(new Meteor.Error(403, "Access denied"));
// expect that createUser shouldnt have run
expect(Accounts.createUser).not.toHaveBeenCalledWith({
username: fakeUser.profile.addressBook[0].fullName
});
return done();
});
// spyOn(ReactionCore, "hasOwnerAccess").and.returnValue(false);
spyOn(ReactionCore, "hasPermission").and.returnValue(false);
spyOn(Accounts, "createUser");
// create user
expect(function () {
return Meteor.call("accounts/inviteShopMember", shopId,
fakeUser.emails[0].address,
fakeUser.profile.addressBook[0].fullName);
}).toThrow(new Meteor.Error(403, "Access denied"));
// expect that createUser shouldnt have run
expect(Accounts.createUser).not.toHaveBeenCalledWith({
username: fakeUser.profile.addressBook[0].fullName
});
return done();
}
);

it("should let a Owner invite a user to the shop", function (done) {
spyOn(Roles, "userIsInRole").and.returnValue(true);
// TODO checking this is failing, even though we can see it happening in the log.
// spyOn(Email, "send");
expect(function () {
return Meteor.call("accounts/inviteShopMember",
shopId,
fakeUser.emails[0].address,
fakeUser.profile.addressBook[0].fullName);
}).not.toThrow(new Meteor.Error(403, "Access denied"));
// expect(Email.send).toHaveBeenCalled();
return done();
});
it(
"should let a Owner invite a user to the shop",
function (done) {
// spyOn(Roles, "userIsInRole").and.returnValue(true);
spyOn(ReactionCore, "hasPermission").and.returnValue(true);
// TODO checking this is failing, even though we can see it happening in the log.
// spyOn(Email, "send");
expect(function () {
return Meteor.call("accounts/inviteShopMember",
shopId,
fakeUser.emails[0].address,
fakeUser.profile.addressBook[0].fullName);
}).not.toThrow(new Meteor.Error(403, "Access denied"));
// expect(Email.send).toHaveBeenCalled();
return done();
}
);
});
});
3 changes: 3 additions & 0 deletions packages/reaction-catalog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# reaction-catalog
This package contains server side and common products methods and helpers.
WIP - reaction product, content catalog
137 changes: 137 additions & 0 deletions packages/reaction-catalog/common/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
Object.assign(ReactionCore, {
/**
* ReactionCore.setProduct
* @summary method to set default/parameterized product variant
* @param {String} currentProductId - set current productId
* @param {String} currentVariantId - set current variantId
* @return {undefined} return nothing, sets in session
*/
setProduct: function (currentProductId, currentVariantId) {
let productId = currentProductId;
let variantId = currentVariantId;
if (!productId.match(/^[A-Za-z0-9]{17}$/)) {
let product = ReactionCore.Collections.Products.findOne({
handle: productId.toLowerCase()
});
if (product) {
productId = product._id;
}
}
setCurrentProduct(productId);
setCurrentVariant(variantId);
},
/**
* getProductPriceRange
* @summary get price range of a product
* if no only one price available, return it
* otherwise return a string range
* @todo remove string return and replace with object
* @todo move all this methods this to export function after 1.3
* @param {String} [productId] - current product _id
* @return {String} formatted price or price range
*/
getProductPriceRange(productId) {
const product = ReactionCore.Collections.Products.findOne(productId);
if (!product) {
return "";
}
const variants = ReactionCore.getTopVariants(product._id);

if (variants.length > 0) {
let variantPrices = [];
variants.forEach(variant => {
let range = ReactionCore.getVariantPriceRange(variant._id);
if (typeof range === "string") {
let firstPrice = parseFloat(range.substr(0, range.indexOf(" ")));
let lastPrice = parseFloat(range.substr(range.lastIndexOf(" ") + 1));
variantPrices.push(firstPrice, lastPrice);
} else {
variantPrices.push(range);
}
});
let priceMin = _.min(variantPrices);
let priceMax = _.max(variantPrices);

if (priceMin === priceMax) {
return priceMin.toString();
}
return `${priceMin} - ${priceMax}`;
}
},
/**
* getVariantPriceRange
* @summary get price range of a variant if it has child options.
* if no child options, return main price value
* @todo remove string return and replace with object
* @param {String} [variantId] - current variant _Id
* @return {String} formatted price or price range
*/
getVariantPriceRange(variantId) {
const children = ReactionCore.getVariants(variantId);

switch (children.length) {
case 0:
return ReactionCore.Collections.Products.findOne(variantId).price;
case 1:
return children[0].price;
default:
let priceMin = Number.POSITIVE_INFINITY;
let priceMax = Number.NEGATIVE_INFINITY;

children.map(child => {
if (child.price < priceMin) {
priceMin = child.price;
}
if (child.price > priceMax) {
priceMax = child.price;
}
});

if (priceMin === priceMax) {
// TODO check impact on i18n/formatPrice from moving return to string
return priceMin.toString();
}
return `${priceMin} - ${priceMax}`;
}
},
/**
* getVariantQuantity
* @description calculate a sum of descendants `inventoryQuantity`
* @param {Object} variant - top-level variant
* @return {Number} summary of options quantity
*/
getVariantQuantity(variant) {
const options = ReactionCore.getVariants(variant._id);
if (options && options.length) {
return options.reduce((sum, option) =>
sum + option.inventoryQuantity || 0, 0);
}
return variant.inventoryQuantity || 0;
},
/**
* @method getVariants
* @description Get all parent variants
* @summary could be useful for products and for top level variants
* @param {String} [id] - product _id
* @param {String} [type] - type of variant
* @return {Array} Parent variants or empty array
*/
getVariants(id, type) {
return ReactionCore.Collections.Products.find({
ancestors: { $in: [id] },
type: type || "variant"
}).fetch();
},
/**
* @method getTopVariants
* @description Get only product top level variants
* @param {String} [id] - product _id
* @return {Array} Product top level variants or empty array
*/
getTopVariants(id) {
return ReactionCore.Collections.Products.find({
ancestors: [id],
type: "variant"
}).fetch();
}
});
Loading