Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Run the product tests that moved into the framework

Damian Legawiec4853f4e10bf6
diff --git a/docs/plans/6.0-seller-product-submission.md b/docs/plans/6.0-seller-product-submission.md
index eb88e70c9e..4938302991 100644
--- a/docs/plans/6.0-seller-product-submission.md
+++ b/docs/plans/6.0-seller-product-submission.md
@@ -89,7 +89,7 @@ drift.
### Status lifecycle
-```
+```text
draft ──propose──▶ proposed ──approve──▶ active
▲ │
│ └──reject───▶ rejected
diff --git a/packages/dashboard-core/src/api-client.ts b/packages/dashboard-core/src/api-client.ts
index d60c1a199c..8660ebc56d 100644
--- a/packages/dashboard-core/src/api-client.ts
+++ b/packages/dashboard-core/src/api-client.ts
@@ -113,9 +113,18 @@ export interface PanelApiClient {
* Naming a new option (Size, Colour) while building a variant matrix.
* Operator-only: a seller names options inline on the variant instead,
* so their client leaves these out and the builder hides.
+ *
+ * `name` and `label` are named rather than left to a loose record — they
+ * are what the API requires, and a contract that did not say so would
+ * push the check to a cast at the registration site.
*/
- create?(params: Record<string, unknown>): Promise<PanelOptionType>
- update?(id: string, params: Record<string, unknown>): Promise<PanelOptionType>
+ create?(
+ params: { name: string; label: string } & Record<string, unknown>,
+ ): Promise<PanelOptionType>
+ update?(
+ id: string,
+ params: { option_values?: Array<{ name: string; label: string }> } & Record<string, unknown>,
+ ): Promise<PanelOptionType>
}
categories?: {
list(params?: Record<string, unknown>): Promise<{ data: PanelNamedRecord[] }>
diff --git a/packages/dashboard-core/src/products/use-product-form-data.ts b/packages/dashboard-core/src/products/use-product-form-data.ts
index 958efa68b3..e17c0eb844 100644
--- a/packages/dashboard-core/src/products/use-product-form-data.ts
+++ b/packages/dashboard-core/src/products/use-product-form-data.ts
@@ -155,7 +155,7 @@ export function useCreateOptionType() {
const optionTypesKey = useResourceKey('panel-form-option-types')
return useMutation({
- mutationFn: (params: Record<string, unknown>) =>
+ mutationFn: (params: { name: string; label: string } & Record<string, unknown>) =>
client.optionTypes?.create?.(params) as Promise<PanelOptionType>,
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: optionTypesKey })
@@ -169,8 +169,9 @@ export function useUpdateOptionType(id: string) {
const optionTypesKey = useResourceKey('panel-form-option-types')
return useMutation({
- mutationFn: (params: Record<string, unknown>) =>
- client.optionTypes?.update?.(id, params) as Promise<PanelOptionType>,
+ mutationFn: (
+ params: { option_values?: Array<{ name: string; label: string }> } & Record<string, unknown>,
+ ) => client.optionTypes?.update?.(id, params) as Promise<PanelOptionType>,
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: optionTypesKey })
},
diff --git a/packages/dashboard-core/vitest.config.ts b/packages/dashboard-core/vitest.config.ts
index 9eef0e8a80..9f02c7cd24 100644
--- a/packages/dashboard-core/vitest.config.ts
+++ b/packages/dashboard-core/vitest.config.ts
@@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
environment: 'node',
- include: ['tests/**/*.test.ts'],
+ // `src/**` too: the product form's tests live beside the code they cover,
+ // and a pattern that only saw `tests/` silently stopped running them when
+ // that code moved into this package.
+ include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
},
})
diff --git a/packages/dashboard/src/api-client-setup.ts b/packages/dashboard/src/api-client-setup.ts
index cc9e8d4e8b..2d1306a5e7 100644
--- a/packages/dashboard/src/api-client-setup.ts
+++ b/packages/dashboard/src/api-client-setup.ts
@@ -31,8 +31,8 @@ setApiClient({
// Reference data for the shared product form.
optionTypes: {
list: (params) => adminClient.optionTypes.list({ ...params, expand: ['option_values'] }),
- create: (params) => adminClient.optionTypes.create(params as never),
- update: (id, params) => adminClient.optionTypes.update(id, params as never),
+ create: (params) => adminClient.optionTypes.create(params),
+ update: (id, params) => adminClient.optionTypes.update(id, params),
},
categories: { list: (params) => adminClient.categories.list(params) },
collections: { list: (params) => adminClient.collections.list(params) },
diff --git a/spree/core/lib/spree/core/permission_configuration.rb b/spree/core/lib/spree/core/permission_configuration.rb
index bec1ecc912..024c60e566 100644
--- a/spree/core/lib/spree/core/permission_configuration.rb
+++ b/spree/core/lib/spree/core/permission_configuration.rb
@@ -320,8 +320,17 @@ module Spree
register_resource(:product_types, group: :catalog,
audiences: %i[seller], read_only_for: %i[seller],
subjects: -> { [Spree::ProductType] })
- # Which channels carry a product is marketplace merchandising. Closed to
- # the seller audience: a seller lists, the marketplace distributes.
+ # Which channels carry a product is marketplace merchandising, so this
+ # is closed to the seller audience entirely — a seller lists, the
+ # marketplace distributes, and the seller branch serializes no
+ # publication at all.
+ #
+ # Publishing is written through the products endpoint rather than one of
+ # its own, so `write_publishing` gates nothing today; what this
+ # registration does is take `ProductPublication` out of the `products`
+ # subject list, which is what a seller's role would otherwise reach. A
+ # staff role that manages publications needs this key alongside
+ # `write_products`.
register_resource(:publishing, group: :catalog, subjects: -> {
[Spree::ProductPublication]
})