T009
This commit is contained in:
19
packages/storage/package.json
Normal file
19
packages/storage/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@glowtrack/storage",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"description": "Storage layer for GlowTrack (models, IndexedDB, export/import)",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"test:unit": "vitest run",
|
||||
"test:ui": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": "^8.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.4",
|
||||
"vitest": "^2.1.1"
|
||||
}
|
||||
}
|
||||
42
packages/storage/tests/contract/export.spec.ts
Normal file
42
packages/storage/tests/contract/export.spec.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import Ajv, { type ErrorObject } from 'ajv';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
// Implementation placeholder import; will fail until implemented per tasks T016, T018
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error - module not implemented yet
|
||||
import { exportToJson } from '../../src/export';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const repoRoot = path.resolve(__dirname, '../../../../');
|
||||
const schemaPath = path.join(
|
||||
repoRoot,
|
||||
'specs/001-glowtrack-a-mood/contracts/export.schema.json'
|
||||
);
|
||||
|
||||
describe('Contract: export JSON schema (T009)', () => {
|
||||
it('exportToJson() output should validate against export.schema.json', async () => {
|
||||
const schemaJson = JSON.parse(fs.readFileSync(schemaPath, 'utf-8'));
|
||||
const ajv = new Ajv({ allErrors: true, strict: true });
|
||||
const validate = ajv.compile(schemaJson);
|
||||
|
||||
// Minimal call; actual implementation will read from DB/models
|
||||
// For now, call without args or with undefined to get full export
|
||||
const data = await exportToJson();
|
||||
const valid = validate(data);
|
||||
|
||||
if (!valid) {
|
||||
// Show helpful aggregated errors
|
||||
const errors = (validate.errors || [])
|
||||
.map((e: ErrorObject) => `${e.instancePath || '/'} ${e.message}`)
|
||||
.join('\n');
|
||||
// Intentionally using expect(...).toBe(true) so test fails until impl is ready
|
||||
expect({ valid, errors }).toEqual({ valid: true, errors: '' });
|
||||
}
|
||||
|
||||
expect(valid).toBe(true);
|
||||
});
|
||||
});
|
||||
14
packages/storage/tsconfig.json
Normal file
14
packages/storage/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ES2022",
|
||||
"moduleResolution": "Bundler",
|
||||
"types": ["node", "vitest/globals"],
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["tests", "src"]
|
||||
}
|
||||
@@ -68,7 +68,7 @@ Paths below are absolute to this repo.
|
||||
## Phase 3.2: Tests First (TDD) — MUST FAIL before 3.3
|
||||
Contract files from /home/jawz/Development/Projects/GlowTrack/specs/001-glowtrack-a-mood/contracts/ → contract tests [P]
|
||||
|
||||
- [ ] T009 [P] Contract test: export JSON schema
|
||||
- [X] T009 [P] Contract test: export JSON schema
|
||||
- Create /home/jawz/Development/Projects/GlowTrack/packages/storage/tests/contract/export.spec.ts
|
||||
- Use Ajv to validate object from exportToJson() against export.schema.json at /home/jawz/Development/Projects/GlowTrack/specs/001-glowtrack-a-mood/contracts/export.schema.json
|
||||
- Expect failure until export service implemented
|
||||
|
||||
Reference in New Issue
Block a user