feat(core-flows, fulfillment): Add create return specific method and add more tests (#7357)

* feat(core-flows, fulfillment): Add create return specific method and add more tests

* fix defautl providers in tests fixtures

* more tests

* wip fixes

* fix flow and tests

* cleanup
This commit is contained in:
Adrien de Peretti
2024-05-21 13:48:59 +02:00
committed by GitHub
parent 35dc3c5cf7
commit c4fde7ea5c
9 changed files with 318 additions and 91 deletions
@@ -14,6 +14,10 @@ export class FulfillmentProviderServiceFixtures extends AbstractFulfillmentProvi
async getFulfillmentOptions(): Promise<any> {
return {}
}
async createReturnFulfillment(fulfillment): Promise<any> {
return {}
}
}
export const services = [FulfillmentProviderServiceFixtures]
@@ -137,6 +137,63 @@ moduleIntegrationTestRunner({
})
)
})
it("should create a return fulfillment", async () => {
const shippingProfile = await service.createShippingProfiles({
name: "test",
type: "default",
})
const fulfillmentSet = await service.create({
name: "test",
type: "test-type",
})
const serviceZone = await service.createServiceZones({
name: "test",
fulfillment_set_id: fulfillmentSet.id,
})
const shippingOption = await service.createShippingOptions(
generateCreateShippingOptionsData({
provider_id: providerId,
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
})
)
const fulfillment = await service.createReturnFulfillment(
generateCreateFulfillmentData({
provider_id: providerId,
shipping_option_id: shippingOption.id,
})
)
expect(fulfillment).toEqual(
expect.objectContaining({
id: expect.any(String),
packed_at: null,
shipped_at: null,
delivered_at: null,
canceled_at: null,
data: null,
provider_id: providerId,
shipping_option_id: shippingOption.id,
metadata: null,
delivery_address: expect.objectContaining({
id: expect.any(String),
}),
items: [
expect.objectContaining({
id: expect.any(String),
}),
],
labels: [
expect.objectContaining({
id: expect.any(String),
}),
],
})
)
})
})
describe("on cancel", () => {