Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fulfillment): implementation part 2 #6408

Merged
merged 42 commits into from
Feb 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
270591b
Afeat(fulfillment): implementation part 2
adrien2p Feb 15, 2024
f7b4b61
Add a name on the shipping profile
adrien2p Feb 15, 2024
1a6e872
Improve filters and add default profiles loader
adrien2p Feb 15, 2024
e093097
create shipping profiles and integration tests
adrien2p Feb 15, 2024
d8bbc09
relation work and migration
adrien2p Feb 15, 2024
826ce14
Shipping options creation
adrien2p Feb 15, 2024
1ef968a
Shipping options creation
adrien2p Feb 15, 2024
cbe3455
fix tests
adrien2p Feb 15, 2024
5114e5b
Merge branch 'develop' into feat/fulfillment-implementation-2
adrien2p Feb 15, 2024
937c474
Migrate indexes
adrien2p Feb 15, 2024
4f2b1c2
fix unit tests
adrien2p Feb 15, 2024
ca60b16
Add read tests
adrien2p Feb 15, 2024
e27576d
fix tests
adrien2p Feb 16, 2024
23ce69b
fixes
adrien2p Feb 16, 2024
f8786a8
Merge branch 'develop' into feat/fulfillment-implementation-2
adrien2p Feb 16, 2024
ea4535c
cleanup
adrien2p Feb 16, 2024
4845aed
Create real-teachers-yawn.md
adrien2p Feb 16, 2024
1d9d2d8
cleanup
adrien2p Feb 16, 2024
7577ddd
Merge branch 'feat/fulfillment-implementation-2' of github.com:medusa…
adrien2p Feb 16, 2024
b86b3a4
Module integration test runner research
adrien2p Feb 16, 2024
c2a1013
Module integration test runner research
adrien2p Feb 16, 2024
5f80f53
rm comment
adrien2p Feb 16, 2024
5393f0b
Merge branch 'develop' into feat/fulfillment-implementation-2
adrien2p Feb 16, 2024
a0b56cd
revert unnecessary changes
adrien2p Feb 16, 2024
3a835d9
first runner simplification
adrien2p Feb 16, 2024
b809065
fix cwd
adrien2p Feb 16, 2024
b5b878a
improve
adrien2p Feb 16, 2024
77fa49b
remove unnecessary return
adrien2p Feb 16, 2024
3241743
move things
adrien2p Feb 16, 2024
b90c518
improve
adrien2p Feb 16, 2024
e28e428
proxyfied
adrien2p Feb 16, 2024
0eac58e
Merge branch 'develop' into feat/fulfillment-implementation-2
adrien2p Feb 16, 2024
62b4eca
use unique connection
adrien2p Feb 16, 2024
042ffcd
improve readability
adrien2p Feb 16, 2024
3af5726
rm createProxy
adrien2p Feb 16, 2024
c793734
Merge branch 'develop' into feat/fulfillment-implementation-2
adrien2p Feb 17, 2024
ee6f0eb
cleanup test util
adrien2p Feb 19, 2024
da0bf90
address feedback
adrien2p Feb 19, 2024
0a2b592
Merge branch 'feat/fulfillment-implementation-2' of github.com:medusa…
adrien2p Feb 19, 2024
7d7901c
Merge branch 'develop' into feat/fulfillment-implementation-2
adrien2p Feb 19, 2024
54db034
fix tests
adrien2p Feb 19, 2024
cd6ef57
fixes
adrien2p Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
create shipping profiles and integration tests
  • Loading branch information
adrien2p committed Feb 15, 2024

Verified

This commit was signed with the committer’s verified signature.
mikz Michal Cichra
commit e09309778bfb816b9b43cc749676a48c6bbc0734
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import {
CreateFulfillmentSetDTO,
CreateGeoZoneDTO,
CreateServiceZoneDTO,
CreateShippingProfileDTO,
GeoZoneDTO,
IFulfillmentModuleService,
ServiceZoneDTO,
@@ -18,6 +19,8 @@ describe("fulfillment module service", function () {
let shutdownFunc: () => Promise<void>

beforeAll(async () => {
await MikroOrmWrapper.setupDatabase()

const initModulesConfig = getInitModuleConfig()

const { medusaApp, shutdown } = await initModules(initModulesConfig)
@@ -674,6 +677,72 @@ describe("fulfillment module service", function () {
})
})

describe("on create shipping profiles", () => {
it("should create a new shipping profile", async function () {
const createData: CreateShippingProfileDTO = {
name: "test-default-profile",
type: "default",
}

const createdShippingProfile = await service.createShippingProfiles(
createData
)

expect(createdShippingProfile).toEqual(
expect.objectContaining({
name: createData.name,
type: createData.type,
})
)
})

it("should create multiple new shipping profiles", async function () {
const createData: CreateShippingProfileDTO[] = [
{
name: "test-profile-1",
type: "default",
},
{
name: "test-profile-2",
type: "custom",
},
]

const createdShippingProfiles = await service.createShippingProfiles(
createData
)

expect(createdShippingProfiles).toHaveLength(2)

let i = 0
for (const data_ of createData) {
expect(createdShippingProfiles[i]).toEqual(
expect.objectContaining({
name: data_.name,
type: data_.type,
})
)
++i
}
})

it("should fail on duplicated shipping profile name", async function () {
const createData: CreateShippingProfileDTO = {
name: "test-default-profile",
type: "default",
}

await service.createShippingProfiles(createData)

const err = await service
.createShippingProfiles(createData)
.catch((e) => e)

expect(err).toBeDefined()
expect(err.constraint).toBe("IDX_shipping_profile_name_unique")
})
})

describe("on update", () => {
it("should update an existing fulfillment set", async function () {
const createData: CreateFulfillmentSetDTO = {
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ShippingProfileType } from "@medusajs/utils"
import { LoaderOptions } from "@medusajs/types"
import { Modules } from "@medusajs/modules-sdk"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"

export async function createDefaultShippingProfilesLoader({
container,
@@ -16,7 +16,7 @@ export async function createDefaultShippingProfilesLoader({
},
]

const service = container.resolve(Modules.FULFILLMENT)
const service = container.resolve(ModuleRegistrationName.FULFILLMENT)
const shippingProfiles = await service.listShippingProfiles({
type: { $in: [ShippingProfileType.DEFAULT, ShippingProfileType.GIFT_CARD] },
})
Loading