From 72445470b08b8248ddd444e6a409725addd583d0 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Mon, 30 Mar 2026 12:30:04 +0530 Subject: [PATCH 1/5] fix: deploy only granted suggestions for summitPlg for ASO UI --- package-lock.json | 24 ++++++++++++++++++++++++ src/controllers/suggestions.js | 9 +++++++++ test/controllers/suggestions.test.js | 21 +++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/package-lock.json b/package-lock.json index 79e474208..7611a84dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -632,6 +632,7 @@ "resolved": "https://registry.npmjs.org/@adobe/helix-universal/-/helix-universal-5.4.0.tgz", "integrity": "sha512-3ZfFdjYtpv7RCgul9yyOBsRVsxLNapwt0YjASBhyzJGNjnPxrWDlqDtbpBdwAgA1Nuh9nmjzFDFu8CJWv6BMKw==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@adobe/fetch": "4.2.3", "aws4": "1.13.2" @@ -10134,6 +10135,7 @@ "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.940.0.tgz", "integrity": "sha512-u2sXsNJazJbuHeWICvsj6RvNyJh3isedEfPvB21jK/kxcriK+dE/izlKC2cyxUjERCmku0zTFNzY9FhrLbYHjQ==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", @@ -14258,6 +14260,7 @@ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.80.tgz", "integrity": "sha512-vcJDV2vk1AlCwSh3aBm/urQ1ZrlXFFBocv11bz/NBUfLWD5/UDNMzwPdaAd2dKvNmTWa9FM2lirLU3+JCf4cRA==", "license": "MIT", + "peer": true, "dependencies": { "@cfworker/json-schema": "^4.0.2", "ansi-styles": "^5.0.0", @@ -14489,6 +14492,7 @@ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz", "integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==", "license": "MIT", + "peer": true, "dependencies": { "@octokit/auth-token": "^6.0.0", "@octokit/graphql": "^9.0.3", @@ -14695,6 +14699,7 @@ "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "engines": { "node": ">=8.0.0" } @@ -14858,6 +14863,7 @@ "integrity": "sha512-xYLlvk/xdScGx1aEqvxLwf6sXQLXCjk3/1SQT9X9AoN5rXRhkdvIFShuNNmtTEPRBqcsMbS4p/gJLNI2wXaDuQ==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/core": "2.0.1", "@opentelemetry/resources": "2.0.1", @@ -16799,6 +16805,7 @@ "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", "license": "MIT", + "peer": true, "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^5.0.0", @@ -17105,6 +17112,7 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -17152,6 +17160,7 @@ "integrity": "sha512-F+LMD2IDIXuHxgpLJh3nkLj9+tSaEzoUWd+7fONGq5pe2169FUDjpEkOfEpoGLz1sbZni/69p07OsecNfAOpqA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -17627,6 +17636,7 @@ "resolved": "https://registry.npmjs.org/aws-xray-sdk-core/-/aws-xray-sdk-core-3.12.0.tgz", "integrity": "sha512-lwalRdxXRy+Sn49/vN7W507qqmBRk5Fy2o0a9U6XTjL9IV+oR5PUiiptoBrOcaYCiVuGld8OEbNqhm6wvV3m6A==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@aws-sdk/types": "^3.4.1", "@smithy/service-error-classification": "^2.0.4", @@ -18277,6 +18287,7 @@ "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -20466,6 +20477,7 @@ "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -24482,6 +24494,7 @@ "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", "dev": true, "license": "MIT", + "peer": true, "bin": { "marked": "bin/marked.js" }, @@ -25537,6 +25550,7 @@ "integrity": "sha512-UczzB+0nnwGotYSgllfARAqWCJ5e/skuV2K/l+Zyck/H6pJIhLXuBnz+6vn2i211o7DtbE78HQtsYEKICHGI+g==", "dev": true, "license": "MIT", + "peer": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/mobx" @@ -28709,6 +28723,7 @@ "dev": true, "inBundle": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -29378,6 +29393,7 @@ "resolved": "https://registry.npmjs.org/openai/-/openai-5.12.2.tgz", "integrity": "sha512-xqzHHQch5Tws5PcKR2xsZGX9xtch+JQFz5zb14dGqlshmmDAFBFEWmeIpf7wVqWV+w7Emj7jRgkNJakyKE0tYQ==", "license": "Apache-2.0", + "peer": true, "bin": { "openai": "bin/cli" }, @@ -30486,6 +30502,7 @@ "integrity": "sha512-DGrYcCWK7tvYMnWh79yrPHt+vdx9tY+1gPZa7nJQtO/p8bLTDaHp4dzwEhQB7pZ4Xe3ok4XKuEPrVuc+wlpkmw==", "devOptional": true, "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -30496,6 +30513,7 @@ "integrity": "sha512-ibrK8llX2a4eOskq1mXKu/TGZj9qzomO+sNfO98M6d9zIPOEhlBkMkBUBLd1vgS0gQsLDBzA+8jJBVXDnfHmJg==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -31205,6 +31223,7 @@ "integrity": "sha512-phCkJ6pjDi9ANdhuF5ElS10GGdAKY6R1Pvt9lT3SFhOwM4T7QZE7MLpBDbNruUx/Q3gFD92/UOFringGipRqZA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@semantic-release/commit-analyzer": "^13.0.0-beta.1", "@semantic-release/error": "^4.0.0", @@ -32666,6 +32685,7 @@ "integrity": "sha512-J72R4ltw0UBVUlEjTzI0gg2STOqlI9JBhQOL4Dxt7aJOnnSesy0qJDn4PYfMCafk9cWOaVg129Pesl5o+DIh0Q==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@emotion/is-prop-valid": "1.4.0", "@emotion/unitless": "0.10.0", @@ -33749,6 +33769,7 @@ "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", "license": "MIT", + "peer": true, "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", @@ -34475,6 +34496,7 @@ "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", "license": "MIT", + "peer": true, "engines": { "node": ">=10.0.0" }, @@ -34739,6 +34761,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } @@ -34748,6 +34771,7 @@ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.0.tgz", "integrity": "sha512-HvWtU2UG41LALjajJrML6uQejQhNJx+JBO9IflpSja4R03iNWfKXrj6W2h7ljuLyc1nKS+9yDyL/9tD1U/yBnQ==", "license": "ISC", + "peer": true, "peerDependencies": { "zod": "^3.25 || ^4" } diff --git a/src/controllers/suggestions.js b/src/controllers/suggestions.js index abb9f7700..b134a732e 100644 --- a/src/controllers/suggestions.js +++ b/src/controllers/suggestions.js @@ -1024,6 +1024,15 @@ function SuggestionsController(ctx, sqs, env) { return badRequest('variations must be an array'); } + // Block auto-deploy on non-granted suggestions for summit-plg users + if (await getIsSummitPlgEnabled(site, ctx, context)) { + const { grantedIds } = await SuggestionGrant.splitSuggestionsByGrantStatus(suggestionIds); + const ungrantedIds = suggestionIds.filter((id) => !grantedIds.includes(id)); + if (ungrantedIds.length > 0) { + return forbidden(`The following suggestions are not granted: ${ungrantedIds.join(', ')}`); + } + } + const configuration = await Configuration.findLatest(); if (!configuration.isHandlerEnabledForSite(`${opportunity.getType()}-auto-fix`, site)) { return badRequest(`Handler is not enabled for site ${site.getId()} autofix type ${opportunity.getType()}`); diff --git a/test/controllers/suggestions.test.js b/test/controllers/suggestions.test.js index d65d05c7a..9a5dd5faa 100644 --- a/test/controllers/suggestions.test.js +++ b/test/controllers/suggestions.test.js @@ -3626,6 +3626,27 @@ describe('Suggestions Controller', () => { expect(bulkPatchResponse.suggestions[0].suggestion).to.have.property('status', 'IN_PROGRESS'); }); + it('returns forbidden when summit-plg is enabled and suggestions are not granted for autofix', async () => { + mockSuggestionGrant.splitSuggestionsByGrantStatus.resolves({ + grantedIds: [SUGGESTION_IDS[0]], + notGrantedIds: [SUGGESTION_IDS[2]], + grantIds: [`grant-${SUGGESTION_IDS[0]}`], + }); + const response = await suggestionsControllerWithMock.autofixSuggestions({ + params: { + siteId: SITE_ID, + opportunityId: OPPORTUNITY_ID, + }, + data: { suggestionIds: [SUGGESTION_IDS[0], SUGGESTION_IDS[2]] }, + ...context, + }); + + expect(response.status).to.equal(403); + const body = await response.json(); + expect(body.message).to.include('not granted'); + expect(body.message).to.include(SUGGESTION_IDS[2]); + }); + it('triggers autofixSuggestion and sets suggestions to in-progress for alt-text', async () => { opportunity.getType = sandbox.stub().returns('alt-text'); mockSuggestion.allByOpportunityId.resolves( From f359f8635c2727e84b88a36710ee2b2037a3e318 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Mon, 30 Mar 2026 12:37:26 +0530 Subject: [PATCH 2/5] fix: update calls --- src/controllers/suggestions.js | 7 +++---- test/controllers/suggestions.test.js | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/suggestions.js b/src/controllers/suggestions.js index b134a732e..730e0b972 100644 --- a/src/controllers/suggestions.js +++ b/src/controllers/suggestions.js @@ -1026,10 +1026,9 @@ function SuggestionsController(ctx, sqs, env) { // Block auto-deploy on non-granted suggestions for summit-plg users if (await getIsSummitPlgEnabled(site, ctx, context)) { - const { grantedIds } = await SuggestionGrant.splitSuggestionsByGrantStatus(suggestionIds); - const ungrantedIds = suggestionIds.filter((id) => !grantedIds.includes(id)); - if (ungrantedIds.length > 0) { - return forbidden(`The following suggestions are not granted: ${ungrantedIds.join(', ')}`); + const { notGrantedIds } = await SuggestionGrant.splitSuggestionsByGrantStatus(suggestionIds); + if (notGrantedIds.length > 0) { + return forbidden(`The following suggestions are not granted: ${notGrantedIds.join(', ')}`); } } diff --git a/test/controllers/suggestions.test.js b/test/controllers/suggestions.test.js index 9a5dd5faa..88776554c 100644 --- a/test/controllers/suggestions.test.js +++ b/test/controllers/suggestions.test.js @@ -3645,6 +3645,7 @@ describe('Suggestions Controller', () => { const body = await response.json(); expect(body.message).to.include('not granted'); expect(body.message).to.include(SUGGESTION_IDS[2]); + expect(body.message).to.not.include(SUGGESTION_IDS[0]); }); it('triggers autofixSuggestion and sets suggestions to in-progress for alt-text', async () => { From e692f3d0947cf3da49c7523291946c396da1e1b5 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Mon, 30 Mar 2026 14:07:37 +0530 Subject: [PATCH 3/5] test: add autofix suggestions tests for summit-plg grant status Co-Authored-By: Claude Opus 4.6 (1M context) --- package-lock.json | 24 ----------- test/controllers/suggestions.test.js | 60 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7611a84dd..79e474208 100644 --- a/package-lock.json +++ b/package-lock.json @@ -632,7 +632,6 @@ "resolved": "https://registry.npmjs.org/@adobe/helix-universal/-/helix-universal-5.4.0.tgz", "integrity": "sha512-3ZfFdjYtpv7RCgul9yyOBsRVsxLNapwt0YjASBhyzJGNjnPxrWDlqDtbpBdwAgA1Nuh9nmjzFDFu8CJWv6BMKw==", "license": "Apache-2.0", - "peer": true, "dependencies": { "@adobe/fetch": "4.2.3", "aws4": "1.13.2" @@ -10135,7 +10134,6 @@ "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.940.0.tgz", "integrity": "sha512-u2sXsNJazJbuHeWICvsj6RvNyJh3isedEfPvB21jK/kxcriK+dE/izlKC2cyxUjERCmku0zTFNzY9FhrLbYHjQ==", "license": "Apache-2.0", - "peer": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", @@ -14260,7 +14258,6 @@ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.80.tgz", "integrity": "sha512-vcJDV2vk1AlCwSh3aBm/urQ1ZrlXFFBocv11bz/NBUfLWD5/UDNMzwPdaAd2dKvNmTWa9FM2lirLU3+JCf4cRA==", "license": "MIT", - "peer": true, "dependencies": { "@cfworker/json-schema": "^4.0.2", "ansi-styles": "^5.0.0", @@ -14492,7 +14489,6 @@ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz", "integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==", "license": "MIT", - "peer": true, "dependencies": { "@octokit/auth-token": "^6.0.0", "@octokit/graphql": "^9.0.3", @@ -14699,7 +14695,6 @@ "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=8.0.0" } @@ -14863,7 +14858,6 @@ "integrity": "sha512-xYLlvk/xdScGx1aEqvxLwf6sXQLXCjk3/1SQT9X9AoN5rXRhkdvIFShuNNmtTEPRBqcsMbS4p/gJLNI2wXaDuQ==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@opentelemetry/core": "2.0.1", "@opentelemetry/resources": "2.0.1", @@ -16805,7 +16799,6 @@ "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", "license": "MIT", - "peer": true, "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^5.0.0", @@ -17112,7 +17105,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -17160,7 +17152,6 @@ "integrity": "sha512-F+LMD2IDIXuHxgpLJh3nkLj9+tSaEzoUWd+7fONGq5pe2169FUDjpEkOfEpoGLz1sbZni/69p07OsecNfAOpqA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -17636,7 +17627,6 @@ "resolved": "https://registry.npmjs.org/aws-xray-sdk-core/-/aws-xray-sdk-core-3.12.0.tgz", "integrity": "sha512-lwalRdxXRy+Sn49/vN7W507qqmBRk5Fy2o0a9U6XTjL9IV+oR5PUiiptoBrOcaYCiVuGld8OEbNqhm6wvV3m6A==", "license": "Apache-2.0", - "peer": true, "dependencies": { "@aws-sdk/types": "^3.4.1", "@smithy/service-error-classification": "^2.0.4", @@ -18287,7 +18277,6 @@ "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=18" } @@ -20477,7 +20466,6 @@ "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -24494,7 +24482,6 @@ "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", "dev": true, "license": "MIT", - "peer": true, "bin": { "marked": "bin/marked.js" }, @@ -25550,7 +25537,6 @@ "integrity": "sha512-UczzB+0nnwGotYSgllfARAqWCJ5e/skuV2K/l+Zyck/H6pJIhLXuBnz+6vn2i211o7DtbE78HQtsYEKICHGI+g==", "dev": true, "license": "MIT", - "peer": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/mobx" @@ -28723,7 +28709,6 @@ "dev": true, "inBundle": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -29393,7 +29378,6 @@ "resolved": "https://registry.npmjs.org/openai/-/openai-5.12.2.tgz", "integrity": "sha512-xqzHHQch5Tws5PcKR2xsZGX9xtch+JQFz5zb14dGqlshmmDAFBFEWmeIpf7wVqWV+w7Emj7jRgkNJakyKE0tYQ==", "license": "Apache-2.0", - "peer": true, "bin": { "openai": "bin/cli" }, @@ -30502,7 +30486,6 @@ "integrity": "sha512-DGrYcCWK7tvYMnWh79yrPHt+vdx9tY+1gPZa7nJQtO/p8bLTDaHp4dzwEhQB7pZ4Xe3ok4XKuEPrVuc+wlpkmw==", "devOptional": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -30513,7 +30496,6 @@ "integrity": "sha512-ibrK8llX2a4eOskq1mXKu/TGZj9qzomO+sNfO98M6d9zIPOEhlBkMkBUBLd1vgS0gQsLDBzA+8jJBVXDnfHmJg==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -31223,7 +31205,6 @@ "integrity": "sha512-phCkJ6pjDi9ANdhuF5ElS10GGdAKY6R1Pvt9lT3SFhOwM4T7QZE7MLpBDbNruUx/Q3gFD92/UOFringGipRqZA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@semantic-release/commit-analyzer": "^13.0.0-beta.1", "@semantic-release/error": "^4.0.0", @@ -32685,7 +32666,6 @@ "integrity": "sha512-J72R4ltw0UBVUlEjTzI0gg2STOqlI9JBhQOL4Dxt7aJOnnSesy0qJDn4PYfMCafk9cWOaVg129Pesl5o+DIh0Q==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@emotion/is-prop-valid": "1.4.0", "@emotion/unitless": "0.10.0", @@ -33769,7 +33749,6 @@ "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", "license": "MIT", - "peer": true, "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", @@ -34496,7 +34475,6 @@ "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", "license": "MIT", - "peer": true, "engines": { "node": ">=10.0.0" }, @@ -34761,7 +34739,6 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } @@ -34771,7 +34748,6 @@ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.0.tgz", "integrity": "sha512-HvWtU2UG41LALjajJrML6uQejQhNJx+JBO9IflpSja4R03iNWfKXrj6W2h7ljuLyc1nKS+9yDyL/9tD1U/yBnQ==", "license": "ISC", - "peer": true, "peerDependencies": { "zod": "^3.25 || ^4" } diff --git a/test/controllers/suggestions.test.js b/test/controllers/suggestions.test.js index 88776554c..2668a4888 100644 --- a/test/controllers/suggestions.test.js +++ b/test/controllers/suggestions.test.js @@ -3567,6 +3567,66 @@ describe('Suggestions Controller', () => { sandbox.restore(); }); + it('proceeds with autofix when summit-plg is enabled and all suggestions are granted', async () => { + opportunity.getType = sandbox.stub().returns('meta-tags'); + mockSuggestionGrant.splitSuggestionsByGrantStatus.resolves({ + grantedIds: [SUGGESTION_IDS[0], SUGGESTION_IDS[2]], + notGrantedIds: [], + grantIds: [`grant-${SUGGESTION_IDS[0]}`, `grant-${SUGGESTION_IDS[2]}`], + }); + mockSuggestion.allByOpportunityId.resolves( + [mockSuggestionEntity(suggs[0]), mockSuggestionEntity(suggs[2])], + ); + mockSuggestion.bulkUpdateStatus.resolves([mockSuggestionEntity({ ...suggs[0], status: 'IN_PROGRESS' }), + mockSuggestionEntity({ ...suggs[2], status: 'IN_PROGRESS' }), + ]); + const response = await suggestionsControllerWithMock.autofixSuggestions({ + params: { + siteId: SITE_ID, + opportunityId: OPPORTUNITY_ID, + }, + data: { suggestionIds: [SUGGESTION_IDS[0], SUGGESTION_IDS[2]] }, + ...context, + }); + + expect(response.status).to.equal(207); + expect(mockSuggestionGrant.splitSuggestionsByGrantStatus).to.have.been.calledOnce; + }); + + it('does not check grant status when summit-plg is disabled for autofix', async () => { + const controllerPlgDisabled = await esmock('../../src/controllers/suggestions.js', { + '../../src/support/utils.js': { + getIMSPromiseToken: async () => ({ promise_token: 'token', expires_in: 14399, token_type: 'promise_token' }), + getIsSummitPlgEnabled: async () => false, + }, + }); + const ctrl = controllerPlgDisabled({ + dataAccess: mockSuggestionDataAccess, + pathInfo: { headers: { 'x-product': 'abcd' } }, + ...authContext, + }, mockSqs, { AUTOFIX_JOBS_QUEUE: 'https://autofix-jobs-queue' }); + + opportunity.getType = sandbox.stub().returns('meta-tags'); + mockSuggestionGrant.splitSuggestionsByGrantStatus.resetHistory(); + mockSuggestion.allByOpportunityId.resolves( + [mockSuggestionEntity(suggs[0]), mockSuggestionEntity(suggs[2])], + ); + mockSuggestion.bulkUpdateStatus.resolves([mockSuggestionEntity({ ...suggs[0], status: 'IN_PROGRESS' }), + mockSuggestionEntity({ ...suggs[2], status: 'IN_PROGRESS' }), + ]); + const response = await ctrl.autofixSuggestions({ + params: { + siteId: SITE_ID, + opportunityId: OPPORTUNITY_ID, + }, + data: { suggestionIds: [SUGGESTION_IDS[0], SUGGESTION_IDS[2]] }, + ...context, + }); + + expect(response.status).to.equal(207); + expect(mockSuggestionGrant.splitSuggestionsByGrantStatus).to.not.have.been.called; + }); + it('triggers autofixSuggestion and sets suggestions to in-progress', async () => { opportunity.getType = sandbox.stub().returns('meta-tags'); mockSuggestion.allByOpportunityId.resolves( From b26ee0f3f83f2a31ac8b079082e936f36c25582b Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Wed, 8 Apr 2026 12:49:46 +0530 Subject: [PATCH 4/5] fix: dev test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f832acabc..3cd9cc3d0 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,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", + "deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l sandsinh --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h", "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", From 9cade2da6621d2a8af318e1247a9556c7d0da660 Mon Sep 17 00:00:00 2001 From: Sandesh Sinha Date: Wed, 8 Apr 2026 15:36:24 +0530 Subject: [PATCH 5/5] fix: update dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3cd9cc3d0..f832acabc 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,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", + "deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l latest --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h", "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",