Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { hasText, isObject } from '@adobe/spacecat-shared-utils';
import { Base } from './base.js';
import { Config, DEFAULT_CONFIG } from './site/config.js';

export const DEFAULT_ORGANIZATION_ID = 'default';

/**
* Creates a new Organization.
*
Expand Down
7 changes: 6 additions & 1 deletion packages/spacecat-shared-data-access/src/models/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
* governing permissions and limitations under the License.
*/

import { isObject, isValidUrl } from '@adobe/spacecat-shared-utils';
import { hasText, isObject, isValidUrl } from '@adobe/spacecat-shared-utils';

import { Base } from './base.js';
import AuditConfig from './site/audit-config.js';
import { Config, DEFAULT_CONFIG } from './site/config.js';
import { DEFAULT_ORGANIZATION_ID } from './organization.js';

export const DELIVERY_TYPES = {
AEM_CS: 'aem_cs',
Expand Down Expand Up @@ -162,6 +163,10 @@ export const createSite = (data) => {
throw new Error('Base URL must be a valid URL');
}

if (!hasText(newState.organizationId)) {
newState.organizationId = DEFAULT_ORGANIZATION_ID;
}

newState.deliveryType = newState.deliveryType || DEFAULT_DELIVERY_TYPE;
if (!Object.values(DELIVERY_TYPES).includes(newState.deliveryType)) {
throw new Error(`Invalid delivery type: ${newState.deliveryType}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ describe('Site Model Tests', () => {
expect(site.getBaseURL()).to.equal(validData.baseURL);
});

it('creates a site with default organization id', () => {
const site = createSite({ ...validData, organizationId: undefined });
expect(site.getOrganizationId()).to.equal('default');
});

it('creates a site with default auditConfig when none provided', () => {
const site = createSite({ ...validData });
const auditConfig = site.getAuditConfig();
Expand Down