1- /**
2- * Represents the configuration for a product type
3- */
1+ // tests/fixtures/product-types.ts
42export interface ProductType {
53 id : string ;
4+ sku : string ;
65 name : string ;
76 isSubscription : boolean ;
87 subscriptionPlugin ?: string ; // 'woocommerce' or 'yith'
98 sampleProductId ?: number ; // ID of a sample product of this type for testing
109 sampleProductSlug ?: string ; // Slug of a sample product
11- price ?: number ; // Price to expect
10+ price : number ; // Price to expect
11+ // Add WooCommerce-specific fields
12+ woocommerce ?: {
13+ type : 'simple' | 'variable' | 'subscription' | 'grouped' | 'external' ;
14+ status ?: 'draft' | 'pending' | 'private' | 'publish' ;
15+ catalog_visibility ?: 'visible' | 'catalog' | 'search' | 'hidden' ;
16+ description ?: string ;
17+ short_description ?: string ;
18+ categories ?: Array < { id : number ; name : string ; } > ;
19+ images ?: Array < { src : string ; alt : string ; } > ;
20+ attributes ?: any [ ] ;
21+ variations ?: any [ ] ;
22+ meta_data ?: Array < { key : string ; value : any ; } > ;
23+ } ;
1224}
1325
1426/**
@@ -18,42 +30,110 @@ export const PRODUCT_TYPES: Record<string, ProductType> = {
1830 // Simple product
1931 SIMPLE : {
2032 id : 'simple' ,
33+ sku : 'TEST-SIMPLE-01' ,
2134 name : 'Simple Product' ,
2235 isSubscription : false ,
2336 sampleProductId : 63 ,
2437 sampleProductSlug : 'simple' ,
25- price : 19.99
38+ price : 19.99 ,
39+ woocommerce : {
40+ type : 'simple' ,
41+ status : 'publish' ,
42+ catalog_visibility : 'visible' ,
43+ description : 'A simple test product for automated testing' ,
44+ short_description : 'Simple test product'
45+ }
2646 } ,
2747
2848 // Variable product
2949 VARIABLE : {
3050 id : 'variable' ,
51+ sku : 'TEST-VARIABLE-01' ,
3152 name : 'Variable Product' ,
3253 isSubscription : false ,
33- sampleProductId : 456 ,
34- sampleProductSlug : 'sample-variable-product' ,
35- price : 29.99
54+ sampleProductId : 64 ,
55+ sampleProductSlug : 'variable' ,
56+ price : 29.99 ,
57+ woocommerce : {
58+ type : 'variable' ,
59+ status : 'publish' ,
60+ catalog_visibility : 'visible' ,
61+ description : 'A variable test product for automated testing' ,
62+ short_description : 'Variable test product' ,
63+ attributes : [
64+ {
65+ id : 1 ,
66+ name : 'Size' ,
67+ options : [ 'Small' , 'Medium' , 'Large' ] ,
68+ visible : true ,
69+ variation : true
70+ }
71+ ]
72+ }
3673 } ,
3774
3875 // WooCommerce Subscription
39- WC_SUBSCRIPTION : {
40- id : 'subscription' ,
41- name : 'WooCommerce Subscription' ,
76+ /*WOO_SUBSCRIPTION: {
77+ id: 'woo-subscription',
78+ sku: 'TEST-SUBSCRIPTION-WOO-01',
79+ name: 'WooCommerce Subscription Product',
4280 isSubscription: true,
4381 subscriptionPlugin: 'woocommerce',
44- sampleProductId : 789 ,
45- sampleProductSlug : 'sample-wc-subscription' ,
46- price : 9.99
82+ sampleProductId: 65,
83+ sampleProductSlug: 'woo-subscription',
84+ price: 9.99,
85+ woocommerce: {
86+ type: 'subscription',//check this cause it fails
87+ status: 'publish',
88+ catalog_visibility: 'visible',
89+ description: 'A WooCommerce subscription test product',
90+ short_description: 'WooCommerce subscription test product',
91+ meta_data: [
92+ { key: '_subscription_price', value: '9.99' },
93+ { key: '_subscription_period', value: 'month' },
94+ { key: '_subscription_period_interval', value: '1' }
95+ ]
96+ }
4797 },
4898
4999 // YITH Subscription
50100 YITH_SUBSCRIPTION: {
51- id : 'yith_subscription' ,
52- name : 'YITH Subscription' ,
101+ id: 'yith-subscription',
102+ sku: 'TEST-SUBSCRIPTION-YITH-01',
103+ name: 'YITH Subscription Product',
53104 isSubscription: true,
54105 subscriptionPlugin: 'yith',
55- sampleProductId : 1011 ,
56- sampleProductSlug : 'sample-yith-subscription' ,
57- price : 14.99
58- }
106+ sampleProductId: 66,
107+ sampleProductSlug: 'yith-subscription',
108+ price: 14.99,
109+ woocommerce: {
110+ type: 'simple',
111+ status: 'publish',
112+ catalog_visibility: 'visible',
113+ description: 'A YITH subscription test product',
114+ short_description: 'YITH subscription test product',
115+ meta_data: [
116+ { key: '_ywsbs_subscription', value: 'yes' },
117+ { key: '_ywsbs_price_is_per', value: 'month' },
118+ { key: '_ywsbs_price_time', value: '1' }
119+ ]
120+ }
121+ }*/
122+ } ;
123+
124+ // Helper to get specific product types
125+ export const getProductsByType = ( type : 'simple' | 'variable' | 'subscription' ) => {
126+ return Object . values ( PRODUCT_TYPES ) . filter ( product => {
127+ if ( type === 'subscription' ) return product . isSubscription ;
128+ if ( type === 'variable' ) return product . woocommerce ?. type === 'variable' ;
129+ if ( type === 'simple' ) return product . woocommerce ?. type === 'simple' && ! product . isSubscription ;
130+ return false ;
131+ } ) ;
132+ } ;
133+
134+ // Helper to get products by subscription plugin
135+ export const getSubscriptionProducts = ( plugin ?: 'woocommerce' | 'yith' ) => {
136+ return Object . values ( PRODUCT_TYPES ) . filter ( product =>
137+ product . isSubscription && ( ! plugin || product . subscriptionPlugin === plugin )
138+ ) ;
59139} ;
0 commit comments