Skip to content

Commit

Permalink
Merge branch 'develop' into feature/set-token-in-auth-package
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-gx committed Apr 17, 2024
2 parents 3907784 + 122b3ea commit dc5ee1a
Show file tree
Hide file tree
Showing 236 changed files with 8,407 additions and 2,626 deletions.
13 changes: 13 additions & 0 deletions .changeset/little-buttons-sort.md
@@ -0,0 +1,13 @@
---
"@medusajs/ui": major
---

feat(ui): Re-work `<Toaster />` and `<Toast />` based on `sonner`.

This update contains breaking changes to how toasts work in `@medusajs/ui`. This update has been made to provide a better user experience and to make it easier to use toasts in your Medusa application.

### BREAKING CHANGES

The `useToast` hook has been removed. Users should instead use the `toast` function that is exported from the `@medusajs/ui` package. This function can be used to show toasts in your application. For more information on how to use the `toast` function, please refer to the documentation.

The `Toaster` component is still available but the options for the component have changed. The default position has been changed to `bottom-right`. For more information on the `Toaster` component, please refer to the documentation.
7 changes: 7 additions & 0 deletions .changeset/twenty-stingrays-work.md
@@ -0,0 +1,7 @@
---
"@medusajs/core-flows": patch
"@medusajs/medusa": patch
"@medusajs/types": patch
---

feat(medusa, core-flows,types): delete fulfillment set, delete shipping profile
6 changes: 6 additions & 0 deletions .changeset/wicked-days-buy.md
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/types": patch
---

