Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promotions Feature Branch #6591

Draft
wants to merge 302 commits into
base: release-5
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
302 commits
Select commit Hold shift + click to select a range
f59a564
fix: fix integration mutation test fail
vanpho93 Nov 7, 2022
64030bd
fix: calculate percentage discount
vanpho93 Nov 7, 2022
1baccb1
fix: split order discount for cart items
vanpho93 Nov 8, 2022
01b77aa
fix: fix calculate the order total
vanpho93 Nov 8, 2022
0cd9287
fix: fix test fail for order plugin
vanpho93 Nov 9, 2022
47bf3c7
feat: update the promotion data on sample-data plugin
vanpho93 Nov 8, 2022
95ff058
feat: add sequence creation in startup, plus graqhQL for promotions
zenweasel Nov 14, 2022
d621e76
feat: refactoring plus adds setting start sequence via env var
zenweasel Nov 14, 2022
fe43600
Merge branch 'feat/promotions' into feat/promotions-create-auto-incre…
zenweasel Nov 14, 2022
5eb5859
feat: add duplicatePromotion plus name field
zenweasel Nov 14, 2022
359a5f9
fix: rename from Sequences to sequenceConfigs
zenweasel Nov 14, 2022
257bdd8
fix: rename from Sequences to sequenceConfigs for README
zenweasel Nov 14, 2022
945252d
fix: fixes for tests
zenweasel Nov 14, 2022
7edd660
fix: change import style to appease Jest
zenweasel Nov 14, 2022
ef527e5
fix: typo in index creation declaration
zenweasel Nov 14, 2022
11c1754
Merge pull request #6645 from reactioncommerce/feat/promotions-create…
zenweasel Nov 14, 2022
9ef557c
Merge branch 'feat/promotions' into feat/promotions-add-duplicate-pro…
zenweasel Nov 14, 2022
c497802
fix: fix test
zenweasel Nov 14, 2022
719002a
feat: add integration test for promotions
vanpho93 Nov 14, 2022
f4cf8fd
feat: update lockfile
vanpho93 Nov 15, 2022
9c27f54
Merge pull request #6646 from reactioncommerce/promotion-api-changes-1
zenweasel Nov 15, 2022
cbf069f
fix: fix sample-data records
zenweasel Nov 15, 2022
1f003d3
Merge pull request #6652 from reactioncommerce/feat/promotions-add-du…
zenweasel Nov 15, 2022
5f04d01
fix: fix for botched rename
zenweasel Nov 15, 2022
cc6a9c2
fix: fix typo on the tests
vanpho93 Nov 15, 2022
0ba84fe
feat: add promotion date before/after filter
vannguyenn Nov 16, 2022
bc2451b
chore: rename variable
vanpho93 Nov 16, 2022
e8f5762
Merge pull request #6575 from reactioncommerce/feat/promotions-discou…
zenweasel Nov 16, 2022
db4bacc
fix: fix typo and format
vannguyenn Nov 16, 2022
88df3cb
Merge pull request #6656 from reactioncommerce/feat/promotions-date-f…
zenweasel Nov 16, 2022
1ae312a
feat: add discount max units for discount action
vanpho93 Nov 16, 2022
22ff026
feat: add state field and archivePromotion endpoint
zenweasel Nov 17, 2022
5aa8a46
feat: initial work on changing state
zenweasel Nov 18, 2022
200ba38
Merge pull request #6658 from reactioncommerce/feat/promotions-limit-…
zenweasel Nov 21, 2022
7e34549
feat: add discount max value for discount action
vanpho93 Nov 16, 2022
69a8d27
Merge pull request #6657 from reactioncommerce/feat/promotions-limit-…
vanpho93 Nov 21, 2022
51882bb
feat: watcher that sets state to active/completed when ready
zenweasel Nov 21, 2022
7ba3676
feat: add tests
zenweasel Nov 21, 2022
5adbfd1
feat: updated lock file
zenweasel Nov 21, 2022
b64a7e0
feat: add changed package.json
zenweasel Nov 21, 2022
93b0cde
feat: update lock-file
zenweasel Nov 21, 2022
9c7a90f
feat: more test fixes
zenweasel Nov 21, 2022
3ba4b7f
feat: updates from C/R
zenweasel Nov 21, 2022
7ea33bd
feat: move memory-mongo to the root
zenweasel Nov 21, 2022
24e977e
feat: fix false eslint error
zenweasel Nov 21, 2022
49945b3
feat: increase timeout for tests
zenweasel Nov 21, 2022
9bba848
feat: remove tests for now
zenweasel Nov 21, 2022
a3886c2
feat: remove memory-mongo from root
zenweasel Nov 21, 2022
b44dd50
Merge pull request #6662 from reactioncommerce/feat/promotions-add-st…
zenweasel Nov 21, 2022
e88a628
feat: new stack ability
vanpho93 Nov 21, 2022
7946721
feat: change stackAbility to stackability
vanpho93 Nov 22, 2022
56aa637
feat: add per-item stackability for discount plugin
vanpho93 Nov 22, 2022
e1c2924
feat: bull queue proof of concept
zenweasel Nov 23, 2022
8719138
feat: experimenting with adding different types of jobs
zenweasel Nov 24, 2022
af27bcb
Merge pull request #6666 from reactioncommerce/feat/new-stackability
zenweasel Nov 24, 2022
d79e8dd
Merge pull request #6654 from reactioncommerce/feat/promotion-fix-seq…
zenweasel Nov 24, 2022
5e92f6c
fix: some fixes for promotion update API
vannguyenn Nov 29, 2022
55be36f
fix: fix item discount calculation-methods
vanpho93 Nov 30, 2022
5a52352
feat: clean out the api to the bare minimum, remove client plugin
Dec 1, 2022
386d5c7
fix: failed test
vannguyenn Dec 5, 2022
cd988b4
fix: update mock fn
vannguyenn Dec 5, 2022
fc4c422
fix: update mock return value
vannguyenn Dec 5, 2022
1a2189b
fix: rename inclusionRule adn exclusionRule variables
vanpho93 Dec 5, 2022
e12a9f9
fix: use returnDocument
vannguyenn Dec 5, 2022
65ef2d6
Merge pull request #6686 from reactioncommerce/fix/inconsistence-in-p…
vanpho93 Dec 5, 2022
5512410
Merge pull request #6685 from reactioncommerce/fix/promotion-updates
vannguyenn Dec 5, 2022
3e8742c
feat: add cart messages
vanpho93 Nov 29, 2022
e470b52
feat: add acknowledge cart message mutation
vanpho93 Dec 6, 2022
303332e
fix: add cart message condition
vanpho93 Dec 6, 2022
201bb38
feat: working email sending via bull queue
Dec 6, 2022
21a75d8
fix: duplicated messages
vanpho93 Dec 6, 2022
530cb7a
feat: add defaults set by env var for adding jobs
Dec 6, 2022
5fbc6a6
fix: applyItemDiscountToCart test fail
vanpho93 Dec 6, 2022
9026a4f
feat: apply some helpful defaults to created queues
zenweasel Dec 6, 2022
0656b06
feat: convert set promotion state to use bull queue
Dec 7, 2022
e4d9277
feat: add redis to integration test configuration
zenweasel Dec 7, 2022
5053e61
feat: don't start queues/jobs if in test mode
Dec 7, 2022
595711c
feat: don't use promises and only emit event when record is modified
Dec 7, 2022
b123b54
feat: changes from c/r
Dec 8, 2022
328f24c
feat: update lock file
Dec 8, 2022
cf55083
feat: remove scheduled job when job with same name is added
Dec 8, 2022
f684fff
feat: remove unneeded reference to REACTION_WORKERS_ENABLED
Dec 8, 2022
d5dd874
feat: added missing resolve
Dec 8, 2022
6d78354
chore: changed indentation
Dec 8, 2022
33ad53f
feat: add archive promotion filter and permissions
vannguyenn Dec 8, 2022
a0930f6
chore: fix test by adding nodemailer to deps
Dec 8, 2022
6ca43c3
chore: put docker-files back
Dec 8, 2022
e367ec2
chore: point to published version
Dec 8, 2022
2851203
chore: update package and readme
zenweasel Dec 8, 2022
d0ebc06
fix: applyItemDiscountToCart test fail
vanpho93 Dec 6, 2022
d19e813
feat: use findOneAndUpdate instead updateOne for cartMessage
vanpho93 Dec 8, 2022
7bbf6ae
fix: add archive promotions to default roles
vannguyenn Dec 9, 2022
dcb5592
fix: add inclusive date filter and fix permission condition
vannguyenn Dec 12, 2022
0611de3
fix: fix format
vannguyenn Dec 12, 2022
346e86e
fix: revert archive permission
vannguyenn Dec 12, 2022
94675f7
fix: fix format and unnecessary changes
vannguyenn Dec 12, 2022
158052c
fix: don't wrap shutdown in a promise
Dec 13, 2022
1def92c
Merge branch 'trunk' into feat/promotions
zenweasel Dec 13, 2022
9a2acc8
Merge branch 'feat/promotions' into use-bull-queue
zenweasel Dec 13, 2022
6f20010
fix: remove archive permission
vannguyenn Dec 13, 2022
20b24ae
fix: remove space
vannguyenn Dec 13, 2022
9414b95
Merge pull request #6693 from reactioncommerce/feat/add-archived-filter
zenweasel Dec 13, 2022
cfe8714
fix: update promotion with new fields
Dec 13, 2022
7e7e00a
feat: add handlers that reprocess carts when promotion state changes
Dec 13, 2022
8e2a60c
fix: use removeRepeatableByKey
Dec 13, 2022
b20db78
feat: emit afterCartUpdate event when acknowledged cart messasge
vanpho93 Dec 13, 2022
94b3c2b
fix: supply jobName so queue is properly linked to processor
Dec 13, 2022
2aa9a9b
fix: allow attaching job name to processors
Dec 13, 2022
f33dd18
feat: add price type to CartItem
vanpho93 Dec 14, 2022
aaad9aa
Merge pull request #6688 from reactioncommerce/feat/implement-cart-me…
vanpho93 Dec 14, 2022
47a3636
fix: tweaks from testing
Dec 14, 2022
a26c161
fix: changes suggested by brian for circleci file
zenweasel Dec 14, 2022
ad3d9c5
fix: update lockfile
Dec 14, 2022
882ed76
fix: bump dotenv to 7 and add dotenv
Dec 14, 2022
b11007a
fix: change import style
Dec 14, 2022
402b1c4
fix: add redis env var to jest
zenweasel Dec 14, 2022
49f7248
fix: fix envvar format
Dec 14, 2022
b6a6f1c
fix: eliminate duplicate logging
Dec 14, 2022
5ad24ec
Merge pull request #6670 from reactioncommerce/use-bull-queue
zenweasel Dec 14, 2022
6671d5b
Merge pull request #6696 from reactioncommerce/feat/add-price-type-fo…
vanpho93 Dec 14, 2022
d84ed74
Merge branch 'feat/promotions' into process-existing-carts-when-promo…
zenweasel Dec 14, 2022
51aaa79
fix: non-working code
Dec 14, 2022
2706951
fix: working cart changed test
Dec 14, 2022
7f0dd30
fix: fully working check and update carts in batches
Dec 15, 2022
5cdcd2f
fix: tweaks from re-checking
Dec 15, 2022
34c642b
fix: name was changed from triggerKey to key
Dec 15, 2022
03c1761
fix: discounts instead of discount
Dec 15, 2022
8ab18ef
fix: discount to discounts
Dec 15, 2022
9f527ff
fix: grab first trigger via destructuring
Dec 15, 2022
368ded4
fix: handle promotion without triggers
Dec 15, 2022
abf820d
fix: remove unneeded let
Dec 15, 2022
bc5f711
Merge pull request #6711 from reactioncommerce/api-fixes
zenweasel Dec 15, 2022
36b1150
fix: fix projection
Dec 15, 2022
cc2bb3d
fix: cleaner implementation of cart changed check
Dec 16, 2022
3909e7c
Merge pull request #6709 from reactioncommerce/process-existing-carts…
zenweasel Dec 16, 2022
409d928
feat: preview promotion
vanpho93 Dec 20, 2022
09096a9
feat: change role review to preview
vanpho93 Dec 26, 2022
0168329
feat: add migration for promotion permissions
vanpho93 Dec 26, 2022
15685cd
Merge branch 'trunk' into feat/promotions
zenweasel Dec 29, 2022
12fb021
feat: filter for promotions
sujithvn Jan 1, 2023
9fb1a70
fix: add changeset
sujithvn Jan 1, 2023
e4dfe64
fix: pnpm-lock socks mongodb-connection-string-url
sujithvn Jan 3, 2023
5a6ef70
Merge pull request #6726 from reactioncommerce/feat/add-promotion-review
zenweasel Jan 3, 2023
d1ef084
feat: add down function for mitation 6
vanpho93 Jan 4, 2023
e1e82a2
feat: create standard coupon mutation
vanpho93 Dec 29, 2022
3606eed
fix: newly duplicated promotion should have created state
vannguyenn Jan 5, 2023
2fb7397
fix: failed build
vannguyenn Jan 6, 2023
fa83eb3
revert change of snyk
vannguyenn Jan 6, 2023
43d3981
fix: revert change to snyk
vannguyenn Jan 6, 2023
eb76d6c
fix: add state to update promotion input
vannguyenn Jan 6, 2023
b8b015a
Merge pull request #6742 from reactioncommerce/fix/duplicated-promoti…
zenweasel Jan 6, 2023
9689695
Merge pull request #6732 from reactioncommerce/feat/add-migration-for…
zenweasel Jan 6, 2023
d160ec7
feat: promotion-add-integration tests
vanpho93 Dec 22, 2022
05830de
feat: create promotion mutation on test
vanpho93 Jan 5, 2023
79a70a0
Merge pull request #6730 from reactioncommerce/feat/promotion-add-int…
vanpho93 Jan 11, 2023
163e39d
fix: change start/end dates to DateTime rather than Date
Jan 13, 2023
6b8bd48
feat: add metafields as fact on get eligibleitems function
vanpho93 Jan 13, 2023
2622e9e
feat: improve promotion validation
vanpho93 Jan 14, 2023
06d1efd
feat: update first version for new packages
vanpho93 Jan 16, 2023
eeb16fa
Merge pull request #6762 from reactioncommerce/feat/improve-promotion…
zenweasel Jan 16, 2023
c7908a6
fix: promotion disabled but still can appliable
vanpho93 Jan 16, 2023
23e79a5
Merge pull request #6758 from reactioncommerce/feat/filterable-exclud…
zenweasel Jan 17, 2023
5f1ea9f
Merge pull request #6763 from reactioncommerce/fix/promotion-can-not-…
zenweasel Jan 17, 2023
ba30716
Merge pull request #6764 from reactioncommerce/feat/update-version-fo…
zenweasel Jan 17, 2023
ee67e47
Merge branch 'feat/promotions' into fix/use-date-time-for-promo-dates
zenweasel Jan 18, 2023
4b34ead
fix: use DateTime rather than Date for tests
Jan 18, 2023
b9e65a5
fix: make it a string for GraphQL
zenweasel Jan 18, 2023
6759eb8
fix: use UTC for graphQL tests
Jan 18, 2023
56904e1
fix: use ISO for graphQL tests
Jan 18, 2023
84fe265
Merge pull request #6761 from reactioncommerce/fix/use-date-time-for-…
zenweasel Jan 26, 2023
f65959b
feat: improve apply coupon mutation
vanpho93 Dec 29, 2022
e1353bd
feat: remove coupon from cart mutation
vanpho93 Dec 27, 2022
db17285
Merge pull request #6735 from reactioncommerce/feat/improve-apply-cou…
vanpho93 Jan 30, 2023
13b876e
Merge pull request #6736 from reactioncommerce/feat/add-remove-coupon…
vanpho93 Jan 30, 2023
df9de17
Merge pull request #6734 from reactioncommerce/feat/create-standard-c…
vanpho93 Jan 30, 2023
343703a
feat: update coupon trigger parameter schema
vanpho93 Jan 30, 2023
e73f2c9
Merge pull request #6738 from reactioncommerce/filter-for-promotions
zenweasel Jan 30, 2023
1d83098
feat: add name field to coupon
vanpho93 Feb 1, 2023
65e9795
Merge pull request #6770 from reactioncommerce/feat/update-coupon-tri…
vanpho93 Feb 1, 2023
d288e4e
feat: promotion graphql schema for cart and order
vanpho93 Jan 4, 2023
366a11a
feat: add additional coupon validation
vanpho93 Feb 1, 2023
bb4fdd5
fix: update promotion shema
vannguyenn Feb 3, 2023
31edfa0
fix: update graphql schema
vannguyenn Feb 6, 2023
7d9e5c0
Merge branch 'release-5' into feat/promotions
zenweasel Feb 6, 2023
2e2e108
Merge pull request #6777 from reactioncommerce/fix/promotion-shema
zenweasel Feb 6, 2023
f56ba81
Merge pull request #6772 from reactioncommerce/feat/promotions-schema…
zenweasel Feb 6, 2023
729b4a5
feat: update promotion error message
vanpho93 Feb 6, 2023
193751c
Merge pull request #6771 from reactioncommerce/feat/add-additional-co…
vanpho93 Feb 7, 2023
dd7b735
Merge branch 'release-5' into feat/promotions
zenweasel Feb 8, 2023
da1de62
fix: add coupon to promotion
vannguyenn Feb 8, 2023
3fd4690
Merge pull request #6785 from reactioncommerce/fix/sample-data
zenweasel Feb 8, 2023
7328b63
feat: enhance duplicate promotion mutation
vanpho93 Feb 8, 2023
b637a08
feat: add additional fields to promotions
vannguyenn Feb 9, 2023
3b431a5
fix: lock file
vannguyenn Feb 9, 2023
a91fb42
Merge pull request #6786 from reactioncommerce/feat/enhance-duplicate…
zenweasel Feb 9, 2023
9649323
fix: revert snyk changes
vannguyenn Feb 9, 2023
4e2b811
Merge pull request #6788 from reactioncommerce/feat/addtional-fields
vannguyenn Feb 9, 2023
f18b2e8
feat: create migration for old discoupon
vanpho93 Feb 1, 2023
919caa1
fix: add migration down method
vanpho93 Feb 9, 2023
562f8dd
fix: revert accidental changes
vannguyenn Feb 9, 2023
ce0d117
feat: add archive coupon mutation
vanpho93 Feb 1, 2023
9db5e13
Merge pull request #6782 from reactioncommerce/feat/archive-coupon-mu…
vanpho93 Feb 10, 2023
e6ab079
Merge pull request #6789 from reactioncommerce/fix/lock-file
zenweasel Feb 13, 2023
f2a2321
fix: migration up error
vanpho93 Feb 10, 2023
93381c5
Merge pull request #6784 from reactioncommerce/feat/create-migration-…
zenweasel Feb 13, 2023
ccde2a2
feat: add load sequencies sample data
vanpho93 Feb 9, 2023
b96e479
fix: cart promotion item schema
vannguyenn Feb 14, 2023
d71b8ac
Merge pull request #6798 from reactioncommerce/fix/promotion-schema-bugs
zenweasel Feb 14, 2023
1bbb011
fix: duplicate index key on sequences
vanpho93 Feb 14, 2023
15c2bfc
Merge pull request #6791 from reactioncommerce/fix/assigning-first-se…
zenweasel Feb 14, 2023
58e29f2
Merge branch 'feat/promotions' into feat/coupons
vanpho93 Feb 14, 2023
4312af6
fix: merge issue
vanpho93 Feb 14, 2023
94501ed
Merge pull request #6800 from reactioncommerce/fix/merge-issue
vanpho93 Feb 14, 2023
4a614a3
fix: should query un-archived coupon in promotion
vannguyenn Feb 16, 2023
8da5f07
feat: shipping discount method
vanpho93 Feb 16, 2023
7d6032c
Merge pull request #6801 from reactioncommerce/fix/archived-coupon-pr…
zenweasel Feb 16, 2023
b2297cd
fix: prevent applied coupon when is archived
vanpho93 Feb 14, 2023
d4578d7
Merge pull request #6804 from reactioncommerce/fix/prevent-applied-co…
zenweasel Feb 20, 2023
fb551ee
feat: add calculate discount amount util
vanpho93 Feb 20, 2023
9aa30d9
fix: use insertedId instead of insertedCount
vannguyenn Feb 21, 2023
9e3feec
fix: place order with shipping discount
vanpho93 Feb 21, 2023
234c47e
fix: calculate shipping discount amount
vanpho93 Feb 21, 2023
0c41448
Merge pull request #6806 from reactioncommerce/fix/duplicate-endpoint
zenweasel Feb 22, 2023
96cdd6b
Merge branch 'release-5' into feat/promotions
zenweasel Feb 22, 2023
7d9b8c1
feat: estimate discount amount for shipment quotes
vanpho93 Feb 22, 2023
88b213f
fix: applyPromotion unit test fail
vanpho93 Feb 24, 2023
3dcde45
fix: max discount value for shipping discount
vanpho93 Feb 24, 2023
f21dfaa
feat: add integration test for shipping disocunt
vanpho93 Feb 26, 2023
7bb460b
fix: unit test fail on disocuntAction
vanpho93 Feb 27, 2023
dc2704a
feat: deprecate discounts plugins
vanpho93 Feb 27, 2023
93a5c47
feat: add expect discount amount for integraiton test
vanpho93 Feb 27, 2023
da22cdb
feat: remove discount code integration test
vanpho93 Feb 27, 2023
e7fe1a3
feat: remove discount code query integration test
vanpho93 Feb 27, 2023
070b284
feat: two shipping promotion test case
vanpho93 Feb 27, 2023
9789fc9
Merge pull request #6815 from reactioncommerce/feat/deprecate-discoun…
zenweasel Feb 27, 2023
6be616a
feat: add additional redeemed coupon information
vanpho93 Feb 27, 2023
dc51fd5
fix: revert snyk
vanpho93 Feb 27, 2023
c88826b
feat: remove usedLogs field on CouponLog schema
vanpho93 Feb 28, 2023
5c6e241
Merge pull request #6816 from reactioncommerce/feat/add-additional-re…
zenweasel Feb 28, 2023
dbb9c88
fix: temporary promotions
vanpho93 Feb 28, 2023
5769600
Merge branch 'feat/coupons' into feat/shipping-discounts
vanpho93 Mar 1, 2023
dd89dcd
fix: pnpm-lock file
vanpho93 Mar 1, 2023
6fbde96
feat: add sample data for shipping promotion
vanpho93 Mar 1, 2023
4072436
fix: promotion plugin unit test fail
vanpho93 Mar 1, 2023
686d7e2
fix: remove sampleData from plugin file
vanpho93 Mar 1, 2023
490044c
fix: checkout promotion test fail
vanpho93 Mar 1, 2023
c2471d3
feat: add check stackability for the shipping discount
vanpho93 Mar 2, 2023
36dd29c
fix: revert promotion starup file
vanpho93 Mar 2, 2023
e0c0e7c
Merge pull request #6802 from reactioncommerce/feat/shipping-discounts
vanpho93 Mar 3, 2023
b49f72a
Merge pull request #6769 from reactioncommerce/feat/coupons
vanpho93 May 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .changeset/funny-scissors-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@reactioncommerce/api-plugin-promotions": minor
---

