// --------------------------------------------------------------------------- // Shared mock data for Inventory frontend test suite // --------------------------------------------------------------------------- import type { ConstructeurLinkEntry, ConstructeurSummary } from '~/shared/constructeurUtils' import type { CustomFieldDefinition, CustomFieldValue } from '~/shared/utils/customFields' import type { ComponentModelStructure } from '~/shared/types/inventory' // --------------------------------------------------------------------------- // Constructeurs // --------------------------------------------------------------------------- export const mockConstructeurSKF: ConstructeurSummary = { id: 'cstr-skf-001', name: 'SKF', email: 'contact@skf.com', phone: '+33 1 23 45 67 89', } export const mockConstructeurFAG: ConstructeurSummary = { id: 'cstr-fag-002', name: 'FAG', email: 'info@fag.de', phone: '+49 9721 91 0', } // --------------------------------------------------------------------------- // Constructeur link entries // --------------------------------------------------------------------------- export const mockLinkSKF: ConstructeurLinkEntry = { linkId: 'link-skf-001', constructeurId: mockConstructeurSKF.id, constructeur: mockConstructeurSKF, supplierReference: 'SKF-6205-2RS', } export const mockLinkFAG: ConstructeurLinkEntry = { linkId: 'link-fag-002', constructeurId: mockConstructeurFAG.id, constructeur: mockConstructeurFAG, supplierReference: 'FAG-6205-C-2HRS', } // --------------------------------------------------------------------------- // Custom field definitions (6 types) // --------------------------------------------------------------------------- export const mockCustomFieldDefs: CustomFieldDefinition[] = [ { id: 'cf-def-001', name: 'Tension nominale', type: 'number', required: true, options: [], defaultValue: '220', orderIndex: 0, machineContextOnly: false, }, { id: 'cf-def-002', name: 'Certifié CE', type: 'boolean', required: false, options: [], defaultValue: 'false', orderIndex: 1, machineContextOnly: false, }, { id: 'cf-def-003', name: 'Indice de protection', type: 'select', required: false, options: ['IP54', 'IP55', 'IP65'], defaultValue: null, orderIndex: 2, machineContextOnly: false, }, { id: 'cf-def-004', name: 'Date de calibration', type: 'date', required: false, options: [], defaultValue: null, orderIndex: 3, machineContextOnly: false, }, { id: 'cf-def-005', name: 'Remarques techniques', type: 'text', required: false, options: [], defaultValue: null, orderIndex: 4, machineContextOnly: false, }, { id: 'cf-def-006', name: 'Position sur machine', type: 'text', required: false, options: [], defaultValue: null, orderIndex: 5, machineContextOnly: true, }, ] // --------------------------------------------------------------------------- // Custom field values (matching first 5 defs) // --------------------------------------------------------------------------- export const mockCustomFieldValues: CustomFieldValue[] = [ { id: 'cfv-001', value: '220', customField: mockCustomFieldDefs[0]!, }, { id: 'cfv-002', value: 'true', customField: mockCustomFieldDefs[1]!, }, { id: 'cfv-003', value: 'IP65', customField: mockCustomFieldDefs[2]!, }, { id: 'cfv-004', value: '2025-06-15', customField: mockCustomFieldDefs[3]!, }, { id: 'cfv-005', value: 'Roulement renforcé pour environnement humide', customField: mockCustomFieldDefs[4]!, }, ] // --------------------------------------------------------------------------- // Component ModelType structure // --------------------------------------------------------------------------- export const mockComponentStructure: ComponentModelStructure = { customFields: [ { name: 'Tension nominale', type: 'number', required: true, defaultValue: '220', orderIndex: 0 }, { name: 'Certifié CE', type: 'boolean', required: false, defaultValue: 'false', orderIndex: 1 }, { name: 'Indice de protection', type: 'select', required: false, options: ['IP54', 'IP55', 'IP65'], orderIndex: 2 }, ], pieces: [ { typePieceId: 'tp-bearing-001', typePieceLabel: 'Roulement', reference: 'REF-PIECE-001', familyCode: 'ROUL', role: 'support', quantity: 2, }, { typePieceId: 'tp-seal-002', typePieceLabel: 'Joint', reference: 'REF-PIECE-002', familyCode: 'JOINT', role: 'étanchéité', quantity: 1, }, ], products: [ { typeProductId: 'tprod-grease-001', typeProductLabel: 'Graisse SKF', reference: 'REF-PROD-001', familyCode: 'LUB', role: 'lubrification', }, ], subcomponents: [ { typeComposantId: 'tc-sub-001', typeComposantLabel: 'Sous-ensemble palier', familyCode: 'PAL', alias: 'Palier avant', subcomponents: [], }, ], } // --------------------------------------------------------------------------- // Full API response — Composant // --------------------------------------------------------------------------- export const mockComponentFromApi = { '@id': '/api/composants/comp-001', '@type': 'Composant', id: 'comp-001', name: 'Moteur principal', reference: 'COMP-MOT-001', typeComposant: { id: 'tc-moteur', name: 'Moteur électrique', code: 'MOT' }, site: { id: 'site-001', name: 'Usine Nord' }, pieceSlots: [ { id: 'ps-001', piece: { id: 'piece-001', name: 'Roulement 6205', reference: 'ROUL-6205' }, typePiece: { id: 'tp-bearing-001', name: 'Roulement' }, role: 'support', quantity: 2, }, { id: 'ps-002', piece: { id: 'piece-002', name: 'Joint torique', reference: 'JOINT-001' }, typePiece: { id: 'tp-seal-002', name: 'Joint' }, role: 'étanchéité', quantity: 1, }, ], productSlots: [ { id: 'prs-001', product: { id: 'prod-001', name: 'Graisse LGMT2', reference: 'LUB-LGMT2' }, typeProduct: { id: 'tprod-grease-001', name: 'Graisse SKF' }, role: 'lubrification', }, ], subcomponentSlots: [ { id: 'scs-001', subcomponent: { id: 'comp-sub-001', name: 'Palier avant', reference: 'PAL-AV-001' }, typeComposant: { id: 'tc-sub-001', name: 'Sous-ensemble palier' }, alias: 'Palier avant', }, ], constructeurLinks: [ { id: mockLinkSKF.linkId, constructeur: mockConstructeurSKF, supplierReference: mockLinkSKF.supplierReference, }, ], customFieldValues: mockCustomFieldValues.map(cfv => ({ id: cfv.id, value: cfv.value, customField: { id: cfv.customField.id, name: cfv.customField.name, type: cfv.customField.type, required: cfv.customField.required, options: cfv.customField.options, defaultValue: cfv.customField.defaultValue, orderIndex: cfv.customField.orderIndex, machineContextOnly: cfv.customField.machineContextOnly, }, })), createdAt: '2025-01-15T10:00:00+00:00', updatedAt: '2025-03-20T14:30:00+00:00', } // --------------------------------------------------------------------------- // Full API response — Piece // --------------------------------------------------------------------------- export const mockPieceFromApi = { '@id': '/api/pieces/piece-001', '@type': 'Piece', id: 'piece-001', name: 'Roulement 6205', reference: 'ROUL-6205', typePiece: { id: 'tp-bearing-001', name: 'Roulement', code: 'ROUL' }, site: { id: 'site-001', name: 'Usine Nord' }, productSlots: [ { id: 'pps-001', product: { id: 'prod-001', name: 'Graisse LGMT2', reference: 'LUB-LGMT2' }, typeProduct: { id: 'tprod-grease-001', name: 'Graisse SKF' }, role: 'lubrification', }, ], constructeurLinks: [ { id: mockLinkSKF.linkId, constructeur: mockConstructeurSKF, supplierReference: mockLinkSKF.supplierReference, }, { id: mockLinkFAG.linkId, constructeur: mockConstructeurFAG, supplierReference: mockLinkFAG.supplierReference, }, ], customFieldValues: [ { id: 'cfv-piece-001', value: '6205', customField: { id: 'cf-piece-def-001', name: 'Référence interne', type: 'text', required: true, options: [], defaultValue: null, orderIndex: 0, machineContextOnly: false, }, }, ], createdAt: '2025-01-10T08:00:00+00:00', updatedAt: '2025-03-18T11:00:00+00:00', } // --------------------------------------------------------------------------- // Full API response — Product // --------------------------------------------------------------------------- export const mockProductFromApi = { '@id': '/api/products/prod-001', '@type': 'Product', id: 'prod-001', name: 'Graisse LGMT2', reference: 'LUB-LGMT2', typeProduct: { id: 'tprod-grease-001', name: 'Graisse SKF', code: 'LUB' }, site: { id: 'site-001', name: 'Usine Nord' }, supplierPrice: 45.90, constructeurLinks: [ { id: mockLinkSKF.linkId, constructeur: mockConstructeurSKF, supplierReference: 'LGMT2/1', }, ], createdAt: '2025-02-01T09:00:00+00:00', updatedAt: '2025-03-10T16:00:00+00:00', } // --------------------------------------------------------------------------- // JSON-LD collection wrapper // --------------------------------------------------------------------------- export function wrapCollection(items: T[], total?: number) { return { '@context': '/api/contexts/Collection', '@id': '/api/collection', '@type': 'Collection', 'totalItems': total ?? items.length, 'member': items, } } // --------------------------------------------------------------------------- // Machine custom field definitions (5 types) // --------------------------------------------------------------------------- export const mockMachineCustomFieldDefs: CustomFieldDefinition[] = [ { id: 'mcf-def-001', name: 'Numéro de série', type: 'text', required: true, options: [], defaultValue: null, orderIndex: 0, machineContextOnly: false, }, { id: 'mcf-def-002', name: 'En service', type: 'boolean', required: false, options: [], defaultValue: 'false', orderIndex: 1, machineContextOnly: false, }, { id: 'mcf-def-003', name: 'Puissance (kW)', type: 'number', required: false, options: [], defaultValue: null, orderIndex: 2, machineContextOnly: false, }, { id: 'mcf-def-004', name: 'Catégorie ATEX', type: 'select', required: false, options: ['Zone 0', 'Zone 1', 'Zone 2', 'Non classé'], defaultValue: null, orderIndex: 3, machineContextOnly: false, }, { id: 'mcf-def-005', name: 'Date mise en service', type: 'date', required: false, options: [], defaultValue: null, orderIndex: 4, machineContextOnly: false, }, ] // --------------------------------------------------------------------------- // Machine custom field values (matching defs, includes number '0' and boolean 'true') // --------------------------------------------------------------------------- export const mockMachineCustomFieldValues: CustomFieldValue[] = [ { id: 'mcfv-001', value: 'SN-2025-001234', customField: mockMachineCustomFieldDefs[0]!, }, { id: 'mcfv-002', value: 'true', customField: mockMachineCustomFieldDefs[1]!, }, { id: 'mcfv-003', value: '0', customField: mockMachineCustomFieldDefs[2]!, }, { id: 'mcfv-004', value: 'Zone 1', customField: mockMachineCustomFieldDefs[3]!, }, { id: 'mcfv-005', value: '2025-01-15', customField: mockMachineCustomFieldDefs[4]!, }, ]