From ad12458774719982a9db6eea4bea15af60ddabe9 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 4 Feb 2025 07:50:39 +0530 Subject: [PATCH] Tweak --- web/apps/photos/tests/upload.test.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/web/apps/photos/tests/upload.test.ts b/web/apps/photos/tests/upload.test.ts index 5707634715..b9f77682ed 100644 --- a/web/apps/photos/tests/upload.test.ts +++ b/web/apps/photos/tests/upload.test.ts @@ -137,14 +137,14 @@ export async function testUpload() { const jsonString = process.env.NEXT_PUBLIC_ENTE_TEST_EXPECTED_JSON; if (!jsonString) { - throw Error( - "Please specify the NEXT_PUBLIC_ENTE_TEST_EXPECTED_JSON to run the upload tests", + console.warn( + "Not running upload tests. Please specify the NEXT_PUBLIC_ENTE_TEST_EXPECTED_JSON to run the upload tests", ); + return; } + const expectedState = JSON.parse(jsonString); - if (!expectedState) { - throw Error("upload test failed expectedState missing"); - } + if (!expectedState) throw Error("Invalid JSON"); try { await totalCollectionCountCheck(expectedState); @@ -426,28 +426,26 @@ function parseDateTimeFromFileNameTest() { } const fileNameToJSONMappingTests = () => { - fileNameToJSONMappingCases.forEach(({ filename, jsonFilename }) => { + for (const { filename, jsonFilename } of fileNameToJSONMappingCases) { const jsonKey = metadataJSONMapKeyForJSON(0, jsonFilename); // This duplicates somewhat the logic in takeout.ts:matchTakeoutMetadata() const components = getFileNameComponents(filename); let fileKey = getMetadataJSONMapKeyForFile(0, components); - if (fileKey !== jsonKey) { + if (fileKey != jsonKey) { fileKey = getClippedMetadataJSONMapKeyForFile(0, components); } - if (fileKey !== jsonKey) { + if (fileKey != jsonKey) { fileKey = getSupplementaryMetadataJSONMapKeyForFile(0, components); } - if (fileKey !== jsonKey) { + if (fileKey != jsonKey) { throw Error( - `mappingFileAndJSONFileCheck failed ❌ , - for ${filename} - expected: ${jsonKey} got: ${fileKey}`, + `fileNameToJSONMappingTests failed ❌ for ${filename} (expected: ${jsonKey} got: ${fileKey})`, ); } - }); - console.log("mappingFileAndJSONFileCheck passed ✅"); + } + console.log("fileNameToJSONMappingTests passed ✅"); }; // format: YYYY-MM-DD HH:MM:SS