filter feature for promotions
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ jobs:
command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
ports:
- "27017:27017"
- image: redis
ports:
- "6379:6379"
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -129,6 +132,9 @@ jobs:
command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
ports:
- "27017:27017"
- image: redis
ports:
- "6379:6379"
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -189,6 +195,7 @@ jobs:
echo "ROOT_URL=http://localhost:3000" >> .env
echo "STORE_URL=http://localhost:4000" >> .env
echo "STRIPE_API_KEY=YOUR_PRIVATE_STRIPE_API_KEY" >> .env
echo "REDIS_SERVER=redis://127.0.0.1:6379" >> .env
- run:
name: Create reaction.localhost network
command: docker network create "reaction.localhost" || true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,7 @@ yalc-packages

# Build
dist

# Editor
.vscode
.idea
18 changes: 0 additions & 18 deletions .vscode/launch.json

This file was deleted.

2 changes: 2 additions & 0 deletions apps/reaction/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MONGO_URL=mongodb://mongo.reaction.localhost:27017/reaction
ROOT_URL=http://localhost:3000
STRIPE_API_KEY=YOUR_PRIVATE_STRIPE_API_KEY
REDIS_SERVER=redis://127.0.0.1:6379
MAIL_URL=smtp://localhost:1025
11 changes: 8 additions & 3 deletions apps/reaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
"@reactioncommerce/api-plugin-address-validation-test": "1.0.3",
"@reactioncommerce/api-plugin-authentication": "2.2.5",
"@reactioncommerce/api-plugin-authorization-simple": "1.3.2",
"@reactioncommerce/api-plugin-bull-queue": "0.0.0",
"@reactioncommerce/api-plugin-carts": "1.3.5",
"@reactioncommerce/api-plugin-catalogs": "1.1.2",
"@reactioncommerce/api-plugin-discounts": "1.0.4",
"@reactioncommerce/api-plugin-discounts-codes": "1.2.4",
"@reactioncommerce/api-plugin-email": "1.1.5",
"@reactioncommerce/api-plugin-email-smtp": "1.0.8",
"@reactioncommerce/api-plugin-email-templates": "1.1.7",
Expand All @@ -49,6 +48,11 @@
"@reactioncommerce/api-plugin-payments-stripe-sca": "1.0.2",
"@reactioncommerce/api-plugin-pricing-simple": "1.0.7",
"@reactioncommerce/api-plugin-products": "1.3.1",
"@reactioncommerce/api-plugin-promotions": "0.0.0",
"@reactioncommerce/api-plugin-promotions-coupons": "0.0.0",
"@reactioncommerce/api-plugin-promotions-discounts": "0.0.0",
"@reactioncommerce/api-plugin-promotions-offers": ".0.0",
"@reactioncommerce/api-plugin-sequences": "0.0.0",
"@reactioncommerce/api-plugin-settings": "1.0.7",
"@reactioncommerce/api-plugin-shipments": "1.0.3",
"@reactioncommerce/api-plugin-shipments-flat-rate": "1.0.10",
Expand All @@ -66,9 +70,9 @@
"@reactioncommerce/file-collections": "0.9.3",
"@reactioncommerce/file-collections-sa-gridfs": "0.1.5",
"@reactioncommerce/logger": "1.1.5",
"@reactioncommerce/nodemailer": "5.0.5",
"@reactioncommerce/random": "1.0.2",
"@snyk/protect": "latest",
"nodemailer": "^6.8.0",
"graphql": "~16.6.0",
"semver": "~6.3.0",
"sharp": "^0.30.7"
Expand All @@ -84,6 +88,7 @@
},
"scripts": {
"start": "node --experimental-modules --experimental-json-modules ./src/index.js",
"start:debug": "npm run check-node-version && NODE_ENV=development NODE_OPTIONS='--experimental-modules --experimental-json-modules' nodemon --inspect ./src/index.js",
"start:dev": "npm run check-node-version && NODE_ENV=development NODE_OPTIONS='--experimental-modules --experimental-json-modules' nodemon ./src/index.js",
"inspect": "NODE_ENV=development node --experimental-modules --experimental-json-modules --inspect ./src/index.js",
"inspect-brk": "NODE_ENV=development node --experimental-modules --experimental-json-modules --inspect-brk ./src/index.js",
Expand Down
10 changes: 7 additions & 3 deletions apps/reaction/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"files": "@reactioncommerce/api-plugin-files",
"shops": "@reactioncommerce/api-plugin-shops",
"settings": "@reactioncommerce/api-plugin-settings",
"sequences": "@reactioncommerce/api-plugin-sequences",
"i18": "@reactioncommerce/api-plugin-i18n",
"email": "@reactioncommerce/api-plugin-email",
"addressValidation": "@reactioncommerce/api-plugin-address-validation",
Expand All @@ -25,8 +26,6 @@
"payments": "@reactioncommerce/api-plugin-payments",
"paymentsStripeSCA": "@reactioncommerce/api-plugin-payments-stripe-sca",
"paymentsExample": "@reactioncommerce/api-plugin-payments-example",
"discounts": "@reactioncommerce/api-plugin-discounts",
"discountCodes": "@reactioncommerce/api-plugin-discounts-codes",
"surcharges": "@reactioncommerce/api-plugin-surcharges",
"shipments": "@reactioncommerce/api-plugin-shipments",
"shipmentsFlatRate": "@reactioncommerce/api-plugin-shipments-flat-rate",
Expand All @@ -35,5 +34,10 @@
"navigation": "@reactioncommerce/api-plugin-navigation",
"sitemapGenerator": "@reactioncommerce/api-plugin-sitemap-generator",
"notifications": "@reactioncommerce/api-plugin-notifications",
"addressValidationTest": "@reactioncommerce/api-plugin-address-validation-test"
"addressValidationTest": "@reactioncommerce/api-plugin-address-validation-test",
"promotions": "@reactioncommerce/api-plugin-promotions",
"promotionsCoupons": "@reactioncommerce/api-plugin-promotions-coupons",
"promotionsDiscounts": "@reactioncommerce/api-plugin-promotions-discounts",
"promotionsOffers": "@reactioncommerce/api-plugin-promotions-offers",
"bullJobQueue": "@reactioncommerce/api-plugin-bull-queue"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ beforeAll(async () => {
catalogItem = Factory.Catalog.makeOne({
isDeleted: false,
product: Factory.CatalogProduct.makeOne({
title: "Test Product",
isDeleted: false,
isVisible: true,
variants: Factory.CatalogProductVariant.makeMany(1, {
Expand Down Expand Up @@ -79,7 +80,8 @@ beforeAll(async () => {
anonymousAccessToken: hashToken(cartToken),
shipping: null,
items: [],
workflow: null
workflow: null,
discounts: []
});
opaqueCartId = encodeOpaqueId("reaction/cart", mockCart._id);
await testApp.collections.Cart.insertOne(mockCart);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mutation CreatePromotion($input: PromotionCreateInput!) {
createPromotion(input: $input) {
success
promotion {
_id
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const SelectFulfillmentOptionForGroupMutation = importAsString("./SelectFulfillm
const SetShippingAddressOnCartMutation = importAsString("./SetShippingAddressOnCartMutation.graphql");
const UpdateCartItemsQuantityMutation = importAsString("./UpdateCartItemsQuantityMutation.graphql");
const UpdateFulfillmentOptionsForGroupMutation = importAsString("./UpdateFulfillmentOptionsForGroupMutation.graphql");
const CreatePromotionMutation = importAsString("./CreatePromotionMutation.graphql");

jest.setTimeout(300000);

Expand All @@ -25,6 +26,10 @@ const opaqueProductId = encodeProductOpaqueId(999);
const internalTagIds = ["923", "924"];
const internalVariantIds = ["875", "874", "925"];

const internalProductTwoId = "888";
const opaqueProductTwoId = encodeProductOpaqueId(888);
const internalVariantTwoIds = ["889", "890"];

const shopName = "Test Shop";

const mockProduct = {
Expand Down Expand Up @@ -65,6 +70,35 @@ const mockOptionTwo = {
price: 29.99
};

const mockProductTwo = {
_id: internalProductTwoId,
ancestors: [],
title: "Fake Product two",
isDeleted: false,
isVisible: true,
supportedFulfillmentTypes: ["shipping"],
vendor: "Nike"
};

const mockVariantTwo = {
_id: internalVariantTwoIds[0],
ancestors: [internalProductTwoId],
attributeLabel: "Variant",
title: "Fake Product Two Variant",
isDeleted: false,
isVisible: true
};

const mockOptionTwoOne = {
_id: internalVariantTwoIds[1],
ancestors: [internalProductTwoId, internalVariantTwoIds[0]],
attributeLabel: "Option",
title: "Fake Product Two Option One",
isDeleted: false,
isVisible: true,
price: 19.99
};

const mockShippingMethod = {
_id: "mockShippingMethod",
name: "Default Shipping Provider",
Expand All @@ -76,9 +110,7 @@ const mockShippingMethod = {
methods: [
{
cost: 2.5,
fulfillmentTypes: [
"shipping"
],
fulfillmentTypes: ["shipping"],
group: "Ground",
handling: 1.5,
label: "Standard mockMethod",
Expand All @@ -94,6 +126,7 @@ let addCartItems;
let availablePaymentMethods;
let createCart;
let createShop;
let createPromotion;
let internalShopId;
let opaqueShopId;
let placeOrder;
Expand Down Expand Up @@ -127,6 +160,7 @@ beforeAll(async () => {
setShippingAddressOnCart = testApp.mutate(SetShippingAddressOnCartMutation);
updateCartItemsQuantity = testApp.mutate(UpdateCartItemsQuantityMutation);
updateFulfillmentOptionsForGroup = testApp.mutate(UpdateFulfillmentOptionsForGroupMutation);
createPromotion = testApp.mutate(CreatePromotionMutation);

const shopCreateGroup = Factory.Group.makeOne({
_id: "shopCreateGroup",
Expand All @@ -149,29 +183,27 @@ beforeAll(async () => {

const {
createShop: {
shop: {
_id: newShopId
}
shop: { _id: newShopId }
}
} = await createShop({
input: {
name: shopName
}
});

opaqueShopId = newShopId;
internalShopId = decodeOpaqueIdForNamespace("reaction/shop", newShopId);

const adminGroup = Factory.Group.makeOne({
_id: "adminGroup",
createdBy: null,
name: "admin",
permissions: ["reaction:legacy:products/publish"],
permissions: ["reaction:legacy:products/publish", "reaction:legacy:promotions/create"],
slug: "admin",
shopId: newShopId
shopId: internalShopId
});
await testApp.collections.Groups.insertOne(adminGroup);

opaqueShopId = newShopId;
internalShopId = decodeOpaqueIdForNamespace("reaction/shop", newShopId);

// Set other shop settings
await testApp.collections.Shops.updateOne(
{ _id: internalShopId },
Expand All @@ -193,14 +225,20 @@ beforeAll(async () => {
mockVariant.shopId = internalShopId;
mockOptionOne.shopId = internalShopId;
mockOptionTwo.shopId = internalShopId;
mockProductTwo.shopId = internalShopId;
mockVariantTwo.shopId = internalShopId;
mockOptionTwoOne.shopId = internalShopId;
await Promise.all(internalTagIds.map((_id) => testApp.collections.Tags.insertOne({ _id, shopId: internalShopId, slug: `slug${_id}` })));
await testApp.collections.Products.insertOne(mockProduct);
await testApp.collections.Products.insertOne(mockVariant);
await testApp.collections.Products.insertOne(mockOptionOne);
await testApp.collections.Products.insertOne(mockOptionTwo);
await testApp.collections.Products.insertOne(mockProductTwo);
await testApp.collections.Products.insertOne(mockVariantTwo);
await testApp.collections.Products.insertOne(mockOptionTwoOne);

// Publish products to the catalog
await publishProducts({ productIds: [opaqueProductId] });
await publishProducts({ productIds: [opaqueProductId, opaqueProductTwoId] });
});

// eslint-disable-next-line require-jsdoc
Expand All @@ -210,10 +248,13 @@ export default function getCommonData() {
availablePaymentMethods,
createCart,
createShop,
createPromotion,
encodeProductOpaqueId,
internalShopId,
internalVariantIds,
internalVariantTwoIds,
opaqueProductId,
opaqueProductTwoId,
opaqueShopId,
placeOrder,
publishProducts,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export const fixedDiscountPromotion = {
name: "$10 off when you spend more than $100",
label: "Order promotion",
description: "$10 off when you spend more than $100",
actions: [
{
actionKey: "discounts",
actionParameters: {
discountType: "order",
discountCalculationType: "fixed",
discountValue: 10
}
}
],
triggers: [
{
triggerKey: "offers",
triggerParameters: {
name: "$10 off when you spend more than $100",
conditions: {
all: [
{
fact: "totalItemAmount",
operator: "greaterThanInclusive",
value: 100
}
]
}
}
}
],
promotionType: "order-discount",
enabled: true,
stackability: {
key: "all",
parameters: {}
}
};

export const percentagePromotion = {
name: "%10 off when you spend more than $100",
description: "%10 off when you spend more than $100",
actions: [
{
actionKey: "discounts",
actionParameters: {
discountType: "order",
discountCalculationType: "percentage",
discountValue: 10
}
}
],
triggers: [
{
triggerKey: "offers",
triggerParameters: {
name: "%10 off when you spend more than $100",
conditions: {
all: [
{
fact: "totalItemAmount",
operator: "greaterThanInclusive",
value: 100
}
]
}
}
}
],
triggerType: "implicit",
promotionType: "order-discount",
enabled: true,
stackability: {
key: "all",
parameters: {}
}
};