diff --git a/client/src/components/User/DiskUsage/Management/Cleanup/CleanupOperationSummary.test.ts b/client/src/components/User/DiskUsage/Management/Cleanup/CleanupOperationSummary.test.ts index ea56e1bb0731..dd6ef1ec9e0e 100644 --- a/client/src/components/User/DiskUsage/Management/Cleanup/CleanupOperationSummary.test.ts +++ b/client/src/components/User/DiskUsage/Management/Cleanup/CleanupOperationSummary.test.ts @@ -2,13 +2,18 @@ import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { getLocalVue } from "@tests/jest/helpers"; import CleanupOperationSummary from "./CleanupOperationSummary.vue"; -import { CleanableSummary, type CleanupOperation, CleanupResult } from "./model"; +import { CleanableSummary, type CleanupOperation, CleanupResult, type CleanableItem } from "./model"; const localVue = getLocalVue(); const REVIEW_ITEMS_LINK = '[data-test-id="review-link"]'; const NO_ITEMS_INDICATOR = '[data-test-id="no-items-indicator"]'; +const EXPECTED_ITEMS: CleanableItem[] = [ + { id: "1", name: "Item 1", size: 512, type: "dataset", update_time: new Date().toISOString() }, + { id: "2", name: "Item 2", size: 512, type: "dataset", update_time: new Date().toISOString() }, +]; + /** Operation that can clean some items */ const CLEANUP_OPERATION: CleanupOperation = { id: "operation-id", @@ -16,16 +21,20 @@ const CLEANUP_OPERATION: CleanupOperation = { description: "operation description", fetchSummary: async () => new CleanableSummary({ - totalSize: 1024, - totalItems: 2, + total_size: 1024, + total_items: 2, }), fetchItems: async () => [], cleanupItems: async () => - new CleanupResult({ - totalItemCount: 2, - totalFreeBytes: 1024, - errors: [], - }), + new CleanupResult( + { + total_item_count: 2, + success_item_count: 2, + total_free_bytes: 1024, + errors: [], + }, + EXPECTED_ITEMS + ), }; /** Operation without items to clean*/ const EMPTY_CLEANUP_OPERATION: CleanupOperation = { @@ -34,8 +43,8 @@ const EMPTY_CLEANUP_OPERATION: CleanupOperation = { description: "operation that has no items to clean", fetchSummary: async () => new CleanableSummary({ - totalSize: 0, - totalItems: 0, + total_size: 0, + total_items: 0, }), fetchItems: async () => [], cleanupItems: async () => new CleanupResult(), diff --git a/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.test.ts b/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.test.ts index c556f9e15826..e36462251f83 100644 --- a/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.test.ts +++ b/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.test.ts @@ -2,7 +2,7 @@ import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; import CleanupResultDialog from "./CleanupResultDialog.vue"; -import { CleanupResult } from "./model"; +import { CleanupResult, type CleanableItem } from "./model"; const localVue = getLocalVue(); @@ -14,25 +14,41 @@ const ERRORS_TABLE = '[data-test-id="errors-table"]'; const NO_RESULT_YET = undefined; const FAILED_RESULT = () => { - return new CleanupResult({ - errorMessage: "The operation failed", - totalFreeBytes: 0, - totalItemCount: 0, - errors: [], - }); + return new CleanupResult( + { + total_item_count: 0, + errors: [], + success_item_count: 0, + total_free_bytes: 0, + }, + [], + "The operation failed" + ); }; +const TEST_ITEMS: CleanableItem[] = [ + { id: "1", name: "Dataset X", size: 512, type: "dataset", update_time: new Date().toISOString() }, + { id: "2", name: "Dataset Y", size: 512, type: "dataset", update_time: new Date().toISOString() }, + { id: "3", name: "Dataset Z", size: 512, type: "dataset", update_time: new Date().toISOString() }, +]; const PARTIAL_SUCCESS_RESULT = () => { - return new CleanupResult({ - totalItemCount: 3, - totalFreeBytes: 1, - errors: [ - { name: "Dataset X", reason: "Failed because of X" }, - { name: "Dataset Y", reason: "Failed because of Y" }, - ], - }); + return new CleanupResult( + { + total_item_count: 3, + success_item_count: 1, + total_free_bytes: 512, + errors: [ + { item_id: "1", error: "Failed because of X" }, + { item_id: "2", error: "Failed because of Y" }, + ], + }, + TEST_ITEMS + ); }; const SUCCESS_RESULT = () => { - return new CleanupResult({ totalItemCount: 2, totalFreeBytes: 2, errors: [] }); + return new CleanupResult( + { total_item_count: 3, success_item_count: 3, total_free_bytes: 512 * 3, errors: [] }, + TEST_ITEMS + ); }; async function mountCleanupResultDialogWith(result?: CleanupResult) { const wrapper = mount(CleanupResultDialog, { propsData: { result, show: true }, localVue }); diff --git a/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.vue b/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.vue index fe6e1e90844a..ad473d87af35 100644 --- a/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.vue +++ b/client/src/components/User/DiskUsage/Management/Cleanup/CleanupResultDialog.vue @@ -2,6 +2,7 @@ import localize from "@/utils/localization"; import { computed, ref } from "vue"; import type { CleanupResult } from "./model"; +import Alert from "components/Alert.vue"; interface CleanupResultDialogProps { result?: CleanupResult; @@ -46,6 +47,9 @@ defineExpose({