product variant test adjustsments after variant was removed from the api
This commit is contained in:
1 parent
6bd0d4458c
commit
f5ee870854
2 files changed
+25
-37
No files matched your search
@@ -81,7 +81,7 @@ Array [
|
|||||||
"ean": "test-ean",
|
"ean": "test-ean",
|
||||||
"height": null,
|
"height": null,
|
||||||
"hs_code": null,
|
"hs_code": null,
|
||||||
"id": StringMatching /\\^test-variant\\*/,
|
"id": "test-variant",
|
||||||
"inventory_quantity": 10,
|
"inventory_quantity": 10,
|
||||||
"length": null,
|
"length": null,
|
||||||
"manage_inventory": true,
|
"manage_inventory": true,
|
||||||
@@ -119,7 +119,6 @@ Array [
|
|||||||
"title": "Test variant",
|
"title": "Test variant",
|
||||||
"upc": "test-upc",
|
"upc": "test-upc",
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"variant_rank": 0,
|
|
||||||
"weight": null,
|
"weight": null,
|
||||||
"width": null,
|
"width": null,
|
||||||
},
|
},
|
||||||
@@ -131,7 +130,7 @@ Array [
|
|||||||
"ean": "test-ean2",
|
"ean": "test-ean2",
|
||||||
"height": null,
|
"height": null,
|
||||||
"hs_code": null,
|
"hs_code": null,
|
||||||
"id": StringMatching /\\^test-variant\\*/,
|
"id": "test-variant_2",
|
||||||
"inventory_quantity": 10,
|
"inventory_quantity": 10,
|
||||||
"length": null,
|
"length": null,
|
||||||
"manage_inventory": true,
|
"manage_inventory": true,
|
||||||
@@ -169,7 +168,6 @@ Array [
|
|||||||
"title": "Test variant rank (2)",
|
"title": "Test variant rank (2)",
|
||||||
"upc": "test-upc2",
|
"upc": "test-upc2",
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"variant_rank": 1,
|
|
||||||
"weight": null,
|
"weight": null,
|
||||||
"width": null,
|
"width": null,
|
||||||
},
|
},
|
||||||
@@ -181,7 +179,7 @@ Array [
|
|||||||
"ean": "test-ean1",
|
"ean": "test-ean1",
|
||||||
"height": null,
|
"height": null,
|
||||||
"hs_code": null,
|
"hs_code": null,
|
||||||
"id": StringMatching /\\^test-variant\\*/,
|
"id": "test-variant_1",
|
||||||
"inventory_quantity": 10,
|
"inventory_quantity": 10,
|
||||||
"length": null,
|
"length": null,
|
||||||
"manage_inventory": true,
|
"manage_inventory": true,
|
||||||
@@ -219,7 +217,6 @@ Array [
|
|||||||
"title": "Test variant rank (1)",
|
"title": "Test variant rank (1)",
|
||||||
"upc": "test-upc1",
|
"upc": "test-upc1",
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"variant_rank": 2,
|
|
||||||
"weight": null,
|
"weight": null,
|
||||||
"width": null,
|
"width": null,
|
||||||
},
|
},
|
||||||
@@ -287,7 +284,7 @@ Array [
|
|||||||
"ean": "test-ean4",
|
"ean": "test-ean4",
|
||||||
"height": null,
|
"height": null,
|
||||||
"hs_code": null,
|
"hs_code": null,
|
||||||
"id": StringMatching /\\^test-variant\\*/,
|
"id": "test-variant_4",
|
||||||
"inventory_quantity": 10,
|
"inventory_quantity": 10,
|
||||||
"length": null,
|
"length": null,
|
||||||
"manage_inventory": true,
|
"manage_inventory": true,
|
||||||
@@ -325,7 +322,6 @@ Array [
|
|||||||
"title": "Test variant rank (2)",
|
"title": "Test variant rank (2)",
|
||||||
"upc": "test-upc4",
|
"upc": "test-upc4",
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"variant_rank": 0,
|
|
||||||
"weight": null,
|
"weight": null,
|
||||||
"width": null,
|
"width": null,
|
||||||
},
|
},
|
||||||
@@ -337,7 +333,7 @@ Array [
|
|||||||
"ean": "test-ean3",
|
"ean": "test-ean3",
|
||||||
"height": null,
|
"height": null,
|
||||||
"hs_code": null,
|
"hs_code": null,
|
||||||
"id": StringMatching /\\^test-variant\\*/,
|
"id": "test-variant_3",
|
||||||
"inventory_quantity": 10,
|
"inventory_quantity": 10,
|
||||||
"length": null,
|
"length": null,
|
||||||
"manage_inventory": true,
|
"manage_inventory": true,
|
||||||
@@ -375,7 +371,6 @@ Array [
|
|||||||
"title": "Test variant rank (2)",
|
"title": "Test variant rank (2)",
|
||||||
"upc": "test-upc3",
|
"upc": "test-upc3",
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"variant_rank": 1,
|
|
||||||
"weight": null,
|
"weight": null,
|
||||||
"width": null,
|
"width": null,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe("/admin/products", () => {
|
|||||||
await db.teardown()
|
await db.teardown()
|
||||||
})
|
})
|
||||||
|
|
||||||
it.only("returns a list of products with child entities", async () => {
|
it("returns a list of products with child entities", async () => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
|
|
||||||
const response = await api
|
const response = await api
|
||||||
@@ -55,15 +55,6 @@ describe("/admin/products", () => {
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
const testProduct = response.data.products[0]
|
|
||||||
|
|
||||||
console.log(JSON.stringify(testProduct, null, 2))
|
|
||||||
|
|
||||||
const testProduct1 = response.data.products[1]
|
|
||||||
|
|
||||||
console.log(JSON.stringify(testProduct1, null, 2))
|
|
||||||
// console.log(testProduct.variants)
|
|
||||||
|
|
||||||
expect(response.data.products).toMatchSnapshot([
|
expect(response.data.products).toMatchSnapshot([
|
||||||
{
|
{
|
||||||
id: expect.stringMatching(/^test-*/),
|
id: expect.stringMatching(/^test-*/),
|
||||||
@@ -85,10 +76,9 @@ describe("/admin/products", () => {
|
|||||||
],
|
],
|
||||||
variants: [
|
variants: [
|
||||||
{
|
{
|
||||||
id: expect.stringMatching(/^test-variant*/),
|
id: "test-variant", //expect.stringMatching(/^test-variant*/),
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
variant_rank: 0,
|
|
||||||
product_id: expect.stringMatching(/^test-*/),
|
product_id: expect.stringMatching(/^test-*/),
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
@@ -109,10 +99,9 @@ describe("/admin/products", () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: expect.stringMatching(/^test-variant*/),
|
id: "test-variant_2", //expect.stringMatching(/^test-variant*/),
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
variant_rank: 1,
|
|
||||||
product_id: expect.stringMatching(/^test-*/),
|
product_id: expect.stringMatching(/^test-*/),
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
@@ -133,10 +122,9 @@ describe("/admin/products", () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: expect.stringMatching(/^test-variant*/),
|
id: "test-variant_1", // expect.stringMatching(/^test-variant*/),
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
variant_rank: 2,
|
|
||||||
product_id: expect.stringMatching(/^test-*/),
|
product_id: expect.stringMatching(/^test-*/),
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
@@ -184,10 +172,9 @@ describe("/admin/products", () => {
|
|||||||
options: [],
|
options: [],
|
||||||
variants: [
|
variants: [
|
||||||
{
|
{
|
||||||
id: expect.stringMatching(/^test-variant*/),
|
id: "test-variant_4", //expect.stringMatching(/^test-variant*/),
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
variant_rank: 0,
|
|
||||||
product_id: expect.stringMatching(/^test-*/),
|
product_id: expect.stringMatching(/^test-*/),
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
@@ -208,10 +195,9 @@ describe("/admin/products", () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: expect.stringMatching(/^test-variant*/),
|
id: "test-variant_3", //expect.stringMatching(/^test-variant*/),
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
variant_rank: 1,
|
|
||||||
product_id: expect.stringMatching(/^test-*/),
|
product_id: expect.stringMatching(/^test-*/),
|
||||||
prices: [
|
prices: [
|
||||||
{
|
{
|
||||||
@@ -393,7 +379,7 @@ describe("/admin/products", () => {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await api
|
const creationResponse = await api
|
||||||
.post("/admin/products", payload, {
|
.post("/admin/products", payload, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: "Bearer test_token",
|
Authorization: "Bearer test_token",
|
||||||
@@ -403,7 +389,19 @@ describe("/admin/products", () => {
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(creationResponse.status).toEqual(200)
|
||||||
|
|
||||||
|
const productId = creationResponse.data.product.id
|
||||||
|
|
||||||
|
const response = await api
|
||||||
|
.get(`/admin/products/${productId}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer test_token",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
|
||||||
expect(response.data.product).toEqual(
|
expect(response.data.product).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@@ -411,11 +409,9 @@ describe("/admin/products", () => {
|
|||||||
variants: [
|
variants: [
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
title: "Test variant 1",
|
title: "Test variant 1",
|
||||||
variant_rank: 0,
|
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
title: "Test variant 2",
|
title: "Test variant 2",
|
||||||
variant_rank: 1,
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -563,17 +559,14 @@ describe("/admin/products", () => {
|
|||||||
variants: [
|
variants: [
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-variant",
|
id: "test-variant",
|
||||||
variant_rank: 0,
|
|
||||||
title: "Test variant",
|
title: "Test variant",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-variant_1",
|
id: "test-variant_1",
|
||||||
variant_rank: 1,
|
|
||||||
title: "Test variant rank (1)",
|
title: "Test variant rank (1)",
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-variant_2",
|
id: "test-variant_2",
|
||||||
variant_rank: 2,
|
|
||||||
title: "Test variant rank (2)",
|
title: "Test variant rank (2)",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in new issue
Block a user