Skip to content

Commit 9f238be

Browse files
committed
🧪 test(ui): close coverage gaps in composables, preferences, services, and views
- Add new specs for useOperationDisplayHold and views/containers/useContainerPolicy - Extend coverage on useContainerFilters, preferences/migrate, services/logs, services/system-log-stream, and utils/container-update - Drop unreachable short-circuit in useOperationDisplayHold.removeHeldOperation and scheduleHeldOperationRelease existing-record guard - Simplify preferences/migrate pruneResponsiveDashboardLayouts early return to undefined on the missing-key path
1 parent 72d6d68 commit 9f238be

File tree

9 files changed

+800
-10
lines changed

9 files changed

+800
-10
lines changed

‎ui/src/composables/useOperationDisplayHold.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ function setHeldOperation(operationId: string, hold: OperationDisplayHoldRecord)
2626
}
2727

2828
function removeHeldOperation(operationId: string) {
29-
if (!heldOperations.value.has(operationId)) {
30-
return;
31-
}
3229
const next = new Map(heldOperations.value);
3330
next.delete(operationId);
3431
heldOperations.value = next;
@@ -179,12 +176,7 @@ function scheduleHeldOperationRelease(args: {
179176
let scheduled = false;
180177

181178
for (const operationId of operationIds) {
182-
const existing = heldOperations.value.get(operationId);
183-
if (!existing) {
184-
continue;
185-
}
186-
187-
const nextHold = updateHoldTargets(existing, args);
179+
const nextHold = updateHoldTargets(heldOperations.value.get(operationId)!, args);
188180
setHeldOperation(operationId, nextHold);
189181

190182
const remaining = nextHold.displayUntil - (args.now ?? Date.now());

‎ui/src/preferences/migrate.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function pruneResponsiveDashboardLayouts(
5858
dashboard: Record<string, unknown>,
5959
): Record<string, unknown> | undefined {
6060
if (!('gridLayouts' in dashboard)) {
61-
return isRecord(dashboard.gridLayouts) ? dashboard.gridLayouts : undefined;
61+
return undefined;
6262
}
6363

6464
if (!isRecord(dashboard.gridLayouts)) {

‎ui/tests/composables/useContainerFilters.spec.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ describe('useContainerFilters', () => {
193193
'postgres',
194194
]);
195195
});
196+
197+
it('should filter blocked containers only when they have a newTag', async () => {
198+
const blockedWithTag = makeContainer({
199+
id: 'c4',
200+
name: 'api',
201+
image: 'api:latest',
202+
bouncer: 'blocked',
203+
newTag: '2.0',
204+
});
205+
const mod = await import('@/composables/useContainerFilters');
206+
const localContainers = ref([...containers.value, blockedWithTag]);
207+
const filters = mod.useContainerFilters(localContainers);
208+
filters.filterKind.value = 'blocked';
209+
210+
expect(filters.filteredContainers.value.map((c) => c.name)).toEqual(['api']);
211+
});
196212
});
197213

198214
describe('activeFilterCount', () => {

0 commit comments

Comments
 (0)