Skip to content

Commit 61d54c3

Browse files
ElderMattsvcAPLBot
andauthored
fix: broken object storage wizard when cluster name is not of type string (#889)
* fix: extra string check if input is not of type string * fix: test * fix: better check * fix: test description --------- Co-authored-by: svcAPLBot <174728082+svcAPLBot@users.noreply.github.com>
1 parent 8885ae3 commit 61d54c3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/utils/wizardUtils.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ describe('ObjectStorageClient', () => {
107107
expect(clusterId).toBe('123')
108108
})
109109

110+
test('should return 123 when clusterId is a number', () => {
111+
const settings = { cluster: { name: 123 } }
112+
clusterId = defineClusterId(settings.cluster.name)
113+
114+
expect(clusterId).toBe('123')
115+
})
116+
110117
test('should return undefined when cluster name is undefined', () => {
111118
const settings: any = { cluster: {} }
112119
clusterId = defineClusterId(settings.cluster?.name)

src/utils/wizardUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export class ObjectStorageClient {
5757
}
5858
}
5959
// define cluster id based on cluster name
60-
export function defineClusterId(clusterName: string | undefined): string | undefined {
60+
export function defineClusterId(clusterName: string | number | undefined): string | undefined {
6161
if (!clusterName) return undefined
62-
return clusterName.replace('aplinstall', '')
62+
const clusterNameStr = String(clusterName)
63+
return clusterNameStr.replace('aplinstall', '')
6364
}

0 commit comments

Comments
 (0)