-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage) use config api for form fields help text on storage poo…
…ls and volumes WD-7393 Signed-off-by: David Edler <[email protected]>
- Loading branch information
Showing
15 changed files
with
224 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { getConfigRowMetadata } from "util/configInheritance"; | ||
import { StoragePoolFormValues } from "pages/storage/forms/StoragePoolForm"; | ||
import { StorageVolumeFormValues } from "pages/storage/forms/StorageVolumeForm"; | ||
|
||
beforeEach(() => { | ||
vi.mock("@tanstack/react-query", () => ({ | ||
useQuery: vi.fn().mockReturnValue({ | ||
data: { | ||
configs: { | ||
"storage-ceph": { | ||
"pool-conf": { | ||
keys: [ | ||
{ | ||
"ceph.cluster_name": { | ||
defaultdesc: "`ceph`", | ||
longdesc: "", | ||
shortdesc: | ||
"Name of the Ceph cluster in which to create new storage pools", | ||
type: "string", | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
"storage-zfs": { | ||
"volume-conf": { | ||
keys: [ | ||
{ | ||
"block.filesystem": { | ||
condition: | ||
"block-based volume with content type `filesystem`", | ||
defaultdesc: "same as `volume.block.filesystem`", | ||
longdesc: | ||
"Valid options are: `btrfs`, `ext4`, `xfs`\nIf not set, `ext4` is assumed.", | ||
shortdesc: "File system of the storage volume", | ||
type: "string", | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}), | ||
})); | ||
}); | ||
|
||
describe("getConfigRowMetadata", () => { | ||
it("responds with row metadata for a storage pool", () => { | ||
const poolValues = { | ||
driver: "ceph", | ||
entityType: "storagePool", | ||
} as StoragePoolFormValues; | ||
|
||
const result = getConfigRowMetadata(poolValues, "ceph_cluster_name"); | ||
|
||
expect(result.configField?.shortdesc).toBe( | ||
"Name of the Ceph cluster in which to create new storage pools", | ||
); | ||
expect(result.configField?.default).toBe("ceph"); | ||
}); | ||
|
||
it("responds with row metadata for a storage volume", () => { | ||
const volumeValues = { | ||
entityType: "storageVolume", | ||
} as StorageVolumeFormValues; | ||
|
||
const result = getConfigRowMetadata(volumeValues, "block_filesystem"); | ||
|
||
expect(result.configField?.shortdesc).toBe( | ||
"File system of the storage volume", | ||
); | ||
expect(result.configField?.longdesc).toBe( | ||
"Valid options are: `btrfs`, `ext4`, `xfs`\n" + | ||
"If not set, `ext4` is assumed.", | ||
); | ||
}); | ||
}); |
Oops, something went wrong.