Changeset 0.37.10 (#222)

Co-authored-by: gobha <jasafpro@gmail.com>
Co-committed-by: gobha <jasafpro@gmail.com>
This commit is contained in:
2026-03-21 23:39:23 +00:00
committed by xcaliber
parent 37b639c9c8
commit 8d8a118232
52 changed files with 3209 additions and 13811 deletions

View File

@@ -1,8 +1,15 @@
const { describe, it } = require('node:test');
const assert = require('node:assert');
const { createBrowserContext, loadSource } = require('./helpers');
const fs = require('fs');
const path = require('path');
const { createBrowserContext, loadSource, SRC } = require('./helpers');
const vm = require('vm');
// v0.37.10: extensions.js deleted — extension system moves to Preact in v0.37.12.
// Skip all tests if the source file doesn't exist.
const EXTENSIONS_EXISTS = fs.existsSync(path.join(SRC, 'extensions.js'));
const maybeDescribe = EXTENSIONS_EXISTS ? describe : describe.skip;
/**
* Load Events + Extensions into a browser context.
* Returns an object with Events, Extensions, and the sandbox.
@@ -25,7 +32,7 @@ function loadExtensions(overrides = {}) {
// ── Registration ─────────────────────────────
describe('Extensions.register', () => {
maybeDescribe('Extensions.register', () => {
it('registers an extension by id', () => {
const ctx = loadExtensions();
ctx.Extensions.register({ id: 'test-ext', init() {} });
@@ -48,7 +55,7 @@ describe('Extensions.register', () => {
// ── Lifecycle ────────────────────────────────
describe('Extensions.initAll', () => {
maybeDescribe('Extensions.initAll', () => {
it('calls init on registered extensions', async () => {
const ctx = loadExtensions();
let initialized = false;
@@ -84,7 +91,7 @@ describe('Extensions.initAll', () => {
});
});
describe('Extensions.destroyAll', () => {
maybeDescribe('Extensions.destroyAll', () => {
it('calls destroy and deactivates extensions', async () => {
const ctx = loadExtensions();
let destroyed = false;
@@ -102,7 +109,7 @@ describe('Extensions.destroyAll', () => {
// ── Context Object ──────────────────────────
describe('Extension context', () => {
maybeDescribe('Extension context', () => {
it('provides scoped events', async () => {
const ctx = loadExtensions();
let receivedPayload = null;
@@ -159,7 +166,7 @@ describe('Extension context', () => {
// ── Tool Registration ───────────────────────
describe('ctx.tools.handle', () => {
maybeDescribe('ctx.tools.handle', () => {
it('registers a tool handler', async () => {
const ctx = loadExtensions();
ctx.Extensions.register({
@@ -177,7 +184,7 @@ describe('ctx.tools.handle', () => {
// ── Tool Bridge ─────────────────────────────
describe('Tool bridge', () => {
maybeDescribe('Tool bridge', () => {
it('routes tool.call.* to registered handler and emits result', async () => {
const ctx = loadExtensions();
let resultEmitted = null;
@@ -269,7 +276,7 @@ describe('Tool bridge', () => {
// ── Renderer Pipeline ───────────────────────
describe('Renderer pipeline', () => {
maybeDescribe('Renderer pipeline', () => {
it('registers and runs block renderers', async () => {
const ctx = loadExtensions();
let rendered = false;
@@ -356,7 +363,7 @@ describe('Renderer pipeline', () => {
// ── Debug ────────────────────────────────────
describe('Extensions.debug', () => {
maybeDescribe('Extensions.debug', () => {
it('returns extension info and renderer count', async () => {
const ctx = loadExtensions();
ctx.Extensions.register({
@@ -376,7 +383,7 @@ describe('Extensions.debug', () => {
// ── Mermaid Extension ─────────────────────────────
describe('Mermaid renderer extension', () => {
maybeDescribe('Mermaid renderer extension', () => {
function loadWithMermaid() {
const ctx = loadExtensions();
// Load the mermaid extension script into the same VM context