v0.7.2 Package Runners + CI Gate
Five package-level test runners validating extension API contracts: - notes-runner: CRUD, folders, tags, search, backlinks (12 tests) - chat-runner: conversations, messaging, search (9 tests) - schedules-runner: CRUD + run (5 tests) - workflow-runner: definitions, instances, stage progression (5 tests) - renderer-runner: registry contract, block matching (4 tests) Runner Result API (in-memory, 3 admin endpoints) stores results from browser runs for CI consumption. Test-runners surface v0.2.0 posts results after each run and fixes suite prefix matching. CI integration via Playwright: wait-for-healthy.sh, run-surface-tests.sh, surface-test-driver.js. New test-runners stage in Gitea CI pipeline. Verified: 169 passed, 0 failed, 9 warned, 8 skipped on fresh install. Go handler tests: 4/4 passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
59
packages/notes-runner/js/folders.js
Normal file
59
packages/notes-runner/js/folders.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Notes Runner — notes/folders suite
|
||||
*
|
||||
* Tests folder CRUD and note-folder association.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var api = window.NR.api;
|
||||
|
||||
sw.testing.suite('notes/folders', async function (s) {
|
||||
var folderId, noteId;
|
||||
|
||||
s.test('create folder', async function (t) {
|
||||
var r = await api.post('/folders', {
|
||||
name: 'runner-test-folder-' + Date.now()
|
||||
});
|
||||
t.assert.ok(r.id, 'folder has id');
|
||||
t.assert.ok(r.name, 'folder has name');
|
||||
folderId = r.id;
|
||||
s.track('folder', folderId);
|
||||
});
|
||||
|
||||
s.test('create note in folder', async function (t) {
|
||||
t.assert.ok(folderId, 'folderId from previous test');
|
||||
var r = await api.post('/notes', {
|
||||
title: 'Folder Note',
|
||||
body: 'Note in test folder',
|
||||
folder_id: folderId
|
||||
});
|
||||
t.assert.ok(r.id, 'note has id');
|
||||
t.assert.eq(r.folder_id, folderId, 'note assigned to folder');
|
||||
noteId = r.id;
|
||||
s.track('note', noteId);
|
||||
});
|
||||
|
||||
s.test('move note to folder', async function (t) {
|
||||
var f2 = await api.post('/folders', {
|
||||
name: 'runner-move-target-' + Date.now()
|
||||
});
|
||||
s.track('folder', f2.id);
|
||||
|
||||
t.assert.ok(noteId, 'noteId from previous test');
|
||||
await api.post('/notes/move', {
|
||||
note_id: noteId,
|
||||
folder_id: f2.id
|
||||
});
|
||||
var note = await api.get('/notes/' + noteId);
|
||||
t.assert.eq(note.folder_id, f2.id, 'note moved to new folder');
|
||||
});
|
||||
|
||||
s.test('list folders', async function (t) {
|
||||
var r = await api.get('/folders');
|
||||
t.assert.ok(Array.isArray(r), 'response is array');
|
||||
var found = r.some(function (f) { return f.id === folderId; });
|
||||
t.assert.ok(found, 'created folder appears in list');
|
||||
});
|
||||
});
|
||||
})();
|
||||
64
packages/notes-runner/js/main.js
Normal file
64
packages/notes-runner/js/main.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Notes Runner — Entry Point
|
||||
*
|
||||
* Boot SDK, load test modules in dependency order.
|
||||
* Each module is an IIFE that registers suites via sw.testing.suite().
|
||||
*/
|
||||
(async function () {
|
||||
'use strict';
|
||||
|
||||
try {
|
||||
var base = window.__BASE__ || '';
|
||||
var ver = window.__VERSION__ || '0';
|
||||
if (!window.preact) {
|
||||
var { h, render } = await import(base + '/js/sw/vendor/preact.module.js');
|
||||
var hooksModule = await import(base + '/js/sw/vendor/hooks.module.js');
|
||||
var htmModule = await import(base + '/js/sw/vendor/htm.module.js');
|
||||
window.preact = { h, render };
|
||||
window.hooks = hooksModule;
|
||||
window.html = htmModule.default.bind(h);
|
||||
}
|
||||
var sdk = await import(base + '/js/sw/sdk/index.js?v=' + ver);
|
||||
await sdk.boot();
|
||||
} catch (e) {
|
||||
console.warn('[NotesRunner] SDK boot failed:', e.message);
|
||||
}
|
||||
|
||||
window.NR = {
|
||||
base: window.__BASE__ || '',
|
||||
api: sw.api.ext('notes')
|
||||
};
|
||||
|
||||
var surfaceId = 'notes-runner';
|
||||
var assetBase = '/surfaces/' + surfaceId + '/js/';
|
||||
if (window.NR.base) assetBase = window.NR.base + assetBase;
|
||||
|
||||
var modules = [
|
||||
'notes-crud.js',
|
||||
'folders.js',
|
||||
'tags-search.js'
|
||||
];
|
||||
|
||||
var loaded = 0;
|
||||
function loadNext() {
|
||||
if (loaded >= modules.length) { onReady(); return; }
|
||||
var script = document.createElement('script');
|
||||
script.src = assetBase + modules[loaded] + '?v=' + (window.__VERSION__ || '0') + '.' + Date.now();
|
||||
script.onload = function () { loaded++; loadNext(); };
|
||||
script.onerror = function () {
|
||||
console.error('[NotesRunner] Failed to load: ' + modules[loaded]);
|
||||
loaded++; loadNext();
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function onReady() {
|
||||
console.log('[NotesRunner] All modules loaded — ' + sw.testing.suites().length + ' suites registered');
|
||||
var manifest = window.__MANIFEST__ || {};
|
||||
if (manifest.id === surfaceId) {
|
||||
window.location.href = (window.__BASE__ || '') + '/s/test-runners';
|
||||
}
|
||||
}
|
||||
|
||||
loadNext();
|
||||
})();
|
||||
63
packages/notes-runner/js/notes-crud.js
Normal file
63
packages/notes-runner/js/notes-crud.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Notes Runner — notes/crud suite
|
||||
*
|
||||
* Tests basic note CRUD operations via the Notes ext API.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var api = window.NR.api;
|
||||
|
||||
sw.testing.suite('notes/crud', async function (s) {
|
||||
var noteId;
|
||||
|
||||
s.test('create note', async function (t) {
|
||||
var r = await api.post('/notes', {
|
||||
title: 'Runner Test Note',
|
||||
body: '# Hello from notes-runner\n\nTest body content.'
|
||||
});
|
||||
t.assert.ok(r.id, 'note has id');
|
||||
t.assert.eq(r.title, 'Runner Test Note', 'title matches');
|
||||
t.assert.ok(r.body, 'body present');
|
||||
t.assert.ok(r.created_at, 'created_at present');
|
||||
noteId = r.id;
|
||||
s.track('note', noteId);
|
||||
});
|
||||
|
||||
s.test('get note by id', async function (t) {
|
||||
t.assert.ok(noteId, 'noteId from previous test');
|
||||
var r = await api.get('/notes/' + noteId);
|
||||
t.assert.eq(r.id, noteId, 'id matches');
|
||||
t.assert.eq(r.title, 'Runner Test Note', 'title matches');
|
||||
});
|
||||
|
||||
s.test('update note', async function (t) {
|
||||
t.assert.ok(noteId, 'noteId from previous test');
|
||||
var r = await api.put('/notes/' + noteId, {
|
||||
title: 'Updated Test Note',
|
||||
body: '# Updated\n\nNew body.'
|
||||
});
|
||||
t.assert.eq(r.title, 'Updated Test Note', 'title updated');
|
||||
});
|
||||
|
||||
s.test('list notes', async function (t) {
|
||||
var r = await api.get('/notes');
|
||||
t.assert.ok(Array.isArray(r), 'response is array');
|
||||
var found = r.some(function (n) { return n.id === noteId; });
|
||||
t.assert.ok(found, 'created note appears in list');
|
||||
});
|
||||
|
||||
s.test('delete note', async function (t) {
|
||||
t.assert.ok(noteId, 'noteId from previous test');
|
||||
await api.del('/notes/' + noteId);
|
||||
// Verify gone
|
||||
try {
|
||||
await api.get('/notes/' + noteId);
|
||||
t.assert.ok(false, 'expected 404 after delete');
|
||||
} catch (e) {
|
||||
t.assert.ok(true, 'note not found after delete');
|
||||
}
|
||||
noteId = null;
|
||||
});
|
||||
});
|
||||
})();
|
||||
66
packages/notes-runner/js/tags-search.js
Normal file
66
packages/notes-runner/js/tags-search.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Notes Runner — notes/tags-search suite
|
||||
*
|
||||
* Tests tags, search, and backlinks.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var api = window.NR.api;
|
||||
|
||||
sw.testing.suite('notes/tags-search', async function (s) {
|
||||
var noteA, noteB;
|
||||
|
||||
s.beforeAll(async function () {
|
||||
noteA = await api.post('/notes', {
|
||||
title: 'Tag Test A',
|
||||
body: 'First note with [[Tag Test B]] link and some searchable content: xyzzy.'
|
||||
});
|
||||
s.track('note', noteA.id);
|
||||
|
||||
noteB = await api.post('/notes', {
|
||||
title: 'Tag Test B',
|
||||
body: 'Second note — backlink target.'
|
||||
});
|
||||
s.track('note', noteB.id);
|
||||
});
|
||||
|
||||
s.test('set tags on note', async function (t) {
|
||||
await api.put('/tags/' + noteA.id, {
|
||||
tags: ['runner-test', 'integration']
|
||||
});
|
||||
var tags = await api.get('/tags/' + noteA.id);
|
||||
t.assert.ok(Array.isArray(tags), 'tags is array');
|
||||
t.assert.ok(tags.indexOf('runner-test') !== -1, 'runner-test tag present');
|
||||
t.assert.ok(tags.indexOf('integration') !== -1, 'integration tag present');
|
||||
});
|
||||
|
||||
s.test('list all tags', async function (t) {
|
||||
var tags = await api.get('/tags');
|
||||
t.assert.ok(Array.isArray(tags), 'tags is array');
|
||||
var found = tags.some(function (tag) {
|
||||
var name = typeof tag === 'string' ? tag : (tag.tag || tag.name || '');
|
||||
return name === 'runner-test';
|
||||
});
|
||||
t.assert.ok(found, 'runner-test tag appears in global list');
|
||||
});
|
||||
|
||||
s.test('search notes', async function (t) {
|
||||
var r = await api.get('/search?q=xyzzy');
|
||||
t.assert.ok(Array.isArray(r), 'search returns array');
|
||||
var found = r.some(function (n) { return n.id === noteA.id; });
|
||||
t.assert.ok(found, 'noteA found by search term');
|
||||
});
|
||||
|
||||
s.test('backlinks', async function (t) {
|
||||
var links = await api.get('/backlinks/' + noteB.id);
|
||||
t.assert.ok(Array.isArray(links), 'backlinks is array');
|
||||
if (links.length === 0) {
|
||||
t.warn('No backlinks found — wikilink resolution may not have matched by title');
|
||||
} else {
|
||||
var found = links.some(function (l) { return l.source_id === noteA.id; });
|
||||
t.assert.ok(found, 'noteA is a backlink source for noteB');
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user