Feat v0.7.2 package runners ci gate (#56)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m39s
CI/CD / test-sqlite (push) Successful in 2m55s
CI/CD / build-and-deploy (push) Successful in 29s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #56.
This commit is contained in:
2026-04-02 12:10:57 +00:00
committed by xcaliber
parent 829caa3b20
commit d6c7b21713
37 changed files with 1504 additions and 36 deletions

View 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');
});
});
})();

View 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();
})();

View 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;
});
});
})();

View 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');
}
});
});
})();