Skip to content

Commit 8d562d2

Browse files
Merge pull request #18897 from mozilla/FXA-11640-cart-error
fix(payments-next): CartError: Cart not created: Out of range value for column 'amount' at row 1
2 parents fbc881f + 9f9ed9e commit 8d562d2

5 files changed

Lines changed: 18 additions & 4 deletions

File tree

libs/payments/cart/src/lib/cart.manager.in.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ describe('CartManager', () => {
9999
expect(error.jse_cause).not.toBeUndefined();
100100
}
101101
});
102+
103+
it('succeeds - creates a cart with a negative amount', async () => {
104+
const setupCart = SetupCartFactory({
105+
amount: -500,
106+
});
107+
const cart = await cartManager.createCart(setupCart);
108+
expect(cart).toEqual(expect.objectContaining(setupCart));
109+
});
102110
});
103111

104112
describe('createErrorCart', () => {
@@ -108,7 +116,7 @@ describe('CartManager', () => {
108116
});
109117
const cart = await cartManager.createErrorCart(
110118
setupCart,
111-
CartErrorReasonId.CartEligibilityStatusSame
119+
CartErrorReasonId.CART_ELIGIBILITY_STATUS_SAME
112120
);
113121
expect(cart).toEqual(expect.objectContaining(setupCart));
114122
});
@@ -121,7 +129,7 @@ describe('CartManager', () => {
121129
try {
122130
await cartManager.createErrorCart(
123131
setupCart,
124-
CartErrorReasonId.CartEligibilityStatusInvalid
132+
CartErrorReasonId.CART_ELIGIBILITY_STATUS_INVALID
125133
);
126134
} catch (error) {
127135
expect(error).toBeInstanceOf(CartNotCreatedError);

libs/shared/db/mysql/account/src/test/carts.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CREATE TABLE `carts` (
1313
`couponCode` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
1414
`stripeCustomerId` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL,
1515
`email` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
16-
`amount` int unsigned NOT NULL,
16+
`amount` int NOT NULL,
1717
`version` smallint unsigned DEFAULT 0 NOT NULL,
1818
`eligibilityStatus` enum('create', 'upgrade', 'downgrade', 'blocked_iap', 'invalid') COLLATE utf8mb4_bin NOT NULL,
1919
PRIMARY KEY (`id`),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE carts MODIFY COLUMN amount INT NOT NULL;
2+
3+
UPDATE dbMetadata SET value = '171' WHERE name = 'schema-patch-level';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- ALTER TABLE carts MODIFY COLUMN amount INT UNSIGNED NOT NULL;
2+
3+
-- UPDATE dbMetadata SET value = '170' WHERE name = 'schema-patch-level';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"level": 170
2+
"level": 171
33
}

0 commit comments

Comments
 (0)