feat(medusa,event-bus-local,event-bus-redis): Event Bus modules (#2599)
This commit is contained in:
committed by
GitHub
parent
7408111d11
commit
ef5ef9f5a2
@@ -1,83 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/admin/batch-jobs GET /admin/batch-jobs lists batch jobs created by the user 1`] = `
|
||||
Object {
|
||||
"batch_jobs": Array [
|
||||
Object {
|
||||
"canceled_at": null,
|
||||
"completed_at": "2022-06-27T22:00:00.000Z",
|
||||
"confirmed_at": null,
|
||||
"context": Object {},
|
||||
"created_at": Any<String>,
|
||||
"created_by": "admin_user",
|
||||
"deleted_at": null,
|
||||
"dry_run": false,
|
||||
"failed_at": null,
|
||||
"id": "job_5",
|
||||
"pre_processed_at": null,
|
||||
"processing_at": null,
|
||||
"result": null,
|
||||
"status": "completed",
|
||||
"type": "product-export",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
Object {
|
||||
"canceled_at": null,
|
||||
"completed_at": null,
|
||||
"confirmed_at": null,
|
||||
"context": Object {},
|
||||
"created_at": Any<String>,
|
||||
"created_by": "admin_user",
|
||||
"deleted_at": null,
|
||||
"dry_run": false,
|
||||
"failed_at": null,
|
||||
"id": "job_3",
|
||||
"pre_processed_at": null,
|
||||
"processing_at": null,
|
||||
"result": null,
|
||||
"status": "created",
|
||||
"type": "product-export",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
Object {
|
||||
"canceled_at": null,
|
||||
"completed_at": null,
|
||||
"confirmed_at": null,
|
||||
"context": Object {},
|
||||
"created_at": Any<String>,
|
||||
"created_by": "admin_user",
|
||||
"deleted_at": null,
|
||||
"dry_run": false,
|
||||
"failed_at": null,
|
||||
"id": "job_2",
|
||||
"pre_processed_at": null,
|
||||
"processing_at": null,
|
||||
"result": null,
|
||||
"status": "created",
|
||||
"type": "product-export",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
Object {
|
||||
"canceled_at": null,
|
||||
"completed_at": null,
|
||||
"confirmed_at": null,
|
||||
"context": Object {},
|
||||
"created_at": Any<String>,
|
||||
"created_by": "admin_user",
|
||||
"deleted_at": null,
|
||||
"dry_run": false,
|
||||
"failed_at": null,
|
||||
"id": "job_1",
|
||||
"pre_processed_at": null,
|
||||
"processing_at": null,
|
||||
"result": null,
|
||||
"status": "created",
|
||||
"type": "product-export",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
],
|
||||
"count": 4,
|
||||
"limit": 10,
|
||||
"offset": 0,
|
||||
}
|
||||
`;
|
||||
@@ -84,34 +84,36 @@ describe("/admin/batch-jobs", () => {
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.batch_jobs.length).toEqual(4)
|
||||
expect(response.data).toMatchSnapshot({
|
||||
batch_jobs: [
|
||||
{
|
||||
id: "job_5",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
},
|
||||
{
|
||||
id: "job_3",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
},
|
||||
{
|
||||
id: "job_2",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
},
|
||||
{
|
||||
id: "job_1",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
},
|
||||
],
|
||||
})
|
||||
expect(response.data).toEqual(
|
||||
expect.objectContaining({
|
||||
batch_jobs: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "job_5",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "job_3",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "job_2",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "job_1",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
created_by: "admin_user",
|
||||
}),
|
||||
]),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("lists batch jobs created by the user and where completed_at is null ", async () => {
|
||||
@@ -214,8 +216,6 @@ describe("/admin/batch-jobs", () => {
|
||||
created_by: "admin_user",
|
||||
status: "created",
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -264,28 +264,6 @@ describe("/admin/batch-jobs", () => {
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("Cancels batch job created by the user", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const jobId = "job_1"
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/batch-jobs/${jobId}/cancel`,
|
||||
{},
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.batch_job).toEqual(
|
||||
expect.objectContaining({
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
canceled_at: expect.any(String),
|
||||
status: "canceled",
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("Fails to cancel a batch job created by a different user", async () => {
|
||||
expect.assertions(3)
|
||||
const api = useApi()
|
||||
@@ -319,5 +297,27 @@ describe("/admin/batch-jobs", () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("Cancels batch job created by the user", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const jobId = "job_1"
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/batch-jobs/${jobId}/cancel`,
|
||||
{},
|
||||
adminReqConfig
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.batch_job).toEqual(
|
||||
expect.objectContaining({
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
canceled_at: expect.any(String),
|
||||
status: "canceled",
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -29,7 +29,6 @@ describe("Batchjob with type order-export", () => {
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({
|
||||
cwd,
|
||||
redisUrl: "redis://127.0.0.1:6379",
|
||||
uploadDir: __dirname,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -64,7 +64,6 @@ describe("Price list import batch job", () => {
|
||||
|
||||
medusaProcess = await setupServer({
|
||||
cwd,
|
||||
redisUrl: "redis://127.0.0.1:6379",
|
||||
uploadDir: __dirname,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -30,7 +30,6 @@ describe("Batch job of product-export type", () => {
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({
|
||||
cwd,
|
||||
redisUrl: "redis://127.0.0.1:6379",
|
||||
uploadDir: __dirname,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,7 +8,9 @@ const adminSeeder = require("../../../helpers/admin-seeder")
|
||||
const userSeeder = require("../../../helpers/user-seeder")
|
||||
const { simpleSalesChannelFactory } = require("../../../factories")
|
||||
const batchJobSeeder = require("../../../helpers/batch-job-seeder")
|
||||
const { simpleProductCollectionFactory } = require("../../../factories/simple-product-collection-factory");
|
||||
const {
|
||||
simpleProductCollectionFactory,
|
||||
} = require("../../../factories/simple-product-collection-factory")
|
||||
|
||||
const startServerWithEnvironment =
|
||||
require("../../../../helpers/start-server-with-environment").default
|
||||
@@ -52,7 +54,7 @@ describe("Product import - Sales Channel", () => {
|
||||
let dbConnection
|
||||
let medusaProcess
|
||||
|
||||
let collectionHandle1 = "test-collection1"
|
||||
const collectionHandle1 = "test-collection1"
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
|
||||
@@ -62,7 +64,6 @@ describe("Product import - Sales Channel", () => {
|
||||
const [process, connection] = await startServerWithEnvironment({
|
||||
cwd,
|
||||
env: { MEDUSA_FF_SALES_CHANNELS: true },
|
||||
redisUrl: "redis://127.0.0.1:6379",
|
||||
uploadDir: __dirname,
|
||||
})
|
||||
dbConnection = connection
|
||||
@@ -90,7 +91,7 @@ describe("Product import - Sales Channel", () => {
|
||||
name: "Import Sales Channel 2",
|
||||
})
|
||||
await simpleProductCollectionFactory(dbConnection, {
|
||||
handle: collectionHandle1
|
||||
handle: collectionHandle1,
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -169,8 +170,8 @@ describe("Product import - Sales Channel", () => {
|
||||
}),
|
||||
],
|
||||
collection: expect.objectContaining({
|
||||
handle: collectionHandle1
|
||||
})
|
||||
handle: collectionHandle1,
|
||||
}),
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
@@ -63,7 +63,6 @@ describe("Product import batch job", () => {
|
||||
|
||||
medusaProcess = await setupServer({
|
||||
cwd,
|
||||
redisUrl: "redis://127.0.0.1:6379",
|
||||
uploadDir: __dirname,
|
||||
})
|
||||
})
|
||||
@@ -81,7 +80,7 @@ describe("Product import batch job", () => {
|
||||
await batchJobSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
await userSeeder(dbConnection)
|
||||
await simpleProductCollectionFactory(dbConnection, [
|
||||
await simpleProductCollectionFactory(dbConnection, [
|
||||
{
|
||||
handle: collectionHandle1,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user