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>
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
/**
|
|
* 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;
|
|
});
|
|
});
|
|
})();
|