chore: retry util on tests (#12126)
This commit is contained in:
committed by
GitHub
parent
cb26c224ea
commit
f615ebb7e8
@@ -6,6 +6,7 @@ import {
|
||||
adminHeaders,
|
||||
createAdminUser,
|
||||
} from "../../../helpers/create-admin-user"
|
||||
import { fetchAndRetry } from "../../../helpers/retry"
|
||||
|
||||
jest.setTimeout(120000)
|
||||
|
||||
@@ -108,34 +109,42 @@ medusaIntegrationTestRunner({
|
||||
ContainerRegistrationKeys.QUERY
|
||||
) as RemoteQueryFunction
|
||||
|
||||
const resultset = await query.index({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"id",
|
||||
"description",
|
||||
"status",
|
||||
"title",
|
||||
"variants.sku",
|
||||
"variants.barcode",
|
||||
"variants.material",
|
||||
"variants.options.value",
|
||||
"variants.prices.amount",
|
||||
"variants.prices.currency_code",
|
||||
"variants.inventory_items.inventory.sku",
|
||||
"variants.inventory_items.inventory.description",
|
||||
],
|
||||
filters: {
|
||||
"variants.sku": { $like: "%-1" },
|
||||
"variants.prices.amount": { $gt: 30 },
|
||||
},
|
||||
pagination: {
|
||||
take: 10,
|
||||
skip: 0,
|
||||
order: {
|
||||
"variants.prices.amount": "DESC",
|
||||
},
|
||||
},
|
||||
})
|
||||
const resultset = await fetchAndRetry(
|
||||
async () =>
|
||||
await query.index({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"id",
|
||||
"description",
|
||||
"status",
|
||||
"title",
|
||||
"variants.sku",
|
||||
"variants.barcode",
|
||||
"variants.material",
|
||||
"variants.options.value",
|
||||
"variants.prices.amount",
|
||||
"variants.prices.currency_code",
|
||||
"variants.inventory_items.inventory.sku",
|
||||
"variants.inventory_items.inventory.description",
|
||||
],
|
||||
filters: {
|
||||
"variants.sku": { $like: "%-1" },
|
||||
"variants.prices.amount": { $gt: 30 },
|
||||
},
|
||||
pagination: {
|
||||
take: 10,
|
||||
skip: 0,
|
||||
order: {
|
||||
"variants.prices.amount": "DESC",
|
||||
},
|
||||
},
|
||||
}),
|
||||
({ data }) => data.length > 0,
|
||||
{
|
||||
retries: 3,
|
||||
waitSeconds: 3,
|
||||
}
|
||||
)
|
||||
|
||||
expect(resultset.metadata).toEqual({
|
||||
count: 2,
|
||||
@@ -261,24 +270,32 @@ medusaIntegrationTestRunner({
|
||||
ContainerRegistrationKeys.QUERY
|
||||
) as RemoteQueryFunction
|
||||
|
||||
const resultset = await query.index({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"id",
|
||||
"variants.prices.amount",
|
||||
"variants.prices.currency_code",
|
||||
],
|
||||
filters: {
|
||||
"variants.prices.currency_code": "USD",
|
||||
},
|
||||
pagination: {
|
||||
take: 1,
|
||||
skip: 0,
|
||||
order: {
|
||||
"variants.prices.amount": "DESC",
|
||||
},
|
||||
},
|
||||
})
|
||||
const resultset = await fetchAndRetry(
|
||||
async () =>
|
||||
await query.index({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"id",
|
||||
"variants.prices.amount",
|
||||
"variants.prices.currency_code",
|
||||
],
|
||||
filters: {
|
||||
"variants.prices.currency_code": "USD",
|
||||
},
|
||||
pagination: {
|
||||
take: 1,
|
||||
skip: 0,
|
||||
order: {
|
||||
"variants.prices.amount": "DESC",
|
||||
},
|
||||
},
|
||||
}),
|
||||
({ data }) => data.length > 0,
|
||||
{
|
||||
retries: 3,
|
||||
waitSeconds: 3,
|
||||
}
|
||||
)
|
||||
|
||||
// Limiting to 1 on purpose to keep it simple and check the correct order is maintained
|
||||
expect(resultset.data).toEqual([
|
||||
@@ -303,32 +320,40 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
])
|
||||
|
||||
const resultset2 = await query.index({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"id",
|
||||
"variants.prices.amount",
|
||||
"variants.prices.currency_code",
|
||||
],
|
||||
filters: {
|
||||
variants: {
|
||||
prices: {
|
||||
currency_code: "USD",
|
||||
},
|
||||
},
|
||||
},
|
||||
pagination: {
|
||||
take: 1,
|
||||
skip: 0,
|
||||
order: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: "ASC",
|
||||
const resultset2 = await fetchAndRetry(
|
||||
async () =>
|
||||
query.index({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"id",
|
||||
"variants.prices.amount",
|
||||
"variants.prices.currency_code",
|
||||
],
|
||||
filters: {
|
||||
variants: {
|
||||
prices: {
|
||||
currency_code: "USD",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
pagination: {
|
||||
take: 1,
|
||||
skip: 0,
|
||||
order: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: "ASC",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
({ data }) => data.length > 0,
|
||||
{
|
||||
retries: 3,
|
||||
waitSeconds: 3,
|
||||
}
|
||||
)
|
||||
|
||||
// Limiting to 1 on purpose to keep it simple and check the correct order is maintained
|
||||
expect(resultset2.data).toEqual([
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
adminHeaders,
|
||||
createAdminUser,
|
||||
} from "../../../helpers/create-admin-user"
|
||||
import { fetchAndRetry } from "../../../helpers/retry"
|
||||
|
||||
jest.setTimeout(100000)
|
||||
|
||||
@@ -67,33 +68,41 @@ medusaIntegrationTestRunner({
|
||||
// Timeout to allow indexing to finish
|
||||
await setTimeout(4000)
|
||||
|
||||
const { data: results } = await indexEngine.query<"product">({
|
||||
fields: [
|
||||
"product.*",
|
||||
"product.variants.*",
|
||||
"product.variants.prices.*",
|
||||
],
|
||||
filters: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: { $gt: 50 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
pagination: {
|
||||
order: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: "DESC",
|
||||
const { data: results } = await fetchAndRetry(
|
||||
async () =>
|
||||
indexEngine.query<"product">({
|
||||
fields: [
|
||||
"product.*",
|
||||
"product.variants.*",
|
||||
"product.variants.prices.*",
|
||||
],
|
||||
filters: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: { $gt: 50 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
pagination: {
|
||||
order: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: "DESC",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
({ data }) => data.length > 0,
|
||||
{
|
||||
retries: 3,
|
||||
waitSeconds: 3,
|
||||
}
|
||||
)
|
||||
|
||||
expect(results.length).toBe(1)
|
||||
|
||||
@@ -146,34 +155,42 @@ medusaIntegrationTestRunner({
|
||||
// Timeout to allow indexing to finish
|
||||
await setTimeout(4000)
|
||||
|
||||
const { data: results } = await indexEngine.query<"product">({
|
||||
fields: [
|
||||
"product.*",
|
||||
"product.variants.*",
|
||||
"product.variants.prices.*",
|
||||
],
|
||||
filters: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: { $gt: 50 },
|
||||
currency_code: { $eq: "AUD" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
pagination: {
|
||||
order: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: "DESC",
|
||||
const { data: results } = await fetchAndRetry(
|
||||
async () =>
|
||||
indexEngine.query<"product">({
|
||||
fields: [
|
||||
"product.*",
|
||||
"product.variants.*",
|
||||
"product.variants.prices.*",
|
||||
],
|
||||
filters: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: { $gt: 50 },
|
||||
currency_code: { $eq: "AUD" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
pagination: {
|
||||
order: {
|
||||
product: {
|
||||
variants: {
|
||||
prices: {
|
||||
amount: "DESC",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
({ data }) => data.length > 0,
|
||||
{
|
||||
retries: 3,
|
||||
waitSeconds: 3,
|
||||
}
|
||||
)
|
||||
|
||||
expect(results.length).toBe(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user