Skip to content

Commit 1f42265

Browse files
authored
fix(sites): update hlxConfig via API (#707)
1 parent 1b70ea9 commit 1f42265

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/controllers/sites.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
hasText,
2323
isBoolean,
2424
isObject,
25-
getStoredMetrics, getRUMDomainKey, isValidUUID,
25+
getStoredMetrics, getRUMDomainKey, isValidUUID, deepEqual,
2626
} from '@adobe/spacecat-shared-utils';
2727
import { Site as SiteModel } from '@adobe/spacecat-shared-data-access';
2828

@@ -280,6 +280,11 @@ function SitesController(dataAccess, log, env) {
280280
updates = true;
281281
}
282282

283+
if (isObject(requestBody.hlxConfig) && !deepEqual(requestBody.hlxConfig, site.getHlxConfig())) {
284+
site.setHlxConfig(requestBody.hlxConfig);
285+
updates = true;
286+
}
287+
283288
if (updates) {
284289
const updatedSite = await site.save();
285290
return ok(SiteDto.toJSON(updatedSite));

test/controllers/sites.test.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ describe('Sites Controller', () => {
3737

3838
const sites = [
3939
{
40-
siteId: SITE_IDS[0], baseURL: 'https://site1.com', deliveryType: 'aem_edge', config: Config({}),
40+
siteId: SITE_IDS[0], baseURL: 'https://site1.com', deliveryType: 'aem_edge', config: Config({}), hlxConfig: {},
4141
},
4242
{
43-
siteId: SITE_IDS[1], baseURL: 'https://site2.com', deliveryType: 'aem_edge', config: Config({}),
43+
siteId: SITE_IDS[1], baseURL: 'https://site2.com', deliveryType: 'aem_edge', config: Config({}), hlxConfig: {},
4444
},
4545
].map((site) => new Site(
4646
{
@@ -55,6 +55,7 @@ describe('Sites Controller', () => {
5555
gitHubURL: { type: 'string', name: 'gitHubURL', get: (value) => value },
5656
isLive: { type: 'boolean', name: 'isLive', get: (value) => value },
5757
organizationId: { type: 'string', name: 'organizationId', get: (value) => value },
58+
hlxConfig: { type: 'any', name: 'hlxConfig', get: (value) => value },
5859
},
5960
},
6061
},
@@ -222,6 +223,9 @@ describe('Sites Controller', () => {
222223
deliveryType: 'other',
223224
gitHubURL: 'https://github.com/blah/bluh',
224225
config: {},
226+
hlxConfig: {
227+
field: true,
228+
},
225229
},
226230
});
227231

@@ -233,6 +237,7 @@ describe('Sites Controller', () => {
233237
expect(updatedSite).to.have.property('baseURL', 'https://site1.com');
234238
expect(updatedSite).to.have.property('deliveryType', 'other');
235239
expect(updatedSite).to.have.property('gitHubURL', 'https://github.com/blah/bluh');
240+
expect(updatedSite.hlxConfig).to.deep.equal({ field: true });
236241
});
237242

238243
it('returns bad request when updating a site if id not provided', async () => {

0 commit comments

Comments
 (0)