chore(utils): Add default ordering to the internal service factory list/listAndCount (#6436)

**What**
Default ordering. By default, only the top level entity ordering is applied using the primary keys, the relations are default ordered by the foreign keys.

It include tests fixing for deterministic data ordering
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-02-20 11:07:39 +00:00
1 parent 691f68c3b8
commit c319edb8e0
14 files changed
+208 -78

No files matched your search

@@ -46,10 +46,6 @@ describe("PricingModule Service - Currency", () => {
const currenciesResult = await service.listCurrencies()
expect(currenciesResult).toEqual([
expect.objectContaining({
code: "USD",
name: "US Dollar",
}),
expect.objectContaining({
code: "CAD",
name: "Canadian Dollar",
@@ -58,6 +54,10 @@ describe("PricingModule Service - Currency", () => {
code: "EUR",
name: "Euro",
}),
expect.objectContaining({
code: "USD",
name: "US Dollar",
}),
])
})
@@ -79,10 +79,6 @@ describe("PricingModule Service - Currency", () => {
expect(count).toEqual(3)
expect(currenciesResult).toEqual([
expect.objectContaining({
code: "USD",
name: "US Dollar",
}),
expect.objectContaining({
code: "CAD",
name: "Canadian Dollar",
@@ -91,6 +87,10 @@ describe("PricingModule Service - Currency", () => {
code: "EUR",
name: "Euro",
}),
expect.objectContaining({
code: "USD",
name: "US Dollar",
}),
])
})
@@ -117,8 +117,10 @@ describe("PricingModule Service - Currency", () => {
expect(count).toEqual(3)
expect(currenciesResult).toEqual([
expect.objectContaining({
code: "CAD",
name: "Canadian Dollar",
code: "EUR",
name: "Euro",
symbol: "€",
symbol_native: "€",
}),
])
})
@@ -137,7 +139,7 @@ describe("PricingModule Service - Currency", () => {
expect(count).toEqual(3)
expect(serialized).toEqual([
{
code: "USD",
code: "CAD",
},
])
})
@@ -201,7 +201,7 @@ describe("PricingModule Service - MoneyAmount", () => {
expect(count).toEqual(3)
expect(serialized).toEqual([
{
id: "money-amount-USD",
id: "money-amount-CAD",
amount: null,
},
])
@@ -273,16 +273,14 @@ describe("PricingModule Service - PriceSetMoneyAmountRules", () => {
},
])
const priceSetMoneyAmountRules =
await service.listPriceSetMoneyAmountRules(
{},
{
relations: ["price_set_money_amount", "rule_type"],
}
)
const created =
priceSetMoneyAmountRules[priceSetMoneyAmountRules.length - 1]
const [created] = await service.listPriceSetMoneyAmountRules(
{
value: ["New priceSetMoneyAmountRule"],
},
{
relations: ["price_set_money_amount", "rule_type"],
}
)
expect(created).toEqual(
expect.objectContaining({