From cc9f2963641854c372aa153f4742c47b9496730a Mon Sep 17 00:00:00 2001 From: Chris Millar Date: Wed, 3 Sep 2025 16:45:34 -0600 Subject: [PATCH] chore: fix tests to match production * Org is handled outside of the key, made mocks match reality --- src/storage/utils/list.js | 4 +--- test/storage/utils/list.test.js | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/storage/utils/list.js b/src/storage/utils/list.js index 7e9acc26..41a0996c 100644 --- a/src/storage/utils/list.js +++ b/src/storage/utils/list.js @@ -107,9 +107,7 @@ export async function listCommand(daCtx, details, s3client) { const { Contents = [], NextContinuationToken } = resp; - console.log(Contents); - - sourceKeys.push(...Contents.map(({ Key }) => Key)); + sourceKeys.push(...Contents.map(({ Key }) => Key.replace(`${daCtx.org}/`, ''))); return { sourceKeys, continuationToken: NextContinuationToken }; } diff --git a/test/storage/utils/list.test.js b/test/storage/utils/list.test.js index 12da216b..d93c6b59 100644 --- a/test/storage/utils/list.test.js +++ b/test/storage/utils/list.test.js @@ -237,7 +237,7 @@ describe('listCommand', () => { assert.strictEqual(mockS3Client.send.callCount, 1); assert.deepStrictEqual(result, { - sourceKeys: [testDaCtx.key, `${testDaCtx.key}.props`, 'adobecom/test/file1.html', 'adobecom/test/file2.html'], + sourceKeys: [testDaCtx.key, `${testDaCtx.key}.props`, 'test/file1.html', 'test/file2.html'], continuationToken: 'next-token' }); }); @@ -260,7 +260,7 @@ describe('listCommand', () => { // The command should have the continuation token assert.strictEqual(callArgs.input.ContinuationToken, 'prev-token'); assert.deepStrictEqual(result, { - sourceKeys: ['adobecom/test/file3.html'], + sourceKeys: ['test/file3.html'], continuationToken: undefined }); }); @@ -283,7 +283,7 @@ describe('listCommand', () => { it('should handle response without NextContinuationToken', async () => { const mockResponse = { Contents: [ - { Key: 'adobecom/test/file1.html' } + { Key: 'test/file1.html' } ] }; @@ -292,7 +292,7 @@ describe('listCommand', () => { const result = await listCommand(testDaCtx, {}, mockS3Client); assert.deepStrictEqual(result, { - sourceKeys: [testDaCtx.key, `${testDaCtx.key}.props`, 'adobecom/test/file1.html'], + sourceKeys: [testDaCtx.key, `${testDaCtx.key}.props`, 'test/file1.html'], continuationToken: undefined }); });