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