feat: annuleren taak toegevoegd

This commit is contained in:
kodi
2026-03-15 13:06:48 +01:00
parent 7d910479f9
commit a52493459a
32 changed files with 835 additions and 61 deletions
@@ -240,6 +240,8 @@ class UiSmokeGoldenTest(unittest.TestCase):
self._extract_js_function(app_js, "formatTaskLine"),
self._extract_js_function(app_js, "isActiveTask"),
self._extract_js_function(app_js, "activeTasksFromItems"),
self._extract_js_function(app_js, "taskIsCancellable"),
self._extract_js_function(app_js, "cancelTaskRequest"),
self._extract_js_function(app_js, "activeTaskChipLabel"),
self._extract_js_function(app_js, "headerTaskRenderKey"),
self._extract_js_function(app_js, "shouldPollHeaderTasks"),
@@ -289,6 +291,8 @@ class UiSmokeGoldenTest(unittest.TestCase):
textContent: "",
innerHTML: "",
children: [],
disabled: false,
onclick: null,
scrollTop: 0,
attributes: {{}},
append(...nodes) {{
@@ -329,6 +333,9 @@ class UiSmokeGoldenTest(unittest.TestCase):
return value || "now";
}}
async function refreshTasksSnapshot() {{}}
function setError() {{}}
let headerTaskState = {{
activeItems: [],
popoverOpen: false,
@@ -336,7 +343,7 @@ class UiSmokeGoldenTest(unittest.TestCase):
lastRenderKey: "",
}};
const ACTIVE_TASK_OPERATIONS = new Set(["copy", "move", "duplicate", "delete"]);
const ACTIVE_TASK_STATUSES = new Set(["queued", "running"]);
const ACTIVE_TASK_STATUSES = new Set(["queued", "running", "cancelling"]);
{functions}
@@ -347,6 +354,7 @@ class UiSmokeGoldenTest(unittest.TestCase):
{{ id: "d", operation: "download", status: "preparing", source: "/src/d", destination: "folder.zip" }},
{{ id: "dup", operation: "duplicate", status: "queued", source: "/src/dup", destination: "/dst/dup" }},
{{ id: "del", operation: "delete", status: "running", source: "/src/del", destination: "" }},
{{ id: "stop", operation: "copy", status: "cancelling", source: "/src/stop", destination: "/dst/stop" }},
{{ id: "e", operation: "copy", status: "completed", source: "/src/e", destination: "/dst/e" }},
{{ id: "f", operation: "move", status: "failed", source: "/src/f", destination: "/dst/f" }},
{{ id: "g", operation: "download", status: "ready", source: "/src/g", destination: "folder.zip" }},
@@ -354,21 +362,28 @@ class UiSmokeGoldenTest(unittest.TestCase):
];
const activeTasks = activeTasksFromItems(mixedTasks);
assert(activeTasks.length === 4, "Only task-based file actions in queued or running should count as active");
assert(activeTasks.length === 5, "Only active task-based file actions should count as active");
assert(activeTasks.every((task) => isActiveTask(task)), "All filtered tasks should be active");
assert(activeTasks.some((task) => task.operation === "delete"), "Delete should count once it uses the shared task flow");
assert(activeTaskChipLabel(activeTasks.length) === "4 active tasks", "Chip label should reflect active task count");
assert(activeTasks.some((task) => task.status === "cancelling"), "Cancelling tasks should remain visible while stopping");
assert(activeTaskChipLabel(activeTasks.length) === "5 active tasks", "Chip label should reflect active task count");
updateHeaderTaskState(mixedTasks);
assert(!elements["header-task-chip-container"].classList.contains("hidden"), "Chip should be visible with active tasks");
assert(elements["header-task-chip-label"].textContent === "4 active tasks", "Chip label should render active task count");
assert(elements["header-task-chip-label"].textContent === "5 active tasks", "Chip label should render active task count");
assert(shouldPollHeaderTasks(), "Active tasks should enable header polling");
setHeaderTaskPopoverOpen(true);
assert(headerTaskState.popoverOpen, "Popover should open when active tasks exist");
assert(!elements["header-task-popover"].classList.contains("hidden"), "Popover should be visible when open");
assert(elements["header-task-chip-btn"].attributes["aria-expanded"] === "true", "Chip button should expose expanded state");
assert(elements["header-task-popover-list"].children.length === 4, "Popover should render only active file-action tasks");
assert(elements["header-task-popover-list"].children.length === 5, "Popover should render only active file-action tasks");
const firstActionButton = elements["header-task-popover-list"].children[0].children[3].children[0];
const cancellingActionButton = elements["header-task-popover-list"].children[4].children[3].children[0];
assert(firstActionButton.textContent === "Stop", "Queued/running tasks should expose a Stop action");
assert(!firstActionButton.disabled, "Queued/running tasks should be cancellable");
assert(cancellingActionButton.textContent === "Stopping...", "Cancelling tasks should show stopping state");
assert(cancellingActionButton.disabled, "Cancelling tasks should not expose a second stop action");
updateHeaderTaskState([
{{ id: "z1", operation: "copy", status: "completed", source: "/src/z1", destination: "/dst/z1" }},
@@ -399,6 +414,8 @@ class UiSmokeGoldenTest(unittest.TestCase):
self._extract_js_function(app_js, "formatTaskLine"),
self._extract_js_function(app_js, "isActiveTask"),
self._extract_js_function(app_js, "activeTasksFromItems"),
self._extract_js_function(app_js, "taskIsCancellable"),
self._extract_js_function(app_js, "cancelTaskRequest"),
self._extract_js_function(app_js, "activeTaskChipLabel"),
self._extract_js_function(app_js, "headerTaskRenderKey"),
self._extract_js_function(app_js, "shouldPollHeaderTasks"),
@@ -449,6 +466,8 @@ class UiSmokeGoldenTest(unittest.TestCase):
textContent: "",
innerHTML: "",
children: [],
disabled: false,
onclick: null,
scrollTop: 0,
attributes: {{}},
append(...nodes) {{
@@ -489,6 +508,9 @@ class UiSmokeGoldenTest(unittest.TestCase):
return value || "now";
}}
async function refreshTasksSnapshot() {{}}
function setError() {{}}
let state = {{ lastTaskCount: 0 }};
let headerTaskState = {{
activeItems: [],
@@ -497,7 +519,7 @@ class UiSmokeGoldenTest(unittest.TestCase):
lastRenderKey: "",
}};
const ACTIVE_TASK_OPERATIONS = new Set(["copy", "move", "duplicate", "delete"]);
const ACTIVE_TASK_STATUSES = new Set(["queued", "running"]);
const ACTIVE_TASK_STATUSES = new Set(["queued", "running", "cancelling"]);
{functions}
@@ -781,11 +803,13 @@ class UiSmokeGoldenTest(unittest.TestCase):
self.assertIn('function formatTaskLine(task)', app_js)
self.assertIn('let headerTaskState = {', app_js)
self.assertIn('const ACTIVE_TASK_OPERATIONS = new Set(["copy", "move", "duplicate", "delete"]);', app_js)
self.assertIn('const ACTIVE_TASK_STATUSES = new Set(["queued", "running"]);', app_js)
self.assertIn('const ACTIVE_TASK_STATUSES = new Set(["queued", "running", "cancelling"]);', app_js)
self.assertIn("The header chip reflects only user-visible file actions that use the shared task system.", app_js)
self.assertIn('function headerTaskElements()', app_js)
self.assertIn('function isActiveTask(task)', app_js)
self.assertIn('function activeTasksFromItems(items)', app_js)
self.assertIn('function taskIsCancellable(task)', app_js)
self.assertIn('async function cancelTaskRequest(taskId)', app_js)
self.assertIn('function activeTaskChipLabel(count)', app_js)
self.assertIn('function shouldPollHeaderTasks()', app_js)
self.assertIn('function scheduleHeaderTaskPolling()', app_js)