diff --git a/src/utils/wizardUtils.test.ts b/src/utils/wizardUtils.test.ts index 4c2eeaf4..340610c1 100644 --- a/src/utils/wizardUtils.test.ts +++ b/src/utils/wizardUtils.test.ts @@ -107,6 +107,13 @@ describe('ObjectStorageClient', () => { expect(clusterId).toBe('123') }) + test('should return 123 when clusterId is a number', () => { + const settings = { cluster: { name: 123 } } + clusterId = defineClusterId(settings.cluster.name) + + expect(clusterId).toBe('123') + }) + test('should return undefined when cluster name is undefined', () => { const settings: any = { cluster: {} } clusterId = defineClusterId(settings.cluster?.name) diff --git a/src/utils/wizardUtils.ts b/src/utils/wizardUtils.ts index 57c448b8..35bd9a40 100644 --- a/src/utils/wizardUtils.ts +++ b/src/utils/wizardUtils.ts @@ -57,7 +57,8 @@ export class ObjectStorageClient { } } // define cluster id based on cluster name -export function defineClusterId(clusterName: string | undefined): string | undefined { +export function defineClusterId(clusterName: string | number | undefined): string | undefined { if (!clusterName) return undefined - return clusterName.replace('aplinstall', '') + const clusterNameStr = String(clusterName) + return clusterNameStr.replace('aplinstall', '') }