1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// delete-button.test.mjs — visibility logic for the Delete button on task cards
//
// Run with: node --test web/test/delete-button.test.mjs
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
// ── Logic under test ──────────────────────────────────────────────────────────
// A delete button should be shown for any task that is not actively executing.
// RUNNING and QUEUED tasks cannot be deleted via the API (409), so we hide the button.
const NON_DELETABLE_STATES = new Set(['RUNNING', 'QUEUED']);
function showDeleteButton(state) {
return !NON_DELETABLE_STATES.has(state);
}
// ── Tests ─────────────────────────────────────────────────────────────────────
describe('delete button visibility', () => {
it('shows for PENDING', () => {
assert.equal(showDeleteButton('PENDING'), true);
});
it('shows for COMPLETED', () => {
assert.equal(showDeleteButton('COMPLETED'), true);
});
it('shows for FAILED', () => {
assert.equal(showDeleteButton('FAILED'), true);
});
it('shows for CANCELLED', () => {
assert.equal(showDeleteButton('CANCELLED'), true);
});
it('shows for TIMED_OUT', () => {
assert.equal(showDeleteButton('TIMED_OUT'), true);
});
it('shows for BUDGET_EXCEEDED', () => {
assert.equal(showDeleteButton('BUDGET_EXCEEDED'), true);
});
it('shows for READY', () => {
assert.equal(showDeleteButton('READY'), true);
});
it('shows for BLOCKED', () => {
assert.equal(showDeleteButton('BLOCKED'), true);
});
it('hides for RUNNING', () => {
assert.equal(showDeleteButton('RUNNING'), false);
});
it('hides for QUEUED', () => {
assert.equal(showDeleteButton('QUEUED'), false);
});
});
|