caterium-app/tests/training-catalog-fixture.mjs
pavlov346346-source 716a79c58d
Optional per-profile training catalog with reversible example visibility (#35)
Add Settings > Учебный каталог, off by default and available on ordinary writable profiles. Load ready example boxes, photos, TTKs and linked sample inventory additively; preserve own data, saved orders and edited examples when hiding or re-enabling. Respect company/profile scope, read-only permissions, failed downloads and tenant changes. Preserve the opened recipe guide across real catalog refreshes on iPhone. Integrated feature checks and full pull-request QA passed. Standard main QA and exact-asset production UI verification remain in place.
2026-09-20 12:18:40 +03:00

18 lines
2.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export function trainingInit(){
const ws='training-workspace',user={id:'training-user',email:'training@example.invalid',email_confirmed_at:'2026-01-01T00:00:00Z'};
localStorage.setItem('sunCloudV2Config',JSON.stringify({workspaceId:ws,localWorkspaceId:ws,tenantStorageReady:true,autoSync:false}));
if(!localStorage.getItem('training-fixture-ready')){
localStorage.setItem('sunBoxes',JSON.stringify([{id:'own-box',name:'Мой настоящий бокс',category:0,price:1700,weight:'900 г',pieces:12,ingredients:[['Томаты',1,'кг']]}]));
localStorage.setItem('sunOrders',JSON.stringify([{id:1,event:'Настоящий заказ',date:'2099-12-20',time:'12:00',status:'Новый',lines:[{id:'own-box',qty:2,price:1500}],total:3000}]));
localStorage.setItem('sunStock',JSON.stringify([{id:'own-stock',name:'Томаты',unit:'кг',cost:380,qty:12,min:1,supplierId:'own-supplier'}]));
localStorage.setItem('sunSuppliers',JSON.stringify([{id:'own-supplier',name:'Мой поставщик',active:true,phone:'70000000000'}]));
localStorage.setItem('training-fixture-ready','1');
}
const features=Object.fromEntries('orders calendar clients catalog_view catalog_edit production shopping stock routes mailings money stats_basic stats_advanced team suppliers print settings branding client_offers offer_templates backups audit users_manage'.split(' ').map(k=>[k,true]));
window.supabase={createClient:()=>({
auth:{onAuthStateChange:()=>({data:{subscription:{unsubscribe(){}}}}),getSession:async()=>({data:{session:{user}},error:null}),getUser:async()=>({data:{user},error:null})},
rpc:async name=>({data:name==='sun_my_workspaces'?[{id:ws,name:'Тестовая компания',role:'admin',is_active:true,permissions:{}}]:name==='sun_subscription_snapshot'?{plan_id:'full',plan_name:'Полный',status:'active',access_mode:'full',features}:name==='sun_is_platform_admin'?false:name==='caterium_trial_demo_status'?{canInstall:false,canUpgrade:false}:null,error:null}),
channel:()=>({on(){return this},subscribe(){return this}}),removeChannel(){}
})};
}