60 lines
2.8 KiB
JavaScript
60 lines
2.8 KiB
JavaScript
// Dewey's four proof tests for row 63 round 1 (#1556). Appended to the end of
|
|
// packages/tasks/tests/verbs.test.mjs in a scratch copy of candidate ec28d736, they pass
|
|
// there and kill the five mutants that survived the packet's tests (mutants.txt). They use
|
|
// that file's own tree(), task(), refusedWith, TREE, world, assert and FakeVikunja. Take,
|
|
// rename or rewrite them as you like.
|
|
const treeWith = async (t, extra) => {
|
|
const w = await world(t, { ...TREE, ...extra });
|
|
const child = w.fake.project('Child', w.owner, { parent: w.project });
|
|
const board = w.fake.install(child);
|
|
await w.adapter.start('demo');
|
|
assert.equal(w.adapter.status()[0].state, 'ready', w.adapter.status()[0].refused);
|
|
return { w, child, board };
|
|
};
|
|
test('DEWEY a child verb and a child create record their final read', async (t) => {
|
|
const { w, child } = await tree(t);
|
|
const pm = w.agent('pm');
|
|
const made = await task(w, { project: child });
|
|
assert.notEqual(w.snapshots(made.task_ref).at(-1).etag, null);
|
|
await w.call(pm, 'task.assign', { task_ref: made.task_ref, role: 'coder' });
|
|
assert.notEqual(w.snapshots(made.task_ref).at(-1).etag, null);
|
|
});
|
|
test('DEWEY a child create whose final read fails records the child todo bucket', async (t) => {
|
|
const fake = new FakeVikunja();
|
|
let armed = false;
|
|
const fetch = async (url, init = {}) => {
|
|
const res = await fake.fetch(url, init);
|
|
if (armed && (init.method ?? 'GET') === 'POST' && /\/projects\/\d+\/tasks$/.test(new URL(url).pathname)) {
|
|
armed = false;
|
|
fake.fault('GET', /^\/tasks\/\d+$/, 0);
|
|
}
|
|
return res;
|
|
};
|
|
const { w, child, board } = await treeWith(t, { fake, fetch });
|
|
w.agent('pm');
|
|
armed = true;
|
|
const r = await task(w, { project: child });
|
|
assert.equal(w.snapshots(r.task_ref).at(-1).fields.bucket, board.buckets.todo);
|
|
});
|
|
test('DEWEY a lost answer in the child settles on the child board', async (t) => {
|
|
const { w, child } = await tree(t);
|
|
const pm = w.agent('pm');
|
|
const coder = w.agent('coder');
|
|
const { task_ref } = await task(w, { project: child });
|
|
await w.call(pm, 'task.assign', { task_ref, role: 'coder' });
|
|
w.fake.fault('PUT', /\/buckets\/\d+\/tasks$/, 500, { apply: true });
|
|
await w.call(coder, 'task.update.assigned', { task_ref, state: 'in-progress' });
|
|
assert.equal(w.events('task.state').length, 1);
|
|
});
|
|
test('DEWEY every related task is read, not only the first', async (t) => {
|
|
const { w, child } = await tree(t);
|
|
const pm = w.agent('pm');
|
|
const root = await task(w);
|
|
const other = await task(w);
|
|
const id = Number(other.task_ref.split('/')[1]);
|
|
await assert.rejects(
|
|
w.call(pm, 'task.schedule', { task_ref: root.task_ref, relations: { add: [{ kind: 'related', task_ref: other.task_ref }, { kind: 'blocking', task_ref: `vikunja:${child}/${id}` }] } }),
|
|
refusedWith('task-moved'),
|
|
);
|
|
});
|