Skip to content

Commit 2554042

Browse files
fix name missing issue
1 parent ad782cc commit 2554042

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/tasks/demo-url-processor/handler.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ function getImsTenantId(organization, context, log) {
3535
} catch (error) {
3636
log.error('Error loading IMS_ORG_TENANT_ID_MAPPINGS mapping:', error.message);
3737
}
38+
39+
if (!name) {
40+
log.error('Organization name is missing, using fallback tenant ID');
41+
return 'unknown-tenant';
42+
}
43+
3844
return name.toLowerCase().replace(/\s+/g, '');
3945
}
4046

test/tasks/demo-url-processor/demo-url-processor.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,20 @@ describe('Demo URL Processor', () => {
151151
// Should not log the success message
152152
expect(context.log.info.calledWithMatch(sinon.match('Setup complete!'))).to.be.false;
153153
});
154+
155+
it('should handle organization with missing name property', async () => {
156+
// Mock Organization.findById to return organization without name
157+
context.dataAccess.Organization.findById.resolves({
158+
imsOrgId: '8C6043F15F43B6390A49401A@AdobeOrg',
159+
// name property is missing
160+
});
161+
162+
await runDemoUrlProcessor(message, context);
163+
164+
// Should log error about missing name and use fallback
165+
expect(context.log.error.calledWith('Organization name is missing, using fallback tenant ID')).to.be.true;
166+
const expectedDemoUrl = 'https://example.com?organizationId=test-org-id#/@unknown-tenant/sites-optimizer/sites/test-site-id/home';
167+
expect(context.log.info.calledWith(`Setup complete! Access your demo environment here: ${expectedDemoUrl}`)).to.be.true;
168+
});
154169
});
155170
});

0 commit comments

Comments
 (0)