Fix unit tests

This commit is contained in:
Laurent Nguyen 2024-08-22 14:24:44 +02:00
parent c9398e303b
commit a2556dad06
2 changed files with 52 additions and 1139 deletions

View File

@ -486,7 +486,7 @@ export const buildQuery = (
filter, filter,
partitionKeyProperties, partitionKeyProperties,
partitionKey, partitionKey,
additionalField.filter((f) => !f.startsWith("/")), additionalField?.filter((f) => !f.startsWith("/")) || [],
); );
}; };
@ -987,15 +987,15 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
const deletePromise = !isPreferredApiMongoDB const deletePromise = !isPreferredApiMongoDB
? _deleteNoSqlDocuments(_collection, toDeleteDocumentIds) ? _deleteNoSqlDocuments(_collection, toDeleteDocumentIds)
: MongoProxyClient.deleteDocuments( : MongoProxyClient.deleteDocuments(
_collection.databaseId, _collection.databaseId,
_collection as ViewModels.Collection, _collection as ViewModels.Collection,
toDeleteDocumentIds, toDeleteDocumentIds,
).then(({ deletedCount, isAcknowledged }) => { ).then(({ deletedCount, isAcknowledged }) => {
if (deletedCount === toDeleteDocumentIds.length && isAcknowledged) { if (deletedCount === toDeleteDocumentIds.length && isAcknowledged) {
return toDeleteDocumentIds; return toDeleteDocumentIds;
} }
throw new Error(`Delete failed with deletedCount: ${deletedCount} and isAcknowledged: ${isAcknowledged}`); throw new Error(`Delete failed with deletedCount: ${deletedCount} and isAcknowledged: ${isAcknowledged}`);
}); });
return deletePromise return deletePromise
.then( .then(
@ -1068,8 +1068,8 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
? `the selected ${selectedRows.size} items` ? `the selected ${selectedRows.size} items`
: "the selected item" : "the selected item"
: isPlural : isPlural
? `the selected ${selectedRows.size} documents` ? `the selected ${selectedRows.size} documents`
: "the selected document"; : "the selected document";
const msg = `Are you sure you want to delete ${documentName}?`; const msg = `Are you sure you want to delete ${documentName}?`;
useDialog useDialog