mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
fix tests
This commit is contained in:
parent
5fa068e77b
commit
5495b9c269
@ -793,17 +793,13 @@ it("should block one-time purchase for same product after prior one-time purchas
|
||||
accessType: "client",
|
||||
body: { customer_type: "user", customer_id: userId, offer_id: "ot" },
|
||||
});
|
||||
expect(createUrl2.status).toBe(200);
|
||||
const code2 = (createUrl2.body as { url: string }).url.match(/\/purchase\/([a-z0-9-_]+)/)?.[1];
|
||||
expect(code2).toBeDefined();
|
||||
|
||||
const res = await niceBackendFetch("/api/v1/payments/purchases/purchase-session", {
|
||||
method: "POST",
|
||||
accessType: "client",
|
||||
body: { full_code: code2, price_id: "one", quantity: 1 },
|
||||
});
|
||||
expect(res.status).toBe(400);
|
||||
expect(String(res.body)).toBe("Customer already has purchased this product; this product is not stackable");
|
||||
expect(createUrl2).toMatchInlineSnapshot(`
|
||||
NiceResponse {
|
||||
"status": 400,
|
||||
"body": "Customer already has purchased this product; this product is not stackable",
|
||||
"headers": Headers { <some fields may have been hidden> },
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it("should block one-time purchase in same group after prior one-time purchase in that group (test-mode persisted)", async ({ expect }) => {
|
||||
|
||||
@ -122,39 +122,10 @@ it("should set already_bought_non_stackable when user already owns non-stackable
|
||||
offer_id: "test-offer",
|
||||
},
|
||||
});
|
||||
expect(createUrlRes2.status).toBe(200);
|
||||
const code2 = (createUrlRes2.body as { url: string }).url.match(/\/purchase\/([a-z0-9-_]+)/)?.[1];
|
||||
expect(code2).toBeDefined();
|
||||
|
||||
const validateResponse = await niceBackendFetch("/api/v1/payments/purchases/validate-code", {
|
||||
method: "POST",
|
||||
accessType: "client",
|
||||
body: { full_code: code2 },
|
||||
});
|
||||
expect(validateResponse).toMatchInlineSnapshot(`
|
||||
expect(createUrlRes2).toMatchInlineSnapshot(`
|
||||
NiceResponse {
|
||||
"status": 200,
|
||||
"body": {
|
||||
"already_bought_non_stackable": true,
|
||||
"conflicting_products": [],
|
||||
"product": {
|
||||
"customer_type": "user",
|
||||
"display_name": "Test Offer",
|
||||
"prices": {
|
||||
"monthly": {
|
||||
"USD": "1000",
|
||||
"interval": [
|
||||
1,
|
||||
"month",
|
||||
],
|
||||
},
|
||||
},
|
||||
"stackable": false,
|
||||
},
|
||||
"project_id": "<stripped UUID>",
|
||||
"stripe_account_id": <stripped field 'stripe_account_id'>,
|
||||
"test_mode": true,
|
||||
},
|
||||
"status": 400,
|
||||
"body": "Customer already has purchased this product; this product is not stackable",
|
||||
"headers": Headers { <some fields may have been hidden> },
|
||||
}
|
||||
`);
|
||||
|
||||
@ -809,17 +809,13 @@ it("should block one-time purchase for same product after prior one-time purchas
|
||||
accessType: "client",
|
||||
body: { customer_type: "user", customer_id: userId, product_id: "ot" },
|
||||
});
|
||||
expect(createUrl2.status).toBe(200);
|
||||
const code2 = (createUrl2.body as { url: string }).url.match(/\/purchase\/([a-z0-9-_]+)/)?.[1];
|
||||
expect(code2).toBeDefined();
|
||||
|
||||
const res = await niceBackendFetch("/api/latest/payments/purchases/purchase-session", {
|
||||
method: "POST",
|
||||
accessType: "client",
|
||||
body: { full_code: code2, price_id: "one", quantity: 1 },
|
||||
});
|
||||
expect(res.status).toBe(400);
|
||||
expect(String(res.body)).toBe("Customer already has purchased this product; this product is not stackable");
|
||||
expect(createUrl2).toMatchInlineSnapshot(`
|
||||
NiceResponse {
|
||||
"status": 400,
|
||||
"body": "Customer already has purchased this product; this product is not stackable",
|
||||
"headers": Headers { <some fields may have been hidden> },
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it("should block one-time purchase in same group after prior one-time purchase in that group (test-mode persisted)", async ({ expect }) => {
|
||||
|
||||
@ -122,39 +122,10 @@ it("should set already_bought_non_stackable when user already owns non-stackable
|
||||
product_id: "test-product",
|
||||
},
|
||||
});
|
||||
expect(createUrlRes2.status).toBe(200);
|
||||
const code2 = (createUrlRes2.body as { url: string }).url.match(/\/purchase\/([a-z0-9-_]+)/)?.[1];
|
||||
expect(code2).toBeDefined();
|
||||
|
||||
const validateResponse = await niceBackendFetch("/api/latest/payments/purchases/validate-code", {
|
||||
method: "POST",
|
||||
accessType: "client",
|
||||
body: { full_code: code2 },
|
||||
});
|
||||
expect(validateResponse).toMatchInlineSnapshot(`
|
||||
expect(createUrlRes2).toMatchInlineSnapshot(`
|
||||
NiceResponse {
|
||||
"status": 200,
|
||||
"body": {
|
||||
"already_bought_non_stackable": true,
|
||||
"conflicting_products": [],
|
||||
"product": {
|
||||
"customer_type": "user",
|
||||
"display_name": "Test Product",
|
||||
"prices": {
|
||||
"monthly": {
|
||||
"USD": "1000",
|
||||
"interval": [
|
||||
1,
|
||||
"month",
|
||||
],
|
||||
},
|
||||
},
|
||||
"stackable": false,
|
||||
},
|
||||
"project_id": "<stripped UUID>",
|
||||
"stripe_account_id": <stripped field 'stripe_account_id'>,
|
||||
"test_mode": true,
|
||||
},
|
||||
"status": 400,
|
||||
"body": "Customer already has purchased this product; this product is not stackable",
|
||||
"headers": Headers { <some fields may have been hidden> },
|
||||
}
|
||||
`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user