All checks were successful
CI/CD / detect-changes (pull_request) Successful in 23s
CI/CD / test-frontend (pull_request) Successful in 26s
CI/CD / test-go-pg (pull_request) Successful in 2m35s
CI/CD / test-sqlite (pull_request) Successful in 3m19s
CI/CD / build-and-deploy (pull_request) Successful in 1m46s
sw.testing SDK module — structured test framework for surface runners: - suite/test registration, lifecycle hooks (beforeAll/afterAll/beforeEach/afterEach) - Assertion library (ok/eq/neq/gt/match/throws/status/shape/arrayOf) - Auto-cleanup via track(type, id) with LIFO deletion - Three result statuses: passed/failed/warned - Structured JSON results with timing, warnings, cleanup stats test-runner manifest type: - ValidateManifest accepts "test-runner" packages - Excluded from sidebar nav (extensionNavItems filters surface/full only) - DB migrations: SQLite 013, Postgres 014 (CHECK constraint) ICD runner migration (kernel-only): - Migrated from T.test()/T.assert() to sw.testing.suite() - Stripped extension-dependent tests (channels, notes, personas, etc.) - Kernel suites: smoke, crud, authz, security, providers, packaging, sdk - Deleted ui.js + css (rendering delegated to registry surface) SDK runner migration (kernel-only): - Migrated from T.dualTest()/T.domains to sw.testing.suite() - Stripped extension domains (belong in v0.7.2 package runners) - Kernel suites: misc, workflows, admin, packages, connections, deps, composition Runner registry surface (/s/test-runners): - Admin-only dashboard discovering test-runner packages - Run All / per-runner Run buttons, real-time results - Export Failures / Export Full Results (JSON download) - Dark mode styling using kernel CSS variables - Suite count polling for async runner script loading 141 passed, 0 failed on fresh minimal install. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
134 lines
5.3 KiB
JavaScript
134 lines
5.3 KiB
JavaScript
/**
|
|
* SDK Test Runner — Domain: connections (v0.38.1)
|
|
*
|
|
* Tests extension connection CRUD and scope resolution.
|
|
* Requires admin role (global connection CRUD).
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
var T = window.SDKR;
|
|
if (!T) return;
|
|
|
|
sw.testing.suite('sdk/connections', async function (s) {
|
|
|
|
if (!window.sw || !sw.isAdmin) {
|
|
s.test('guard: skip — not admin', async function (t) {
|
|
T.assert(true, 'skipped (user is not admin)');
|
|
});
|
|
return;
|
|
}
|
|
|
|
var globalId = null;
|
|
var personalId = null;
|
|
|
|
// ── Global CRUD ──────────────────────────
|
|
|
|
s.test('admin-create: create global connection', async function (t) {
|
|
var r = await sw.api.admin.connections.create({
|
|
type: 'sdk-test-conn',
|
|
package_id: 'sdk-test-pkg',
|
|
name: 'Global Test',
|
|
config: { base_url: 'https://test.example.com', org: 'test-org' }
|
|
});
|
|
T.assert(r && r.id, 'should return id');
|
|
T.assert(r.type === 'sdk-test-conn', 'type matches');
|
|
globalId = r.id;
|
|
});
|
|
|
|
T.cleanup.push(async function () {
|
|
if (globalId) try { await sw.api.admin.connections.del(globalId); } catch (_) {}
|
|
});
|
|
|
|
s.test('admin-list: list global connections includes created', async function (t) {
|
|
var r = await sw.api.admin.connections.list();
|
|
T.assert(Array.isArray(r), 'should be array');
|
|
var found = r.find(function (c) { return c.id === globalId; });
|
|
T.assert(found, 'created connection should be in list');
|
|
T.assert(found.type === 'sdk-test-conn', 'type matches');
|
|
T.assert(found.name === 'Global Test', 'name matches');
|
|
});
|
|
|
|
s.test('admin-update: update global connection', async function (t) {
|
|
await sw.api.admin.connections.update(globalId, { name: 'Global Test Updated' });
|
|
var list = await sw.api.admin.connections.list();
|
|
var found = list.find(function (c) { return c.id === globalId; });
|
|
T.assert(found && found.name === 'Global Test Updated', 'name should be updated');
|
|
});
|
|
|
|
// ── Personal CRUD ────────────────────────
|
|
|
|
s.test('personal-create: create personal connection', async function (t) {
|
|
var r = await sw.api.connections.create({
|
|
type: 'sdk-test-conn',
|
|
package_id: 'sdk-test-pkg',
|
|
name: 'Personal Test',
|
|
config: { base_url: 'https://personal.example.com' }
|
|
});
|
|
T.assert(r && r.id, 'should return id');
|
|
personalId = r.id;
|
|
});
|
|
|
|
T.cleanup.push(async function () {
|
|
if (personalId) try { await sw.api.connections.del(personalId); } catch (_) {}
|
|
});
|
|
|
|
s.test('personal-list: list personal connections', async function (t) {
|
|
var r = await sw.api.connections.list();
|
|
T.assert(Array.isArray(r), 'should be array');
|
|
var found = r.find(function (c) { return c.id === personalId; });
|
|
T.assert(found, 'personal connection in list');
|
|
});
|
|
|
|
// ── Scope Resolution ─────────────────────
|
|
|
|
s.test('resolve-prefers-personal: resolve prefers personal over global', async function (t) {
|
|
var r = await sw.api.connections.resolve('sdk-test-conn');
|
|
T.assert(r && r.id, 'should resolve');
|
|
// Personal scope should win over global
|
|
T.assert(r.scope === 'personal', 'should resolve personal scope first');
|
|
T.assert(r.id === personalId, 'should be the personal connection');
|
|
});
|
|
|
|
s.test('resolve-by-name: resolve by name returns specific connection', async function (t) {
|
|
var r = await sw.api.connections.resolve('sdk-test-conn', 'Global Test Updated');
|
|
T.assert(r && r.id, 'should resolve');
|
|
T.assert(r.id === globalId, 'should match global connection by name');
|
|
});
|
|
|
|
// ── Connection Type Discovery (v0.38.4) ──
|
|
|
|
s.test('types-list: GET /connection-types returns array', async function (t) {
|
|
var r = await sw.api.connectionTypes.list();
|
|
T.assert(Array.isArray(r), 'should be array');
|
|
});
|
|
|
|
s.test('types-include-sdk-test: connection types include sdk-test-conn from global conn', async function (t) {
|
|
// The global connection we created above references package_id sdk-test-pkg
|
|
// but that package may not exist. The endpoint scans active package manifests,
|
|
// so this test verifies the endpoint returns without error. Actual type matching
|
|
// is tested in the composition domain with a real library.
|
|
var r = await sw.api.connectionTypes.list();
|
|
T.assert(Array.isArray(r), 'should be array (may be empty if no packages declare connections)');
|
|
});
|
|
|
|
// ── Cleanup ──────────────────────────────
|
|
|
|
s.test('personal-delete: delete personal connection', async function (t) {
|
|
await sw.api.connections.del(personalId);
|
|
var list = await sw.api.connections.list();
|
|
var found = list.find(function (c) { return c.id === personalId; });
|
|
T.assert(!found, 'should be deleted');
|
|
personalId = null;
|
|
});
|
|
|
|
s.test('admin-delete: delete global connection', async function (t) {
|
|
await sw.api.admin.connections.del(globalId);
|
|
var list = await sw.api.admin.connections.list();
|
|
var found = list.find(function (c) { return c.id === globalId; });
|
|
T.assert(!found, 'should be deleted');
|
|
globalId = null;
|
|
});
|
|
|
|
});
|
|
})();
|