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
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:
59
packages/chat-runner/js/conversations.js
Normal file
59
packages/chat-runner/js/conversations.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Chat Runner — chat/conversations suite
|
||||
*
|
||||
* Tests conversation CRUD via the chat-core ext API.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var api = window.CR.api;
|
||||
|
||||
sw.testing.suite('chat/conversations', async function (s) {
|
||||
var convId;
|
||||
|
||||
s.test('create conversation', async function (t) {
|
||||
var r = await api.post('/conversations', {
|
||||
title: 'Runner Test Convo ' + Date.now(),
|
||||
type: 'direct'
|
||||
});
|
||||
t.assert.ok(r.id, 'conversation has id');
|
||||
t.assert.ok(r.title, 'conversation has title');
|
||||
convId = r.id;
|
||||
s.track('conversation', convId);
|
||||
});
|
||||
|
||||
s.test('get conversation', async function (t) {
|
||||
t.assert.ok(convId, 'convId from previous test');
|
||||
var r = await api.get('/conversations/' + convId);
|
||||
t.assert.eq(r.id, convId, 'id matches');
|
||||
});
|
||||
|
||||
s.test('update conversation', async function (t) {
|
||||
t.assert.ok(convId, 'convId from previous test');
|
||||
var r = await api.put('/conversations/' + convId, {
|
||||
title: 'Updated Convo Title'
|
||||
});
|
||||
t.assert.eq(r.title, 'Updated Convo Title', 'title updated');
|
||||
});
|
||||
|
||||
s.test('list conversations', async function (t) {
|
||||
var r = await api.get('/conversations');
|
||||
var list = Array.isArray(r) ? r : (r.data || []);
|
||||
t.assert.ok(Array.isArray(list), 'response is array');
|
||||
var found = list.some(function (c) { return c.id === convId; });
|
||||
t.assert.ok(found, 'created conversation in list');
|
||||
});
|
||||
|
||||
s.test('delete conversation', async function (t) {
|
||||
t.assert.ok(convId, 'convId from previous test');
|
||||
await api.del('/conversations/' + convId);
|
||||
try {
|
||||
await api.get('/conversations/' + convId);
|
||||
t.assert.ok(false, 'expected error after delete');
|
||||
} catch (e) {
|
||||
t.assert.ok(true, 'conversation not found after delete');
|
||||
}
|
||||
convId = null;
|
||||
});
|
||||
});
|
||||
})();
|
||||
63
packages/chat-runner/js/main.js
Normal file
63
packages/chat-runner/js/main.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Chat 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('[ChatRunner] SDK boot failed:', e.message);
|
||||
}
|
||||
|
||||
window.CR = {
|
||||
base: window.__BASE__ || '',
|
||||
api: sw.api.ext('chat-core')
|
||||
};
|
||||
|
||||
var surfaceId = 'chat-runner';
|
||||
var assetBase = '/surfaces/' + surfaceId + '/js/';
|
||||
if (window.CR.base) assetBase = window.CR.base + assetBase;
|
||||
|
||||
var modules = [
|
||||
'conversations.js',
|
||||
'messaging.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('[ChatRunner] Failed to load: ' + modules[loaded]);
|
||||
loaded++; loadNext();
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function onReady() {
|
||||
console.log('[ChatRunner] 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();
|
||||
})();
|
||||
60
packages/chat-runner/js/messaging.js
Normal file
60
packages/chat-runner/js/messaging.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Chat Runner — chat/messaging suite
|
||||
*
|
||||
* Tests message CRUD and search within conversations.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var api = window.CR.api;
|
||||
|
||||
sw.testing.suite('chat/messaging', async function (s) {
|
||||
var convId, msgId;
|
||||
|
||||
s.beforeAll(async function () {
|
||||
var r = await api.post('/conversations', {
|
||||
title: 'Messaging Test ' + Date.now(),
|
||||
type: 'direct'
|
||||
});
|
||||
convId = r.id;
|
||||
s.track('conversation', convId);
|
||||
});
|
||||
|
||||
s.test('send message', async function (t) {
|
||||
var r = await api.post('/messages/' + convId, {
|
||||
content: 'Hello from chat-runner test!',
|
||||
content_type: 'text'
|
||||
});
|
||||
t.assert.ok(r.id, 'message has id');
|
||||
t.assert.ok(r.content, 'message has content');
|
||||
msgId = r.id;
|
||||
});
|
||||
|
||||
s.test('list messages', async function (t) {
|
||||
var r = await api.get('/messages/' + convId);
|
||||
var list = Array.isArray(r) ? r : (r.data || r.messages || []);
|
||||
t.assert.ok(Array.isArray(list), 'messages is array');
|
||||
t.assert.ok(list.length > 0, 'at least one message');
|
||||
var found = list.some(function (m) { return m.id === msgId; });
|
||||
t.assert.ok(found, 'sent message appears in list');
|
||||
});
|
||||
|
||||
s.test('search conversations', async function (t) {
|
||||
var r = await api.get('/search?q=chat-runner');
|
||||
var list = Array.isArray(r) ? r : (r.data || r.conversations || r.results || []);
|
||||
t.assert.ok(Array.isArray(list), 'search returns array');
|
||||
if (list.length === 0) {
|
||||
t.warn('Search returned empty — may need time for indexing');
|
||||
}
|
||||
});
|
||||
|
||||
s.test('mark read', async function (t) {
|
||||
try {
|
||||
await api.post('/read/' + convId, {});
|
||||
t.assert.ok(true, 'mark read succeeded');
|
||||
} catch (e) {
|
||||
t.warn('mark read failed: ' + e.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user