feat(medusa,types): added tax flows end to end
30 changes: 28 additions & 2 deletions integration-tests/api/__tests__/admin/fulfillment-sets.spec.ts
@@ -1,5 +1,8 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { IFulfillmentModuleService } from "@medusajs/types"
import {
IFulfillmentModuleService,
IStockLocationServiceNext,
} from "@medusajs/types"
import {
adminHeaders,
createAdminUser,
Expand All @@ -15,7 +18,7 @@ medusaIntegrationTestRunner({
},
testSuite: ({ dbConnection, getContainer, api }) => {
let appContainer
let service: IFulfillmentModuleService
let service: IStockLocationServiceNext

beforeEach(async () => {
appContainer = getContainer()
Expand All @@ -25,6 +28,29 @@ medusaIntegrationTestRunner({
service = appContainer.resolve(ModuleRegistrationName.STOCK_LOCATION)
})

describe("POST /admin/fulfillment-sets/:id", () => {
it("should delete a fulfillment set", async () => {
const fulfillmentService: IFulfillmentModuleService =
appContainer.resolve(ModuleRegistrationName.FULFILLMENT)

const set = await fulfillmentService.create({
name: "Test fulfillment set",
type: "pickup",
})

const deleteResponse = await api.delete(
`/admin/fulfillment-sets/${set.id}`,
adminHeaders
)

expect(deleteResponse.data).toEqual({
id: set.id,
object: "fulfillment_set",
deleted: true,
})
})
})

describe("POST /admin/fulfillment-sets/:id/service-zones", () => {
it("should create, update, and delete a service zone for a fulfillment set", async () => {
const stockLocationResponse = await api.post(
Expand Down
20 changes: 18 additions & 2 deletions integration-tests/api/__tests__/admin/shipping-profile.spec.ts
Expand Up @@ -35,7 +35,7 @@ medusaIntegrationTestRunner({
})

describe("Admin - Shipping Profiles", () => {
// TODO: Missing update and delete tests
// TODO: Missing update tests
it("should test the entire lifecycle of a shipping profile", async () => {
const payload = {
name: "test-profile-2023",
Expand Down Expand Up @@ -84,6 +84,23 @@ medusaIntegrationTestRunner({
created_at: expect.any(String),
})
)

const { data } = await api.delete(
`/admin/shipping-profiles/${shipping_profile.id}`,
adminHeaders
)

expect(data).toEqual({
id: retrievedProfile.id,
object: "shipping_profile",
deleted: true,
})

await api
.get(`/admin/shipping-profiles/${shipping_profile.id}`, adminHeaders)
.catch((err) => {
expect(err.response.status).toEqual(404)
})
})
})

Expand Down Expand Up @@ -205,7 +222,6 @@ medusaIntegrationTestRunner({
})

describe("DELETE /admin/shipping-profiles", () => {
// TODO: Delete is not added yet
it("deletes a shipping profile", async () => {
expect.assertions(2)

Expand Down
Expand Up @@ -269,9 +269,9 @@ medusaIntegrationTestRunner({
.catch((e) => e)

expect(err.response.status).toEqual(400)
expect(err.response.data.message).toEqual(
"name must be a string, currency_code must be a string"
)
// expect(err.response.data.message).toEqual(
// "name must be a string, currency_code must be a string"
// )
})

it("should throw on unknown properties in create", async () => {
Expand All @@ -288,9 +288,9 @@ medusaIntegrationTestRunner({
.catch((e) => e)

expect(error.response.status).toEqual(400)
expect(error.response.data.message).toEqual(
"property foo should not exist"
)
// expect(error.response.data.message).toEqual(
// "property foo should not exist"
// )
})

it("should throw on unknown properties in update", async () => {
Expand All @@ -312,9 +312,9 @@ medusaIntegrationTestRunner({
.catch((e) => e)

expect(error.response.status).toEqual(400)
expect(error.response.data.message).toEqual(
"property foo should not exist"
)
// expect(error.response.data.message).toEqual(
// "property foo should not exist"
// )
})

it("should get all regions and count", async () => {
Expand Down
75 changes: 73 additions & 2 deletions integration-tests/modules/__tests__/tax/admin/tax.spec.ts
@@ -1,8 +1,8 @@
import { ITaxModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { ITaxModuleService } from "@medusajs/types"

import { createAdminUser } from "../../../../helpers/create-admin-user"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import { createAdminUser } from "../../../../helpers/create-admin-user"

jest.setTimeout(50000)

Expand Down Expand Up @@ -58,6 +58,8 @@ medusaIntegrationTestRunner({
updated_at: expect.any(String),
deleted_at: null,
created_by: null,
rules: [],
tax_region: expect.any(Object),
},
})
})
Expand Down Expand Up @@ -91,6 +93,9 @@ medusaIntegrationTestRunner({
created_by: "admin_user",
provider_id: null,
metadata: null,
children: [],
parent: null,
tax_rates: expect.any(Array),
},
})

Expand Down Expand Up @@ -121,6 +126,13 @@ medusaIntegrationTestRunner({
deleted_at: null,
created_by: "admin_user",
is_combinable: false,
tax_region: expect.any(Object),
rules: [
expect.objectContaining({
reference: "product",
reference_id: "prod_1234",
}),
],
},
})

Expand All @@ -147,6 +159,11 @@ medusaIntegrationTestRunner({
created_by: "admin_user",
metadata: null,
provider_id: null,
children: [],
tax_rates: [],
parent: expect.objectContaining({
id: usRegionId,
}),
},
})

Expand Down Expand Up @@ -219,6 +236,9 @@ medusaIntegrationTestRunner({
created_by: "admin_user",
provider_id: null,
metadata: null,
children: [],
parent: null,
tax_rates: expect.any(Array),
},
})

Expand Down Expand Up @@ -249,6 +269,13 @@ medusaIntegrationTestRunner({
deleted_at: null,
created_by: "admin_user",
is_combinable: false,
tax_region: expect.any(Object),
rules: [
expect.objectContaining({
reference: "product",
reference_id: "prod_1234",
}),
],
},
})

Expand Down Expand Up @@ -279,6 +306,13 @@ medusaIntegrationTestRunner({
updated_at: expect.any(String),
created_by: "admin_user",
is_combinable: true,
tax_region: expect.any(Object),
rules: [
expect.objectContaining({
reference: "product",
reference_id: "prod_1234",
}),
],
},
})
})
Expand Down Expand Up @@ -331,6 +365,43 @@ medusaIntegrationTestRunner({
expect(rates[0].deleted_at).not.toBeNull()
})

it("can retrieve a tax region", async () => {
const region = await service.createTaxRegions({
country_code: "us",
})

const rate = await service.create({
tax_region_id: region.id,
code: "test",
rate: 2.5,
name: "Test Rate",
})

const response = await api.get(
`/admin/tax-regions/${region.id}`,
adminHeaders
)

expect(response.status).toEqual(200)
expect(response.data).toEqual({
tax_region: {
id: region.id,
country_code: "us",
province_code: null,
parent_id: null,
provider_id: null,
created_by: null,
created_at: expect.any(String),
updated_at: expect.any(String),
tax_rates: expect.any(Array),
deleted_at: null,
metadata: null,
children: [],
parent: null,
},
})
})

it("can create a tax region and delete it", async () => {
const regionRes = await api.post(
`/admin/tax-regions`,
Expand Down
21 changes: 21 additions & 0 deletions packages/admin-next/dashboard/public/locales/$schema.json
Expand Up @@ -140,6 +140,27 @@
},
"required": ["domain"]
},
"taxRegions": {
"type": "object",
"properties": {
"domain": {
"type": "string"
}
},
"required": ["domain"]
},
"taxRates": {
"type": "object",
"properties": {
"domain": {
"type": "string"
},
"fields": {
"type": "object"
}
},
"required": ["domain"]
},
"campaigns": {
"type": "object",
"properties": {
Expand Down

0 comments on commit dc5ee1a

Please sign in to comment.