From 551c6f312f918ed4829644727c27f9ffaab6494d Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Tue, 30 Sep 2025 13:53:34 +0530 Subject: [PATCH 1/7] fix: update data-access --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4d9b62f6c..1baca42c2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "build": "hedy -v --test-bundle", "deploy": "hedy -v --deploy --aws-deploy-bucket=spacecat-prod-deploy --pkgVersion=latest", "deploy-stage": "hedy -v --deploy --aws-deploy-bucket=spacecat-stage-deploy --pkgVersion=latest", - "deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l latest --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h --aws-api vldld6qz1d", + "deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l sandsinh --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h --aws-api vldld6qz1d", "deploy-secrets": "hedy --aws-update-secrets --params-file=secrets/secrets.env", "docs": "npm run docs:lint && npm run docs:build", "docs:build": "npx @redocly/cli build-docs -o ./docs/index.html --config docs/openapi/redocly-config.yaml", @@ -74,7 +74,7 @@ "@adobe/spacecat-helix-content-sdk": "1.4.23", "@adobe/spacecat-shared-athena-client": "1.3.4", "@adobe/spacecat-shared-brand-client": "1.1.23", - "@adobe/spacecat-shared-data-access": "2.64.1", + "@adobe/spacecat-shared-data-access": "https://gitpkg.now.sh/adobe/spacecat-shared/packages/spacecat-shared-data-access?SITES-35629", "@adobe/spacecat-shared-gpt-client": "1.6.4", "@adobe/spacecat-shared-http-utils": "1.17.3", "@adobe/spacecat-shared-ims-client": "1.8.12", From 00585ec8ee329b22989bcbd06e25ea4c38b50f49 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Tue, 30 Sep 2025 14:03:03 +0530 Subject: [PATCH 2/7] fix: update package lock --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0d7d0e209..5b6ba9c50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@adobe/spacecat-helix-content-sdk": "1.4.23", "@adobe/spacecat-shared-athena-client": "1.3.4", "@adobe/spacecat-shared-brand-client": "1.1.23", - "@adobe/spacecat-shared-data-access": "2.64.4", + "@adobe/spacecat-shared-data-access": "https://gitpkg.now.sh/adobe/spacecat-shared/packages/spacecat-shared-data-access?SITES-35629", "@adobe/spacecat-shared-gpt-client": "1.6.4", "@adobe/spacecat-shared-http-utils": "1.17.5", "@adobe/spacecat-shared-ims-client": "1.8.12", @@ -9255,9 +9255,9 @@ } }, "node_modules/@adobe/spacecat-shared-data-access": { - "version": "2.64.4", - "resolved": "https://registry.npmjs.org/@adobe/spacecat-shared-data-access/-/spacecat-shared-data-access-2.64.4.tgz", - "integrity": "sha512-5uE4pDQlDjS49nh05EqpCZ+67Gwk3mz3zrGNGLrTaS2DUnSFeEhCEHkpOrH1KgAx5+ao7FJlu6cOili1EmaadQ==", + "version": "2.65.0", + "resolved": "https://gitpkg.now.sh/adobe/spacecat-shared/packages/spacecat-shared-data-access?SITES-35629", + "integrity": "sha512-+Spw34U/R5hnLCWmk+eTnI7jPGcPKhM+6rZ4iqlxZzQLhR3WJTwrCKCPJvsIJ2MaEY47kHkeUVwcgW8TDJXaMA==", "license": "Apache-2.0", "dependencies": { "@adobe/spacecat-shared-utils": "1.49.0", From cc319a5e9bd37ddd5b0d78fabea85ec202a4d9b0 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Tue, 30 Sep 2025 14:40:43 +0530 Subject: [PATCH 3/7] fix: update stub --- test/controllers/sites.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/controllers/sites.test.js b/test/controllers/sites.test.js index 37d1f7a6d..320813a05 100644 --- a/test/controllers/sites.test.js +++ b/test/controllers/sites.test.js @@ -39,6 +39,7 @@ describe('Sites Controller', () => { info: sandbox.stub(), error: sandbox.stub(), warn: sandbox.stub(), + debug: sandbox.stub(), }; const SITE_IDS = ['0b4dcf79-fe5f-410b-b11f-641f0bf56da3', 'c4420c67-b4e8-443d-b7ab-0099cfd5da20']; From 4ec6c62b923d1ebc9ed7ca6f1f3091d08c06234b Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Wed, 1 Oct 2025 09:47:36 +0530 Subject: [PATCH 4/7] fix: updates the dto --- src/dto/fix.js | 3 +- test/controllers/fixes.test.js | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/dto/fix.js b/src/dto/fix.js index 632c812e8..a71edeb27 100644 --- a/src/dto/fix.js +++ b/src/dto/fix.js @@ -39,11 +39,12 @@ export const FixDto = { opportunityId: fix.getOpportunityId(), type: fix.getType(), createdAt: fix.getCreatedAt(), - executedBy: fix.getExecutedAt(), + executedBy: fix.getExecutedBy(), executedAt: fix.getExecutedAt(), publishedAt: fix.getPublishedAt(), changeDetails: fix.getChangeDetails(), status: fix.getStatus(), + origin: fix.getOrigin(), }; }, }; diff --git a/test/controllers/fixes.test.js b/test/controllers/fixes.test.js index 4df3a78a7..5d64877de 100644 --- a/test/controllers/fixes.test.js +++ b/test/controllers/fixes.test.js @@ -1001,12 +1001,67 @@ describe('Fixes Controller', () => { }); }); }); + + describe('FixDto', () => { + it('serializes fix entity with origin field', async () => { + const fixData = { + type: Suggestion.TYPES.CONTENT_UPDATE, + opportunityId, + changeDetails: { arbitrary: 'test value' }, + origin: FixEntity.ORIGINS.ASO, + status: FixEntity.STATUSES.DEPLOYED, + executedBy: 'test-user', + executedAt: '2025-05-19T01:23:45.678Z', + publishedAt: '2025-05-19T02:23:45.678Z', + }; + + const fix = await fixEntityCollection.create(fixData); + const serialized = FixDto.toJSON(fix); + + expect(serialized).to.include.keys([ + 'id', + 'opportunityId', + 'type', + 'createdAt', + 'executedBy', + 'executedAt', + 'publishedAt', + 'changeDetails', + 'status', + 'origin', + ]); + + expect(serialized.origin).to.equal(FixEntity.ORIGINS.ASO); + expect(serialized.status).to.equal(FixEntity.STATUSES.DEPLOYED); + expect(serialized.type).to.equal(Suggestion.TYPES.CONTENT_UPDATE); + expect(serialized.opportunityId).to.equal(opportunityId); + expect(serialized.changeDetails).to.deep.equal({ arbitrary: 'test value' }); + expect(serialized.executedBy).to.equal('test-user'); + expect(serialized.executedAt).to.equal('2025-05-19T01:23:45.678Z'); + expect(serialized.publishedAt).to.equal('2025-05-19T02:23:45.678Z'); + }); + + it('serializes fix entity with default origin when not specified', async () => { + const fixData = { + type: Suggestion.TYPES.METADATA_UPDATE, + opportunityId, + changeDetails: { arbitrary: 'default test' }, + }; + + const fix = await fixEntityCollection.create(fixData); + const serialized = FixDto.toJSON(fix); + + expect(serialized.origin).to.equal(FixEntity.ORIGINS.SPACECAT); + expect(serialized.status).to.equal(FixEntity.STATUSES.PENDING); + }); + }); }); const ISO_DATE = '2025-05-19T01:23:45.678Z'; function fakeCreateFix(data) { data.fixEntityId ??= crypto.randomUUID(); data.status ??= FixEntity.STATUSES.PENDING; + data.origin ??= FixEntity.ORIGINS.SPACECAT; data.changeDetails ??= { arbitrary: 'details' }; data.createdAt ??= ISO_DATE; data.executedAt ??= ISO_DATE; From 2bd0646842ddfe1e5af3cb98f8b56326cceb1c71 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Wed, 1 Oct 2025 10:09:57 +0530 Subject: [PATCH 5/7] fix: update patch controller --- src/controllers/fixes.js | 7 ++++++- test/controllers/fixes.test.js | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/controllers/fixes.js b/src/controllers/fixes.js index fcc8eed7e..2d7cfa60b 100644 --- a/src/controllers/fixes.js +++ b/src/controllers/fixes.js @@ -315,7 +315,7 @@ export class FixesController { } const { - executedBy, executedAt, publishedAt, changeDetails, suggestionIds, + executedBy, executedAt, publishedAt, changeDetails, suggestionIds, origin, } = context.data; const Suggestion = this.#Suggestion; @@ -353,6 +353,11 @@ export class FixesController { hasUpdates = true; } + if (origin !== fix.getOrigin() && hasText(origin)) { + fix.setOrigin(origin); + hasUpdates = true; + } + if (hasUpdates) { return ok(FixDto.toJSON(await fix.save())); } else { diff --git a/test/controllers/fixes.test.js b/test/controllers/fixes.test.js index 5d64877de..e8cc80c27 100644 --- a/test/controllers/fixes.test.js +++ b/test/controllers/fixes.test.js @@ -848,6 +848,27 @@ describe('Fixes Controller', () => { expect(new Set(await fix.getSuggestions())).deep.equals(new Set(suggestions)); }); + it('can patch a fix origin field', async () => { + const suggestions = await Promise.all([ + createSuggestion({ type: 'CONTENT_UPDATE' }), + createSuggestion({ type: 'METADATA_UPDATE' }), + ]); + + const newOrigin = FixEntity.ORIGINS.ASO; + requestContext.data = { + origin: newOrigin, + suggestionIds: suggestions.map((s) => s.getId()), + }; + + const response = await fixesController.patchFix(requestContext); + expect(response).includes({ status: 200 }); + const responseData = await response.json(); + expect(responseData).deep.equals(FixDto.toJSON(fix)); + expect(responseData.origin).to.equal(FixEntity.ORIGINS.ASO); + expect(fix.getOrigin()).equals(newOrigin); + expect(new Set(await fix.getSuggestions())).deep.equals(new Set(suggestions)); + }); + it('responds 404 if a suggestion does not exist', async () => { requestContext.data = { suggestionIds: ['15345195-62e6-494c-81b1-1d0da0b51d84'], From e2705cdea1a99c5b5fd00b418df458395494c525 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Fri, 17 Oct 2025 14:49:57 +0530 Subject: [PATCH 6/7] fix: adjust tests --- test/controllers/fixes.test.js | 19 +++++++++++++++++++ test/controllers/suggestions.test.js | 2 ++ test/dto/fix.test.js | 2 ++ 3 files changed, 23 insertions(+) diff --git a/test/controllers/fixes.test.js b/test/controllers/fixes.test.js index 7b5759303..0dc604d6a 100644 --- a/test/controllers/fixes.test.js +++ b/test/controllers/fixes.test.js @@ -1243,6 +1243,25 @@ describe('Fixes Controller', () => { createSuggestion({ type: 'METADATA_UPDATE' }), ]); + fixEntitySuggestionCollection.allByFixEntityId.resolves(suggestions.map((s) => ({ + getSuggestionId: () => s.getId(), + getFixEntityId: () => fix.getId(), + }))); + + fixEntityCollection.setSuggestionsForFixEntity.resolves({ + createdItems: suggestions.map((s) => ({ + getSuggestionId: () => s.getId(), + getFixEntityId: () => fix.getId(), + })), + errorItems: [], + removedCount: 0, + }); + + suggestionCollection.batchGetByKeys.resolves({ + data: suggestions, + unprocessed: [], + }); + const newOrigin = FixEntity.ORIGINS.ASO; requestContext.data = { origin: newOrigin, diff --git a/test/controllers/suggestions.test.js b/test/controllers/suggestions.test.js index 099a3d3d7..8b9a56a4a 100644 --- a/test/controllers/suggestions.test.js +++ b/test/controllers/suggestions.test.js @@ -729,6 +729,7 @@ describe('Suggestions Controller', () => { getPublishedAt: () => '2025-01-01T02:00:00.000Z', getChangeDetails: () => ({ file: 'index.js', changes: 'updated' }), getStatus: () => 'COMPLETED', + getOrigin: () => 'MANUAL', }, { getId: () => FIX_IDS[1], @@ -741,6 +742,7 @@ describe('Suggestions Controller', () => { getPublishedAt: () => null, getChangeDetails: () => ({ content: 'new content' }), getStatus: () => 'IN_PROGRESS', + getOrigin: () => 'MANUAL', }, ]; diff --git a/test/dto/fix.test.js b/test/dto/fix.test.js index fb0d153a0..7711a8ab9 100644 --- a/test/dto/fix.test.js +++ b/test/dto/fix.test.js @@ -39,6 +39,7 @@ describe('Fix DTO', () => { getPublishedAt: () => '2025-01-04T00:00:00.000Z', getChangeDetails: () => ({ field: 'value' }), getStatus: () => 'PENDING', + getOrigin: () => 'MANUAL', ...overrides, }); @@ -72,6 +73,7 @@ describe('Fix DTO', () => { publishedAt: '2025-01-04T00:00:00.000Z', changeDetails: { field: 'value' }, status: 'PENDING', + origin: 'MANUAL', }); expect(json).to.not.have.property('suggestions'); }); From 90d1b9f74624a784c485b7992bd3214b46f7e0cd Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Fri, 17 Oct 2025 15:00:09 +0530 Subject: [PATCH 7/7] fix: update env --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac91ac9e7..8d70b968e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "build": "hedy -v --test-bundle", "deploy": "hedy -v --deploy --aws-deploy-bucket=spacecat-prod-deploy --pkgVersion=latest", "deploy-stage": "hedy -v --deploy --aws-deploy-bucket=spacecat-stage-deploy --pkgVersion=latest", - "deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l sandsinh --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h --aws-api vldld6qz1d", + "deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l latest --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h --aws-api vldld6qz1d", "deploy-secrets": "hedy --aws-update-secrets --params-file=secrets/secrets.env", "docs": "npm run docs:lint && npm run docs:build", "docs:build": "npx @redocly/cli build-docs -o ./docs/index.html --config docs/openapi/redocly-config.yaml",