feat: import private content from external bundles
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtempSync, rmSync } from 'node:fs';
|
||||
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { openDatabase, migrateDatabase } from '../src/server/db';
|
||||
@@ -43,13 +43,15 @@ test('runtime projects and arbitrary locales resolve, hidden and missing URLs do
|
||||
for (const parts of [['en'], ['unknown'], ['ar','bad'], ['admin']]) assert.throws(() => resolvePublicRoute(readContent(connection), parts));
|
||||
assert.throws(() => saveContent(connection, 'languages', { code: 'en', name: 'English', direction: 'ltr', enabled: false, messages: {} }));
|
||||
});
|
||||
test('legacy import preserves English and Persian projects and only runs once', t => {
|
||||
const connection = setup(t); importLegacy(connection);
|
||||
const snapshot = readContent(connection);
|
||||
assert.equal(resolvePublicRoute(snapshot, ['projects','qlockify']).project?.title, 'Qlockify');
|
||||
assert.equal(resolvePublicRoute(snapshot, ['fa']).portfolio.direction, 'rtl');
|
||||
assert.ok(snapshot.entries.length > 5);
|
||||
assert.throws(() => importLegacy(connection));
|
||||
test('external import preserves content and only runs once', t => {
|
||||
const connection = setup(t);
|
||||
const directory = mkdtempSync(path.join(tmpdir(), 'portfolio-bundle-'));
|
||||
t.after(() => rmSync(directory, { recursive: true, force: true }));
|
||||
const content = readContent(connection);
|
||||
writeFileSync(path.join(directory, 'bundle.json'), JSON.stringify({ version: 1, content, files: [] }));
|
||||
importLegacy(connection, directory, false, directory);
|
||||
assert.deepEqual(readContent(connection), content);
|
||||
assert.throws(() => importLegacy(connection, directory));
|
||||
});
|
||||
test('startup rejects a database migrated by an incompatible application image', t => {
|
||||
const connection = setup(t);
|
||||
|
||||
Reference in New Issue
Block a user