diff --git a/packages/spacecat-shared-data-access/src/models/audit/audit.model.js b/packages/spacecat-shared-data-access/src/models/audit/audit.model.js index 87bd9bee9..a8ba2a4ee 100644 --- a/packages/spacecat-shared-data-access/src/models/audit/audit.model.js +++ b/packages/spacecat-shared-data-access/src/models/audit/audit.model.js @@ -95,7 +95,9 @@ class Audit extends BaseModel { COMMERCE_PRODUCT_CATALOG_ENRICHMENT_AUTO_FIX: 'commerce-product-catalog-enrichment-auto-fix', CWV_TRENDS_AUDIT: 'cwv-trends-audit', OFFSITE_BRAND_PRESENCE: 'offsite-brand-presence', - SEMANTIC_VALUE_VISIBILITY: 'semantic-value-visibility', + IMAGE_ENRICHMENT: 'image-enrichment', + // @deprecated use IMAGE_ENRICHMENT — remove after producer cutover + SEMANTIC_VALUE_VISIBILITY: 'image-enrichment', }; static AUDIT_TYPE_PROPERTIES = { diff --git a/packages/spacecat-shared-data-access/test/unit/models/audit/audit.model.test.js b/packages/spacecat-shared-data-access/test/unit/models/audit/audit.model.test.js index 70798e9a0..8cd381dab 100755 --- a/packages/spacecat-shared-data-access/test/unit/models/audit/audit.model.test.js +++ b/packages/spacecat-shared-data-access/test/unit/models/audit/audit.model.test.js @@ -220,7 +220,8 @@ describe('AuditModel', () => { COMMERCE_PRODUCT_CATALOG_ENRICHMENT_AUTO_FIX: 'commerce-product-catalog-enrichment-auto-fix', CWV_TRENDS_AUDIT: 'cwv-trends-audit', OFFSITE_BRAND_PRESENCE: 'offsite-brand-presence', - SEMANTIC_VALUE_VISIBILITY: 'semantic-value-visibility', + IMAGE_ENRICHMENT: 'image-enrichment', + SEMANTIC_VALUE_VISIBILITY: 'image-enrichment', }; it('should have all audit types present in AUDIT_TYPES', () => { diff --git a/packages/spacecat-shared-tokowaka-client/src/mappers/semantic-value-visibility-mapper.js b/packages/spacecat-shared-tokowaka-client/src/mappers/image-enrichment-mapper.js similarity index 88% rename from packages/spacecat-shared-tokowaka-client/src/mappers/semantic-value-visibility-mapper.js rename to packages/spacecat-shared-tokowaka-client/src/mappers/image-enrichment-mapper.js index ceeb040d5..b1a4ba967 100644 --- a/packages/spacecat-shared-tokowaka-client/src/mappers/semantic-value-visibility-mapper.js +++ b/packages/spacecat-shared-tokowaka-client/src/mappers/image-enrichment-mapper.js @@ -16,13 +16,13 @@ import BaseOpportunityMapper from './base-mapper.js'; import { htmlToHast } from '../utils/html-utils.js'; /** - * Mapper for semantic-value-visibility opportunity + * Mapper for image-enrichment opportunity * Handles conversion of image semantic HTML suggestions to Tokowaka patches */ -export default class SemanticValueVisibilityMapper extends BaseOpportunityMapper { +export default class ImageEnrichmentMapper extends BaseOpportunityMapper { constructor(log) { super(log); - this.opportunityType = 'semantic-value-visibility'; + this.opportunityType = 'image-enrichment'; this.prerenderRequired = true; this.validActions = ['insertAfter', 'insertBefore', 'appendChild']; } @@ -48,7 +48,7 @@ export default class SemanticValueVisibilityMapper extends BaseOpportunityMapper suggestions.forEach((suggestion) => { const eligibility = this.canDeploy(suggestion); if (!eligibility.eligible) { - this.log.warn(`Semantic-value-visibility suggestion ${suggestion.getId()} cannot be deployed: ${eligibility.reason}`); + this.log.warn(`Image-enrichment suggestion ${suggestion.getId()} cannot be deployed: ${eligibility.reason}`); return; } @@ -74,7 +74,7 @@ export default class SemanticValueVisibilityMapper extends BaseOpportunityMapper } /** - * Checks if a semantic-value-visibility suggestion can be deployed + * Checks if an image-enrichment suggestion can be deployed * @param {Object} suggestion - Suggestion object * @returns {Object} { eligible: boolean, reason?: string } */ diff --git a/packages/spacecat-shared-tokowaka-client/src/mappers/mapper-registry.js b/packages/spacecat-shared-tokowaka-client/src/mappers/mapper-registry.js index 22b187d86..b8d1cfa1d 100644 --- a/packages/spacecat-shared-tokowaka-client/src/mappers/mapper-registry.js +++ b/packages/spacecat-shared-tokowaka-client/src/mappers/mapper-registry.js @@ -18,7 +18,7 @@ import TocMapper from './toc-mapper.js'; import GenericMapper from './generic-mapper.js'; import PrerenderMapper from './prerender-mapper.js'; import CommercePageEnrichmentMapper from './commerce-page-enrichment-mapper.js'; -import SemanticValueVisibilityMapper from './semantic-value-visibility-mapper.js'; +import ImageEnrichmentMapper from './image-enrichment-mapper.js'; /** * Registry for opportunity mappers @@ -45,13 +45,19 @@ export default class MapperRegistry { GenericMapper, PrerenderMapper, CommercePageEnrichmentMapper, - SemanticValueVisibilityMapper, + ImageEnrichmentMapper, ]; defaultMappers.forEach((MapperClass) => { const mapper = new MapperClass(this.log); this.registerMapper(mapper); }); + + // Deprecated alias — remove after mystique PR 1704 producer cutover + const imageEnrichmentInstance = this.mappers.get('image-enrichment'); + if (imageEnrichmentInstance) { + this.mappers.set('semantic-value-visibility', imageEnrichmentInstance); + } } /** diff --git a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Carahsoft.json b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Carahsoft.json similarity index 99% rename from packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Carahsoft.json rename to packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Carahsoft.json index a4e894e82..c3842b41c 100644 --- a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Carahsoft.json +++ b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Carahsoft.json @@ -1,6 +1,6 @@ { "url": "https://carahsoft.com/", - "opportunityType": "semantic-value-visibility", + "opportunityType": "image-enrichment", "suggestions": [ { "data": { diff --git a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Koffievoordeel.json b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Koffievoordeel.json similarity index 99% rename from packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Koffievoordeel.json rename to packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Koffievoordeel.json index d26ba12ae..6dc7ab2ed 100644 --- a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Koffievoordeel.json +++ b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Koffievoordeel.json @@ -1,6 +1,6 @@ { "url": "https://koffievoordeel.nl/", - "opportunityType": "semantic-value-visibility", + "opportunityType": "image-enrichment", "suggestions": [ { "data": { diff --git a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Krisshop.json b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Krisshop.json similarity index 99% rename from packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Krisshop.json rename to packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Krisshop.json index c05224e0b..b4be8c889 100644 --- a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Krisshop.json +++ b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Krisshop.json @@ -1,6 +1,6 @@ { "url": "https://www.krisshop.com/en", - "opportunityType": "semantic-value-visibility", + "opportunityType": "image-enrichment", "suggestions": [ { "data": { diff --git a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Veseris.json b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Veseris.json similarity index 99% rename from packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Veseris.json rename to packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Veseris.json index b2e9154b9..61f281763 100644 --- a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Veseris.json +++ b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Veseris.json @@ -1,6 +1,6 @@ { "url": "https://veseris.com/default/", - "opportunityType": "semantic-value-visibility", + "opportunityType": "image-enrichment", "suggestions": [ { "data": { diff --git a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Vuse.json b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Vuse.json similarity index 99% rename from packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Vuse.json rename to packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Vuse.json index db1b16e4d..4da4d8892 100644 --- a/packages/spacecat-shared-tokowaka-client/test/fixtures/semantic-value-visibility/Vuse.json +++ b/packages/spacecat-shared-tokowaka-client/test/fixtures/image-enrichment/Vuse.json @@ -1,6 +1,6 @@ { "url": "https://www.vuse.com/ch/en", - "opportunityType": "semantic-value-visibility", + "opportunityType": "image-enrichment", "suggestions": [ { "data": { diff --git a/packages/spacecat-shared-tokowaka-client/test/mappers/generic-mapper.test.js b/packages/spacecat-shared-tokowaka-client/test/mappers/generic-mapper.test.js index e5949a051..126464843 100644 --- a/packages/spacecat-shared-tokowaka-client/test/mappers/generic-mapper.test.js +++ b/packages/spacecat-shared-tokowaka-client/test/mappers/generic-mapper.test.js @@ -17,7 +17,7 @@ import { expect } from 'chai'; import GenericMapper from '../../src/mappers/generic-mapper.js'; const filename = fileURLToPath(import.meta.url); -const fixturesPath = join(dirname(filename), '../fixtures/semantic-value-visibility'); +const fixturesPath = join(dirname(filename), '../fixtures/image-enrichment'); const carahsoftFixture = JSON.parse( readFileSync(join(fixturesPath, 'Carahsoft.json'), 'utf8'), ); diff --git a/packages/spacecat-shared-tokowaka-client/test/mappers/semantic-value-visibility-mapper.test.js b/packages/spacecat-shared-tokowaka-client/test/mappers/image-enrichment-mapper.test.js similarity index 96% rename from packages/spacecat-shared-tokowaka-client/test/mappers/semantic-value-visibility-mapper.test.js rename to packages/spacecat-shared-tokowaka-client/test/mappers/image-enrichment-mapper.test.js index c23381542..f8a9c5260 100644 --- a/packages/spacecat-shared-tokowaka-client/test/mappers/semantic-value-visibility-mapper.test.js +++ b/packages/spacecat-shared-tokowaka-client/test/mappers/image-enrichment-mapper.test.js @@ -14,10 +14,10 @@ import { expect } from 'chai'; import { readFileSync } from 'fs'; import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; -import SemanticValueVisibilityMapper from '../../src/mappers/semantic-value-visibility-mapper.js'; +import ImageEnrichmentMapper from '../../src/mappers/image-enrichment-mapper.js'; const filename = fileURLToPath(import.meta.url); -const fixturesPath = join(dirname(filename), '../fixtures/semantic-value-visibility'); +const fixturesPath = join(dirname(filename), '../fixtures/image-enrichment'); // Load real Mystique response fixtures // Carahsoft proves the logic is correct, others prove it doesn't crash with different real inputs. @@ -27,7 +27,7 @@ const krisshopFixture = JSON.parse(readFileSync(join(fixturesPath, 'Krisshop.jso const veserisFixture = JSON.parse(readFileSync(join(fixturesPath, 'Veseris.json'), 'utf8')); const vuseFixture = JSON.parse(readFileSync(join(fixturesPath, 'Vuse.json'), 'utf8')); -describe('SemanticValueVisibilityMapper', () => { +describe('ImageEnrichmentMapper', () => { let mapper; let log; @@ -38,12 +38,12 @@ describe('SemanticValueVisibilityMapper', () => { warn: () => {}, error: () => {}, }; - mapper = new SemanticValueVisibilityMapper(log); + mapper = new ImageEnrichmentMapper(log); }); describe('getOpportunityType', () => { - it('should return semantic-value-visibility', () => { - expect(mapper.getOpportunityType()).to.equal('semantic-value-visibility'); + it('should return image-enrichment', () => { + expect(mapper.getOpportunityType()).to.equal('image-enrichment'); }); });