Skip to content

Commit

Permalink
chore(feature-flags): Sales Channels enabled by default (#2966)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl authored Jan 10, 2023
1 parent cac8174 commit 3308766
Show file tree
Hide file tree
Showing 34 changed files with 372 additions and 498 deletions.
4 changes: 4 additions & 0 deletions .changeset/young-parents-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore(feature-flags): Sales Channels enabled by default
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Object {
"status": "draft",
"subtitle": null,
"thumbnail": null,
"title": "Practical Frozen Fish",
"title": "Handmade Frozen Chair",
"type_id": Any<String>,
"updated_at": Any<String>,
"weight": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Array [
],
"origin_country": null,
"profile_id": StringMatching /\\^sp_\\*/,
"sales_channels": Array [],
"status": "draft",
"subtitle": null,
"tags": Array [],
Expand Down Expand Up @@ -174,6 +175,7 @@ Object {
],
"origin_country": null,
"profile_id": StringMatching /\\^sp_\\*/,
"sales_channels": Array [],
"status": "draft",
"subtitle": null,
"tags": Array [
Expand Down Expand Up @@ -351,6 +353,7 @@ Object {
],
"origin_country": null,
"profile_id": StringMatching /\\^sp_\\*/,
"sales_channels": Array [],
"status": "published",
"subtitle": null,
"tags": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,6 @@ Object {
}
`;
exports[`sales channels GET /admin/sales-channels should list the sales channel 1`] = `
Object {
"count": 2,
"limit": 20,
"offset": 0,
"sales_channels": ArrayContaining [
Object {
"created_at": Any<String>,
"deleted_at": null,
"description": "test description",
"id": Any<String>,
"is_disabled": false,
"name": "test name",
"updated_at": Any<String>,
},
Object {
"created_at": Any<String>,
"deleted_at": null,
"description": "test description 2",
"id": Any<String>,
"is_disabled": false,
"name": "test name 2",
"updated_at": Any<String>,
},
],
}
`;
exports[`sales channels GET /admin/sales-channels should list the sales channel using free text search 1`] = `
Object {
"count": 1,
Expand Down
142 changes: 0 additions & 142 deletions integration-tests/api/__tests__/admin/__snapshots__/store.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,145 +6,3 @@ Object {
"type": "invalid_data",
}
`;

exports[`/admin/store POST /admin/store successfully updates and store currencies 1`] = `
Object {
"created_at": Any<String>,
"currencies": Array [
Object {
"code": "jpy",
"name": "Japanese Yen",
"symbol": "¥",
"symbol_native": "",
},
Object {
"code": "usd",
"name": "US Dollar",
"symbol": "$",
"symbol_native": "$",
},
],
"default_currency_code": "usd",
"default_location_id": null,
"id": Any<String>,
"invite_link_template": null,
"metadata": null,
"name": "Medusa Store",
"payment_link_template": null,
"swap_link_template": null,
"updated_at": Any<String>,
}
`;
exports[`/admin/store POST /admin/store successfully updates default currency and store currencies 1`] = `
Object {
"created_at": Any<String>,
"currencies": Array [
Object {
"code": "jpy",
"name": "Japanese Yen",
"symbol": "¥",
"symbol_native": "",
},
Object {
"code": "usd",
"name": "US Dollar",
"symbol": "$",
"symbol_native": "$",
},
],
"default_currency": Object {
"code": "jpy",
"name": "Japanese Yen",
"symbol": "¥",
"symbol_native": "",
},
"default_currency_code": "jpy",
"default_location_id": null,
"id": Any<String>,
"invite_link_template": null,
"metadata": null,
"name": "Medusa Store",
"payment_link_template": null,
"swap_link_template": null,
"updated_at": Any<String>,
}
`;
exports[`/admin/store POST /admin/store successfully updates default currency code 1`] = `
Object {
"created_at": Any<String>,
"currencies": Array [
Object {
"code": "usd",
"name": "US Dollar",
"symbol": "$",
"symbol_native": "$",
},
Object {
"code": "dkk",
"name": "Danish Krone",
"symbol": "Dkr",
"symbol_native": "kr",
},
],
"default_currency": Object {
"code": "dkk",
"name": "Danish Krone",
"symbol": "Dkr",
"symbol_native": "kr",
},
"default_currency_code": "dkk",
"default_location_id": null,
"id": Any<String>,
"invite_link_template": null,
"metadata": null,
"name": "Medusa Store",
"payment_link_template": null,
"swap_link_template": null,
"updated_at": Any<String>,
}
`;
exports[`/admin/store Store creation has created store with default currency 1`] = `
Object {
"created_at": Any<String>,
"currencies": Array [
Object {
"code": "usd",
"name": "US Dollar",
"symbol": "$",
"symbol_native": "$",
},
],
"default_currency": Object {
"code": "usd",
"name": "US Dollar",
"symbol": "$",
"symbol_native": "$",
},
"default_currency_code": "usd",
"default_location_id": null,
"feature_flags": Any<Array>,
"fulfillment_providers": Array [
Object {
"id": "test-ful",
"is_installed": true,
},
],
"id": Any<String>,
"invite_link_template": null,
"metadata": null,
"modules": Any<Array>,
"name": "Medusa Store",
"payment_link_template": null,
"payment_providers": Array [
Object {
"id": "test-pay",
"is_installed": true,
},
],
"swap_link_template": null,
"updated_at": Any<String>,
}
`;
5 changes: 4 additions & 1 deletion integration-tests/api/__tests__/admin/colllections.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const {
DiscountConditionOperator,
} = require("@medusajs/medusa")
const { IdMap } = require("medusa-test-utils")
const { simpleDiscountFactory } = require("../../factories")
const {
simpleDiscountFactory,
simpleSalesChannelFactory,
} = require("../../factories")

jest.setTimeout(30000)

Expand Down
55 changes: 27 additions & 28 deletions integration-tests/api/__tests__/admin/sales-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,20 @@ describe("sales channels", () => {
expect(response.status).toEqual(200)
expect(response.data.sales_channels).toBeTruthy()
expect(response.data.sales_channels.length).toBe(2)
expect(response.data).toMatchSnapshot({
count: 2,
limit: 20,
offset: 0,
sales_channels: expect.arrayContaining([
{
id: expect.any(String),
name: salesChannel1.name,
description: salesChannel1.description,
is_disabled: false,
deleted_at: null,
created_at: expect.any(String),
updated_at: expect.any(String),
},
{
id: expect.any(String),
name: salesChannel2.name,
description: salesChannel2.description,
is_disabled: false,
deleted_at: null,
created_at: expect.any(String),
updated_at: expect.any(String),
},
]),
})
expect(response.data).toEqual(
expect.objectContaining({
sales_channels: expect.arrayContaining([
expect.objectContaining({
name: salesChannel1.name,
description: salesChannel1.description,
}),
expect.objectContaining({
name: salesChannel2.name,
description: salesChannel2.description,
}),
]),
})
)
})

it("should list the sales channel using free text search", async () => {
Expand Down Expand Up @@ -632,7 +621,7 @@ describe("sales channels", () => {
relations: ["sales_channels"],
})

expect(attachedProduct.sales_channels.length).toBe(1)
expect(attachedProduct.sales_channels.length).toBe(2)
expect(attachedProduct.sales_channels).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand All @@ -641,6 +630,10 @@ describe("sales channels", () => {
description: "test description",
is_disabled: false,
}),
expect.objectContaining({
id: expect.any(String),
is_disabled: false,
}),
])
)

Expand Down Expand Up @@ -679,7 +672,8 @@ describe("sales channels", () => {
relations: ["sales_channels"],
})

expect(attachedProduct.sales_channels.length).toBe(0)
// default sales channel
expect(attachedProduct.sales_channels.length).toBe(1)
})
})

Expand Down Expand Up @@ -733,7 +727,8 @@ describe("sales channels", () => {
relations: ["sales_channels"],
})

expect(attachedProduct.sales_channels.length).toBe(1)
// + default sales channel
expect(attachedProduct.sales_channels.length).toBe(2)
expect(attachedProduct.sales_channels).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand All @@ -742,6 +737,10 @@ describe("sales channels", () => {
description: "test description",
is_disabled: false,
}),
expect.objectContaining({
id: expect.any(String),
is_disabled: false,
}),
])
)
})
Expand Down
Loading

0 comments on commit 3308766

Please sign in to comment.