|
| 1 | +// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. |
| 2 | +// |
| 3 | +// Self-contained smoke for @objectstack/metadata-protocol: the package must |
| 4 | +// import cleanly and expose its public surface without needing a data engine. |
| 5 | +// (Protocol behavior is exercised end-to-end by the @objectstack/objectql suite, |
| 6 | +// which injects a real engine.) |
| 7 | + |
| 8 | +import { describe, it, expect } from 'vitest'; |
| 9 | +import { |
| 10 | + ObjectStackProtocolImplementation, |
| 11 | + ConcurrentUpdateError, |
| 12 | + normalizeViewMetadata, |
| 13 | + SysMetadataRepository, |
| 14 | + resetEnvWritableMetadataTypes, |
| 15 | + computeMetadataDiagnostics, |
| 16 | + computeViewReferenceDiagnostics, |
| 17 | + decorateMetadataItem, |
| 18 | + SeedLoaderService, |
| 19 | + runBuildProbes, |
| 20 | +} from './index.js'; |
| 21 | + |
| 22 | +describe('@objectstack/metadata-protocol public surface', () => { |
| 23 | + it('exposes the protocol, repository, seed-loader and probe entry points', () => { |
| 24 | + expect(typeof ObjectStackProtocolImplementation).toBe('function'); |
| 25 | + expect(typeof SysMetadataRepository).toBe('function'); |
| 26 | + expect(typeof SeedLoaderService).toBe('function'); |
| 27 | + expect(typeof runBuildProbes).toBe('function'); |
| 28 | + expect(ConcurrentUpdateError.prototype).toBeInstanceOf(Error); |
| 29 | + }); |
| 30 | + |
| 31 | + it('exposes pure metadata helpers', () => { |
| 32 | + expect(typeof normalizeViewMetadata).toBe('function'); |
| 33 | + expect(typeof computeMetadataDiagnostics).toBe('function'); |
| 34 | + expect(typeof computeViewReferenceDiagnostics).toBe('function'); |
| 35 | + expect(typeof decorateMetadataItem).toBe('function'); |
| 36 | + expect(typeof resetEnvWritableMetadataTypes).toBe('function'); |
| 37 | + }); |
| 38 | + |
| 39 | + it('normalizeViewMetadata passes a non-view item through without throwing', () => { |
| 40 | + const item = { name: 'acct', label: 'Account' }; |
| 41 | + expect(() => normalizeViewMetadata('object', item, 'acct')).not.toThrow(); |
| 42 | + }); |
| 43 | + |
| 44 | + it('resetEnvWritableMetadataTypes is callable (state reset, no engine needed)', () => { |
| 45 | + expect(() => resetEnvWritableMetadataTypes()).not.toThrow(); |
| 46 | + }); |
| 47 | +}); |
0 commit comments