Release 1.0.8 with platform, security, and UI hardening.
Adds API filter registry, style theme registry, SW bitmask cache clear, KV namespacing, session expiry checks, accessibility improvements, and expanded test coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+51
-1
@@ -7,13 +7,17 @@ import { test, describe, beforeEach } from 'node:test';
|
||||
import assert from 'node:assert';
|
||||
import {
|
||||
initEnv,
|
||||
getConfig,
|
||||
getConfig,
|
||||
getConfigSync,
|
||||
setConfig,
|
||||
getConfigDict,
|
||||
isDevelopment,
|
||||
isProduction,
|
||||
isServiceWorkerEnabledSync,
|
||||
resolveServiceWorkerEnabled,
|
||||
CONFIG_KEYS
|
||||
} from '../src/platform/env.js';
|
||||
import { getProvider } from '../src/platform/storage.js';
|
||||
|
||||
describe('env.js', () => {
|
||||
beforeEach(() => {
|
||||
@@ -90,6 +94,34 @@ describe('env.js', () => {
|
||||
// May return null or undefined depending on import.meta.env availability
|
||||
assert.ok(value === null || value === undefined);
|
||||
});
|
||||
|
||||
test('locked keys ignore persisted storage overrides', async () => {
|
||||
initEnv({
|
||||
name: 'TestApp',
|
||||
api: { base_url: '/api/profile' },
|
||||
modules: ['rt', 'game']
|
||||
});
|
||||
|
||||
const configStorage = getProvider('kv', 'config');
|
||||
await configStorage.set(CONFIG_KEYS.API_BASE_URL, '/api/stale');
|
||||
await configStorage.set(CONFIG_KEYS.MODULES, ['stale']);
|
||||
|
||||
assert.strictEqual(await getConfig(CONFIG_KEYS.API_BASE_URL), '/api/profile');
|
||||
assert.deepStrictEqual(await getConfig(CONFIG_KEYS.MODULES), ['rt', 'game']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getConfigSync', () => {
|
||||
test('should return in-memory config without storage reads', () => {
|
||||
initEnv({
|
||||
name: 'SyncApp',
|
||||
api: { base_url: '/api/sync' }
|
||||
});
|
||||
|
||||
assert.strictEqual(getConfigSync(CONFIG_KEYS.APP_NAME), 'SyncApp');
|
||||
assert.strictEqual(getConfigSync(CONFIG_KEYS.API_BASE_URL), '/api/sync');
|
||||
assert.strictEqual(getConfigSync('MISSING', 'fallback'), 'fallback');
|
||||
});
|
||||
});
|
||||
|
||||
describe('setConfig', () => {
|
||||
@@ -148,6 +180,24 @@ describe('env.js', () => {
|
||||
assert.ok('STORAGE_BACKEND' in CONFIG_KEYS);
|
||||
assert.ok('API_BASE_URL' in CONFIG_KEYS);
|
||||
assert.ok('MODULES' in CONFIG_KEYS);
|
||||
assert.ok('SERVICE_WORKER_ENABLED' in CONFIG_KEYS);
|
||||
});
|
||||
});
|
||||
|
||||
describe('service worker profile flag', () => {
|
||||
test('resolveServiceWorkerEnabled defaults to true', () => {
|
||||
assert.strictEqual(resolveServiceWorkerEnabled({}), true);
|
||||
});
|
||||
|
||||
test('resolveServiceWorkerEnabled reads service_worker.enabled', () => {
|
||||
assert.strictEqual(resolveServiceWorkerEnabled({ service_worker: { enabled: false } }), false);
|
||||
assert.strictEqual(resolveServiceWorkerEnabled({ pwa: { service_worker: { enabled: false } } }), false);
|
||||
});
|
||||
|
||||
test('initEnv seeds SERVICE_WORKER_ENABLED into config', () => {
|
||||
initEnv({ service_worker: { enabled: false } });
|
||||
assert.strictEqual(isServiceWorkerEnabledSync(), false);
|
||||
assert.strictEqual(getConfigDict()[CONFIG_KEYS.SERVICE_WORKER_ENABLED], false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user