Chore/rm main entity concept (#7709)
**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Stevche Radevski
Oli Juhl
parent
2895ccfba8
commit
48963f55ef
@@ -21,7 +21,7 @@ export async function createFullDataStructure(
|
||||
name: "test_" + randomString,
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test_" + randomString,
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
+74
-45
@@ -1,4 +1,7 @@
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { FulfillmentEvents, GeoZoneType, Modules } from "@medusajs/utils"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { MockEventBusService } from "medusa-test-utils/dist"
|
||||
import { buildExpectedEventMessageShape } from "../../__fixtures__"
|
||||
import {
|
||||
CreateFulfillmentSetDTO,
|
||||
CreateServiceZoneDTO,
|
||||
@@ -6,10 +9,6 @@ import {
|
||||
ServiceZoneDTO,
|
||||
UpdateFulfillmentSetDTO,
|
||||
} from "@medusajs/types"
|
||||
import { FulfillmentEvents, GeoZoneType } from "@medusajs/utils"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { MockEventBusService } from "medusa-test-utils/dist"
|
||||
import { buildExpectedEventMessageShape } from "../../__fixtures__"
|
||||
|
||||
jest.setTimeout(100000)
|
||||
|
||||
@@ -29,11 +28,11 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
describe("Fulfillment Module Service", () => {
|
||||
describe("read", () => {
|
||||
it("should list fulfillment sets with a filter", async function () {
|
||||
const createdSet1 = await service.create({
|
||||
const createdSet1 = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
const createdSet2 = await service.create({
|
||||
const createdSet2 = await service.createFulfillmentSets({
|
||||
name: "test2",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -67,7 +66,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
})
|
||||
|
||||
let listedSets = await service.list(
|
||||
let listedSets = await service.listFulfillmentSets(
|
||||
{
|
||||
type: createdSet1.type,
|
||||
},
|
||||
@@ -76,7 +75,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
}
|
||||
)
|
||||
|
||||
const listedSets2 = await service.list(
|
||||
const listedSets2 = await service.listFulfillmentSets(
|
||||
{
|
||||
type: createdSet1.type,
|
||||
},
|
||||
@@ -101,7 +100,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
|
||||
expect(listedSets2).toEqual(listedSets2)
|
||||
|
||||
listedSets = await service.list({
|
||||
listedSets = await service.listFulfillmentSets({
|
||||
name: createdSet2.name,
|
||||
})
|
||||
|
||||
@@ -116,7 +115,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
])
|
||||
)
|
||||
|
||||
listedSets = await service.list({
|
||||
listedSets = await service.listFulfillmentSets({
|
||||
service_zones: { name: "test" },
|
||||
})
|
||||
|
||||
@@ -131,7 +130,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
])
|
||||
)
|
||||
|
||||
listedSets = await service.list({
|
||||
listedSets = await service.listFulfillmentSets({
|
||||
service_zones: { geo_zones: { country_code: "fr" } },
|
||||
})
|
||||
|
||||
@@ -156,7 +155,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
type: "test-type",
|
||||
}
|
||||
|
||||
const fulfillmentSet = await service.create(data)
|
||||
const fulfillmentSet = await service.createFulfillmentSets(data)
|
||||
|
||||
expect(fulfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -188,7 +187,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
},
|
||||
]
|
||||
|
||||
const fulfillmentSets = await service.create(data)
|
||||
const fulfillmentSets = await service.createFulfillmentSets(data)
|
||||
|
||||
expect(fulfillmentSets).toHaveLength(2)
|
||||
|
||||
@@ -228,7 +227,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
const fulfillmentSet = await service.create(data)
|
||||
const fulfillmentSet = await service.createFulfillmentSets(data)
|
||||
|
||||
expect(fulfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -291,7 +290,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
},
|
||||
]
|
||||
|
||||
const fulfillmentSets = await service.create(data)
|
||||
const fulfillmentSets = await service.createFulfillmentSets(data)
|
||||
|
||||
expect(fulfillmentSets).toHaveLength(3)
|
||||
|
||||
@@ -349,7 +348,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
const fulfillmentSet = await service.create(data)
|
||||
const fulfillmentSet = await service.createFulfillmentSets(data)
|
||||
|
||||
expect(fulfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -445,7 +444,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
},
|
||||
]
|
||||
|
||||
const fulfillmentSets = await service.create(data)
|
||||
const fulfillmentSets = await service.createFulfillmentSets(data)
|
||||
|
||||
expect(fulfillmentSets).toHaveLength(3)
|
||||
|
||||
@@ -508,8 +507,10 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
type: "test-type",
|
||||
}
|
||||
|
||||
await service.create(data)
|
||||
const err = await service.create(data).catch((e) => e)
|
||||
await service.createFulfillmentSets(data)
|
||||
const err = await service
|
||||
.createFulfillmentSets(data)
|
||||
.catch((e) => e)
|
||||
|
||||
expect(err).toBeDefined()
|
||||
expect(err.message).toContain("exists")
|
||||
@@ -532,7 +533,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
let err = await service.create(data).catch((e) => e)
|
||||
let err = await service.createFulfillmentSets(data).catch((e) => e)
|
||||
expect(err.message).toBe(
|
||||
"Missing required property province_code for geo zone type province"
|
||||
)
|
||||
@@ -554,7 +555,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
err = await service.create(data).catch((e) => e)
|
||||
err = await service.createFulfillmentSets(data).catch((e) => e)
|
||||
expect(err.message).toBe(
|
||||
"Missing required property city for geo zone type city"
|
||||
)
|
||||
@@ -575,7 +576,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
err = await service.create(data).catch((e) => e)
|
||||
err = await service.createFulfillmentSets(data).catch((e) => e)
|
||||
expect(err.message).toBe(
|
||||
"Missing required property country_code for geo zone type zip"
|
||||
)
|
||||
@@ -596,7 +597,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
err = await service.create(data).catch((e) => e)
|
||||
err = await service.createFulfillmentSets(data).catch((e) => e)
|
||||
expect(err.message).toBe(`Invalid geo zone type: unknown`)
|
||||
})
|
||||
})
|
||||
@@ -608,7 +609,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
type: "test-type",
|
||||
}
|
||||
|
||||
const createdFulfillmentSet = await service.create(createData)
|
||||
const createdFulfillmentSet = await service.createFulfillmentSets(
|
||||
createData
|
||||
)
|
||||
|
||||
const updateData = {
|
||||
id: createdFulfillmentSet.id,
|
||||
@@ -616,7 +619,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
type: "updated-test-type",
|
||||
}
|
||||
|
||||
const updatedFulfillmentSets = await service.update(updateData)
|
||||
const updatedFulfillmentSets = await service.updateFulfillmentSets(
|
||||
updateData
|
||||
)
|
||||
|
||||
expect(updatedFulfillmentSets).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -648,7 +653,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
},
|
||||
]
|
||||
|
||||
const createdFulfillmentSets = await service.create(createData)
|
||||
const createdFulfillmentSets = await service.createFulfillmentSets(
|
||||
createData
|
||||
)
|
||||
|
||||
const updateData = createdFulfillmentSets.map(
|
||||
(fulfillmentSet, index) => ({
|
||||
@@ -658,8 +665,10 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
)
|
||||
|
||||
const updatedFulfillmentSets = await service.update(updateData)
|
||||
const fullfillmentSets = await service.list({
|
||||
const updatedFulfillmentSets = await service.updateFulfillmentSets(
|
||||
updateData
|
||||
)
|
||||
const fullfillmentSets = await service.listFulfillmentSets({
|
||||
id: updateData.map((ud) => ud.id),
|
||||
})
|
||||
|
||||
@@ -669,7 +678,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
for (const data_ of updateData) {
|
||||
const currentFullfillmentSet = fullfillmentSets.find(
|
||||
(fs) => fs.id === data_.id
|
||||
)
|
||||
)!
|
||||
|
||||
expect(currentFullfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -709,7 +718,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
const createdFulfillmentSet = await service.create(createData)
|
||||
const createdFulfillmentSet = await service.createFulfillmentSets(
|
||||
createData
|
||||
)
|
||||
|
||||
const createServiceZoneData: CreateServiceZoneDTO = {
|
||||
fulfillment_set_id: createdFulfillmentSet.id,
|
||||
@@ -729,7 +740,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
service_zones: [createServiceZoneData],
|
||||
}
|
||||
|
||||
const updatedFulfillmentSet = await service.update(updateData)
|
||||
const updatedFulfillmentSet = await service.updateFulfillmentSets(
|
||||
updateData
|
||||
)
|
||||
|
||||
expect(updatedFulfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -822,7 +835,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
const createdFulfillmentSet = await service.create(createData)
|
||||
const createdFulfillmentSet = await service.createFulfillmentSets(
|
||||
createData
|
||||
)
|
||||
|
||||
const createServiceZoneData: CreateServiceZoneDTO = {
|
||||
fulfillment_set_id: createdFulfillmentSet.id,
|
||||
@@ -845,7 +860,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}
|
||||
|
||||
const updatedFulfillmentSet = await service.update(updateData)
|
||||
const updatedFulfillmentSet = await service.updateFulfillmentSets(
|
||||
updateData
|
||||
)
|
||||
|
||||
expect(updatedFulfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -876,7 +893,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
|
||||
const createdServiceZone = updatedFulfillmentSet.service_zones.find(
|
||||
(s) => s.name === "service-zone-test2"
|
||||
)
|
||||
)!
|
||||
|
||||
expect(eventBusEmitSpy.mock.calls[1][0]).toHaveLength(3)
|
||||
expect(eventBusEmitSpy).toHaveBeenLastCalledWith(
|
||||
@@ -917,7 +934,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
},
|
||||
]
|
||||
|
||||
const createdFulfillmentSets = await service.create(createData)
|
||||
const createdFulfillmentSets = await service.createFulfillmentSets(
|
||||
createData
|
||||
)
|
||||
|
||||
const updateData = {
|
||||
id: createdFulfillmentSets[1].id,
|
||||
@@ -925,7 +944,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
type: "updated-test-type2",
|
||||
}
|
||||
|
||||
const err = await service.update(updateData).catch((e) => e)
|
||||
const err = await service
|
||||
.updateFulfillmentSets(updateData)
|
||||
.catch((e) => e)
|
||||
|
||||
expect(err).toBeDefined()
|
||||
expect(err.message).toContain("exists")
|
||||
@@ -965,7 +986,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
},
|
||||
]
|
||||
|
||||
const createdFulfillmentSets = await service.create(createData)
|
||||
const createdFulfillmentSets = await service.createFulfillmentSets(
|
||||
createData
|
||||
)
|
||||
|
||||
const updateData: UpdateFulfillmentSetDTO[] =
|
||||
createdFulfillmentSets.map((fulfillmentSet, index) => ({
|
||||
@@ -985,7 +1008,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}))
|
||||
|
||||
const updatedFulfillmentSets = await service.update(updateData)
|
||||
const updatedFulfillmentSets = await service.updateFulfillmentSets(
|
||||
updateData
|
||||
)
|
||||
|
||||
expect(updatedFulfillmentSets).toHaveLength(2)
|
||||
expect(eventBusEmitSpy.mock.calls[1][0]).toHaveLength(10)
|
||||
@@ -993,10 +1018,10 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
for (const data_ of updateData) {
|
||||
const expectedFulfillmentSet = updatedFulfillmentSets.find(
|
||||
(f) => f.id === data_.id
|
||||
)
|
||||
)!
|
||||
const originalFulfillmentSet = createdFulfillmentSets.find(
|
||||
(f) => f.id === data_.id
|
||||
)
|
||||
)!
|
||||
|
||||
expect(expectedFulfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -1115,7 +1140,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
},
|
||||
]
|
||||
|
||||
const createdFulfillmentSets = await service.create(createData)
|
||||
const createdFulfillmentSets = await service.createFulfillmentSets(
|
||||
createData
|
||||
)
|
||||
|
||||
const updateData: UpdateFulfillmentSetDTO[] =
|
||||
createdFulfillmentSets.map((fulfillmentSet, index) => ({
|
||||
@@ -1136,7 +1163,9 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
],
|
||||
}))
|
||||
|
||||
const updatedFulfillmentSets = await service.update(updateData)
|
||||
const updatedFulfillmentSets = await service.updateFulfillmentSets(
|
||||
updateData
|
||||
)
|
||||
|
||||
expect(updatedFulfillmentSets).toHaveLength(2)
|
||||
expect(eventBusEmitSpy.mock.calls[1][0]).toHaveLength(6)
|
||||
@@ -1144,7 +1173,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
for (const data_ of updateData) {
|
||||
const expectedFulfillmentSet = updatedFulfillmentSets.find(
|
||||
(f) => f.id === data_.id
|
||||
)
|
||||
)!
|
||||
expect(expectedFulfillmentSet).toEqual(
|
||||
expect.objectContaining({
|
||||
id: data_.id,
|
||||
@@ -1175,7 +1204,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
const createdServiceZone =
|
||||
expectedFulfillmentSet.service_zones.find((s) =>
|
||||
s.name.includes(`added-service-zone-test`)
|
||||
)
|
||||
)!
|
||||
|
||||
expect(eventBusEmitSpy).toHaveBeenLastCalledWith(
|
||||
expect.arrayContaining([
|
||||
|
||||
+5
-6
@@ -56,7 +56,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -104,7 +104,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -191,7 +191,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -280,7 +280,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -332,7 +332,6 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
)!
|
||||
|
||||
const updateData: UpdateFulfillmentDTO = {
|
||||
id: fulfillment.id,
|
||||
labels: [
|
||||
{ id: label1.id },
|
||||
{ ...label2, label_url: "updated-test-label-url-2" },
|
||||
@@ -417,7 +416,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
+6
-6
@@ -29,7 +29,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
describe("Fulfillment Module Service", () => {
|
||||
describe("read", () => {
|
||||
it("should list geo zones with a filter", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -80,7 +80,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
describe("mutations", () => {
|
||||
describe("on create", () => {
|
||||
it("should create a new geo zone", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -119,7 +119,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should create a collection of geo zones", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -174,7 +174,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should fail to create new geo zones that are not valid", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -230,7 +230,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
|
||||
describe("on update", () => {
|
||||
it("should update an existing geo zone", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -277,7 +277,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should update a collection of geo zones", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
+7
-7
@@ -30,7 +30,7 @@ let providerId = "fixtures-fulfillment-provider_test-provider"
|
||||
|
||||
async function list(
|
||||
service: IFulfillmentModuleService,
|
||||
...args: Parameters<IFulfillmentModuleService["list"]>
|
||||
...args: Parameters<IFulfillmentModuleService["listFulfillmentSets"]>
|
||||
) {
|
||||
const [filters = {}, config = {}] = args
|
||||
|
||||
@@ -48,7 +48,7 @@ async function list(
|
||||
...config,
|
||||
}
|
||||
|
||||
return await service.list(filters, finalConfig)
|
||||
return await service.listFulfillmentSets(filters, finalConfig)
|
||||
}
|
||||
|
||||
function expectSoftDeleted(
|
||||
@@ -109,7 +109,7 @@ moduleIntegrationTestRunner({
|
||||
it("should load and save all the providers on bootstrap with the correct is_enabled value", async () => {
|
||||
const databaseConfig = {
|
||||
schema: "public",
|
||||
clientUrl: MikroOrmWrapper.clientUrl,
|
||||
clientUrl: MikroOrmWrapper.clientUrl!,
|
||||
}
|
||||
|
||||
const providersConfig = {}
|
||||
@@ -159,7 +159,7 @@ moduleIntegrationTestRunner({
|
||||
name
|
||||
)
|
||||
)
|
||||
})
|
||||
})!
|
||||
expect(provider).toBeDefined()
|
||||
expect(provider.is_enabled).toBeTruthy()
|
||||
}
|
||||
@@ -222,7 +222,7 @@ moduleIntegrationTestRunner({
|
||||
name
|
||||
)
|
||||
)
|
||||
})
|
||||
})!
|
||||
expect(provider).toBeDefined()
|
||||
|
||||
const isEnabled = !!providersConfig2[name]
|
||||
@@ -242,7 +242,7 @@ moduleIntegrationTestRunner({
|
||||
* Soft delete the fulfillment set
|
||||
*/
|
||||
|
||||
await service.softDelete(fulfillmentSets[0].id)
|
||||
await service.softDeleteFulfillmentSets([fulfillmentSets[0].id])
|
||||
const deletedFulfillmentSets = await list(
|
||||
service,
|
||||
{},
|
||||
@@ -256,7 +256,7 @@ moduleIntegrationTestRunner({
|
||||
* Restore the fulfillment set
|
||||
*/
|
||||
|
||||
await service.restore(fulfillmentSets[0].id)
|
||||
await service.restoreFulfillmentSets([fulfillmentSets[0].id])
|
||||
const restoredFulfillmentSets = await list(service)
|
||||
expectSoftDeleted(restoredFulfillmentSets)
|
||||
})
|
||||
|
||||
+8
-8
@@ -30,7 +30,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
describe("Fulfillment Module Service", () => {
|
||||
describe("read", () => {
|
||||
it("should list service zones with a filter", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -85,7 +85,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
describe("mutations", () => {
|
||||
describe("on create", () => {
|
||||
it("should create a new service zone", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -119,7 +119,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should create a collection of service zones", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -181,7 +181,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should fail on duplicated service zone name", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -205,7 +205,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should fail on creating a service zone and new geo zones that are not valid", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -277,7 +277,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
|
||||
describe("on update", () => {
|
||||
it("should update an existing service zone", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -396,7 +396,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should fail on duplicated service zone name", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -449,7 +449,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
|
||||
describe("on upsert", () => {
|
||||
it("should upsert a collection of service zones", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
+15
-15
@@ -57,7 +57,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
describe("Fulfillment Module Service", () => {
|
||||
describe("read", () => {
|
||||
it("should list shipping options with a filter", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -113,7 +113,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should list shipping options with a context", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -224,7 +224,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it(`should list the shipping options for a context with a specific address`, async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -341,7 +341,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should validate if a shipping option is applicable to a context", async function () {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
service_zones: [
|
||||
@@ -432,7 +432,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -509,7 +509,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -601,7 +601,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -637,7 +637,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
|
||||
describe("on update", () => {
|
||||
it("should update a shipping option", async () => {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -789,7 +789,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should update a shipping option without updating the rules or the type", async () => {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -880,7 +880,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should update a collection of shipping options", async () => {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -1027,7 +1027,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should fail to update a non-existent shipping option", async () => {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -1075,7 +1075,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should fail to update a shipping option when adding non existing rules", async () => {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -1120,7 +1120,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
})
|
||||
|
||||
it("should fail to update a shipping option when adding invalid rules", async () => {
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -1173,7 +1173,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
@@ -1250,7 +1250,7 @@ moduleIntegrationTestRunner<IFulfillmentModuleService>({
|
||||
name: "test",
|
||||
type: "default",
|
||||
})
|
||||
const fulfillmentSet = await service.create({
|
||||
const fulfillmentSet = await service.createFulfillmentSets({
|
||||
name: "test",
|
||||
type: "test-type",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user