fix(badges-backend): properly build entity uri
Signed-off-by: Bastian Gutschke <bastian.gutschke@gmx.de>
This commit is contained in:
@@ -65,4 +65,28 @@ describe('BadgeFactories', () => {
|
||||
expect(badge.kind).toEqual('entity');
|
||||
}
|
||||
});
|
||||
|
||||
it('returns valid link for entity', () => {
|
||||
const entity: Entity = {
|
||||
apiVersion: 'v1',
|
||||
kind: 'service',
|
||||
metadata: {
|
||||
name: 'test',
|
||||
},
|
||||
};
|
||||
|
||||
const context: BadgeContext = {
|
||||
badgeUrl: '/dummy/url',
|
||||
config,
|
||||
entity,
|
||||
};
|
||||
|
||||
expect.assertions(Object.keys(badgeFactories).length);
|
||||
for (const badgeFactory of Object.values(badgeFactories)) {
|
||||
const badge = badgeFactory.createBadge(context);
|
||||
expect(badge.link).toContain(
|
||||
'http://localhost/catalog/default/service/test',
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,8 +24,8 @@ function appTitle(context: BadgeContext): string {
|
||||
|
||||
function entityUrl(context: BadgeContext): string {
|
||||
const e = context.entity!;
|
||||
const entityUri = `${e.kind}/${
|
||||
e.metadata.namespace || ENTITY_DEFAULT_NAMESPACE
|
||||
const entityUri = `${e.metadata.namespace || ENTITY_DEFAULT_NAMESPACE}/${
|
||||
e.kind
|
||||
}/${e.metadata.name}`;
|
||||
const catalogUrl = `${context.config.getString('app.baseUrl')}/catalog`;
|
||||
return `${catalogUrl}/${entityUri}`.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user