Skip to content

Commit

Permalink
Merge branch 'develop' into docs/commerce-modules-revisit-1
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Oct 10, 2024
2 parents 5776c55 + 0058338 commit 57103be
Show file tree
Hide file tree
Showing 250 changed files with 6,637 additions and 3,233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,16 @@ medusaIntegrationTestRunner({
)

expect(response.status).toEqual(200)
expect(response.data).toEqual(
expect.objectContaining({
collection: expect.objectContaining({
id: expect.stringMatching(/^pcol_*/),
title: "New collection",
handle: "test-new-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
}),
})
)
expect(response.data).toEqual({
collection: {
id: expect.stringMatching(/^pcol_*/),
title: "New collection",
handle: "test-new-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
})
})

it("lists collections", async () => {
Expand All @@ -96,22 +95,33 @@ medusaIntegrationTestRunner({
expect(response.data).toEqual(
expect.objectContaining({
count: 3,
limit: 10,
offset: 0,
collections: expect.arrayContaining([
expect.objectContaining({
id: baseCollection2.id,
{
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
handle: "test-collection",
metadata: null,
title: "test-collection",
},
{
id: baseCollection1.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
id: baseCollection.id,
handle: "test-collection1",
metadata: null,
title: "test-collection1",
},
{
id: baseCollection2.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
handle: "test-collection2",
metadata: null,
title: "test-collection2",
},
]),
})
)
Expand All @@ -127,11 +137,14 @@ medusaIntegrationTestRunner({
expect.objectContaining({
count: 1,
collections: expect.arrayContaining([
expect.objectContaining({
{
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
handle: "test-collection",
metadata: null,
title: "test-collection",
},
]),
})
)
Expand All @@ -154,13 +167,14 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
expect(response.data).toEqual(
expect.objectContaining({
collection: expect.objectContaining({
collection: {
id: expect.stringMatching(/^pcol_*/),
title: "test collection creation",
handle: "test-handle-creation",
created_at: expect.any(String),
updated_at: expect.any(String),
}),
metadata: null,
},
})
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ medusaIntegrationTestRunner({
expect(res.status).toEqual(200)
expect(res.data.product_types).toEqual(
expect.arrayContaining([
expect.objectContaining({
{
id: expect.stringMatching(/ptyp_.{24}/),
value: "test1",
}),
expect.objectContaining({
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
{
id: expect.stringMatching(/ptyp_.{24}/),
value: "test2",
}),
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
])
)
})
Expand All @@ -61,13 +69,35 @@ medusaIntegrationTestRunner({

// The value of the type should match the search param
expect(res.data.product_types).toEqual([
expect.objectContaining({
{
id: expect.stringMatching(/ptyp_.{24}/),
value: "test1",
}),
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
])
})

// BREAKING: Removed a test around filtering based on discount condition id, which is no longer supported
})

describe("/admin/product-types/:id", () => {
it("returns a product type", async () => {
const res = await api.get(
`/admin/product-types/${type1.id}`,
adminHeaders
)

expect(res.status).toEqual(200)
expect(res.data.product_type).toEqual({
id: expect.stringMatching(/ptyp_.{24}/),
value: "test1",
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
})
})
})
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ medusaIntegrationTestRunner({

await deleteLineItemsWorkflow(appContainer).run({
input: {
cart_id: cart.id,
ids: items.map((i) => i.id),
},
throwOnError: false,
Expand Down Expand Up @@ -1211,6 +1212,7 @@ medusaIntegrationTestRunner({

const { errors } = await workflow.run({
input: {
cart_id: cart.id,
ids: items.map((i) => i.id),
},
throwOnError: false,
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/modules/__tests__/cart/store/carts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ProductStatus,
PromotionRuleOperator,
PromotionType,
RuleOperator
RuleOperator,
} from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import {
Expand Down Expand Up @@ -2131,6 +2131,7 @@ medusaIntegrationTestRunner({
)

expect(response.status).toEqual(200)

expect(response.data.cart).toEqual(
expect.objectContaining({
id: cart.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MedusaContainer } from "@medusajs/types"
import { Modules, composeMessage } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import testEventPayloadHandlerMock from "../../dist/subscribers/test-event-payload"
import testEventPayloadHandlerMock from "../../src/subscribers/test-event-payload"

jest.setTimeout(30000)

Expand Down
3 changes: 1 addition & 2 deletions integration-tests/modules/medusa-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { Modules } = require("@medusajs/utils")
const { FulfillmentModuleOptions } = require("@medusajs/fulfillment")

const DB_HOST = process.env.DB_HOST
const DB_USERNAME = process.env.DB_USERNAME
const DB_PASSWORD = process.env.DB_PASSWORD
Expand Down Expand Up @@ -78,7 +78,6 @@ module.exports = {
[Modules.SALES_CHANNEL]: true,
[Modules.CART]: true,
[Modules.WORKFLOW_ENGINE]: true,
[Modules.REGION]: true,
[Modules.API_KEY]: true,
[Modules.STORE]: true,
[Modules.TAX]: true,
Expand Down
3 changes: 1 addition & 2 deletions integration-tests/modules/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
"extends": "../../_tsconfig.base.json",
"include": ["src", "./medusa/**/*"],
"exclude": [
"./dist/**/*",
"dist",
"__tests__",
"helpers",
"./**/helpers",
"./**/__snapshots__",
"node_modules"
]
}

8 changes: 1 addition & 7 deletions integration-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"extends": "../_tsconfig.base.json",
"include": ["**/*"],
"exclude": [
"dist",
"./**/helpers",
"./**/__snapshots__",
"node_modules"
]
"exclude": ["dist", "./**/helpers", "./**/__snapshots__", "node_modules"]
}

20 changes: 13 additions & 7 deletions packages/admin/admin-bundler/src/entry.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import App from "@medusajs/dashboard"
import React from "react"
import { createRoot } from "react-dom/client"
import App from "@medusajs/dashboard";
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";

import "./index.css"
ReactDOM.createRoot(document.getElementById("medusa")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
)

const container = document.getElementById("root")
const root = createRoot(container!)
root.render(<App />)

if (import.meta.hot) {
import.meta.hot.accept()
}
11 changes: 7 additions & 4 deletions packages/admin/admin-bundler/src/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, user-scalable=no"
/>
<link rel="icon" href="data:," data-placeholder-favicon />
</head>

<body>
<div id="root"></div>
<div id="medusa"></div>
<script type="module" src="./entry.tsx"></script>
</body>
</html>
</html>
6 changes: 2 additions & 4 deletions packages/admin/admin-bundler/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export async function getViteConfig(
outDir: path.resolve(process.cwd(), options.outDir),
},
optimizeDeps: {
include: ["@medusajs/dashboard", "react-dom/client"],
exclude: VIRTUAL_MODULES,
include: ["react-dom/client", "@medusajs/ui", "@medusajs/dashboard"],
exclude: [...VIRTUAL_MODULES],
},
define: {
__BASE__: JSON.stringify(options.path),
Expand All @@ -43,7 +43,6 @@ export async function getViteConfig(
hmr: {
port: hmrPort,
},
middlewareMode: true,
},
css: {
postcss: {
Expand All @@ -64,7 +63,6 @@ export async function getViteConfig(

if (options.vite) {
const customConfig = options.vite(baseConfig)

return mergeConfig(baseConfig, customConfig)
}

Expand Down
Loading

0 comments on commit 57103be

Please sign in to comment.