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